From afce4eecd5609b90da101816fe2c61ef073d6895 Mon Sep 17 00:00:00 2001 From: merakor Date: Fri, 21 Aug 2020 20:47:29 +0000 Subject: cpt-chbuild: use cpt library functions FossilOrigin-Name: 129658a961413017e5c128bc970f7b60b64077118a3883664286208825da1448 --- contrib/cpt-chbuild | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'contrib') diff --git a/contrib/cpt-chbuild b/contrib/cpt-chbuild index bfbbcd2..6a619ef 100755 --- a/contrib/cpt-chbuild +++ b/contrib/cpt-chbuild @@ -4,7 +4,8 @@ case "$1" in --help|-h) printf '\033[1;33m-> \033[m%s\n' "usage: ${0##*/} [pkg...]"; exit 0 esac -log() { printf '\033[31;1m->\033[m %s.\n' "$@" ;} +# shellcheck disable=1091 +. cpt-lib die() { rm -f carbs-rootfs.tar.xz carbs-rootfs.tar.xz.sum @@ -15,29 +16,11 @@ die() { exit 1 } -sh256() { - # There's no standard utility to generate sha256 checksums. - # This is a simple wrapper around sha256sum, sha256, shasum - # and openssl which will use whatever is available. - # - # All utilities must match 'sha256sum' output. - # - # Example: ' ' - [ -e "$1" ] || return 0 - - hash=$(sha256sum "$1" || - sha256 -r "$1" || - openssl dgst -sha256 -r "$1" || - shasum -a 256 "$1") - - printf '%s %s\n' "${hash%% *}" "$1" -} 2>/dev/null - case "$(uname -m)" in i*86) arch=i686; esac url="https://dl.carbslinux.org/releases/${arch:-$(uname -m)}/carbs-rootfs.tar.xz" pid=$$ -cd "${cac_dir:=$CPT_ROOT${CPT_CACHE:=${XDG_CACHE_HOME:-$HOME/.cache}/cpt}}" +cd "$cac_dir" [ -f carbs-rootfs.tar.xz ] || { log "Downloading chroot tarball" @@ -70,4 +53,4 @@ cp -a carbs-chroot "chroot-$pid" } log "Entering chroot" -su -c "cpt-chroot chroot-$pid; rm -rf chroot-$pid" +as_root sh -c "cpt-chroot chroot-$pid; rm -rf chroot-$pid" -- cgit v1.2.3