Skip to content

Commit ec6ebe9

Browse files
author
Jeff Frontz
committed
Add support for a centos-based distro
1 parent ee18066 commit ec6ebe9

File tree

1 file changed

+40
-10
lines changed

1 file changed

+40
-10
lines changed

bin/gbuild

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,23 @@ EOF" if build_desc["sudo"] and @options[:allow_sudo]
102102
end
103103
end
104104

105-
info "Updating apt-get repository (log in var/install.log)"
106-
system! "on-target -u root apt-get update >> var/install.log 2>&1"
105+
case build_desc["distro"]
106+
when "centos"
107+
info "Updating yum repository (log in var/install.log)"
108+
system! "on-target -u root yum -y makecache fast >> var/install.log 2>&1"
109+
else
110+
info "Updating apt-get repository (log in var/install.log)"
111+
system! "on-target -u root apt-get update >> var/install.log 2>&1"
112+
end
107113

108114
info "Installing additional packages (log in var/install.log)"
109-
system! "on-target -u root -e DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends -y install #{build_desc["packages"].join(" ")} >> var/install.log 2>&1"
115+
116+
case build_desc["distro"]
117+
when "centos"
118+
system! "on-target -u root yum -y install #{build_desc["packages"].join(" ")} > var/install.log 2>&1"
119+
else
120+
system! "on-target -u root -e DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends -y install #{build_desc["packages"].join(" ")} >> var/install.log 2>&1"
121+
end
110122

111123
if build_desc["alternatives"]
112124
info "Set alternatives (log in var/install.log)"
@@ -117,10 +129,24 @@ EOF" if build_desc["sudo"] and @options[:allow_sudo]
117129

118130
if @options[:upgrade] || system("on-target -u root '[ ! -e /var/cache/gitian/initial-upgrade ]'")
119131
info "Upgrading system, may take a while (log in var/install.log)"
120-
system! "on-target -u root bash < target-bin/upgrade-system.sh >> var/install.log 2>&1"
132+
case build_desc["distro"]
133+
when "centos"
134+
system! "on-target -u root mkdir -p /var/cache/gitian"
135+
system! "on-target -u root yum -y update > var/upgrade.log 2>&1"
136+
system! "copy-to-target #{@quiet_flag} var/upgrade.log /var/cache/gitian/upgrade.log"
137+
system! "on-target -u root touch /var/cache/gitian/initial-upgrade"
138+
else
139+
system! "on-target -u root bash < target-bin/upgrade-system.sh >> var/install.log 2>&1"
140+
end
121141
end
122142
info "Creating package manifest"
123-
system! "on-target -u root bash < target-bin/grab-packages.sh > var/base-#{suitearch}.manifest"
143+
144+
case build_desc["distro"]
145+
when "centos"
146+
system! "on-target -u root yumdb get checksum_data | awk '/checksum_data =/ { print $3, package; next } { package=$1 }' | sort --key 2 > var/base-#{suitearch}.manifest"
147+
else
148+
system! "on-target -u root bash < target-bin/grab-packages.sh > var/base-#{suitearch}.manifest"
149+
end
124150

125151
info "Creating build script (var/build-script)"
126152

@@ -143,7 +169,7 @@ EOF" if build_desc["sudo"] and @options[:allow_sudo]
143169
build_desc["remotes"].each do |remote|
144170
dir = sanitize(remote["dir"], remote["dir"])
145171

146-
author_date = `cd inputs/#{dir} && git log --format=@%at -1 | date +"%F %T" -u -f -`.strip
172+
author_date = `cd inputs/#{dir} > /dev/null && git log --format=@%at -1 | date +"%F %T" -u -f -`.strip
147173
raise "error looking up author date in #{dir}" unless $?.exitstatus == 0
148174

149175
system! "copy-to-target #{@quiet_flag} inputs/#{dir} build/"
@@ -220,11 +246,13 @@ in_sums = []
220246
build_dir = 'build'
221247
result_dir = 'result'
222248
cache_dir = 'cache'
249+
work_dir = 'var'
223250
enable_cache = build_desc["enable_cache"]
224251

225252
FileUtils.rm_rf(build_dir)
226253
FileUtils.mkdir(build_dir)
227254
FileUtils.mkdir_p(result_dir)
255+
FileUtils.mkdir_p(work_dir)
228256

229257
package_name = build_desc["name"] or raise "must supply name"
230258
package_name = sanitize(package_name, "package name")
@@ -290,13 +318,15 @@ build_desc["remotes"].each do |remote|
290318
end
291319
system!("cd inputs/#{dir} && git fetch --update-head-ok #{sanitize_path(remote["url"], remote["url"])} +refs/tags/*:refs/tags/* +refs/heads/*:refs/heads/*")
292320
commit = sanitize(remote["commit"], remote["commit"])
293-
commit = `cd inputs/#{dir} && git log --format=%H -1 #{commit}`.strip
321+
commit = `cd inputs/#{dir} > /dev/null && git log --format=%H -1 #{commit}`.strip
294322
raise "error looking up commit for tag #{remote["commit"]}" unless $?.exitstatus == 0
323+
info("commit is #{commit}")
295324
system!("cd inputs/#{dir} && git checkout -q #{commit}")
296325
system!("cd inputs/#{dir} && git submodule update --init --recursive --force")
297326
in_sums << "git:#{commit} #{dir}"
298327
end
299328

329+
300330
base_manifests = YAML::Omap.new
301331

302332
suites.each do |suite|
@@ -333,7 +363,7 @@ Dir.glob(File.join(out_dir, '**', '*'), File::FNM_DOTMATCH).sort.each do |file_i
333363
next if File.directory?(file_in_out)
334364
file = file_in_out.sub(out_dir + File::SEPARATOR, '')
335365
file = sanitize_path(file, file_in_out)
336-
out_sums[file] = `cd #{out_dir} && sha256sum #{file}`
366+
out_sums[file] = `cd #{out_dir} > /dev/null && sha256sum #{file}`
337367
raise "failed to sum #{file}" unless $? == 0
338368
puts out_sums[file] unless @options[:quiet]
339369
end
@@ -343,15 +373,15 @@ if enable_cache
343373
next if File.directory?(file_in_out)
344374
file = file_in_out.sub(cache_common_dir + File::SEPARATOR, '')
345375
file = sanitize_path(file, file_in_out)
346-
cache_common_sums[file] = `cd #{cache_common_dir} && sha256sum #{file}`
376+
cache_common_sums[file] = `cd #{cache_common_dir} > /dev/null && sha256sum #{file}`
347377
raise "failed to sum #{file}" unless $? == 0
348378
end
349379

350380
Dir.glob(File.join(cache_package_dir, '**', '*'), File::FNM_DOTMATCH).sort.each do |file_in_out|
351381
next if File.directory?(file_in_out)
352382
file = file_in_out.sub(cache_package_dir + File::SEPARATOR, '')
353383
file = sanitize_path(file, file_in_out)
354-
cache_package_sums[file] = `cd #{cache_package_dir} && sha256sum #{file}`
384+
cache_package_sums[file] = `cd #{cache_package_dir} > /dev/null && sha256sum #{file}`
355385
raise "failed to sum #{file}" unless $? == 0
356386
end
357387
end

0 commit comments

Comments
 (0)