Obsolete
/
packaging
Archived
3
0
Fork 0

`.weird` manifest format update.

master
Luka Vandervelden 2019-09-10 16:30:30 +02:00
parent f5ff2de183
commit 42a0d5dc31
1 changed files with 31 additions and 1 deletions

View File

@ -1,3 +1,5 @@
require "openssl"
require "../backends.cr"
@ -18,11 +20,14 @@ class WeirdBackend < Package::Backend::Packaging
context.detail "Generating control.spec"
generate_spec package, "#{tmpdir}/control.spec"
context.detail "Generating manifest"
generate_manifest context, package, "#{tmpdir}/manifest"
context.detail "Assembling '#{destination_package_file}'"
r = context.run tmpdir, "tar", [
"cf", destination_package_file,
"control.spec", "data.tar.xz"
"control.spec", "manifest", "data.tar.xz"
]
r.exit_status == 0
@ -46,5 +51,30 @@ class WeirdBackend < Package::Backend::Packaging
file.close
end
def generate_manifest(context : Package::Context, package : Package::Package, file_name : String)
old_pwd = Dir.current
manifest = File.open(file_name, "w").not_nil!
Dir.cd package.fake_root_directory
FileUtils.find "." do |path|
if File.symlink? path
manifest.puts [path, "symlink", File.readlink(path)].join ':'
elsif File.directory? path
manifest.puts [path, "directory"].join ':'
elsif File.info?(path).try &.file?
digest = OpenSSL::Digest.new("sha256").file(path).hexdigest
manifest.puts [path, "file", digest].join ':'
else
manifest.puts [path, "other"].join ':'
end
end
manifest.close
ensure
Dir.cd old_pwd.not_nil!
end
end