forked from kiss-community/kiss
kiss: Use ggrep if available
This commit is contained in:
parent
0eddd6f612
commit
3c251759bb
17
kiss
17
kiss
@ -270,7 +270,7 @@ pkg_fixdeps() {
|
|||||||
# Get a list of binaries and libraries, false files
|
# Get a list of binaries and libraries, false files
|
||||||
# will be found, however it's faster to get 'ldd' to check
|
# will be found, however it's faster to get 'ldd' to check
|
||||||
# them anyway than to filter them out.
|
# 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
|
while read -r file; do
|
||||||
# Run 'ldd' on the file and parse each line. The code
|
# Run 'ldd' on the file and parse each line. The code
|
||||||
@ -285,7 +285,7 @@ pkg_fixdeps() {
|
|||||||
dep=${dep% *}
|
dep=${dep% *}
|
||||||
|
|
||||||
# Figure out which package owns the file.
|
# 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.
|
# Extract package name from 'grep' match.
|
||||||
dep=${dep%/*}
|
dep=${dep%/*}
|
||||||
@ -612,7 +612,7 @@ pkg_conflicts() {
|
|||||||
# be installed package's manifest and the above filtered
|
# be installed package's manifest and the above filtered
|
||||||
# list.
|
# list.
|
||||||
[ -s "$cac_dir/$pid-m" ] &&
|
[ -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"
|
die "Package '$p_name' conflicts with another package"
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
@ -636,7 +636,7 @@ pkg_remove() {
|
|||||||
[ "$2" = check ] && for file in "$sys_db/"*; do
|
[ "$2" = check ] && for file in "$sys_db/"*; do
|
||||||
# Check each depends file for the package and if it's
|
# Check each depends file for the package and if it's
|
||||||
# a run-time dependency, append to the $required_by string.
|
# 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##*/}', "
|
required_by="$required_by'${file##*/}', "
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -693,7 +693,7 @@ pkg_install() {
|
|||||||
# Figure out which package the tar-ball installs by checking for
|
# Figure out which package the tar-ball installs by checking for
|
||||||
# a database entry inside the tar-ball. If no database entry exists,
|
# 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.
|
# 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"
|
die "'${tar_file##*/}' is not a valid KISS package"
|
||||||
|
|
||||||
pkg_name=${pkg_name%/*}
|
pkg_name=${pkg_name%/*}
|
||||||
@ -750,7 +750,7 @@ pkg_install() {
|
|||||||
# Remove any leftover files if this is an upgrade.
|
# Remove any leftover files if this is an upgrade.
|
||||||
[ "$old_manifest" ] && {
|
[ "$old_manifest" ] && {
|
||||||
printf '%s\n' "$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
|
while read -r file; do
|
||||||
# Skip deleting some leftover files.
|
# 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.
|
# up before we die. This occurs on 'Ctrl+C' as well as success and error.
|
||||||
trap pkg_clean EXIT INT
|
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
|
# This allows for automatic setup of a KISS chroot and will
|
||||||
# do nothing on a normal system.
|
# do nothing on a normal system.
|
||||||
mkdir -p "${sys_db:=$KISS_ROOT/$pkg_db}" 2>/dev/null ||:
|
mkdir -p "${sys_db:=$KISS_ROOT/$pkg_db}" 2>/dev/null ||:
|
||||||
|
Loading…
Reference in New Issue
Block a user