From 50232e8aa98566c4e3b049807f6d23224531492c Mon Sep 17 00:00:00 2001 From: "dylan.araps@gmail.com" Date: Tue, 14 Jan 2020 09:59:29 +0000 Subject: kiss: Use ggrep if available FossilOrigin-Name: e87e775802d26acac691dc5f83feb075b31d8210c36455d0610bbb310d1d800d --- kiss | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'kiss') diff --git a/kiss b/kiss index 28fdb11..f817269 100755 --- a/kiss +++ b/kiss @@ -270,7 +270,7 @@ pkg_fixdeps() { # Get a list of binaries and libraries, false files # will be found, however it's faster to get 'ldd' to check # them anyway than to filter them out. - find "$pkg_dir/$pkg_name" -type f 2>/dev/null | + find "$pkg_dir/$pkg_name/" -type f 2>/dev/null | while read -r file; do # Run 'ldd' on the file and parse each line. The code @@ -285,7 +285,7 @@ pkg_fixdeps() { dep=${dep% *} # Figure out which package owns the file. - dep=$(grep -lFx "${dep##$KISS_ROOT}" "$@") + dep=$("$grep" -lFx "${dep##$KISS_ROOT}" "$@") # Extract package name from 'grep' match. dep=${dep%/*} @@ -612,7 +612,7 @@ pkg_conflicts() { # be installed package's manifest and the above filtered # list. [ -s "$cac_dir/$pid-m" ] && - grep -Fxf "$cac_dir/$pid-m" -- "$@" && + "$grep" -Fxf "$cac_dir/$pid-m" -- "$@" && die "Package '$p_name' conflicts with another package" set -e @@ -636,7 +636,7 @@ pkg_remove() { [ "$2" = check ] && for file in "$sys_db/"*; do # Check each depends file for the package and if it's # a run-time dependency, append to the $required_by string. - grep -qFx "$1" "$file/depends" 2>/dev/null && + "$grep" -qFx "$1" "$file/depends" 2>/dev/null && required_by="$required_by'${file##*/}', " done @@ -693,7 +693,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%/*} @@ -750,7 +750,7 @@ pkg_install() { # Remove any leftover files if this is an upgrade. [ "$old_manifest" ] && { printf '%s\n' "$old_manifest" | - grep -vFxf "$sys_db/$pkg_name/manifest" - | + "$grep" -vFxf "$sys_db/$pkg_name/manifest" - | while read -r file; do # Skip deleting some leftover files. @@ -1088,6 +1088,11 @@ main() { # up before we die. This occurs on 'Ctrl+C' as well as success and error. trap pkg_clean EXIT INT + # Prefer GNU grep if installed as it is much much faster than busybox's + # implementation. Very much worth it if you value performance over + # POSIX correctness. + grep=$(command -v ggrep 2>/dev/null) || grep='grep' + # This allows for automatic setup of a KISS chroot and will # do nothing on a normal system. mkdir -p "${sys_db:=$KISS_ROOT/$pkg_db}" 2>/dev/null ||: -- cgit v1.2.3