From f7dc447c42bb49e2160abb726f58ca213b894926 Mon Sep 17 00:00:00 2001 From: merakor Date: Tue, 10 Aug 2021 22:59:26 +0000 Subject: cpt-chbuild: use pkg_download and update options FossilOrigin-Name: b114643526d6986860e89c5eb6f9b941542f1281bf2c8a3c76895c56c7a6ad69 --- contrib/cpt-chbuild | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'contrib/cpt-chbuild') diff --git a/contrib/cpt-chbuild b/contrib/cpt-chbuild index a58d2ee..dfceab0 100755 --- a/contrib/cpt-chbuild +++ b/contrib/cpt-chbuild @@ -3,6 +3,7 @@ ## SYNOPSIS: ## .Nm +## .Op Fl r ## .Op Ar pkg... ## DESCRIPTION: @@ -13,11 +14,17 @@ ## exist in the user's cache directory, it will download it from the Carbs Linux ## website. If any packages are given as arguments, ## .Nm -## will install those packages to this temporary chroot. +## will install those packages to this temporary chroot. If the +## .Fl r +## flag is given, +## .Nm +## will remove the rootfs tarball and directory to download it again. -case "$1" in - --help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg...]"; exit 0 -esac +parser_definition() { + setup REST help:usage -- "usage: ${0##*/} [-r] [pkg...]" + flag redownload -r hidden:1 + global_options silent +} # shellcheck disable=1091 . cpt-lib @@ -36,15 +43,20 @@ url="https://dl.carbslinux.org/releases/${arch:-$(uname -m)}/carbs-rootfs.tar.xz cd "${cac_dir:?}" +# Remove the existing tarball and the chroot directory, so that they can be +# downloaded again. +[ "$redownload" ] && rm -rf carbs-rootfs.tar.xz \ + carbs-rootfs.tar.xz.sum \ + carbs-chroot + [ -f carbs-rootfs.tar.xz ] || { log "Downloading chroot tarball" - curl -fLO "$url" + pkg_download "$url" } [ -f carbs-rootfs.tar.xz.sum ] || { log "Downloading checksums" - curl -fLo- "${url%/*}/sha256sums.txt" | - grep ' carbs-rootfs.tar.xz$' > carbs-rootfs.tar.xz.sum + pkg_download "$url.sha256" carbs-rootfs.tar.xz.sum } log "Verifying checksums" -- cgit v1.2.3