diff options
author | dylan.araps@gmail.com <dylan.araps@gmail.com> | 2020-02-04 23:20:29 +0000 |
---|---|---|
committer | dylan.araps@gmail.com <dylan.araps@gmail.com> | 2020-02-04 23:20:29 +0000 |
commit | 3f42c1c8dfe18acda4c0331a34d036137d17aa70 (patch) | |
tree | 812d5434a971a49670064098bcdef2b87b481d44 | |
parent | 8f43fba23529db7150487c1d1d5fd8c211737f1d (diff) | |
download | cpt-3f42c1c8dfe18acda4c0331a34d036137d17aa70.tar.gz |
kiss: Use libarchive tar if available.
FossilOrigin-Name: 8e1436af55b74cc393086b2039907bcfa729eaf9ace815d4a0a40117560d5f67
-rwxr-xr-x | kiss | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -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 |