From 2cbf56a4c4b02d6d91b7f5ad86657a0a1a0d718b Mon Sep 17 00:00:00 2001 From: Pablo Castellano Date: Sat, 29 Jul 2017 17:16:43 +0200 Subject: [PATCH] Usability improvements, fix #278 (#279) * Quote architecture in logging message for easier reading * Added shortcut arguments for --rootfs, --buildroot and --suffix * Simply remove beforehand link to nowhere if exists (fix #278) Fixed crash when symlink already existed but pointed to a non-existing location --- pmb/flasher/export.py | 2 ++ pmb/parse/arch.py | 6 +++--- pmb/parse/arguments.py | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pmb/flasher/export.py b/pmb/flasher/export.py index d57945d8..5a2c9905 100644 --- a/pmb/flasher/export.py +++ b/pmb/flasher/export.py @@ -70,6 +70,8 @@ def export(args, flavor, folder): os.path.abspath(os.readlink(link)) == os.path.abspath(file)): continue raise RuntimeError("File exists: " + link) + elif os.path.islink(link): + os.unlink(link) # Create the symlink pmb.helpers.run.user(args, ["ln", "-s", file, link]) diff --git a/pmb/parse/arch.py b/pmb/parse/arch.py index be83947e..feac51df 100644 --- a/pmb/parse/arch.py +++ b/pmb/parse/arch.py @@ -30,7 +30,7 @@ def alpine_native(): } if machine in mapping: return mapping[machine] - raise ValueError("Can not map platform.machine " + machine + + raise ValueError("Can not map platform.machine '" + machine + "'" " to the right Alpine Linux architecture") return ret @@ -61,7 +61,7 @@ def alpine_to_debian(arch): for pattern, arch_debian in mapping.items(): if fnmatch.fnmatch(arch, pattern): return arch_debian - raise ValueError("Can not map Alpine architecture " + arch + + raise ValueError("Can not map Alpine architecture '" + arch + "'" " to the right Debian architecture.") @@ -100,7 +100,7 @@ def alpine_to_hostspec(arch): if arch in mapping: return mapping[arch] - raise ValueError("Can not map Alpine architecture " + arch + + raise ValueError("Can not map Alpine architecture '" + arch + "'" " to the right hostspec value") diff --git a/pmb/parse/arguments.py b/pmb/parse/arguments.py index 9a083e3e..81b9bcee 100644 --- a/pmb/parse/arguments.py +++ b/pmb/parse/arguments.py @@ -152,12 +152,12 @@ def arguments(): " to execute inside the chroot. default: sh", nargs='*') for action in [build_init, chroot]: suffix = action.add_mutually_exclusive_group() - suffix.add_argument("--rootfs", action="store_true", + suffix.add_argument("-r", "--rootfs", action="store_true", help="Chroot for the device root file system") - suffix.add_argument("--buildroot", action="store_true", + suffix.add_argument("-b", "--buildroot", action="store_true", help="Chroot for building packages for the device " "architecture") - suffix.add_argument("--suffix", default=None, + suffix.add_argument("-s", "--suffix", default=None, help="Specify any chroot suffix, defaults to" " 'native'")