Obsolete
/
packaging
Archived
3
0
Fork 0

reading options and user phases in /etc/packaging.cfg

master
Philippe Pittoli 2021-03-09 19:09:02 +01:00
parent 15ccc1518e
commit 42235d107d
2 changed files with 30 additions and 0 deletions

View File

@ -20,6 +20,9 @@ class Package::Context
getter packaging_backends = Hash(String, Backend::Packaging).new
getter splitter_backends = Hash(String, Backend::Splitter).new
# General options, to add to the recipe before reading it.
getter options = Hash(String, String).new
getter all_phase_names = [
"sources-split",
"pre-configure", "configure",
@ -111,9 +114,11 @@ class Package::Context
@sources_directory = value.as_s
when "working-directory"
@working_directory = value.as_s
when "prefixes"
# Prefixes during the build process.
@prefixes = value.as_a_or_s
when "build-cores"
# NB of cores used to compile applications.
@build_cores = value.as_s.to_i
@ -136,6 +141,25 @@ class Package::Context
end
end
when "options"
value.as_a_or_s.each do |option|
match = option.split(':').map(&.strip)
if match.size != 2
STDERR.puts "WARNING: misformed option: #{option}"
next
end
key, value = match
@options[key] = value
end
# (default) user instructions (for testing).
when /(?<phase>(pre-)?(configure|build|install)|post-install)/
phase = $~["phase"]
@user_instructions[phase] = Instructions.new(phase).<<(value.as_s_or_ls)
when "package-manager"
# Targeted package manager (default: package, for BaguetteOS).
begin

View File

@ -80,6 +80,9 @@ class Package::Recipe
property require_stripping = true
def initialize(@context, @name, @version)
@context.options.each do |k, v|
@options[k] = v
end
end
def self.new(context, name, version)
@ -91,6 +94,9 @@ class Package::Recipe
end
def initialize(@context, filename : String)
@context.options.each do |k, v|
@options[k] = v
end
specs = SpecParser.parse File.read(filename), {
"pkg" => fake_root_directory,
"prefix" => prefix