kiss: Use ggrep if available

This commit is contained in:
Dylan Araps 2020-01-14 11:59:30 +02:00
parent 0eddd6f612
commit 3c251759bb
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E
1 changed files with 11 additions and 6 deletions

17
kiss
View File

@ -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 ||: