2019-09-27 13:59:23 +02:00
|
|
|
require "specparser"
|
2019-07-02 03:50:50 +02:00
|
|
|
|
|
|
|
class Package::Package
|
2019-07-03 05:23:48 +02:00
|
|
|
getter recipe : Recipe
|
2019-07-04 23:18:54 +02:00
|
|
|
getter automatic : Bool
|
2019-07-02 03:50:50 +02:00
|
|
|
|
2019-08-02 23:58:42 +02:00
|
|
|
def initialize(@recipe, @automatic = false, @fake_root_directory = nil)
|
2019-07-03 03:17:01 +02:00
|
|
|
end
|
|
|
|
|
2019-09-27 13:59:23 +02:00
|
|
|
def initialize(@recipe, section : SpecParser::Section)
|
2019-08-22 19:16:08 +02:00
|
|
|
@automatic = false
|
|
|
|
|
|
|
|
@name = section.options[0]
|
|
|
|
|
|
|
|
section.content.each do |name, value|
|
|
|
|
case name
|
|
|
|
when "version"
|
|
|
|
@version = value.as_s
|
|
|
|
when "release"
|
|
|
|
@release = value.as_s.to_i
|
|
|
|
when "url"
|
|
|
|
@url = value.as_s
|
|
|
|
when "description"
|
|
|
|
@description = value.as_s_or_ls
|
|
|
|
when "dependencies"
|
2021-02-28 20:56:51 +01:00
|
|
|
# Remember, no build-dep versus run-dep for packages!
|
|
|
|
# Build-deps are recipe-only!
|
2019-08-22 19:16:08 +02:00
|
|
|
@dependencies = value.as_a_or_s
|
|
|
|
when "conflicts"
|
|
|
|
@conflicts = value.as_a_or_s
|
|
|
|
when "provides"
|
|
|
|
@provides = value.as_a_or_s
|
|
|
|
when "files"
|
|
|
|
@files = value.as_a_or_s
|
|
|
|
when "file-patterns"
|
|
|
|
@file_patterns = value.as_a_or_s.map { |x| Regex.new x }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-07-03 03:17:01 +02:00
|
|
|
macro inherit(attribute)
|
|
|
|
@{{attribute.var.id}} : {{attribute.type.id}}?
|
|
|
|
|
|
|
|
def {{attribute.var.id}} : {{attribute.type.id}}
|
|
|
|
@{{attribute.var.id}} || @recipe.{{attribute.var.id}}
|
|
|
|
end
|
2019-07-03 04:24:33 +02:00
|
|
|
|
|
|
|
def {{attribute.var.id}}=(new_value : {{attribute.type.id}})
|
|
|
|
@{{attribute.var.id}} = new_value
|
|
|
|
end
|
2019-07-03 03:17:01 +02:00
|
|
|
end
|
|
|
|
|
2019-07-03 04:24:33 +02:00
|
|
|
inherit name : String
|
|
|
|
inherit version : String
|
|
|
|
inherit release : Int32
|
|
|
|
|
|
|
|
inherit url : String?
|
2019-09-06 11:13:15 +02:00
|
|
|
inherit description : String?
|
2019-07-03 04:24:33 +02:00
|
|
|
|
2019-08-06 20:55:24 +02:00
|
|
|
setter dependencies : Array(String)?
|
2019-07-03 04:24:33 +02:00
|
|
|
inherit conflicts : Array(String)
|
|
|
|
inherit provides : Array(String)
|
2019-07-03 03:17:01 +02:00
|
|
|
|
2019-07-04 07:51:00 +02:00
|
|
|
# Reference for splits. Recipe#packages[0] should keep this set to `nil`.
|
|
|
|
property files : Array(String)?
|
2019-07-23 17:33:38 +02:00
|
|
|
property file_patterns : Array(Regex)?
|
2019-07-04 07:51:00 +02:00
|
|
|
|
2019-09-06 00:39:11 +02:00
|
|
|
inherit prefix : String
|
|
|
|
|
2019-08-02 23:58:42 +02:00
|
|
|
@fake_root_directory : String?
|
|
|
|
|
2019-08-06 20:55:24 +02:00
|
|
|
def dependencies
|
|
|
|
@dependencies || @recipe.run_dependencies
|
|
|
|
end
|
|
|
|
|
2019-07-04 07:51:00 +02:00
|
|
|
def fake_root_directory
|
2019-08-02 23:58:42 +02:00
|
|
|
@fake_root_directory || "#{recipe.working_directory}/root-#{name}"
|
2019-07-04 07:51:00 +02:00
|
|
|
end
|
2019-07-03 03:17:01 +02:00
|
|
|
|
2021-02-28 20:56:51 +01:00
|
|
|
def to_s(io : IO)
|
|
|
|
io << "<Package: #{name}-#{version}>"
|
2019-07-02 03:50:50 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|