cpt

[ARCHIVED] Carbs Packaging Tools
git clone git://git.ckyln.com/~cem/cpt.git
Log | Files | Refs | README | LICENSE

commit e7b88e76877661b1cc65f3570691bb4899b9e105
parent a59f1dad6065314307e1a7601a178bb6389453ba
Author: Dylan Araps <dylan.araps@gmail.com>
Date:   Wed,  5 Feb 2020 01:20:30 +0200

kiss: Use libarchive tar if available.

Diffstat:
Mkiss | 14+++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/kiss b/kiss @@ -228,7 +228,7 @@ pkg_extract() { # Any other file-types are simply copied to '$mak_dir' which # allows for manual extraction. *://*.tar|*://*.tar.??|*://*.tar.???|*://*.tar.????|*://*.tgz) - tar xf "$src_dir/$1/${src##*/}" --strip-components 1 || + "$tar" xf "$src_dir/$1/${src##*/}" --strip-components 1 || die "$1" "Couldn't extract ${src##*/}" ;; @@ -430,7 +430,7 @@ pkg_tar() { read -r version release < "$(pkg_find "$1")/version" # Create a tar-ball from the contents of the built package. - tar zpcf "$bin_dir/$1#$version-$release.tar.gz" -C "$pkg_dir/$1" . || + "$tar" zpcf "$bin_dir/$1#$version-$release.tar.gz" -C "$pkg_dir/$1" . || die "$1" "Failed to create tar-ball" log "$1" "Successfully created tar-ball" @@ -654,7 +654,7 @@ pkg_conflicts() { # Filter the tarball's manifest and select only files # and any files they resolve to on the filesystem # (/bin/ls -> /usr/bin/ls). - tar xf "$1" -O "./$pkg_db/$2/manifest" | while read -r file; do + "$tar" xf "$1" -O "./$pkg_db/$2/manifest" | while read -r file; do case $file in */) continue; esac printf '%s/%s\n' \ @@ -869,7 +869,7 @@ pkg_install() { # Figure out which package the tar-ball installs by checking for # a database entry inside the tar-ball. If no database entry exists, # exit here as the tar-ball is *most likely* not a KISS package. - pkg_name=$(tar tf "$tar_file" | "$grep" -x "\./$pkg_db/.*/version") || + pkg_name=$("$tar" tf "$tar_file" | "$grep" -x "\./$pkg_db/.*/version") || die "'${tar_file##*/}' is not a valid KISS package" pkg_name=${pkg_name%/*} @@ -878,7 +878,7 @@ pkg_install() { mkdir -p "$tar_dir/$pkg_name" # Extract the tar-ball to catch any errors before installation begins. - tar pxf "$tar_file" -C "$tar_dir/$pkg_name" || + "$tar" pxf "$tar_file" -C "$tar_dir/$pkg_name" || die "$pkg_name" "Failed to extract tar-ball" log "$pkg_name" "Checking that all dependencies are installed" @@ -1295,6 +1295,10 @@ main() { # POSIX correctness. grep=$(command -v ggrep) || grep='grep' + # Prefer libarchive tar if installed as it is much much faster than + # busybox's implementation. Very much worth it if you value performance. + tar=$(command -v bsdtar) || tar='tar' + # Figure out which 'sudo' command to use based on the user's choice or # what is available on the system. su=${KISS_SU:-$(command -v sudo || command -v doas)} || su=su