From fac9a556babf748007db6773d0f2bfc85439b6c2 Mon Sep 17 00:00:00 2001 From: Patrik Holmqvist Date: Mon, 9 Sep 2024 16:52:38 +0200 Subject: [PATCH 1/2] Patch for broken eyaml in ubuntu24.04. --- edit-secrets | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/edit-secrets b/edit-secrets index a2c67ac..144afc4 100755 --- a/edit-secrets +++ b/edit-secrets @@ -73,6 +73,41 @@ EOF fi } +function patch_broken_eyaml_noble { + # + # Ubuntu 24.04 (noble) has a hiera-eyaml version that is incompatible with ruby 3.2+ (default in ubuntu24). + # This is fixed in hiera-eyaml version 3.3.0: https://github.com/voxpupuli/hiera-eyaml/pull/340/files + # https://github.com/voxpupuli/hiera-eyaml/blob/master/CHANGELOG.md + # But there is no modern version of hiera-eyanl packaged in debian or ubuntu. + # https://github.com/puppetlabs/puppet/wiki/Puppet-8-Compatibility#filedirexists-removed + # + + . /etc/os-release + if [ "${VERSION_CODENAME}" == "noble" ]; then + plugins_file="/usr/share/rubygems-integration/all/gems/hiera-eyaml-3.3.0/lib/hiera/backend/eyaml/subcommands/edit.rb" + if [ -f $plugins_file ]; then + # We only want to try patching the file if it is the known broken version + bad_sum="59c6eb910ab2eb44f8c75aeaa79bff097038feb673b5c6bdccde23d9b2a393e2" + sum=$(sha256sum $plugins_file | awk '{print $1}') + if [ "$sum" == "$bad_sum" ]; then + patch --fuzz=0 --directory=/ --strip=0 <<'EOF' +--- /usr/share/rubygems-integration/all/gems/hiera-eyaml-3.3.0/lib/hiera/backend/eyaml/subcommands/edit.rb.orig 2022-06-11 16:30:10.000000000 +0000 ++++ /usr/share/rubygems-integration/all/gems/hiera-eyaml-3.3.0/lib/hiera/backend/eyaml/subcommands/edit.rb 2024-09-09 14:13:19.306342025 +0000 +@@ -59,7 +59,7 @@ + Optimist::die "You must specify an eyaml file" if ARGV.empty? + options[:source] = :eyaml + options[:eyaml] = ARGV.shift +- if File.exists? options[:eyaml] ++ if File.exist? options[:eyaml] + begin + options[:input_data] = File.read options[:eyaml] + rescue +EOF + fi + fi + fi +} + function edit_copy_and_commit() { # @@ -234,6 +269,7 @@ function edit_eyaml_file() done patch_broken_eyaml + patch_broken_eyaml_noble # save source file for comparision afterwards cp "${EYAMLFILE}" "${TMPFILE}" From 7941e3f9702ef1a18115e4d5d1507a0dd43c5141 Mon Sep 17 00:00:00 2001 From: Patrik Holmqvist Date: Mon, 9 Sep 2024 17:29:31 +0200 Subject: [PATCH 2/2] Merge the 2 patch functions to 1. --- edit-secrets | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/edit-secrets b/edit-secrets index 144afc4..68d3630 100755 --- a/edit-secrets +++ b/edit-secrets @@ -71,14 +71,12 @@ EOF fi fi fi -} -function patch_broken_eyaml_noble { # # Ubuntu 24.04 (noble) has a hiera-eyaml version that is incompatible with ruby 3.2+ (default in ubuntu24). # This is fixed in hiera-eyaml version 3.3.0: https://github.com/voxpupuli/hiera-eyaml/pull/340/files # https://github.com/voxpupuli/hiera-eyaml/blob/master/CHANGELOG.md - # But there is no modern version of hiera-eyanl packaged in debian or ubuntu. + # But there is no modern version of hiera-eyaml packaged in debian or ubuntu. # https://github.com/puppetlabs/puppet/wiki/Puppet-8-Compatibility#filedirexists-removed # @@ -269,7 +267,6 @@ function edit_eyaml_file() done patch_broken_eyaml - patch_broken_eyaml_noble # save source file for comparision afterwards cp "${EYAMLFILE}" "${TMPFILE}"