Archived
3
0

weirdos => baguetteos, zstd, removing deprecated function call

This commit is contained in:
Karchnu 2021-02-20 10:03:02 +01:00
parent 3b6d14392c
commit fecac6b3d5
2 changed files with 24 additions and 14 deletions

View File

@ -3,31 +3,41 @@ require "openssl"
require "../backends.cr"
class WeirdBackend < Package::Backend::Packaging
class BaguetteBackend < Package::Backend::Packaging
def initialize
@name = "weird"
@name = "baguette"
end
def package(context : Package::Context, package : Package::Package) : Bool
destination_package_file = "#{context.packages_directory}/#{package.name}-#{package.version}-#{package.release}.weird"
tmpdir = package.recipe.working_directory
fake_root = package.fake_root_directory
data_archive_path = "#{tmpdir}/data.tar"
compressed_data_archive_path = "#{tmpdir}/data.tar.zst"
control_spec_file_path = "#{tmpdir}/control.spec"
manifest_file_path = "#{tmpdir}/manifest"
package_filename = "#{context.packages_directory}/#{package.name}-#{package.version}-#{package.release}.baguette"
context.detail "Archiving package content"
context.run fake_root, "tar", ["cJf", "#{tmpdir}/data.tar.xz", "."]
context.run fake_root, "tar", ["cvf", data_archive_path, "."]
context.detail "Compressing the archive"
# produces data.tar.zst
context.run fake_root, "zstd", ["--ultra", data_archive_path]
context.detail "Generating control.spec"
generate_spec package, "#{tmpdir}/control.spec"
generate_spec package, control_spec_file_path
context.detail "Generating manifest"
generate_manifest context, package, "#{tmpdir}/manifest"
context.detail "Assembling '#{destination_package_file}'"
generate_manifest context, package, manifest_file_path
context.detail "Assembling '#{package_filename}'"
r = context.run tmpdir, "tar", [
"cf", destination_package_file,
"control.spec", "manifest", "data.tar.xz"
"cf", package_filename,
# WARNING: relative paths are necessary.
"control.spec", "manifest", "data.tar.zst"
]
r.exit_status == 0
@ -72,7 +82,7 @@ class WeirdBackend < Package::Backend::Packaging
elsif File.directory? path
manifest.puts [file, "directory"].join ':'
elsif File.info?(path).try &.file?
digest = OpenSSL::Digest.new("sha256").file(path).hexdigest
digest = OpenSSL::Digest.new("sha256").file(path).final.hexstring
manifest.puts [file, "file", digest].join ':'
else
manifest.puts [file, "other"].join ':'

View File

@ -6,7 +6,7 @@ require "./exception.cr"
require "./config.cr"
require "./backends/weird.cr"
require "./backends/baguette.cr"
require "./backends/apk.cr"
require "./backends/pkgutils.cr"
require "./backends.cr"
@ -58,14 +58,14 @@ class Package::Context
# but itll be kind of enough for now.
property architecture = "x86_64"
property prefixes = ["/usr", "/", "/usr/weirdos"]
property prefixes = ["/usr", "/", "/usr/baguetteos"]
property environment = {} of String => String
property verbosity = 0
def initialize
@packaging_backends << ApkBackend.new
@packaging_backends << WeirdBackend.new
@packaging_backends << BaguetteBackend.new
@packaging_backends << PkgutilsBackend.new
@selected_packaging_backend = @packaging_backends[0]