require "./context.cr" require "./recipe.cr" extend Package # FIXME: recipe.clean? context autoclean? context = Context.new() context.packaging_backend = "apk" recipes = [] of Package::Recipe # FIXME: context.new_recipe? context.recipe? recipes << Recipe.new(context, "hello", "2.10").tap do |recipe| recipe.sources << "https://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz" # This is a voluntary mix of automatic and manual build # instructions. # Also, installing in /package makes testing with a real-life # package manager trivial and reduces the damage done in case # of… containment failure. ]:-> recipe.instructions.configure << "cd hello-#{recipe.version} && ./configure --prefix=/package" #recipe.instructions.build << "cd hello-#{recipe.version} && make" #recipe.instructions.install << "cd hello-#{recipe.version} && make DESTDIR='${PKG}' install" recipe.url = "https://www.gnu.org/software/hello/" recipe.description = "The GNU Hello program produces a familiar, friendly greeting." recipe.dependencies << "gettext" # Should be automatic now. #recipe.packages << Package::Package.new(recipe).tap do |package| # package.name = "#{recipe.name}-man" # package.files = ["/package/share/man"] #end end # Be careful with that one. It’s not configured to use proper prefixes. # (Not sure that it should though. It’s gotta put things in /sbin anyway.) recipes << Recipe.new(context, "sysvinit", "2.95").tap do |recipe| recipe.sources << "https://git.savannah.nongnu.org/cgit/sysvinit.git/snapshot/sysvinit-#{recipe.version}.tar.gz" recipe.url = "https://savannah.nongnu.org/projects/sysvinit" recipe.description = "System V-like init system." recipe.instructions.install << "cd sysvinit-#{recipe.version} && make ROOT='#{recipe.fake_root_directory}' install" end recipes << Recipe.new(context, "musl", "1.1.23").tap do |recipe| recipe.sources << "https://www.musl-libc.org/releases/musl-#{recipe.version}.tar.gz" recipe.url = "https://www.musl-libc.org/" recipe.description = "The musl c library (libc) implementation." end if ARGV.size == 0 || ARGV[0]? == "-h" pp recipes.map &.name exit 0 end selected_recipes = ARGV.map do |name| recipes.find(&.name.==(name)) || name end if selected_recipes.any? &.is_a?(String) puts "At least one of the requested recipes is not known." selected_recipes.select! &.is_a?(String) pp! selected_recipes end # Getting rid of Strings. selected_recipes = selected_recipes.compact_map do |recipe| if recipe.is_a? String nil else recipe end end selected_recipes.each do |recipe| pp recipe raise "oh no, download failed" unless recipe.download raise "oh no, extraction failed" unless recipe.extract raise "oh no, build failed" unless recipe.build raise "oh no, packaging failed" unless recipe.package recipe.clean end