Implement zapping of apk packages with ver different than aports (466) (#474)
This adds a new option to `zap`: `-m / --mismatch-bins` When set, any binary apks in the work directory packages folder will be removed if their version differs from the version in the relevant APKBUILD in aports.
This commit is contained in:
parent
946ba82cd4
commit
a9e5b362dc
|
@ -18,12 +18,13 @@ along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
|
|||
"""
|
||||
import os
|
||||
import glob
|
||||
import logging
|
||||
|
||||
import pmb.chroot
|
||||
import pmb.helpers.run
|
||||
|
||||
|
||||
def zap(args, confirm=True, packages=False, http=False):
|
||||
def zap(args, confirm=True, packages=False, http=False, mismatch_bins=False):
|
||||
pmb.chroot.shutdown(args)
|
||||
patterns = [
|
||||
"chroot_native",
|
||||
|
@ -44,3 +45,32 @@ def zap(args, confirm=True, packages=False, http=False):
|
|||
for match in matches:
|
||||
if not confirm or pmb.helpers.cli.confirm(args, "Remove " + match + "?"):
|
||||
pmb.helpers.run.root(args, ["rm", "-rf", match])
|
||||
|
||||
if mismatch_bins:
|
||||
binaries(args)
|
||||
# Re-index repos since apks may have been removed
|
||||
pmb.build.other.index_repo(args)
|
||||
|
||||
|
||||
def binaries(args):
|
||||
for arch_dir in os.scandir(os.path.realpath(args.work + "/packages/")):
|
||||
arch = arch_dir.name
|
||||
arch_pkg_path = os.path.realpath(args.work) + "/packages/" + arch
|
||||
bin_apks = pmb.parse.apkindex.parse(args, arch_pkg_path + "/APKINDEX.tar.gz")
|
||||
for bin_apk in bin_apks:
|
||||
bin_pkgname = bin_apks[bin_apk]["pkgname"]
|
||||
bin_version = bin_apks[bin_apk]["version"]
|
||||
bin_apk_path = arch_pkg_path + "/" + bin_pkgname + "-" + bin_version + ".apk"
|
||||
# Do not fail if unable to find aport
|
||||
aport = pmb.build.other.find_aport(args, bin_pkgname, False)
|
||||
if not aport:
|
||||
logging.warning("WARNING: Could not resolve aport for package " + bin_apk_path)
|
||||
continue
|
||||
apkbuild = pmb.parse.apkbuild(args, aport + "/APKBUILD")
|
||||
aport_version = apkbuild["pkgver"] + "-r" + apkbuild["pkgrel"]
|
||||
# Clear out any binary apks that do not match what is in aports
|
||||
if pmb.parse.version.compare(bin_version, aport_version) and os.path.exists(bin_apk_path):
|
||||
logging.info("Remove mismatched binary package (aports version: " +
|
||||
aport_version + "): " + arch + "/" + bin_pkgname + "-" +
|
||||
bin_version + ".apk")
|
||||
pmb.helpers.run.root(args, ["rm", bin_apk_path])
|
||||
|
|
|
@ -164,4 +164,4 @@ def log_distccd(args):
|
|||
|
||||
|
||||
def zap(args):
|
||||
pmb.chroot.zap(args, packages=args.packages, http=args.http)
|
||||
pmb.chroot.zap(args, packages=args.packages, http=args.http, mismatch_bins=args.mismatch_bins)
|
||||
|
|
|
@ -156,6 +156,9 @@ def arguments():
|
|||
" the precious, self-compiled packages")
|
||||
zap.add_argument("-hc", "--http", action="store_true", help="also delete http"
|
||||
"cache")
|
||||
zap.add_argument("-m", "--mismatch-bins", action="store_true", help="also delete"
|
||||
" binary packages that are newer than the corresponding"
|
||||
" package in aports")
|
||||
|
||||
# Action: stats
|
||||
stats = sub.add_parser("stats", help="show ccache stats")
|
||||
|
|
Loading…
Reference in New Issue