forked from Mirror/pmbootstrap
* apkindex: * Also parse the architecture field * symlink_noarch_package: * Renamed to symlink_noarch_packages * Always work on all packages (so we don't need to guess which subpackages have been generated after a certain build) * Get invoked when running 'pmbootstrap index' * Use 'apk index' to generate one index, where the architecture does not get rewritten (abuild does that by default, due to Alpine's repos not having a 'noarch' folder and diverging from that doesn't make things easier for us). That goes super fast, and then we know which packages are noarch packages and can create the symlinks. * Made output less verbose: * Use -q for 'apk index' when calling it directly (when it gets called by abuild we can't control that) * Output that the APKINDEXes get reindexed only to the 'pmbootstrap log'.
This commit is contained in:
parent
0cc7869576
commit
1285f74c5f
6 changed files with 45 additions and 18 deletions
|
@ -1,6 +1,6 @@
|
||||||
pkgname=postmarketos-base
|
pkgname=postmarketos-base
|
||||||
pkgver=3
|
pkgver=3
|
||||||
pkgrel=7
|
pkgrel=8
|
||||||
pkgdesc="Meta package for minimal postmarketOS base"
|
pkgdesc="Meta package for minimal postmarketOS base"
|
||||||
url="https://github.com/postmarketOS"
|
url="https://github.com/postmarketOS"
|
||||||
arch="noarch"
|
arch="noarch"
|
||||||
|
|
|
@ -20,6 +20,6 @@ along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
|
||||||
from pmb.build.init import init
|
from pmb.build.init import init
|
||||||
from pmb.build.checksum import checksum
|
from pmb.build.checksum import checksum
|
||||||
from pmb.build.other import copy_to_buildpath, is_necessary, \
|
from pmb.build.other import copy_to_buildpath, is_necessary, \
|
||||||
symlink_noarch_package, find_aport, ccache_stats, index_repo
|
symlink_noarch_packages, find_aport, ccache_stats, index_repo
|
||||||
from pmb.build.package import package
|
from pmb.build.package import package
|
||||||
from pmb.build.menuconfig import menuconfig
|
from pmb.build.menuconfig import menuconfig
|
||||||
|
|
|
@ -129,7 +129,8 @@ def aports_files_out_of_sync_with_git(args, package=None):
|
||||||
ret = []
|
ret = []
|
||||||
if git_root and os.path.exists(git_root):
|
if git_root and os.path.exists(git_root):
|
||||||
# Find all out of sync files
|
# Find all out of sync files
|
||||||
tracked = pmb.helpers.git.find_out_of_sync_files_tracked(args, git_root)
|
tracked = pmb.helpers.git.find_out_of_sync_files_tracked(
|
||||||
|
args, git_root)
|
||||||
untracked = pmb.helpers.run.user(
|
untracked = pmb.helpers.run.user(
|
||||||
args, ["git", "ls-files", "--others", "--exclude-standard"],
|
args, ["git", "ls-files", "--others", "--exclude-standard"],
|
||||||
working_dir=git_root, return_stdout=True)
|
working_dir=git_root, return_stdout=True)
|
||||||
|
@ -247,9 +248,9 @@ def index_repo(args, arch=None):
|
||||||
for path in paths:
|
for path in paths:
|
||||||
path_arch = os.path.basename(path)
|
path_arch = os.path.basename(path)
|
||||||
path_repo_chroot = "/home/user/packages/user/" + path_arch
|
path_repo_chroot = "/home/user/packages/user/" + path_arch
|
||||||
logging.info("(native) index " + path_arch + " repository")
|
logging.debug("(native) index " + path_arch + " repository")
|
||||||
commands = [
|
commands = [
|
||||||
["apk", "index", "--output", "APKINDEX.tar.gz_",
|
["apk", "-q", "index", "--output", "APKINDEX.tar.gz_",
|
||||||
"--rewrite-arch", path_arch, "*.apk"],
|
"--rewrite-arch", path_arch, "*.apk"],
|
||||||
["abuild-sign", "APKINDEX.tar.gz_"],
|
["abuild-sign", "APKINDEX.tar.gz_"],
|
||||||
["mv", "APKINDEX.tar.gz_", "APKINDEX.tar.gz"]
|
["mv", "APKINDEX.tar.gz_", "APKINDEX.tar.gz"]
|
||||||
|
@ -260,21 +261,44 @@ def index_repo(args, arch=None):
|
||||||
"/APKINDEX.tar.gz")
|
"/APKINDEX.tar.gz")
|
||||||
|
|
||||||
|
|
||||||
def symlink_noarch_package(args, arch_apk):
|
def symlink_noarch_packages(args):
|
||||||
"""
|
"""
|
||||||
:param arch_apk: for example: x86_64/mypackage-1.2.3-r0.apk
|
All noarch packages from the native architecture folder (x86_64 usually)
|
||||||
|
get symlinked to all other architectures.
|
||||||
"""
|
"""
|
||||||
|
# Create the arch folders
|
||||||
for arch in pmb.config.build_device_architectures:
|
architectures = pmb.config.build_device_architectures
|
||||||
# Create the arch folder
|
logging.debug("Symlink noarch-packages to " + ", ".join(architectures))
|
||||||
|
for arch in architectures:
|
||||||
arch_folder = "/home/user/packages/user/" + arch
|
arch_folder = "/home/user/packages/user/" + arch
|
||||||
arch_folder_outside = args.work + "/packages/" + arch
|
arch_folder_outside = args.work + "/packages/" + arch
|
||||||
if not os.path.exists(arch_folder_outside):
|
if not os.path.exists(arch_folder_outside):
|
||||||
pmb.chroot.user(args, ["mkdir", "-p", arch_folder])
|
pmb.chroot.user(args, ["mkdir", "-p", arch_folder])
|
||||||
|
|
||||||
# Add symlink, rewrite index
|
# Create an APKINDEX *without* replaced architectures (that is much
|
||||||
pmb.chroot.user(args, ["ln", "-sf", "../" + arch_apk, "."],
|
# faster than reading each apk file with Python!)
|
||||||
working_dir=arch_folder)
|
index = "/tmp/APKINDEX_without_replaced_archs"
|
||||||
|
index_outside = args.work + "/chroot_native" + index
|
||||||
|
pmb.chroot.user(args, ["apk", "-q", "index", "--output", index, "*.apk"],
|
||||||
|
working_dir="/home/user/packages/user/" + args.arch_native)
|
||||||
|
|
||||||
|
# Iterate over noarch packages
|
||||||
|
for package, data in pmb.parse.apkindex.parse(args, index_outside).items():
|
||||||
|
if data["arch"] != "noarch":
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Create missing symlinks
|
||||||
|
apk_file = data["pkgname"] + "-" + data["version"] + ".apk"
|
||||||
|
for arch in architectures:
|
||||||
|
if os.path.exists(args.work + "/packages/" + arch + "/" + apk_file):
|
||||||
|
continue
|
||||||
|
arch_folder = "/home/user/packages/user/" + arch
|
||||||
|
source = "../" + args.arch_native + "/" + apk_file
|
||||||
|
pmb.chroot.user(args, ["ln", "-sf", source, "."],
|
||||||
|
working_dir=arch_folder)
|
||||||
|
|
||||||
|
# Rewrite indexes
|
||||||
|
for arch in architectures:
|
||||||
index_repo(args, arch)
|
index_repo(args, arch)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -124,9 +124,9 @@ def package(args, pkgname, carch, force=False, buildinfo=False, strict=False):
|
||||||
pmb.build.buildinfo.write(args, output, carch_buildenv, suffix,
|
pmb.build.buildinfo.write(args, output, carch_buildenv, suffix,
|
||||||
apkbuild)
|
apkbuild)
|
||||||
|
|
||||||
# Symlink noarch packages
|
# Symlink noarch package (and subpackages)
|
||||||
if "noarch" in apkbuild["arch"]:
|
if "noarch" in apkbuild["arch"]:
|
||||||
pmb.build.symlink_noarch_package(args, output)
|
pmb.build.symlink_noarch_packages(args)
|
||||||
|
|
||||||
# Clean up (APKINDEX cache, depends when strict)
|
# Clean up (APKINDEX cache, depends when strict)
|
||||||
pmb.parse.apkindex.clear_cache(args, args.work + "/packages/" +
|
pmb.parse.apkindex.clear_cache(args, args.work + "/packages/" +
|
||||||
|
|
|
@ -129,7 +129,8 @@ def config(args):
|
||||||
|
|
||||||
|
|
||||||
def index(args):
|
def index(args):
|
||||||
pmb.build.index_repo(args)
|
pmb.build.index_repo(args, args.arch_native)
|
||||||
|
pmb.build.symlink_noarch_packages(args)
|
||||||
|
|
||||||
|
|
||||||
def initfs(args):
|
def initfs(args):
|
||||||
|
|
|
@ -34,10 +34,11 @@ def parse_next_block(args, path, lines, start):
|
||||||
"by reference". Example: [5]
|
"by reference". Example: [5]
|
||||||
:param lines: all lines from the "APKINDEX" file inside the archive
|
:param lines: all lines from the "APKINDEX" file inside the archive
|
||||||
:returns: a dictionary with the following structure:
|
:returns: a dictionary with the following structure:
|
||||||
{ "pkgname": "postmarketos-mkinitfs",
|
{ "arch": "noarch",
|
||||||
"version": "0.0.4-r10",
|
|
||||||
"depends": ["busybox-extras", "lddtree", ... ],
|
"depends": ["busybox-extras", "lddtree", ... ],
|
||||||
|
"pkgname": "postmarketos-mkinitfs",
|
||||||
"provides": ["mkinitfs=0.0.1"],
|
"provides": ["mkinitfs=0.0.1"],
|
||||||
|
"version": "0.0.4-r10",
|
||||||
}
|
}
|
||||||
:returns: None, when there are no more blocks
|
:returns: None, when there are no more blocks
|
||||||
"""
|
"""
|
||||||
|
@ -45,6 +46,7 @@ def parse_next_block(args, path, lines, start):
|
||||||
# Parse until we hit an empty line or end of file
|
# Parse until we hit an empty line or end of file
|
||||||
ret = {}
|
ret = {}
|
||||||
mapping = {
|
mapping = {
|
||||||
|
"A": "arch",
|
||||||
"P": "pkgname",
|
"P": "pkgname",
|
||||||
"V": "version",
|
"V": "version",
|
||||||
"D": "depends",
|
"D": "depends",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue