Obsolete
/
packaging
Archived
3
0
Fork 0
This repository has been archived on 2022-01-17. You can view files and clone it, but cannot push or open issues/pull-requests.
packaging/src/main.cr

74 lines
1.9 KiB
Crystal
Raw Normal View History

2019-07-02 03:50:50 +02:00
require "./context.cr"
require "./recipe.cr"
extend Package
# FIXME: recipe.clean? context autoclean?
2019-07-20 13:30:09 +02:00
context = Context.new()
context.packaging_backend = "apk"
2019-07-03 03:35:35 +02:00
2019-07-20 13:30:09 +02:00
recipes = [] of Package::Recipe
2019-07-02 03:50:50 +02:00
2019-07-20 13:30:09 +02:00
# 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"
2019-07-02 03:50:50 +02:00
2019-07-20 13:30:09 +02:00
# 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"
2019-07-20 13:30:09 +02:00
recipe.url = "https://www.gnu.org/software/hello/"
recipe.description = "The GNU Hello program produces a familiar, friendly greeting."
recipe.dependencies << "gettext"
2019-07-04 23:18:54 +02:00
2019-07-20 13:30:09 +02:00
# 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
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."
2019-07-20 13:30:09 +02:00
selected_recipes.select! &.is_a?(String)
pp! selected_recipes
end
2019-07-02 03:50:50 +02:00
2019-07-20 13:30:09 +02:00
# Getting rid of Strings.
selected_recipes = selected_recipes.compact_map do |recipe|
if recipe.is_a? String
nil
else
recipe
2019-07-02 03:50:50 +02:00
end
end
2019-07-20 13:30:09 +02:00
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