Obsolete
/
packaging
Archived
3
0
Fork 0

Package::Backends are provided a context when called.

master
Luka Vandervelden 2019-07-04 02:23:15 +02:00
parent 77632f59ab
commit 6fc56f3034
1 changed files with 10 additions and 7 deletions

View File

@ -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 shouldnt 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