Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building pdk using a dev puppet-runtime build #345

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 7 additions & 18 deletions configs/components/pdk-runtime.rb
Original file line number Diff line number Diff line change
@@ -1,34 +1,23 @@
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
# in the ruby bindir since preserving permissions in archives in windows is
# ... 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')}/*"
]

Expand Down
7 changes: 6 additions & 1 deletion configs/projects/pdk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading