From 21c09b3b3c718f9ada374356b24c21fcfed9825a Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Wed, 9 Aug 2017 17:59:21 +0000 Subject: [PATCH] Fix various build issues (fix #189, fix #341) (#345) Changes: * Removed the apkindex_files cache. That particular cache caused bug #189 and didn't bring any real-world performance improvements (tested 3x with that cache and 3x without, no significant speed difference). I decided to remove it instead of keeping it/adding even more code to resolve the bug. * Fix the check for already built packages: always use the architecture, that the package should be built for instead of the architecture of the build environment (e.g. use armhf, even when building a noarch package in the x86_64 chroot). This partially resolves #341. * Make pmb.chroot.apk.install_is_necessary() more robust: If the binary package is missing, although it should be there, print a warning and build it with force. --- pmb/build/package.py | 3 +-- pmb/chroot/apk.py | 14 +++++++++++++- pmb/helpers/repo.py | 5 ----- pmb/parse/arguments.py | 1 - 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/pmb/build/package.py b/pmb/build/package.py index 5950c377..2220992f 100644 --- a/pmb/build/package.py +++ b/pmb/build/package.py @@ -53,8 +53,7 @@ def package(args, pkgname, carch, force=False, buildinfo=False): suffix) # Skip already built versions - if not force and not pmb.build.is_necessary( - args, carch_buildenv, apkbuild): + if not force and not pmb.build.is_necessary(args, carch, apkbuild): return # Initialize build environment, install/build makedepends diff --git a/pmb/chroot/apk.py b/pmb/chroot/apk.py index cca7aadc..2e2ce309 100644 --- a/pmb/chroot/apk.py +++ b/pmb/chroot/apk.py @@ -122,9 +122,21 @@ def install_is_necessary(args, build, arch, package, packages_installed): if package not in packages_installed: return True + # Make sure, that we really have a binary package + data_repo = pmb.parse.apkindex.read_any_index(args, package, arch) + if not data_repo: + logging.warning("WARNING: Internal error in pmbootstrap," + + " package '" + package + "' for " + arch + + " has not been built yet, but it should have" + " been. Rebuilding it with force. Please " + " report this, if there is no ticket about this" + " yet!") + pmb.build.package(args, package, arch, True) + return install_is_necessary(args, build, arch, package, + packages_installed) + # Compare the installed version vs. the version in the repos data_installed = packages_installed[package] - data_repo = pmb.parse.apkindex.read_any_index(args, package, arch) compare = pmb.parse.apkindex.compare_version(data_installed["version"], data_repo["version"]) # a) Installed newer (should not happen normally) diff --git a/pmb/helpers/repo.py b/pmb/helpers/repo.py index 5f756b47..0d4ad0b5 100644 --- a/pmb/helpers/repo.py +++ b/pmb/helpers/repo.py @@ -128,10 +128,6 @@ def apkindex_files(args, arch=None): if not arch: arch = args.arch_native - # Try to get a cached result first. - if arch in args.cache["apkindex_files"]: - return args.cache["apkindex_files"][arch] - # Local user repository (for packages compiled with pmbootstrap) ret = [args.work + "/packages/" + arch + "/APKINDEX.tar.gz"] @@ -151,5 +147,4 @@ def apkindex_files(args, arch=None): ret.append(args.work + "/cache_apk_" + arch + "/APKINDEX." + hash(url) + ".tar.gz") - args.cache["apkindex_files"][arch] = ret return ret diff --git a/pmb/parse/arguments.py b/pmb/parse/arguments.py index d62a0ba2..bd93f995 100644 --- a/pmb/parse/arguments.py +++ b/pmb/parse/arguments.py @@ -241,7 +241,6 @@ def arguments(): # Add a caching dict (caches parsing of files etc. for the current session) setattr(args, "cache", {"apkindex": {}, - "apkindex_files": {}, "apkbuild": {}, "apk_min_version_checked": [], "apk_repository_list_updated": [],