forked from Mirror/pmbootstrap
Also add more comments to the zap function.
This commit is contained in:
parent
41d6a002dd
commit
f7fa7ae1a9
2 changed files with 20 additions and 4 deletions
|
@ -25,20 +25,32 @@ import pmb.helpers.run
|
||||||
|
|
||||||
|
|
||||||
def zap(args, confirm=True, packages=False, http=False, mismatch_bins=False):
|
def zap(args, confirm=True, packages=False, http=False, mismatch_bins=False):
|
||||||
|
"""
|
||||||
|
Shutdown everything inside the chroots (e.g. distccd, adb), umount
|
||||||
|
everything and then safely remove folders from the work-directory.
|
||||||
|
|
||||||
|
:arg packages: Remove *all* self-compiled packages (!)
|
||||||
|
: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
|
||||||
|
compared to what is in the abuilds folder.
|
||||||
|
|
||||||
|
NOTE: This function gets called in pmb/config/init.py, with only args.work
|
||||||
|
and args.device set!
|
||||||
|
"""
|
||||||
pmb.chroot.shutdown(args)
|
pmb.chroot.shutdown(args)
|
||||||
|
|
||||||
|
# Deletion patterns for folders inside args.work
|
||||||
patterns = [
|
patterns = [
|
||||||
"chroot_native",
|
"chroot_native",
|
||||||
"chroot_buildroot_*",
|
"chroot_buildroot_*",
|
||||||
"chroot_rootfs_*",
|
"chroot_rootfs_*",
|
||||||
]
|
]
|
||||||
|
|
||||||
# Only ask for removal, if the user specificed the extra '-p' switch.
|
|
||||||
# Deleting the packages by accident is really annoying.
|
|
||||||
if packages:
|
if packages:
|
||||||
patterns += ["packages"]
|
patterns += ["packages"]
|
||||||
if http:
|
if http:
|
||||||
patterns += ["cache_http"]
|
patterns += ["cache_http"]
|
||||||
|
|
||||||
|
# Delete everything matching the patterns
|
||||||
for pattern in patterns:
|
for pattern in patterns:
|
||||||
pattern = os.path.realpath(args.work + "/" + pattern)
|
pattern = os.path.realpath(args.work + "/" + pattern)
|
||||||
matches = glob.glob(pattern)
|
matches = glob.glob(pattern)
|
||||||
|
@ -46,9 +58,9 @@ def zap(args, confirm=True, packages=False, http=False, mismatch_bins=False):
|
||||||
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:
|
if mismatch_bins:
|
||||||
binaries(args)
|
binaries(args)
|
||||||
# Re-index repos since apks may have been removed
|
|
||||||
pmb.build.other.index_repo(args)
|
pmb.build.other.index_repo(args)
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,6 +73,7 @@ def binaries(args):
|
||||||
bin_pkgname = bin_apks[bin_apk]["pkgname"]
|
bin_pkgname = bin_apks[bin_apk]["pkgname"]
|
||||||
bin_version = bin_apks[bin_apk]["version"]
|
bin_version = bin_apks[bin_apk]["version"]
|
||||||
bin_apk_path = arch_pkg_path + "/" + bin_pkgname + "-" + bin_version + ".apk"
|
bin_apk_path = arch_pkg_path + "/" + bin_pkgname + "-" + bin_version + ".apk"
|
||||||
|
|
||||||
# Do not fail if unable to find aport
|
# Do not fail if unable to find aport
|
||||||
aport = pmb.build.other.find_aport(args, bin_pkgname, False)
|
aport = pmb.build.other.find_aport(args, bin_pkgname, False)
|
||||||
if not aport:
|
if not aport:
|
||||||
|
@ -68,6 +81,7 @@ def binaries(args):
|
||||||
continue
|
continue
|
||||||
apkbuild = pmb.parse.apkbuild(args, aport + "/APKBUILD")
|
apkbuild = pmb.parse.apkbuild(args, aport + "/APKBUILD")
|
||||||
aport_version = apkbuild["pkgver"] + "-r" + apkbuild["pkgrel"]
|
aport_version = apkbuild["pkgver"] + "-r" + apkbuild["pkgrel"]
|
||||||
|
|
||||||
# Clear out any binary apks that do not match what is in aports
|
# 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):
|
if pmb.parse.version.compare(bin_version, aport_version) and os.path.exists(bin_apk_path):
|
||||||
logging.info("Remove mismatched binary package (aports version: " +
|
logging.info("Remove mismatched binary package (aports version: " +
|
||||||
|
|
|
@ -129,6 +129,8 @@ def init(args):
|
||||||
# Save config
|
# Save config
|
||||||
pmb.config.save(args, cfg)
|
pmb.config.save(args, cfg)
|
||||||
|
|
||||||
|
# Zap existing chroots
|
||||||
|
setattr(args, "work", cfg["pmbootstrap"]["work"])
|
||||||
if (device_exists and
|
if (device_exists and
|
||||||
len(glob.glob(args.work + "/chroot_*")) and
|
len(glob.glob(args.work + "/chroot_*")) and
|
||||||
pmb.helpers.cli.confirm(args, "Zap existing chroots to apply configuration?", default=True)):
|
pmb.helpers.cli.confirm(args, "Zap existing chroots to apply configuration?", default=True)):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue