Disable zap on init for new devices (#418)

The device chroot shouldn't exist yet anyways. Also add a 'device_exists'
variable that can be used to determine if the device entered earlier in
the init has a deviceinfo under aports/device/device-*
This commit is contained in:
clayton craft 2017-08-19 09:04:53 -07:00 committed by Oliver Smith
parent c323f21ca5
commit 2d6f9befca
1 changed files with 6 additions and 5 deletions

View File

@ -72,6 +72,8 @@ def init(args):
cfg["pmbootstrap"]["device"] = pmb.helpers.cli.ask(args, "Device",
None, args.device, False, "[a-z0-9]+-[a-z0-9]+")
device_exists = os.path.exists(args.aports + "/device/device-" + cfg["pmbootstrap"]["device"] + "/deviceinfo")
# UI and work folder
cfg["pmbootstrap"]["ui"] = ask_for_ui(args)
cfg["pmbootstrap"]["work"] = ask_for_work_path(args)
@ -104,11 +106,10 @@ def init(args):
# Save config
pmb.config.save(args, cfg)
if len(glob.glob(args.work + "/chroot_*")) and pmb.helpers.cli.confirm(args, "Zap existing chroots to apply configuration?", default=True):
if not os.path.exists(args.aports + "/device/device-" + args.device + "/deviceinfo"):
setattr(args, "deviceinfo", None)
else:
setattr(args, "deviceinfo", pmb.parse.deviceinfo(args))
if (device_exists and
len(glob.glob(args.work + "/chroot_*")) and
pmb.helpers.cli.confirm(args, "Zap existing chroots to apply configuration?", default=True)):
setattr(args, "deviceinfo", pmb.parse.deviceinfo(args, device=cfg["pmbootstrap"]["device"]))
# Do not zap any existing packages or cache_http directories
pmb.chroot.zap(args, confirm=False)