forked from Mirror/pmbootstrap
Add argument to zap (-o) older versions of packages from all chroots (#841)
- also moved the mismatch clean (-m) before zapping the chroots - added confirmation questions to -o and -m
This commit is contained in:
parent
2b7dbb9433
commit
ba3e2f6d26
3 changed files with 35 additions and 8 deletions
|
@ -24,7 +24,8 @@ import pmb.chroot
|
||||||
import pmb.helpers.run
|
import pmb.helpers.run
|
||||||
|
|
||||||
|
|
||||||
def zap(args, confirm=True, packages=False, http=False, mismatch_bins=False, distfiles=False):
|
def zap(args, confirm=True, packages=False, http=False, mismatch_bins=False,
|
||||||
|
old_bins=False, distfiles=False):
|
||||||
"""
|
"""
|
||||||
Shutdown everything inside the chroots (e.g. distccd, adb), umount
|
Shutdown everything inside the chroots (e.g. distccd, adb), umount
|
||||||
everything and then safely remove folders from the work-directory.
|
everything and then safely remove folders from the work-directory.
|
||||||
|
@ -33,11 +34,22 @@ def zap(args, confirm=True, packages=False, http=False, mismatch_bins=False, dis
|
||||||
:arg http: Clear the http cache (used e.g. for the initial apk download)
|
:arg http: Clear the http cache (used e.g. for the initial apk download)
|
||||||
:arg mismatch_bins: Remove the packages, that have a different version
|
:arg mismatch_bins: Remove the packages, that have a different version
|
||||||
compared to what is in the abuilds folder.
|
compared to what is in the abuilds folder.
|
||||||
|
:arg old_bins: Clean out outdated binary packages downloaded from
|
||||||
|
mirrors (e.g. from Alpine)
|
||||||
:arg distfiles: Clear the downloaded files cache
|
:arg distfiles: Clear the downloaded files cache
|
||||||
|
|
||||||
NOTE: This function gets called in pmb/config/init.py, with only args.work
|
NOTE: This function gets called in pmb/config/init.py, with only args.work
|
||||||
and args.device set!
|
and args.device set!
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Delete packages with a different version compared to aports, then re-index
|
||||||
|
if mismatch_bins:
|
||||||
|
zap_mismatch_bins(args, confirm)
|
||||||
|
|
||||||
|
# Delete outdated binary packages
|
||||||
|
if old_bins:
|
||||||
|
zap_old_bins(args, confirm)
|
||||||
|
|
||||||
pmb.chroot.shutdown(args)
|
pmb.chroot.shutdown(args)
|
||||||
|
|
||||||
# Deletion patterns for folders inside args.work
|
# Deletion patterns for folders inside args.work
|
||||||
|
@ -61,13 +73,13 @@ def zap(args, confirm=True, packages=False, http=False, mismatch_bins=False, dis
|
||||||
if not confirm or pmb.helpers.cli.confirm(args, "Remove " + match + "?"):
|
if not confirm or pmb.helpers.cli.confirm(args, "Remove " + match + "?"):
|
||||||
pmb.helpers.run.root(args, ["rm", "-rf", match])
|
pmb.helpers.run.root(args, ["rm", "-rf", match])
|
||||||
|
|
||||||
# Delete packages with a different version compared to aports, then re-index
|
|
||||||
if mismatch_bins and os.path.exists(args.work + "/packages/"):
|
|
||||||
binaries(args)
|
|
||||||
pmb.build.other.index_repo(args)
|
|
||||||
|
|
||||||
|
def zap_mismatch_bins(args, confirm=True):
|
||||||
def binaries(args):
|
if not os.path.exists(args.work + "/packages/"):
|
||||||
|
return
|
||||||
|
if confirm and not pmb.helpers.cli.confirm(args, "Remove packages that are newer than"
|
||||||
|
" the corresponding package in aports?"):
|
||||||
|
return
|
||||||
for arch in os.listdir(os.path.realpath(args.work + "/packages/")):
|
for arch in os.listdir(os.path.realpath(args.work + "/packages/")):
|
||||||
arch_pkg_path = os.path.realpath(args.work) + "/packages/" + arch
|
arch_pkg_path = os.path.realpath(args.work) + "/packages/" + arch
|
||||||
# Delete all broken symbolic links
|
# Delete all broken symbolic links
|
||||||
|
@ -93,3 +105,15 @@ def binaries(args):
|
||||||
aport_version + "): " + arch + "/" + bin_pkgname + "-" +
|
aport_version + "): " + arch + "/" + bin_pkgname + "-" +
|
||||||
bin_version + ".apk")
|
bin_version + ".apk")
|
||||||
pmb.helpers.run.root(args, ["rm", bin_apk_path])
|
pmb.helpers.run.root(args, ["rm", bin_apk_path])
|
||||||
|
pmb.build.other.index_repo(args)
|
||||||
|
|
||||||
|
|
||||||
|
def zap_old_bins(args, confirm=True):
|
||||||
|
if confirm and not pmb.helpers.cli.confirm(args, "Remove outdated binary packages?"):
|
||||||
|
return
|
||||||
|
arch_native = pmb.parse.arch.alpine_native()
|
||||||
|
if os.path.exists(args.work + "/cache_apk_" + arch_native):
|
||||||
|
pmb.chroot.root(args, ["apk", "-v", "cache", "clean"])
|
||||||
|
for arch in pmb.config.build_device_architectures:
|
||||||
|
if arch != arch_native and os.path.exists(args.work + "/cache_apk_" + arch):
|
||||||
|
pmb.chroot.root(args, ["apk", "-v", "cache", "clean"], "buildroot_" + arch)
|
||||||
|
|
|
@ -221,4 +221,5 @@ def log_distccd(args):
|
||||||
|
|
||||||
def zap(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, distfiles=args.distfiles)
|
mismatch_bins=args.mismatch_bins, old_bins=args.old_bins,
|
||||||
|
distfiles=args.distfiles)
|
||||||
|
|
|
@ -174,6 +174,8 @@ def arguments():
|
||||||
zap.add_argument("-m", "--mismatch-bins", action="store_true", help="also delete"
|
zap.add_argument("-m", "--mismatch-bins", action="store_true", help="also delete"
|
||||||
" binary packages that are newer than the corresponding"
|
" binary packages that are newer than the corresponding"
|
||||||
" package in aports")
|
" package in aports")
|
||||||
|
zap.add_argument("-o", "--old-bins", action="store_true", help="also delete outdated"
|
||||||
|
" binary packages downloaded from mirrors (e.g. from Alpine)")
|
||||||
zap.add_argument("-d", "--distfiles", action="store_true", help="also delete"
|
zap.add_argument("-d", "--distfiles", action="store_true", help="also delete"
|
||||||
" downloaded files cache")
|
" downloaded files cache")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue