Splits can be defined in recipes.
This is done using `%split split-name` sections. `files` and `file-patterns` are both array attributes that can be provided to set what paths or files should go in them. Other variables can be overriden as well from that %split section.
This commit is contained in:
parent
bf2e12f673
commit
e6fb4d6c3d
@ -1,3 +1,4 @@
|
||||
require "specfileparser"
|
||||
|
||||
class Package::Package
|
||||
getter recipe : Recipe
|
||||
@ -6,6 +7,37 @@ class Package::Package
|
||||
def initialize(@recipe, @automatic = false, @fake_root_directory = nil)
|
||||
end
|
||||
|
||||
def initialize(@recipe, section : SpecFileParser::Section)
|
||||
@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"
|
||||
# Remember, no build-dep versus run-dep for
|
||||
# packages! Build-deps are recipe-only!
|
||||
@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
|
||||
|
||||
macro inherit(attribute)
|
||||
@{{attribute.var.id}} : {{attribute.type.id}}?
|
||||
|
||||
|
@ -158,14 +158,15 @@ class Package::Recipe
|
||||
|
||||
@name = name
|
||||
@version = version
|
||||
end
|
||||
|
||||
def self.new(context, filename : String)
|
||||
instance = Recipe.allocate.tap &.initialize(context, filename)
|
||||
# Packages can only be created once @name and @version exist!
|
||||
@packages << Package.new self, false, fake_root_directory
|
||||
|
||||
instance.packages << Package.new instance, false, instance.fake_root_directory
|
||||
|
||||
instance
|
||||
specs.sections.each do |section|
|
||||
if section.name == "split"
|
||||
@packages << Package.new self, section
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def working_directory
|
||||
@ -264,7 +265,6 @@ class Package::Recipe
|
||||
|
||||
FileUtils.find fake_root_directory do |file|
|
||||
file = file[fake_root_directory.size..file.size]
|
||||
pp! file
|
||||
files_to_split << file if file_patterns.any? &.match file
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user