Tuesday, June 27, 2017

Update puppet 4.10.4 and package handling change

Index: Makefile
===================================================================
RCS file: /cvs/ports/sysutils/ruby-puppet/4/Makefile,v
retrieving revision 1.21
diff -u -r1.21 Makefile
--- Makefile 22 May 2017 13:07:44 -0000 1.21
+++ Makefile 28 Jun 2017 06:26:40 -0000
@@ -2,7 +2,7 @@

PORTROACH= limit:^4

-VERSION= 4.10.1
+VERSION= 4.10.4

RUN_DEPENDS+= databases/ruby-hiera3,${MODRUBY_FLAVOR} \
devel/ruby-gettext-setup,${MODRUBY_FLAVOR}>=0.10,<1 \
Index: distinfo
===================================================================
RCS file: /cvs/ports/sysutils/ruby-puppet/4/distinfo,v
retrieving revision 1.12
diff -u -r1.12 distinfo
--- distinfo 22 May 2017 13:07:44 -0000 1.12
+++ distinfo 28 Jun 2017 06:26:40 -0000
@@ -1,2 +1,2 @@
-SHA256 (puppet-4.10.1.tar.gz) = Jxc40rWq7I+q/VQwdqwNkBL81gUbzNL3CmbNR5NixgU=
-SIZE (puppet-4.10.1.tar.gz) = 2954351
+SHA256 (puppet-4.10.4.tar.gz) = WbhRDd8vSTQqOcy+Jrx7LqXhbXnendVy2SneWJZ6q5A=
+SIZE (puppet-4.10.4.tar.gz) = 2968202
Index: patches/patch-lib_puppet_defaults_rb
===================================================================
RCS file: /cvs/ports/sysutils/ruby-puppet/4/patches/patch-lib_puppet_defaults_rb,v
retrieving revision 1.3
diff -u -r1.3 patch-lib_puppet_defaults_rb
--- patches/patch-lib_puppet_defaults_rb 30 Aug 2016 12:09:07 -0000 1.3
+++ patches/patch-lib_puppet_defaults_rb 28 Jun 2017 06:26:40 -0000
@@ -1,7 +1,7 @@
$OpenBSD: patch-lib_puppet_defaults_rb,v 1.3 2016/08/30 12:09:07 jasper Exp $
---- lib/puppet/defaults.rb.orig Tue Aug 23 19:23:03 2016
-+++ lib/puppet/defaults.rb Mon Aug 29 19:57:39 2016
-@@ -1110,11 +1110,11 @@ EOT
+--- lib/puppet/defaults.rb.orig Mon May 1 19:38:34 2017
++++ lib/puppet/defaults.rb Tue Jun 20 11:40:52 2017
+@@ -1153,11 +1153,11 @@ EOT

define_settings(:master,
:user => {
@@ -15,7 +15,7 @@
:desc => "The group puppet master should run as.",
},
:default_manifest => {
-@@ -1207,7 +1207,7 @@ EOT
+@@ -1250,7 +1250,7 @@ EOT
:desc => "File that provides mapping between custom SSL oids and user-friendly names"
},
:basemodulepath => {
Index: patches/patch-lib_puppet_provider_package_openbsd_rb
===================================================================
RCS file: /cvs/ports/sysutils/ruby-puppet/4/patches/patch-lib_puppet_provider_package_openbsd_rb,v
retrieving revision 1.3
diff -u -r1.3 patch-lib_puppet_provider_package_openbsd_rb
--- patches/patch-lib_puppet_provider_package_openbsd_rb 28 Apr 2016 16:17:05 -0000 1.3
+++ patches/patch-lib_puppet_provider_package_openbsd_rb 28 Jun 2017 06:26:40 -0000
@@ -4,10 +4,12 @@
- Handle errors from pkg_add
- Handle uninstall_options being 'nil' by default
- Bail out on shortform PKG_PATH (i.e. 'ftp.openbsd.org')
+- pkg.conf is gone

---- lib/puppet/provider/package/openbsd.rb.orig Sat Apr 23 00:15:56 2016
-+++ lib/puppet/provider/package/openbsd.rb Thu Apr 28 18:15:32 2016
-@@ -20,48 +20,49 @@ Puppet::Type.type(:package).provide :openbsd, :parent
+Index: lib/puppet/provider/package/openbsd.rb
+--- lib/puppet/provider/package/openbsd.rb.orig
++++ lib/puppet/provider/package/openbsd.rb
+@@ -20,69 +20,61 @@ Puppet::Type.type(:package).provide :openbsd, :parent
has_feature :install_options
has_feature :uninstall_options
has_feature :upgradeable
@@ -79,18 +81,28 @@
+ end
end

+- def latest
+- parse_pkgconf
+ def flavor=(value)
+ install
+ end
-+
- def latest
- parse_pkgconf

-@@ -78,11 +79,10 @@ Puppet::Type.type(:package).provide :openbsd, :parent
+- if @resource[:source][-1,1] == ::File::SEPARATOR
+- e_vars = { 'PKG_PATH' => @resource[:source] }
+- else
+- e_vars = {}
+- end
+-
++ def latest
+ if @resource[:flavor]
+ query = "#{@resource[:name]}--#{@resource[:flavor]}"
+ else
+ query = @resource[:name]
end

- output = Puppet::Util.withenv(e_vars) {pkginfo "-Q", query}
+- output = Puppet::Util.withenv(e_vars) {pkginfo "-Q", query}
- version = properties[:ensure]
++ output = Puppet::Util.withenv({}) {pkginfo "-Q", query}

if output.nil? or output.size == 0 or output =~ /Error from /
debug "Failed to query for #{resource[:name]}"
@@ -99,7 +111,7 @@
else
# Remove all fuzzy matches first.
output = output.split.select {|p| p =~ /^#{resource[:name]}-(\d[^-]*)[-]?(\w*)/ }.join
-@@ -91,21 +91,22 @@ Puppet::Type.type(:package).provide :openbsd, :parent
+@@ -91,21 +83,22 @@ Puppet::Type.type(:package).provide :openbsd, :parent

if output =~ /^#{resource[:name]}-(\d[^-]*)[-]?(\w*) \(installed\)$/
debug "Package is already the latest available"
@@ -127,24 +139,53 @@
else
return match[2]
end
-@@ -131,6 +132,10 @@ Puppet::Type.type(:package).provide :openbsd, :parent
- end
- end
+@@ -116,53 +109,25 @@ Puppet::Type.type(:package).provide :openbsd, :parent
+ self.install(true)
+ end

-+ if @resource[:source][-1,1] != ::File::SEPARATOR
-+ raise Puppet::Error,
-+ "Please use full PKG_PATH notation instead of '#{@resource[:source]}'"
-+ end
- unless @resource[:source]
- raise Puppet::Error,
- "No valid installpath found in /etc/pkg.conf and no source was set"
-@@ -155,14 +160,22 @@ Puppet::Type.type(:package).provide :openbsd, :parent
- full_name = @resource[:source]
- end
+- def parse_pkgconf
+- unless @resource[:source]
+- if Puppet::FileSystem.exist?("/etc/pkg.conf")
+- File.open("/etc/pkg.conf", "rb").readlines.each do |line|
+- if matchdata = line.match(/^installpath\s*=\s*(.+)\s*$/i)
+- @resource[:source] = matchdata[1]
+- elsif matchdata = line.match(/^installpath\s*\+=\s*(.+)\s*$/i)
+- if @resource[:source].nil?
+- @resource[:source] = matchdata[1]
+- else
+- @resource[:source] += ":" + matchdata[1]
+- end
+- end
+- end
+-
+- unless @resource[:source]
+- raise Puppet::Error,
+- "No valid installpath found in /etc/pkg.conf and no source was set"
+- end
+- else
+- raise Puppet::Error,
+- "You must specify a package source or configure an installpath in /etc/pkg.conf"
+- end
+- end
+- end
+-
+ def install(latest = false)
+ cmd = []

+- parse_pkgconf
+-
+- if @resource[:source][-1,1] == ::File::SEPARATOR
+- e_vars = { 'PKG_PATH' => @resource[:source] }
+- full_name = get_full_name(latest)
+- else
+- e_vars = {}
+- full_name = @resource[:source]
+- end
+-
+ cmd << '-r'
cmd << install_options
- cmd << full_name
+- cmd << full_name
++ cmd << get_full_name(latest)

if latest
- cmd.unshift('-rz')
@@ -154,7 +195,7 @@
- Puppet::Util.withenv(e_vars) { pkgadd cmd.flatten.compact }
+ # pkg_add(1) doesn't set the return value upon failure so we have to peek
+ # at it's output to see if something went wrong.
-+ output = Puppet::Util.withenv(e_vars) { pkgadd cmd.flatten.compact }
++ output = Puppet::Util.withenv({}) { pkgadd cmd.flatten.compact }
+ require 'pp'
+ pp output
+ if output =~ /Can't find /
@@ -163,7 +204,7 @@
end

def get_full_name(latest = false)
-@@ -229,7 +242,7 @@ Puppet::Type.type(:package).provide :openbsd, :parent
+@@ -229,7 +194,7 @@ Puppet::Type.type(:package).provide :openbsd, :parent
end

def uninstall_options
Hi,

attached patch updates puppet to 4.10.4 as well as changing the way packages are installed. Up to now it was looking into a
/etc/pkg.conf, but since that is not there anymore, you may run into problems, if you don't have PKG_PATH exported.
Now /etc/pkg.conf is not consulted anymore, pkg_add is just doing it's magic, you still can export PKG_PATH.

If I don't hear anything I'll go ahead with it on the weekend.

cheers,
Sebastian

No comments:

Post a Comment