Skip to content

Commit c8b08ea

Browse files
authored
Merge pull request #102 from bastelfreak/ezbakefoo
Update release & build tasks
2 parents f5abe7b + b99de05 commit c8b08ea

File tree

3 files changed

+82
-18
lines changed

3 files changed

+82
-18
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
output/
12

23
# Leiningen
34
/target/

tasks/build.rake

Lines changed: 68 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,30 @@ require 'tmpdir'
1212
# To be fixed one of these days. Relevant stuff:
1313
# https://github.com/puppetlabs/ezbake/blob/aeb7735a16d2eecd389a6bd9e5c0cfc7c62e61a5/resources/puppetlabs/lein-ezbake/template/global/tasks/build.rake
1414
# https://github.com/puppetlabs/ezbake/blob/aeb7735a16d2eecd389a6bd9e5c0cfc7c62e61a5/resources/puppetlabs/lein-ezbake/template/global/ext/fpm.rb
15-
deb_platforms = ENV['DEB_PLATFORMS'] || 'ubuntu-20.04,ubuntu-22.04,ubuntu-24.04,debian-10,debian-11,debian-12'
16-
rpm_platforms = ENV['RPM_PLATFORMS'] || 'el-8,el-9,el-10,sles-15,amazon-2023'
15+
deb_platforms = ENV['DEB_PLATFORMS'] || 'ubuntu-20.04,ubuntu-22.04,ubuntu-24.04,ubuntu-25.04,debian-11,debian-12,debian-13'
16+
rpm_platforms = ENV['RPM_PLATFORMS'] || 'el-8,el-9,el-10,sles-15,sles-16,amazon-2,amazon-2023,fedora-42,fedora-43'
1717
@debs = deb_platforms.split(',').map{ |p| "base-#{p.split('-').join}-i386.cow" }.join(' ')
1818
@rpms = rpm_platforms.split(',').map{ |p| "pl-#{p}-x86_64" }.join(' ')
1919

20+
# The deps must be built in this order due to dependencies between them.
21+
# There is a circular dependency between clj-http-client and trapperkeeper-webserver-jetty10,
22+
# but only for tests, so the build *should* work.
23+
DEP_BUILD_ORDER = [
24+
'clj-parent',
25+
'clj-kitchensink',
26+
'clj-i18n',
27+
'comidi',
28+
'jvm-ssl-utils',
29+
'trapperkeeper',
30+
'trapperkeeper-filesystem-watcher',
31+
'trapperkeeper-webserver-jetty10',
32+
'trapperkeeper-authorization',
33+
'trapperkeeper-metrics',
34+
'trapperkeeper-status',
35+
'stockpile',
36+
'structured-logging',
37+
].freeze
38+
2039
def image_exists
2140
!`docker images -q #{@image}`.strip.empty?
2241
end
@@ -34,7 +53,7 @@ def teardown
3453
end
3554

3655
def start_container(ezbake_dir)
37-
run_command("docker run -d --name #{@container} -v .:/code -v #{ezbake_dir}:/ezbake #{@image} /bin/sh -c 'tail -f /dev/null'", silent: false, print_command: true)
56+
run_command("docker run -d --name #{@container} -v .:/code -v #{ezbake_dir}:/deps #{@image} /bin/sh -c 'tail -f /dev/null'", silent: false, print_command: true)
3857
end
3958

4059
def run(cmd)
@@ -60,24 +79,60 @@ namespace :vox do
6079
run_command("docker build -t ezbake-builder .", silent: false, print_command: true)
6180
end
6281

63-
puts "Checking out ezbake"
64-
tmp = Dir.mktmpdir("ezbake")
65-
ezbake_dir = "#{tmp}/ezbake"
66-
ezbake_repo = ENV.fetch('EZBAKE_REPO', 'https://github.com/openvoxproject/ezbake')
67-
ezbake_branch = ENV['EZBAKE_BRANCH'] || 'main'
68-
run_command("git clone -b #{ezbake_branch} #{ezbake_repo} #{ezbake_dir}", silent: false, print_command: true)
82+
libs_to_build_manually = {}
83+
if ENV['EZBAKE_BRANCH'] && !ENV['EZBAKE_BRANCH'].strip.empty?
84+
libs_to_build_manually['ezbake'] = {
85+
:repo => ENV.fetch('EZBAKE_REPO', 'https://github.com/openvoxproject/ezbake'),
86+
:branch => ENV.fetch('EZBAKE_BRANCH', 'main'),
87+
}
88+
end
89+
90+
deps_to_build = []
91+
dep_branch = nil
92+
93+
full_rebuild_branch = ENV['FULL_DEP_REBUILD_BRANCH']
94+
subset_list = (ENV['DEP_REBUILD'] || '').split(',').map(&:strip).reject(&:empty?)
95+
subset_branch = ENV.fetch('DEP_REBUILD_BRANCH', 'main').to_s
96+
rebuild_org = ENV.fetch('DEP_REBUILD_ORG', 'openvoxproject').to_s
97+
98+
if full_rebuild_branch && !full_rebuild_branch.strip.empty?
99+
dep_branch = full_rebuild_branch.strip
100+
deps_to_build = DEP_BUILD_ORDER.dup
101+
elsif !subset_list.empty?
102+
dep_branch = subset_branch
103+
unknown = subset_list.reject { |lib| DEP_BUILD_ORDER.include?(lib) }
104+
puts "WARNING: Unknown deps in DEP_REBUILD (will be ignored): #{unknown.join(', ')}" unless unknown.empty?
105+
deps_to_build = DEP_BUILD_ORDER.select { |lib| subset_list.include?(lib) }
106+
end
107+
108+
deps_to_build.each do |lib|
109+
libs_to_build_manually[lib] = {
110+
:repo => "https://github.com/#{rebuild_org}/#{lib}",
111+
:branch => dep_branch,
112+
}
113+
end
114+
115+
deps_tmp = Dir.mktmpdir("deps")
116+
117+
libs_to_build_manually.each do |lib, config|
118+
puts "Checking out #{lib}"
119+
run_command("git clone -b #{config[:branch]} #{config[:repo]} #{deps_tmp}/#{lib}", silent: false, print_command: true)
120+
end
69121

70122
puts "Starting container"
71123
teardown if container_exists
72-
start_container(ezbake_dir)
124+
start_container(deps_tmp)
73125

74-
puts "Installing ezbake from source"
75-
run("cd /ezbake && lein install")
126+
libs_to_build_manually.each do |lib, _|
127+
puts "Building and installing #{lib} from source"
128+
run("cd /deps/#{lib} && lein install")
129+
end
76130

131+
fips = !ENV['FIPS'].nil?
77132
puts "Building openvoxdb"
78133
ezbake_version_var = ENV['EZBAKE_VERSION'] ? "EZBAKE_VERSION=#{ENV['EZBAKE_VERSION']}" : ''
79134
run("cd /code && rm -rf ruby && rm -rf output && bundle install --without test && lein install")
80-
run("cd /code && COW=\"#{@debs}\" MOCK=\"#{@rpms}\" GEM_SOURCE='https://rubygems.org' #{ezbake_version_var} EZBAKE_ALLOW_UNREPRODUCIBLE_BUILDS=true EZBAKE_NODEPLOY=true LEIN_PROFILES=ezbake lein with-profile user,ezbake,provided,internal ezbake local-build")
135+
run("cd /code && COW=\"#{@debs}\" MOCK=\"#{@rpms}\" GEM_SOURCE='https://rubygems.org' #{ezbake_version_var} EZBAKE_ALLOW_UNREPRODUCIBLE_BUILDS=true EZBAKE_NODEPLOY=true LEIN_PROFILES=ezbake lein with-profile #{fips ? 'fips,' : ''}user,ezbake,provided,internal ezbake local-build")
81136
run_command("sudo chown -R $USER output", print_command: true)
82137
Dir.glob('output/**/*i386*').each { |f| FileUtils.rm_rf(f) }
83138
Dir.glob('output/puppetdb-*.tar.gz').each { |f| FileUtils.mv(f, f.sub('puppetdb','openvoxdb'))}

tasks/upload.rake

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace :vox do
22
desc 'Upload artifacts from the output directory to S3. Requires the AWS CLI to be installed and configured appropriately.'
3-
task :upload, [:tag, :platform] do |_, args|
3+
task :upload, [:platform] do |_, args|
44
endpoint = ENV.fetch('ENDPOINT_URL')
55
bucket = ENV.fetch('BUCKET_NAME')
66
component = 'openvoxdb'
@@ -14,23 +14,31 @@ namespace :vox do
1414

1515
abort 'You must set the ENDPOINT_URL environment variable to the S3 server you want to upload to.' if endpoint.nil? || endpoint.empty?
1616
abort 'You must set the BUCKET_NAME environment variable to the S3 bucket you are uploading to.' if bucket.nil? || bucket.empty?
17-
abort 'You must provide a tag.' if args[:tag].nil? || args[:tag].empty?
1817

19-
munged_tag = args[:tag].gsub('-', '.')
2018
s3 = "aws s3 --endpoint-url=#{endpoint}"
2119

2220
# Ensure the AWS CLI isn't going to fail with the given parameters
2321
run_command("#{s3} ls s3://#{bucket}/")
2422

25-
glob = "#{__dir__}/../output/**/*#{munged_tag}*"
23+
config = File.expand_path("../target/staging/ezbake.rb", __dir__)
24+
abort "Could not find ezbake config from the build at #{config}" unless File.exist?(config)
25+
load config
26+
version = EZBake::Config.fetch(:version)
27+
release = EZBake::Config.fetch(:release)
28+
# If release is a digit, then we built a tagged version. Otherwise,
29+
# we built a snapshot and want to include that in the path to upload to.
30+
tag = release =~ /^\d{1,2}$/ ? version : "#{version}-#{release}"
31+
32+
33+
glob = "#{__dir__}/../output/**/*#{tag}*"
2634
if os
2735
# "arch" is not used here because it's all noarch
2836
glob += "#{os}*"
2937
end
3038
files = Dir.glob(glob)
3139
abort 'No files for the given tag found in the output directory.' if files.empty?
3240

33-
path = "s3://#{bucket}/#{component}/#{args[:tag]}"
41+
path = "s3://#{bucket}/#{component}/#{tag}"
3442
files.each do |f|
3543
run_command("#{s3} cp #{f} #{path}/#{File.basename(f)}", silent: false)
3644
end

0 commit comments

Comments
 (0)