Archived
3
0

Splits (sub-packages) support.

This commit is contained in:
Luka Vandervelden 2019-07-04 07:51:00 +02:00
parent 6fc56f3034
commit 255d644b93
4 changed files with 43 additions and 5 deletions

View File

@ -54,8 +54,6 @@ class Package::Context
puts "#{package.fake_root_directory} -> #{packages_directory}/#{package.name}-#{package.version}-r#{package.release}.apk"
run package.fake_root_directory, "find", [".."]
puts pkginfo package
File.write "#{package.fake_root_directory}/.PKGINFO", pkginfo package

View File

@ -25,6 +25,11 @@ Context.new().tap do |context|
recipe.description = "The GNU Hello program produces a familiar, friendly greeting."
recipe.dependencies << "gettext"
recipe.packages << Package::Package.new(recipe).tap do |package|
package.name = "#{recipe.name}-man"
package.files = ["/package/share/man"]
end
recipe.download
recipe.extract

View File

@ -28,8 +28,12 @@ class Package::Package
inherit conflicts : Array(String)
inherit provides : Array(String)
# Internals
inherit fake_root_directory : String
# Reference for splits. Recipe#packages[0] should keep this set to `nil`.
property files : Array(String)?
def fake_root_directory
"#{@recipe.working_directory}/root-#{name}"
end
def to_s
"<Package: #{name}-#{version}>"

View File

@ -68,7 +68,7 @@ class Package::Recipe
end
def fake_root_directory
"#{working_directory}/root"
@packages[0].fake_root_directory
end
def dirname
@ -120,9 +120,40 @@ class Package::Recipe
ENV["PKG"] = nil
do_splits
success
end
private def do_splits
@packages.each do |package|
next if package == @packages[0]
files = package.files
next if files.nil? # Should only happen to @packages[0].
# TODO: ↑ add public APIs that ensure it.
Dir.mkdir_p package.fake_root_directory
# FIXME: What do we do if those are not on the filesystem?
files.each do |file|
puts "#{package.fake_root_directory}#{File.dirname file}"
Dir.mkdir_p "#{package.fake_root_directory}#{File.dirname file}"
FileUtils.mv(
"#{fake_root_directory}#{file}",
"#{package.fake_root_directory}#{file}"
)
puts file
@context.run "find", [
"#{package.fake_root_directory}/#{file}"
]
end
end
end
# TODO:
# - Errors management. Stop at first failure?
# - Splits. This should be done between #build and #package.