From 624077f2a354519b4470d23abde653c5ef0d1873 Mon Sep 17 00:00:00 2001 From: Josh Cooper Date: Sun, 19 Nov 2023 21:08:41 -0800 Subject: [PATCH] Support building pdk using a dev puppet-runtime build Previously, pdk required the pdk-runtime component to refer to a valid SHA in the https://github.com/puppetlabs/puppet-runtime repo which makes it difficult to test pdk-runtime changes before committing them. This commit allows the pdk-runtime.json component to refer to an already built dev build that only exists locally such as: { "version":"202311141.4.g81059f6", "location":"file:///home/josh/work/puppet-runtime/output" } Or a pdk-runtime build generated via Vanagon Generic Builder: { "version":"202308240.86.g81059f6", "location":"https://builds.delivery.puppetlabs.net/puppet-runtime/81059f6336c6b8f5f77ab9a3700eb0b2b58d5bcc/artifacts/" } Where the pdk-runtime is relative to the 'location': ${location}/pdk-runtime-${version}.windows-2019-x64.tar.gz --- configs/components/pdk-runtime.rb | 25 +++++++------------------ configs/projects/pdk.rb | 7 ++++++- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/configs/components/pdk-runtime.rb b/configs/components/pdk-runtime.rb index b28a1018..4f13bcb7 100644 --- a/configs/components/pdk-runtime.rb +++ b/configs/components/pdk-runtime.rb @@ -1,26 +1,15 @@ component 'pdk-runtime' do |pkg, settings, platform| - if settings[:pdk_runtime_version].length > 9 - # git sha version - git_sha = settings[:pdk_runtime_version] - - require 'open-uri' - require 'uri' - build_metadata = JSON.parse(URI.open("http://builds.delivery.puppetlabs.net/puppet-runtime/#{git_sha}/artifacts/#{git_sha}.build_metadata.json").read) - - pkg.version build_metadata['version'] - runtime_path = git_sha - else - # date-based tag - pkg.version settings[:pdk_runtime_version] - runtime_path = pkg.get_version + unless settings[:pdk_runtime_version] && settings[:pdk_runtime_location] && settings[:pdk_runtime_basename] + raise "Expected to find :pdk_runtime_version, :pdk_runtime_location, and :pdk_runtime_basename settings; Please set these in your project file before including pdk-runtime as a component." end - pkg.sha1sum "http://builds.delivery.puppetlabs.net/puppet-runtime/#{runtime_path}/artifacts/#{pkg.get_name}-#{pkg.get_version}.#{platform.name}.tar.gz.sha1" - pkg.url "http://builds.delivery.puppetlabs.net/puppet-runtime/#{runtime_path}/artifacts/#{pkg.get_name}-#{pkg.get_version}.#{platform.name}.tar.gz" + tarball_name = "#{settings[:pdk_runtime_basename]}.tar.gz" + pkg.url File.join(settings[:pdk_runtime_location], tarball_name) + pkg.sha1sum File.join(settings[:pdk_runtime_location], "#{tarball_name}.sha1") pkg.install_only true - install_commands = ["gunzip -c #{pkg.get_name}-#{pkg.get_version}.#{platform.name}.tar.gz | tar -C / -xf -"] + install_commands = ["gunzip -c #{tarball_name} | tar -C / -xf -"] if platform.is_windows? # We need to make sure we're setting permissions correctly for the executables @@ -28,7 +17,7 @@ # ... weird, and we need to be able to use cygwin environment variable use # so cmd.exe was not working as expected. install_commands = [ - "gunzip -c #{pkg.get_name}-#{pkg.get_version}.#{platform.name}.tar.gz | tar -C /cygdrive/c/ -xf -", + "gunzip -c #{tarball_name} | tar -C /cygdrive/c/ -xf -", "chmod 755 #{settings[:ruby_bindir].sub(/C:/, '/cygdrive/c')}/*" ] diff --git a/configs/projects/pdk.rb b/configs/projects/pdk.rb index 4dac18b8..0df22c58 100644 --- a/configs/projects/pdk.rb +++ b/configs/projects/pdk.rb @@ -2,7 +2,12 @@ # Inherit a bunch of shared settings from pdk-runtime config runtime_config = JSON.parse(File.read(File.join(__dir__, '..', 'components', 'puppet-runtime.json'))) proj.setting(:pdk_runtime_version, runtime_config['version']) - proj.inherit_settings 'pdk-runtime', 'https://github.com/puppetlabs/puppet-runtime', proj.pdk_runtime_version + proj.setting(:pdk_runtime_location, runtime_config['location']) + proj.setting(:pdk_runtime_basename, "pdk-runtime-#{runtime_config['version']}.#{platform.name}") + settings_uri = File.join(runtime_config['location'], "#{proj.settings[:pdk_runtime_basename]}.settings.yaml") + sha1sum_uri = "#{settings_uri}.sha1" + metadata_uri = File.join(runtime_config['location'], "#{proj.settings[:pdk_runtime_basename]}.json") + proj.inherit_yaml_settings(settings_uri, sha1sum_uri, metadata_uri: metadata_uri) proj.description 'Puppet Development Kit' proj.version_from_git