From 6fc56f30344df267519bc31d58d241075c55087c Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Thu, 4 Jul 2019 02:23:15 +0200 Subject: [PATCH] Package::Backends are provided a context when called. --- src/context.cr | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/context.cr b/src/context.cr index 29eac71..20c05df 100644 --- a/src/context.cr +++ b/src/context.cr @@ -18,12 +18,12 @@ end class Package::Backend::Packaging getter name : String - def initialize(@name, &block : Proc(Package, Bool)) + def initialize(@name, &block : Proc(Context, Package, Bool)) @callback = block end - def package(package : Package) - @callback.call package + def package(context : Context, package : Package) + @callback.call context, package end end @@ -40,14 +40,14 @@ class Package::Context property architecture = "x86_64" def initialize - @packaging_backends << Backend::Packaging.new "pkgutils" do |package| + @packaging_backends << Backend::Packaging.new "pkgutils" do |context, package| puts "#{package.fake_root_directory} -> #{packages_directory}/#{package.name}##{package.version}-#{package.release}.pkg.tar.xz" pp! r = run package.fake_root_directory, "tar", ["cJf", "#{packages_directory}/#{package.name}##{package.version}.pkg.tar.xz", "."] r.exit_status == 0 end - @packaging_backends << Backend::Packaging.new "apk" do |package| + @packaging_backends << Backend::Packaging.new "apk" do |context, package| # FIXME: This needs to have access to architecture (from Context?) # to work properly. old_cwd = Dir.current @@ -59,8 +59,11 @@ class Package::Context puts pkginfo package File.write "#{package.fake_root_directory}/.PKGINFO", pkginfo package + # Create data.tar.gz here. - package_target = "#{packages_directory}/#{package.name}-#{package.version}-r#{package.release}.apk" + package_target = "#{packages_directory}/#{context.architecture}/#{package.name}-#{package.version}-r#{package.release}.apk" + Dir.mkdir_p File.dirname package_target + # FIXME: This shouldn’t have to be in users’ PATH. libexec? r = run package.fake_root_directory, "assemble-apk.sh", [ package_target @@ -141,7 +144,7 @@ class Package::Context end def package(package : Package) : Bool - @selected_packaging_backend.package package + @selected_packaging_backend.package self, package end end