added support for managing multiple repositories
removed support for pkgng before version 1.1.4
This commit is contained in:
Родитель
4ef4512d7b
Коммит
96538d0956
|
@ -21,6 +21,11 @@ Then to configure your system to use a PkgNG, a simple include will do.
|
|||
|
||||
include pkgng
|
||||
|
||||
or when you want to use specific PkgNG repositories:
|
||||
|
||||
pkgng::repo { 'pkg.freebsd.org': }
|
||||
pkgng::repo { 'my.own.repo': }
|
||||
|
||||
### Installation via r10K
|
||||
|
||||
You can also clone this repo to somewhere in your modulepath, or use something
|
||||
|
|
|
@ -6,68 +6,42 @@
|
|||
# make -C /usr/ports/ports-mgmg/pkg install clean
|
||||
|
||||
class pkgng (
|
||||
$packagesite = $pkgng::params::packagesite,
|
||||
$repo_name = $pkgng::params::repo_name,
|
||||
$srv_mirrors = $pkgng::params::srv_mirrors,
|
||||
$pkg_dbdir = $pkgng::params::pkg_dbdir,
|
||||
$pkg_cachedir = $pkgng::params::pkg_cachedir,
|
||||
$portsdir = $pkgng::params::portsdir,
|
||||
$repos = {},
|
||||
) inherits pkgng::params {
|
||||
|
||||
# At the time of this writing, only FreeBSD 9 and 10 are supported by pkgng
|
||||
if $pkgng_supported {
|
||||
$config_content = "PKG_DBDIR: ${pkg_dbdir}\nPKG_CACHEDIR: ${pkg_cachedir}\n"
|
||||
|
||||
if $srv_mirrors == "YES" or $packagesite =~ /^pkg\+http/ {
|
||||
$mirror_type = "SRV"
|
||||
} else {
|
||||
$mirror_type = "HTTP"
|
||||
# At the time of this writing, only FreeBSD 9 and up are supported by pkgng
|
||||
if ! $pkgng_supported or versioncmp($pkgng_version, "1.1.4") < 0 {
|
||||
fail("PKGng is either not supported on your system or it is too old")
|
||||
}
|
||||
|
||||
file { "/usr/local/etc/pkg.conf":
|
||||
content => "PKG_DBDIR: ${pkg_dbdir}\nPKG_CACHEDIR: ${pkg_cachedir}\nPORTSDIR: ${portsdir}\n",
|
||||
notify => Exec['pkg update'],
|
||||
}
|
||||
|
||||
# from pkgng 1.1.4 and up, a different repo format is used
|
||||
if versioncmp($pkgng_version, "1.1.4") >= 0 {
|
||||
# make sure repo config dir is present
|
||||
file { "/usr/local/etc/pkg":
|
||||
file { ['/usr/local/etc/pkg', '/usr/local/etc/pkg/repos']:
|
||||
ensure => directory,
|
||||
}
|
||||
|
||||
file { "/usr/local/etc/pkg/repos/":
|
||||
ensure => directory,
|
||||
}
|
||||
|
||||
File["/usr/local/etc/pkg.conf"] {
|
||||
content => "${config_content}"
|
||||
}
|
||||
|
||||
file { "/usr/local/etc/pkg/repos/${repo_name}.conf":
|
||||
content => "${repo_name}: {\n url: ${$packagesite},\n mirror_type: ${mirror_type},\n enabled: true,\n}",
|
||||
notify => Exec['pkg update'],
|
||||
}
|
||||
} else {
|
||||
File["/usr/local/etc/pkg.conf"] {
|
||||
content => "PACKAGESITE: ${packagesite}\n${config_content}",
|
||||
}
|
||||
}
|
||||
|
||||
file { "/etc/make.conf":
|
||||
file { '/etc/make.conf':
|
||||
ensure => present,
|
||||
}
|
||||
|
||||
file_line { "WITH_PKGNG":
|
||||
file_line { 'WITH_PKGNG':
|
||||
path => '/etc/make.conf',
|
||||
line => "WITH_PKGNG=yes\n",
|
||||
require => File['/etc/make.conf'],
|
||||
}
|
||||
|
||||
# Triggered on config changes
|
||||
exec { "pkg update":
|
||||
exec { 'pkg update':
|
||||
path => '/usr/local/sbin',
|
||||
refreshonly => true,
|
||||
command => "pkg -q update -f",
|
||||
command => 'pkg -q update -f',
|
||||
}
|
||||
|
||||
# This exec should really on ever be run once, and only upon converting to
|
||||
|
@ -76,12 +50,13 @@ class pkgng (
|
|||
# is already up to date, and this is not required. As you will see,
|
||||
# refreshonly, but nothing notifies this. I am uncertain at this time how
|
||||
# to proceed, other than manually.
|
||||
exec { "convert pkg database to pkgng":
|
||||
exec { 'convert pkg database to pkgng':
|
||||
path => '/usr/local/sbin',
|
||||
refreshonly => true,
|
||||
command => "pkg2ng",
|
||||
}
|
||||
} else {
|
||||
notice("pkgng is not supported on this release")
|
||||
command => 'pkg2ng',
|
||||
require => File['/etc/make.conf'],
|
||||
}
|
||||
|
||||
# expand all pkg repositories from hashtable
|
||||
create_resources('pkgng::repo', $repos)
|
||||
}
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
class pkgng::params {
|
||||
$repo_name = "FreeBSD"
|
||||
$packagesite = 'pkg+http://pkg.FreeBSD.org/${ABI}/latest'
|
||||
$srv_mirrors = 'NO'
|
||||
$pkg_dbdir = '/var/db/pkg'
|
||||
$pkg_cachedir = '/var/cache/pkg'
|
||||
$portsdir = '/usr/ports'
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
# This configures a single PkgNG repository. Instead of defining the repo
|
||||
# with the repo URL, we split it up in hostname, mirror_type, protocol and
|
||||
# repopath. This way, this resource can be integrated with possible firewalls
|
||||
# better.
|
||||
|
||||
define pkgng::repo (
|
||||
$packagehost = $name,
|
||||
$release = $::operatingsystemrelease,
|
||||
$protocol = 'http',
|
||||
$mirror_type = 'srv',
|
||||
$repopath = '/${ABI}/latest',
|
||||
$enabled = true,
|
||||
) {
|
||||
include ::pkgng
|
||||
|
||||
# validate protocol against chosen mirror_type
|
||||
case $mirror_type {
|
||||
/(?i:srv)/: {
|
||||
if $protocol !~ /(?i:http(s)?)/ {
|
||||
fail("Mirror type ${mirror_type} support http:// and https:// only")
|
||||
}
|
||||
}
|
||||
/(?i:http)/: {
|
||||
if $protocol !~ /(?i:(http|https|ftp|file|ssh))/ {
|
||||
fail("Mirror type ${mirror_type} support http://, https://, ftp://, file://, ssh:// only")
|
||||
}
|
||||
}
|
||||
default: {
|
||||
fail("Mirror type ${mirror_type} not supported")
|
||||
}
|
||||
}
|
||||
|
||||
# define repository configuration
|
||||
file { "/usr/local/etc/pkg/repos/${name}.conf":
|
||||
ensure => $ensure,
|
||||
content => template("${module_name}/repo.erb"),
|
||||
notify => Exec['pkg update'],
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
# File managed by Puppet
|
||||
|
||||
<%= @name -%>: {
|
||||
url: "<% if @mirror_type =~ /srv/i %>pkg+<% end %><%= @protocol %>://<%= @packagehost %><%= @repopath %>",
|
||||
mirror_type: "<%= @mirror_type %>",
|
||||
enabled: <% if @enabled == true or @enabled == 'yes' %>yes<% else %>no<% end %>,
|
||||
}
|
Загрузка…
Ссылка в новой задаче