Packaging backends.

master
Luka Vandervelden 2019-07-03 03:35:35 +02:00
parent 97cd2f5191
commit fa92519f4d
2 changed files with 33 additions and 4 deletions

View File

@ -1,10 +1,40 @@
class Package::Backend::Packaging
getter name : String
def initialize(@name, &block : Proc(Package, Bool))
@callback = block
end
def package(package : Package)
@callback.call package
end
end
class Package::Context
property working_directory = "/tmp/package"
property sources_directory = Dir.current
property packages_directory = Dir.current
@packaging_backends = [] of Backend::Packaging
def initialize
@packaging_backends << Backend::Packaging.new "pkgutils" do |package|
puts "#{package.fake_root_directory} -> #{packages_directory}/#{package.name}##{package.version}.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
@selected_packaging_backend = @packaging_backends[0]
end
def packaging_backend=(name : String)
@selected_packaging_backend = @packaging_backends.find(&.name.==(name)).not_nil!
end
def packaging_backend=(backend : Backend::Packaging)
@selected_packaging_backend = backend
end
def run(chdir, command, args)
@ -20,10 +50,7 @@ class Package::Context
end
def package(package : Package) : Bool
puts "#{package.fake_root_directory} -> #{packages_directory}/#{package.name}##{package.version}.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
@selected_packaging_backend.package package
end
end

View File

@ -6,6 +6,8 @@ extend Package
# FIXME: recipe.clean? context autoclean?
Context.new().tap do |context|
context.packaging_backend = "pkgutils"
# FIXME: context.new_recipe? context.recipe?
Recipe.new(context, "hello", "2.10").tap do |recipe|
recipe.sources << "https://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz"