Index: head/sysutils/puppet/Makefile =================================================================== --- head/sysutils/puppet/Makefile (revision 403617) +++ head/sysutils/puppet/Makefile (revision 403618) @@ -1,105 +1,85 @@ # Created by: Tomoyuki Sakurai # $FreeBSD$ PORTNAME= puppet PORTVERSION= 3.8.4 +PORTREVISION= 1 CATEGORIES= sysutils MASTER_SITES= http://downloads.puppetlabs.com/puppet/ MAINTAINER= mmoll@FreeBSD.org COMMENT= Configuration management framework written in Ruby LICENSE= APACHE20 BUILD_DEPENDS= rubygem-facter>=0:${PORTSDIR}/sysutils/rubygem-facter \ rubygem-hiera1>=0:${PORTSDIR}/sysutils/rubygem-hiera1 RUN_DEPENDS= rubygem-facter>=0:${PORTSDIR}/sysutils/rubygem-facter \ rubygem-ruby-augeas>=0:${PORTSDIR}/textproc/rubygem-ruby-augeas \ rubygem-hiera1>=0:${PORTSDIR}/sysutils/rubygem-hiera1 USES= cpe CPE_VENDOR= puppetlabs CONFLICTS_INSTALL= puppet37-* puppet4-* NO_BUILD= yes USE_RUBY= yes USE_RUBY_FEATURES= iconv USE_RC_SUBR= puppet puppetmaster PORTDOCS= LICENSE README.md PORTEXAMPLES= * USERS= puppet GROUPS= puppet SUB_FILES+= pkg-message SUB_LIST= RUBY=${RUBY} OPTIONS_DEFINE= DOCS EXAMPLES -OPTIONS_DEFAULT= PACKAGE_ORIGIN -OPTIONS_RADIO= PATCHES -OPTIONS_RADIO_PATCHES= PACKAGE_ORIGIN PACKAGE_ROOT -PACKAGE_ORIGIN_DESC= Use port origin as package name -PACKAGE_ROOT_DESC= Use PACKAGEROOT instead of PACKAGESITE -PATCHES_DESC= Optional exclusive patches -.include - -.if ${PORT_OPTIONS:MPACKAGE_ROOT} -.if ! ${PORT_OPTIONS:MPACKAGE_ORIGIN} -EXTRA_PATCHES+= ${FILESDIR}/optpatch-package_root -.else -BROKEN= PACKAGE_ROOT option patch is incompatible with PACKAGE_ORIGIN patch. -.endif -.endif - .include - -.if ${PORT_OPTIONS:MPACKAGE_ORIGIN} -EXTRA_PATCHES+= ${FILESDIR}/optpatch-package_origin -RUN_DEPENDS+= rubygem-bzip2-ruby>=0:${PORTSDIR}/archivers/rubygem-bzip2-ruby -.endif post-patch: @${REINPLACE_CMD} -e "s|/etc/puppet|${ETCDIR}|" \ ${WRKSRC}/install.rb \ ${WRKSRC}/lib/puppet/reference/configuration.rb \ ${WRKSRC}/lib/puppet/defaults.rb \ ${WRKSRC}/lib/puppet/util/run_mode.rb @${REINPLACE_CMD} -e "s|/var/lib/puppet|/var/puppet|" \ ${WRKSRC}/lib/puppet/reference/configuration.rb \ ${WRKSRC}/lib/puppet/util/run_mode.rb @${REINPLACE_CMD} -e "s|\$$vardir/run|/var/run/puppet|" \ ${WRKSRC}/lib/puppet/util/run_mode.rb @${REINPLACE_CMD} -e "s|\$$confdir/ssl|/var/puppet/ssl|" \ ${WRKSRC}/lib/puppet/defaults.rb @${REINPLACE_CMD} -e "s|%%PREFIX%%|${PREFIX}|" \ ${WRKSRC}/ext/rack/config.ru do-install: @cd ${WRKSRC} && ${SETENV} PREFIX=${PREFIX} ${RUBY} ${WRKSRC}/install.rb --no-configs --destdir=${STAGEDIR} post-install: ${MKDIR} ${STAGEDIR}${ETCDIR}/manifests ${MKDIR} ${STAGEDIR}${ETCDIR}/modules ${MKDIR} ${STAGEDIR}/var/puppet ${INSTALL_DATA} ${WRKSRC}/conf/auth.conf ${STAGEDIR}${ETCDIR}/auth.conf-dist ${RUBY} -I ${STAGEDIR}/${RUBY_SITELIBDIR} ${STAGEDIR}${PREFIX}/bin/puppet agent --genconfig \ --confdir=${ETCDIR} \ --rundir=/var/run/puppet \ --vardir=/var/puppet \ --logdir=/var/log/puppet \ > ${STAGEDIR}${ETCDIR}/puppet.conf-dist @${ECHO} ${STAGEDIR}${RUBY_SITELIBDIR}/puppet.rb | \ ${SED} 's,^${STAGEDIR}${PREFIX}/,,' >> ${TMPPLIST} @${ECHO} ${STAGEDIR}${RUBY_SITELIBDIR}/semver.rb | \ ${SED} 's,^${STAGEDIR}${PREFIX}/,,' >> ${TMPPLIST} @${FIND} ${STAGEDIR}${RUBY_SITELIBDIR}/${PORTNAME} -type f | \ ${SED} 's,^${STAGEDIR}${PREFIX}/,,' >> ${TMPPLIST} @${FIND} ${STAGEDIR}${RUBY_SITELIBDIR}/${PORTNAME} -type d | ${SORT} -r | \ ${SED} 's,^${STAGEDIR}${PREFIX}/,@dirrm ,' >> ${TMPPLIST} @${MKDIR} ${STAGEDIR}${WWWDIR} ${INSTALL_DATA} ${WRKSRC}/ext/rack/config.ru ${STAGEDIR}${WWWDIR} @${MKDIR} ${STAGEDIR}${DOCSDIR} cd ${WRKSRC} && ${INSTALL_DATA} ${PORTDOCS} ${STAGEDIR}${DOCSDIR} @${MKDIR} ${STAGEDIR}${EXAMPLESDIR} cd ${WRKSRC}/examples/ && ${COPYTREE_SHARE} . ${STAGEDIR}${EXAMPLESDIR} ${INSTALL_DATA} ${WRKSRC}/ext/rack/example-passenger-vhost.conf ${STAGEDIR}${EXAMPLESDIR} .include Index: head/sysutils/puppet/files/optpatch-package_root =================================================================== --- head/sysutils/puppet/files/optpatch-package_root (revision 403617) +++ head/sysutils/puppet/files/optpatch-package_root (nonexistent) @@ -1,11 +0,0 @@ ---- lib/puppet/provider/package/freebsd.rb.orig 2012-10-21 14:45:57.110106541 -0400 -+++ lib/puppet/provider/package/freebsd.rb 2012-10-21 14:47:41.281104749 -0400 -@@ -20,7 +20,7 @@ - - if @resource[:source] =~ /\/$/ - if @resource[:source] =~ /^(ftp|https?):/ -- Puppet::Util.withenv :PACKAGESITE => @resource[:source] do -+ Puppet::Util.withenv :PACKAGEROOT => @resource[:source] do - pkgadd "-r", @resource[:name] - end - else Property changes on: head/sysutils/puppet/files/optpatch-package_root ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/sysutils/puppet/files/optpatch-package_origin =================================================================== --- head/sysutils/puppet/files/optpatch-package_origin (revision 403617) +++ head/sysutils/puppet/files/optpatch-package_origin (nonexistent) @@ -1,197 +0,0 @@ ---- lib/puppet/provider/package/freebsd.rb.ori 2013-09-19 14:43:54.000000000 -0600 -+++ lib/puppet/provider/package/freebsd.rb 2013-09-19 14:40:09.000000000 -0600 -@@ -1,35 +1,163 @@ --Puppet::Type.type(:package).provide :freebsd, :parent => :openbsd do -- desc "The specific form of package management on FreeBSD. This is an -- extremely quirky packaging system, in that it freely mixes between -- ports and packages. Apparently all of the tools are written in Ruby, -- so there are plans to rewrite this support to directly use those -- libraries." -- -- commands :pkginfo => "/usr/sbin/pkg_info", -- :pkgadd => "/usr/sbin/pkg_add", -- :pkgdelete => "/usr/sbin/pkg_delete" -+require 'open-uri' -+require 'net/ftp' -+require 'bzip2' -+ -+Puppet::Type.type(:package).provide :freebsd, :parent => Puppet::Provider::Package do -+ include Puppet::Util::Execution -+ -+ desc "The specific form of package management on FreeBSD. Resource names must be -+ specified as the port origin: /." -+ -+ commands :pkginfo => "/usr/sbin/pkg_info", -+ :pkgadd => "/usr/sbin/pkg_add", -+ :pkgdelete => "/usr/sbin/pkg_delete" - - confine :operatingsystem => :freebsd -+ defaultfor :operatingsystem => :freebsd - -- def self.listcmd -- command(:pkginfo) -+ class_variable_set(:@@lock, Mutex.new) -+ class_variable_set(:@@ports_index, nil) -+ -+ # fix bug in URI::FTP merge method that tries to set typecode -+ # even when other is a string. -+ class URI::FTP -+ def merge(other) -+ tmp = super(other) -+ if self != tmp -+ tmp.set_typecode(other.typecode) rescue NoMethodError -+ end -+ return tmp -+ end - end - -- def install -- if @resource[:source] =~ /\/$/ -- if @resource[:source] =~ /^(ftp|https?):/ -- Puppet::Util.withenv :PACKAGESITE => @resource[:source] do -- pkgadd "-r", @resource[:name] -+ def self.parse_pkg_string(pkg_string) -+ { -+ :pkg_name => pkg_string.split("-").slice(0..-2).join("-"), -+ :pkg_version => pkg_string.split("-")[-1], -+ } -+ end -+ -+ def self.unparse_pkg_info(pkg_info) -+ [:pkg_name, :pkg_version].map { |key| pkg_info[key] }.join("-") -+ end -+ -+ def self.parse_origin(origin_path) -+ begin -+ origin = { -+ :port_category => origin_path.split("/").fetch(-2), -+ :port_name => origin_path.split("/").fetch(-1), -+ } -+ rescue IndexError -+ raise Puppet::Error.new "#{origin_path}: not in required origin format: .*//" -+ end -+ origin -+ end -+ -+ def self.instances -+ packages = [] -+ output = pkginfo "-aoQ" -+ output.split("\n").each do |data| -+ pkg_string, pkg_origin = data.split(":") -+ pkg_info = self.parse_pkg_string(pkg_string) -+ -+ packages << new({ -+ :provider => self.name, -+ :name => pkg_origin, -+ :ensure => pkg_info[:pkg_version], -+ }) -+ end -+ packages -+ end -+ -+ def ports_index -+ @@lock.synchronize do -+ if @@ports_index.nil? -+ @@ports_index = {} -+ uri = source.merge "INDEX.bz2" -+ Puppet.debug "Fetching INDEX: #{uri.inspect}" -+ begin -+ Bzip2::Reader.open(uri) do |f| -+ while (line = f.gets) -+ fields = line.split("|") -+ pkg_info = self.class.parse_pkg_string(fields[0]) -+ origin = self.class.parse_origin(fields[1]) -+ @@ports_index[origin] = pkg_info -+ end -+ end -+ rescue IOError, OpenURI::HTTPError, Net::FTPError -+ @@ports_index = nil -+ raise Puppet::Error.new "Could not fetch ports INDEX: #{$!}" - end -- else -- Puppet::Util.withenv :PKG_PATH => @resource[:source] do -- pkgadd @resource[:name] -+ end -+ end -+ @@ports_index -+ end -+ -+ def uri_path -+ Facter.loadfacts -+ File.join( -+ "/", "pub", "FreeBSD", "ports", -+ Facter.value(:hardwareisa), -+ [ -+ "packages", -+ Facter.value(:kernelmajversion).split(".")[0], -+ "stable", -+ ].join("-") -+ ) << "/" -+ end -+ -+ def source -+ if !defined? @source -+ if @resource[:source] -+ @source = URI.parse(@resource[:source]) -+ if @source.path.empty? -+ @source.merge! uri_path - end -+ else # source parameter not set; build default source URI -+ @source = URI::FTP.build({ -+ :host => "ftp.freebsd.org", -+ :path => uri_path, -+ }) - end -+ Puppet.debug "Package: #{@resource[:name]}: source => #{@source.inspect}" -+ end -+ @source -+ end -+ -+ def origin -+ if !defined? @origin -+ @origin = self.class.parse_origin(@resource[:name]) -+ Puppet.debug "Package: #{@resource[:name]}: origin => #{@origin.inspect}" -+ end -+ @origin -+ end -+ -+ def package_uri -+ begin -+ pkg_name = self.class.unparse_pkg_info(ports_index.fetch(origin)) -+ rescue IndexError -+ raise Puppet::Error.new "package not found in INDEX" -+ end -+ uri = source.merge File.join("All", pkg_name + ".tbz") -+ Puppet.debug "Package: #{@resource[:name]}: package_uri => #{uri.inspect}" -+ uri -+ end -+ -+ def install -+ should = @resource.should(:ensure) -+ origin # call origin so we check the package name for correctness early -+ -+ # Source URI is for local file path. -+ if !source.absolute? or source.scheme == "file" -+ pkgadd source.path -+ # Source URI is to specific package file -+ elsif source.absolute? && source.path.end_with?(".tbz") -+ pkgadd source.to_s -+ # Source URI is to a package repository - else -- Puppet.warning "source is defined but does not have trailing slash, ignoring #{@resource[:source]}" if @resource[:source] -- pkgadd "-r", @resource[:name] -+ pkgadd "-f", package_uri.to_s - end -+ nil - end - - def query -@@ -42,6 +170,7 @@ - end - - def uninstall -- pkgdelete "#{@resource[:name]}-#{@resource.should(:ensure)}" -+ output = pkginfo "-qO", @resource[:name] -+ output.split("\n").each { |pkg_name| pkgdelete([pkg_name]) } - end - end Property changes on: head/sysutils/puppet/files/optpatch-package_origin ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/sysutils/puppet/files/patch-lib_puppet_provider_package_pkgng.rb =================================================================== --- head/sysutils/puppet/files/patch-lib_puppet_provider_package_pkgng.rb (revision 403617) +++ head/sysutils/puppet/files/patch-lib_puppet_provider_package_pkgng.rb (revision 403618) @@ -1,153 +1,145 @@ --- /dev/null +++ lib/puppet/provider/package/pkgng.rb -@@ -0,0 +1,150 @@ +@@ -0,0 +1,142 @@ +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 ++ pkg(['query', '-a', '%n %v %o']) + end + + def self.get_version_list -+ @version_list = @version_list || pkg(['version', '-voRL=']) -+ @version_list ++ @version_info_list ||= pkg(['version', '-voRL=']) + 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: + 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 ++ # Ensure we handle the version ++ case resource[:ensure] ++ when true, false, Symbol + installname = resource[:name] ++ else ++ # 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] + '-' + resource[:ensure] ++ else ++ installname = resource[:name] + '-' + resource[:ensure] ++ end + 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 ++ ++ def origin ++ @property_hash[:origin] + end + +end