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
This commit is contained in:
Pablo Castellano 2017-07-29 17:16:43 +02:00 committed by Oliver Smith
parent 3926ef5b45
commit 2cbf56a4c4
3 changed files with 8 additions and 6 deletions

View File

@ -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])

View File

@ -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")

View File

@ -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'")