forked from Lainports/freebsd-ports
sysutils/puppet: update to 3.8.3
- update to 3.8.3 [1] - refactor manifest check in puppetmaster rc.d script [2] - bring in the pkgng package provider also used in Puppet 4 [3] - take maintainership PR: 203683 [1] PR: 202704 [2] Submitted by: tdb [1] Submitted by: lemon <yesthanks@lemonia.org> [2] Approved by: swills (maintainer) Obtained from: https://github.com/xaque208/puppet-pkgng [3] Differential Revision: https://reviews.freebsd.org/D4050
This commit is contained in:
parent
8680b4519f
commit
13f94de00d
4 changed files with 159 additions and 7 deletions
|
|
@ -2,12 +2,11 @@
|
|||
# $FreeBSD$
|
||||
|
||||
PORTNAME= puppet
|
||||
PORTVERSION= 3.8.2
|
||||
PORTREVISION= 1
|
||||
PORTVERSION= 3.8.3
|
||||
CATEGORIES= sysutils
|
||||
MASTER_SITES= http://downloads.puppetlabs.com/puppet/
|
||||
|
||||
MAINTAINER= swills@FreeBSD.org
|
||||
MAINTAINER= mmoll@FreeBSD.org
|
||||
COMMENT= Configuration management framework written in Ruby
|
||||
|
||||
LICENSE= APACHE20
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
SHA256 (puppet-3.8.2.tar.gz) = 5a89c623f22fc96a2919801ff874b10f8f1a66e95c09976c73b257b8bbc39986
|
||||
SIZE (puppet-3.8.2.tar.gz) = 2637591
|
||||
SHA256 (puppet-3.8.3.tar.gz) = bbdf5e32428fe005ea7279e9396bfcdf2c9b112763595fbfed48fb599108df7f
|
||||
SIZE (puppet-3.8.3.tar.gz) = 2638669
|
||||
|
|
|
|||
153
sysutils/puppet/files/patch-lib_puppet_provider_package_pkgng.rb
Normal file
153
sysutils/puppet/files/patch-lib_puppet_provider_package_pkgng.rb
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
--- /dev/null
|
||||
+++ lib/puppet/provider/package/pkgng.rb
|
||||
@@ -0,0 +1,150 @@
|
||||
+require 'puppet/provider/package'
|
||||
+
|
||||
+Puppet::Type.type(:package).provide :pkgng, :parent => Puppet::Provider::Package do
|
||||
+ desc "A PkgNG provider for FreeBSD and DragonFly."
|
||||
+
|
||||
+ commands :pkg => "/usr/local/sbin/pkg"
|
||||
+
|
||||
+ confine :operatingsystem => [:freebsd, :dragonfly]
|
||||
+
|
||||
+ defaultfor :operatingsystem => [:freebsd, :dragonfly]
|
||||
+
|
||||
+ has_feature :versionable
|
||||
+ has_feature :upgradeable
|
||||
+
|
||||
+ def self.get_query
|
||||
+ @pkg_query = @pkg_query || pkg(['query', '-a', '%n %v %o'])
|
||||
+ @pkg_query
|
||||
+ end
|
||||
+
|
||||
+ def self.get_version_list
|
||||
+ @version_list = @version_list || pkg(['version', '-voRL='])
|
||||
+ @version_list
|
||||
+ end
|
||||
+
|
||||
+ def self.get_latest_version(origin)
|
||||
+ if latest_version = self.get_version_list.lines.find { |l| l =~ /^#{origin} / }
|
||||
+ latest_version = latest_version.split(' ').last.split(')').first
|
||||
+ return latest_version
|
||||
+ end
|
||||
+ nil
|
||||
+ end
|
||||
+
|
||||
+ def self.instances
|
||||
+ packages = []
|
||||
+ begin
|
||||
+ info = self.get_query
|
||||
+
|
||||
+ unless info
|
||||
+ return packages
|
||||
+ end
|
||||
+
|
||||
+ info.lines.each do |line|
|
||||
+
|
||||
+ name, version, origin = line.chomp.split(" ", 3)
|
||||
+ latest_version = get_latest_version(origin) || version
|
||||
+
|
||||
+ pkg = {
|
||||
+ :ensure => version,
|
||||
+ :name => name,
|
||||
+ :provider => self.name,
|
||||
+ :origin => origin,
|
||||
+ :version => version,
|
||||
+ :latest => latest_version
|
||||
+ }
|
||||
+ packages << new(pkg)
|
||||
+ end
|
||||
+
|
||||
+ return packages
|
||||
+ rescue Puppet::ExecutionFailure
|
||||
+ nil
|
||||
+ end
|
||||
+ end
|
||||
+
|
||||
+ def self.prefetch(resources)
|
||||
+ packages = instances
|
||||
+ resources.keys.each do |name|
|
||||
+ if provider = packages.find{|p| p.name == name or p.origin == name }
|
||||
+ resources[name].provider = provider
|
||||
+ end
|
||||
+ end
|
||||
+ end
|
||||
+
|
||||
+ def repo_tag_from_urn(urn)
|
||||
+ # extract repo tag from URN: urn:freebsd:repo:<tag>
|
||||
+ match = /^urn:freebsd:repo:(.+)$/.match(urn)
|
||||
+ raise ArgumentError urn.inspect unless match
|
||||
+ match[1]
|
||||
+ end
|
||||
+
|
||||
+ def install
|
||||
+ source = resource[:source]
|
||||
+ source = URI(source) unless source.nil?
|
||||
+
|
||||
+ # If resource[:name] is actually an origin (e.g. 'www/curl' instead of
|
||||
+ # just 'curl'), drop the category prefix. pkgng doesn't support version
|
||||
+ # pinning with the origin syntax (pkg install curl-1.2.3 is valid, but
|
||||
+ # pkg install www/curl-1.2.3 is not).
|
||||
+ if resource[:name] =~ /\//
|
||||
+ installname = resource[:name].split('/')[1]
|
||||
+ else
|
||||
+ installname = resource[:name]
|
||||
+ end
|
||||
+
|
||||
+ # Ensure we handle the version
|
||||
+ if resource[:ensure] =~ /\./
|
||||
+ installname += '-' + resource[:ensure]
|
||||
+ end
|
||||
+
|
||||
+ if not source # install using default repo logic
|
||||
+ args = ['install', '-qy', installname]
|
||||
+ elsif source.scheme == 'urn' # install from repo named in URN
|
||||
+ tag = repo_tag_from_urn(source.to_s)
|
||||
+ args = ['install', '-qy', '-r', tag, installname]
|
||||
+ else # add package located at URL
|
||||
+ args = ['add', '-q', source.to_s]
|
||||
+ end
|
||||
+ pkg(args)
|
||||
+ end
|
||||
+
|
||||
+ def uninstall
|
||||
+ pkg(['remove', '-qy', resource[:name]])
|
||||
+ end
|
||||
+
|
||||
+ def query
|
||||
+ debug @property_hash
|
||||
+ if @property_hash[:ensure] == nil
|
||||
+ return nil
|
||||
+ else
|
||||
+ version = @property_hash[:version]
|
||||
+ return { :version => version }
|
||||
+ end
|
||||
+ end
|
||||
+
|
||||
+ def version
|
||||
+ debug @property_hash[:version].inspect
|
||||
+ @property_hash[:version]
|
||||
+ end
|
||||
+
|
||||
+ def version=
|
||||
+ pkg(['install', '-qy', "#{resource[:name]}-#{resource[:version]}"])
|
||||
+ end
|
||||
+
|
||||
+ def origin
|
||||
+ debug @property_hash[:origin].inspect
|
||||
+ @property_hash[:origin]
|
||||
+ end
|
||||
+
|
||||
+ # Upgrade to the latest version
|
||||
+ def update
|
||||
+ debug 'pkgng: update called'
|
||||
+ install
|
||||
+ end
|
||||
+
|
||||
+ # Return the latest version of the package
|
||||
+ def latest
|
||||
+ debug "returning the latest #{@property_hash[:name].inspect} version #{@property_hash[:latest].inspect}"
|
||||
+ @property_hash[:latest]
|
||||
+ end
|
||||
+
|
||||
+end
|
||||
|
|
@ -28,13 +28,13 @@ command_args="master ${puppetmaster_flags}"
|
|||
unset puppetmaster_flags
|
||||
|
||||
pidfile="${puppetmaster_rundir}/master.pid"
|
||||
puppet_manifestdir="$($command config print manifestdir)"
|
||||
puppet_manifest="$($command config print manifest)"
|
||||
|
||||
start_precmd="puppetmaster_checkconfig"
|
||||
restart_precmd="puppetmaster_checkconfig"
|
||||
puppetmaster_checkconfig() {
|
||||
echo -n "Performing sanity check of ${name} configuration: "
|
||||
if ! ${command} parser validate "${puppet_manifestdir}/site.pp"
|
||||
if ! ${command} parser validate "${puppet_manifest}"
|
||||
then
|
||||
echo "FAILED"
|
||||
return 1
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue