context#package(Package), grooming.
Preparations for splits and packaging backends.
This commit is contained in:
parent
ed2a48ca58
commit
97cd2f5191
@ -18,5 +18,12 @@ class Package::Context
|
||||
def run(command)
|
||||
run nil, command, nil
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -10,13 +10,13 @@ Context.new().tap do |context|
|
||||
Recipe.new(context, "hello", "2.10").tap do |recipe|
|
||||
recipe.sources << "https://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz"
|
||||
|
||||
recipe.download
|
||||
recipe.extract
|
||||
|
||||
#recipe.instructions.configure << "cd hello-#{recipe.version} && ./configure"
|
||||
#recipe.instructions.build << "cd hello-#{recipe.version} && make"
|
||||
recipe.instructions.install << "cd hello-#{recipe.version} && make DESTDIR='${PKG}' install"
|
||||
|
||||
recipe.download
|
||||
recipe.extract
|
||||
|
||||
raise "oh no, build failed" unless recipe.build
|
||||
recipe.package
|
||||
|
||||
|
@ -1,9 +1,26 @@
|
||||
|
||||
class Package::Package
|
||||
getter name : String
|
||||
getter version : String
|
||||
@recipe : Recipe
|
||||
|
||||
def initialize(@name, @version)
|
||||
def initialize(@recipe)
|
||||
end
|
||||
|
||||
macro inherit(attribute)
|
||||
@{{attribute.var.id}} : {{attribute.type.id}}?
|
||||
|
||||
def {{attribute.var.id}} : {{attribute.type.id}}
|
||||
@{{attribute.var.id}} || @recipe.{{attribute.var.id}}
|
||||
end
|
||||
end
|
||||
|
||||
inherit name : String
|
||||
inherit version : String
|
||||
|
||||
# Internals
|
||||
inherit fake_root_directory : String
|
||||
|
||||
def to_s
|
||||
"<Package: #{name}-#{version}>"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -26,16 +26,21 @@ class Package::Recipe
|
||||
getter packages : Array(Package)
|
||||
|
||||
getter instructions = Instructions.new
|
||||
|
||||
def initialize(@context, @name, @version)
|
||||
@sources = Sources.new
|
||||
@packages = [
|
||||
Package.new @name, @version
|
||||
]
|
||||
@packages = [] of Package
|
||||
|
||||
@working_uuid = UUID.random
|
||||
end
|
||||
|
||||
def self.new(context, name, version)
|
||||
instance = Recipe.allocate.tap &.initialize(context, name, version)
|
||||
|
||||
instance.packages << Package.new instance
|
||||
|
||||
instance
|
||||
end
|
||||
|
||||
def working_directory
|
||||
@context.working_directory
|
||||
end
|
||||
@ -100,9 +105,13 @@ class Package::Recipe
|
||||
success
|
||||
end
|
||||
|
||||
# TODO:
|
||||
# - Errors management. Stop at first failure?
|
||||
# - Splits. This should be done between #build and #package.
|
||||
def package
|
||||
puts "#{fake_root_directory} -> #{@context.packages_directory}/#{name}##{version}.pkg.tar.xz"
|
||||
pp! @context.run fake_root_directory, "tar", ["cJf", "#{@context.packages_directory}/#{name}##{version}.pkg.tar.xz", "."]
|
||||
@packages.find do |package|
|
||||
! @context.package package
|
||||
end
|
||||
end
|
||||
|
||||
def clean
|
||||
|
Reference in New Issue
Block a user