Merge pull request #64 from theuni/cache

cache fixes
This commit is contained in:
Dev Random 2014-08-12 19:05:39 -07:00
commit 611292cdcb

View File

@ -177,11 +177,13 @@ cache_dir = 'cache'
FileUtils.rm_rf(build_dir)
FileUtils.mkdir(build_dir)
FileUtils.mkdir_p(result_dir)
FileUtils.mkdir_p(cache_dir)
package_name = build_desc["name"] or raise "must supply name"
package_name = sanitize(package_name, "package name")
FileUtils.mkdir_p(File.join(cache_dir, "common"))
FileUtils.mkdir_p(File.join(cache_dir, package_name))
suites = build_desc["suites"] or raise "must supply suites"
archs = build_desc["architectures"] or raise "must supply architectures"
reference_datetime = build_desc["reference_datetime"] or raise "must supply reference_datetime"
@ -257,9 +259,11 @@ suites.each do |suite|
end
out_dir = File.join(build_dir, "out")
out_sums = {}
cache_common_dir = File.join(cache_dir, "common")
cache_package_dir = File.join(cache_dir, "#{package_name}")
out_sums = {}
cache_common_sums = {}
cache_package_sums = {}
info "Generating report"
Dir.glob(File.join(out_dir, '**', '*'), File::FNM_DOTMATCH).sort.each do |file_in_out|
@ -275,29 +279,32 @@ Dir.glob(File.join(cache_common_dir, '**', '*'), File::FNM_DOTMATCH).sort.each d
next if File.directory?(file_in_out)
file = file_in_out.sub(cache_common_dir + File::SEPARATOR, '')
file = sanitize_path(file, file_in_out)
out_sums[file] = `cd #{cache_common_dir} && sha256sum #{file}`
cache_common_sums[file] = `cd #{cache_common_dir} && sha256sum #{file}`
raise "failed to sum #{file}" unless $? == 0
puts out_sums[file] unless @options[:quiet]
end
Dir.glob(File.join(cache_package_dir, '**', '*'), File::FNM_DOTMATCH).sort.each do |file_in_out|
next if File.directory?(file_in_out)
file = file_in_out.sub(cache_package_dir + File::SEPARATOR, '')
file = sanitize_path(file, file_in_out)
out_sums[file] = `cd #{cache_package_dir} && sha256sum #{file}`
cache_package_sums[file] = `cd #{cache_package_dir} && sha256sum #{file}`
raise "failed to sum #{file}" unless $? == 0
puts out_sums[file] unless @options[:quiet]
end
out_manifest = out_sums.keys.sort.map { |key| out_sums[key] }.join('')
in_manifest = in_sums.join('')
cache_common_manifest = cache_common_sums.keys.sort.map { |key| cache_common_sums[key] }.join('')
cache_package_manifest = cache_package_sums.keys.sort.map { |key| cache_package_sums[key] }.join('')
# Use Omap to keep result deterministic
report = YAML::Omap[
'out_manifest', out_manifest,
'in_manifest', in_manifest,
'base_manifests', base_manifests,
'cache_common_manifest', cache_common_manifest,
'cache_package_manifest', cache_package_manifest,
]
result_file = "#{package_name}-res.yml"