2019-09-06 00:39:11 +02:00
|
|
|
|
require "../backends.cr"
|
|
|
|
|
|
|
|
|
|
# FIXME: Where should this go? We can’t just leave it here. :(
|
|
|
|
|
def pkginfo(package)
|
|
|
|
|
du = `du -sk #{package.fake_root_directory}`
|
|
|
|
|
size = du.sub(/[ \t].*/, "").to_i * 1024
|
|
|
|
|
|
|
|
|
|
lines = [] of String
|
|
|
|
|
|
|
|
|
|
lines << "# Generated by `package`."
|
|
|
|
|
lines << "pkgname = #{package.name}"
|
|
|
|
|
lines << "pkgver = #{package.version}-r#{package.release}"
|
|
|
|
|
lines << "url = #{package.url || ""} "
|
|
|
|
|
lines << "size = #{size}"
|
|
|
|
|
lines << "origin = #{package.recipe.name}"
|
|
|
|
|
lines << "buildtype = host" # This’ll need to be imported from Context.
|
|
|
|
|
lines << "builddate = #{Time.utc.to_unix}"
|
|
|
|
|
|
|
|
|
|
package.dependencies.each do |atom|
|
|
|
|
|
lines << "depend = #{atom.to_s}"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
package.provides.each do |atom|
|
|
|
|
|
lines << "provides = #{atom.to_s}"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
package.conflicts.each do |atom|
|
|
|
|
|
lines << "conflicts = #{atom.to_s}"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
lines.join("\n") + "\n"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
class ApkBackend < Package::Backend::Packaging
|
|
|
|
|
def initialize
|
|
|
|
|
@name = "apk"
|
|
|
|
|
end
|
|
|
|
|
|
2019-09-27 13:59:23 +02:00
|
|
|
|
def package(context : Package::Context, package : Package::Package) : Bool
|
2019-09-06 00:39:11 +02:00
|
|
|
|
# FIXME: This needs to have access to architecture (from Context?)
|
|
|
|
|
# to work properly.
|
|
|
|
|
old_cwd = Dir.current
|
|
|
|
|
|
|
|
|
|
File.write "#{package.fake_root_directory}/.PKGINFO", pkginfo package
|
|
|
|
|
|
|
|
|
|
# Create data.tar.gz here.
|
|
|
|
|
package_target = "#{context.packages_directory}/#{context.architecture}/#{package.name}-#{package.version}-r#{package.release}.apk"
|
|
|
|
|
Dir.mkdir_p File.dirname package_target
|
|
|
|
|
|
|
|
|
|
# FIXME: This shouldn’t have to be in users’ PATH. libexec?
|
|
|
|
|
r = context.run package.fake_root_directory, "#{OWN_LIBEXEC_DIR}/assemble-apk.sh", [
|
|
|
|
|
package_target
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
r.exit_status == 0
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|