Obsolete
/
packaging
Archived
3
0
Fork 0

Improved recipe.spec reader.

master
Luka Vandervelden 2019-08-02 23:58:42 +02:00
parent e0ce1ddd2a
commit c2843858ee
3 changed files with 19 additions and 17 deletions

View File

@ -179,13 +179,7 @@ class Package::Context
end end
def read_recipe(filename : String) def read_recipe(filename : String)
specs = Specs.parse filename Recipe.new self, filename
if specs.nil?
raise Exception.new "file could not be parsed"
end
Recipe.new self, specs
end end
end end

View File

@ -3,7 +3,7 @@ class Package::Package
getter recipe : Recipe getter recipe : Recipe
getter automatic : Bool getter automatic : Bool
def initialize(@recipe, @automatic = false) def initialize(@recipe, @automatic = false, @fake_root_directory = nil)
end end
macro inherit(attribute) macro inherit(attribute)
@ -33,8 +33,10 @@ class Package::Package
property files : Array(String)? property files : Array(String)?
property file_patterns : Array(Regex)? property file_patterns : Array(Regex)?
@fake_root_directory : String?
def fake_root_directory def fake_root_directory
"#{@recipe.working_directory}/root-#{name}" @fake_root_directory || "#{recipe.working_directory}/root-#{name}"
end end
def to_s def to_s

View File

@ -121,14 +121,20 @@ class Package::Recipe
def self.new(context, name, version) def self.new(context, name, version)
instance = Recipe.allocate.tap &.initialize(context, name, version) instance = Recipe.allocate.tap &.initialize(context, name, version)
instance.packages << Package.new instance instance.packages << Package.new instance, false, instance.fake_root_directory
instance instance
end end
def initialize(@context, specs : Specs) def initialize(@context, filename : String)
name : String? = nil specs = Specs.parse filename, {
version : String? = nil "pkg" => fake_root_directory
}
raise "Could not parse `#{filename}`" if specs.nil?
@name = "" # Needed to avoid build-time errors.
@version = "" # Same.
specs.assignments.each do |key, value| specs.assignments.each do |key, value|
case key case key
@ -192,10 +198,10 @@ class Package::Recipe
@version = version @version = version
end end
def self.new(context, specs : Specs) def self.new(context, filename : String)
instance = Recipe.allocate.tap &.initialize(context, specs) instance = Recipe.allocate.tap &.initialize(context, filename)
instance.packages << Package.new instance instance.packages << Package.new instance, false, instance.fake_root_directory
instance instance
end end
@ -209,7 +215,7 @@ class Package::Recipe
end end
def fake_root_directory def fake_root_directory
@packages[0].fake_root_directory "#{working_directory}/root"
end end
def dirname def dirname