-
Notifications
You must be signed in to change notification settings - Fork 145
/
puppet-runtime.rb
62 lines (54 loc) · 2.76 KB
/
puppet-runtime.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
component 'puppet-runtime' do |pkg, settings, platform|
unless settings[:puppet_runtime_version] && settings[:puppet_runtime_location] && settings[:puppet_runtime_basename]
raise "Expected to find :puppet_runtime_version, :puppet_runtime_location, and :puppet_runtime_basename settings; Please set these in your project file before including puppet-runtime as a component."
end
pkg.version settings[:puppet_runtime_version]
tarball_name = "#{settings[:puppet_runtime_basename]}.tar.gz"
pkg.url File.join(settings[:puppet_runtime_location], tarball_name)
pkg.sha1sum File.join(settings[:puppet_runtime_location], "#{tarball_name}.sha1")
pkg.requires 'findutils' if platform.is_linux?
pkg.install_only true
# Even though puppet's ruby comes from puppet-runtime, we still need a ruby
# to build with on these platforms:
if platform.is_cross_compiled?
if platform.is_solaris?
raise "Unknown solaris os_version: #{platform.os_version}" unless platform.os_version == '11'
pkg.build_requires 'pl-ruby'
elsif platform.is_linux?
pkg.build_requires 'pl-ruby'
elsif platform.is_macos?
ruby_version_y = settings[:ruby_version].gsub(/(\d+)\.(\d+)\.(\d+)/, '\1.\2')
pkg.build_requires "ruby@#{ruby_version_y}"
end
end
if platform.is_windows?
# Elevate.exe is simply used when one of the run_facter.bat or
# run_puppet.bat files are called. These set up the required environment
# for the program, and elevate.exe gives the program the elevated
# privileges it needs to run
pkg.add_source "file://resources/files/windows/elevate.exe.config", sum: "a5aecf3f7335fa1250a0f691d754d561"
pkg.add_source "#{settings[:buildsources_url]}/windows/elevate/elevate.exe", sum: "bd81807a5c13da32dd2a7157f66fa55d"
pkg.install_file 'elevate.exe.config', "#{settings[:bindir]}/elevate.exe.config"
pkg.install_file 'elevate.exe', "#{settings[:bindir]}/elevate.exe"
# 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_command = [
"gunzip -c #{tarball_name} | tar -k -C /cygdrive/c/ -xf -",
"chmod 755 #{settings[:bindir].sub('C:', '/cygdrive/c')}/*"
]
elsif platform.is_macos?
# We can't untar into '/' because of SIP on macOS; Just copy the contents
# of these directories instead:
install_command = [
"tar -xzf #{tarball_name}",
"for d in opt var private; do rsync -ka \"$${d}/\" \"/$${d}/\"; done"
]
else
install_command = ["gunzip -c #{tarball_name} | #{platform.tar} -k -C / -xf -"]
end
pkg.install do
install_command
end
end