enum Package::BuildStatus Success Failed Pass end # Building instructions # phases: src-split, (pre-)(configure|build|install) and post-install # name examples: autotools, cmake, make # build(context, recipe) class Package::Backend::Building getter phase : String getter name : String getter callback : Proc(Context, Recipe, BuildStatus) def initialize(@phase, @name, &block : Proc(Context, Recipe, BuildStatus)) @callback = block end def build(context : Context, recipe : Recipe) @callback.call context, recipe end end abstract class Package::Backend::Packaging getter name : String def initialize(@name) end abstract def package(pkgdir : String, architecture : String, package : Package) : Bool def self.install(packages : Array(String)) raise "'install' unimplemented for this backend, yet" end def install(packages : Array(String)) self.install packages end end # Package::Backend::Splitter = create new package from a recipe # takes (then stores) the given block # this block takes a recipe as a parameter and create a new package # the new package: # keep prefixes # new name = split name (-man, -src, ...) # split files class Package::Backend::Splitter def initialize(&block : Proc(Recipe, Package)) @callback = block end def create_split(recipe : Recipe) : Package @callback.call recipe end end require "./backends/*"