Obsolete
/
packaging
Archived
3
0
Fork 0

%{prefix} macro added.

- It is used in automated building instructions.
	- It is used in auto-splits.
	- It is preset before reading the recipe to the first of the
	  default prefixes defined in this context, and can be reset
	  to force the recipe to build somewhere else.
master
Luka Vandervelden 2019-08-28 20:26:15 +02:00
parent aac0eff75f
commit 4c66f13cae
2 changed files with 24 additions and 8 deletions

View File

@ -71,6 +71,8 @@ class Package::Context
# but itll be kind of enough for now. # but itll be kind of enough for now.
property architecture = "x86_64" property architecture = "x86_64"
property prefixes = ["/usr", "/", "/usr/weirdos"]
def initialize def initialize
@packaging_backends << Backend::Packaging.new "pkgutils" do |context, package| @packaging_backends << Backend::Packaging.new "pkgutils" do |context, package|
puts "#{package.fake_root_directory} -> #{packages_directory}/#{package.name}##{package.version}-#{package.release}.pkg.tar.xz" puts "#{package.fake_root_directory} -> #{packages_directory}/#{package.name}##{package.version}-#{package.release}.pkg.tar.xz"
@ -111,7 +113,7 @@ class Package::Context
next BuildStatus::Pass next BuildStatus::Pass
end end
child = context.sh "./configure --prefix=/usr #{recipe.options["configure"]? || ""}" child = context.sh "./configure --prefix=#{recipe.prefix} #{recipe.options["configure"]? || ""}"
if child.exit_status == 0 if child.exit_status == 0
BuildStatus::Success BuildStatus::Success
@ -154,19 +156,24 @@ class Package::Context
@splitter_backends << Backend::Splitter.new do |recipe| @splitter_backends << Backend::Splitter.new do |recipe|
Package.new(recipe, true).tap do |split| Package.new(recipe, true).tap do |split|
prefixes = (@prefixes + [recipe.prefix]).uniq
split.name = "#{recipe.name}-man" split.name = "#{recipe.name}-man"
split.files = ["/usr/share/man"] split.files = prefixes.map do |prefix|
"#{prefix}/share/man"
end
end end
end end
@splitter_backends << Backend::Splitter.new do |recipe| @splitter_backends << Backend::Splitter.new do |recipe|
Package.new(recipe, true).tap do |split| Package.new(recipe, true).tap do |split|
prefixes = (@prefixes + [recipe.prefix]).uniq
split.name = "#{recipe.name}-dev" split.name = "#{recipe.name}-dev"
split.files = ["/usr/include"] split.files = prefixes.map { |x| "#{x}/include" }
split.file_patterns = [ split.file_patterns = prefixes.map do |prefix|
Regex.new("^/lib/.*\\.a$"), Regex.new("^" + prefix + ".*\\.a$")
Regex.new("^/usr/lib/.*\\.a$") end
]
end end
end end
end end

View File

@ -57,6 +57,8 @@ class Package::Recipe
getter sources = Sources.new getter sources = Sources.new
getter packages = Array(Package).new getter packages = Array(Package).new
@prefix : String?
property recipe_directory = "." property recipe_directory = "."
@working_uuid : UUID = UUID.random @working_uuid : UUID = UUID.random
@ -74,7 +76,8 @@ class Package::Recipe
def initialize(@context, filename : String) def initialize(@context, filename : String)
specs = SpecFileParser.parse filename, { specs = SpecFileParser.parse filename, {
"pkg" => fake_root_directory "pkg" => fake_root_directory,
"prefix" => prefix
} }
name : String? = nil name : String? = nil
@ -112,6 +115,8 @@ class Package::Recipe
@instructions.install << value.as_s_or_ls @instructions.install << value.as_s_or_ls
when "dirname" when "dirname"
@dirname = value.as_s @dirname = value.as_s
when "prefix"
@prefix = value.as_s
when "dependencies" when "dependencies"
value.as_a_or_s.each do |atom| value.as_a_or_s.each do |atom|
@run_dependencies << atom @run_dependencies << atom
@ -182,6 +187,10 @@ class Package::Recipe
@dirname || "#{name}-#{version}" @dirname || "#{name}-#{version}"
end end
def prefix : String
@prefix || @context.prefixes[0]? || "/usr"
end
def download def download
sources.each do |url| sources.each do |url|
next if url.scheme == "file" next if url.scheme == "file"