Skip to content

Commit

Permalink
kiss: fix pkg_fixdeps
Browse files Browse the repository at this point in the history
The fixdeps function now,
* Follows links of the dependent files
* Fallbacks by removing the '/usr' prefix
    for rare cases where a package is installed
    without the /usr prefix

FossilOrigin-Name: 600311a79f1514ca7aa10adb86e70d004d230b73f3ff3c3394f0f74c514799d8
  • Loading branch information
cemkeylan committed Apr 12, 2020
1 parent 7286ebf commit 33c83ea
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions kiss
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,7 @@ pkg_fixdeps() {

# Generate a list of all installed manifests.
pkg_name=$1
set +f
set -f -- "$sys_db/"*/manifest
set +f; set -f -- "$sys_db/"*/manifest

# Get a list of binaries and libraries, false files
# will be found, however it's faster to get 'ldd' to check
Expand All @@ -424,22 +423,31 @@ pkg_fixdeps() {
# Skip lines containing 'ldd'.
[ "${dep##*ldd*}" ] || continue

# Extract the file path from 'ldd' output.
# Extract the file path from 'ldd' output, and
# canonicalize the path.
dep=${dep#* => }
dep=${dep% *}
dep=$(readlink -f "$dep")

# Figure out which package owns the file.
dep=$("$grep" -lFx "${dep##$KISS_ROOT}" "$@")
own=$("$grep" -lFx "${dep##$KISS_ROOT}" "$@")

# If the package wasn't found, retry by removing
# the '/usr' prefix.
if [ -z "$own" ] && [ -z "${dep%%/usr*}" ]; then
dep=${dep#/usr}
own=$("$grep" -lFx "${dep##$KISS_ROOT}" "$@")
fi

# Extract package name from 'grep' match.
dep=${dep%/*}
dep=${dep##*/}
own=${own%/*}
own=${own##*/}

case $dep in
# Skip listing these packages as dependencies.
musl|gcc|${PWD##*/}|"") ;;
*) printf '%s\n' "$dep" ;;
esac
case $own in musl|gcc|"$pkg_name"|"") continue ; esac
printf 'Found %s (%s) in (%s)\n' "$own" "$dep" \
"${file##$pkg_dir/$pkg_name}" >/dev/tty

printf '%s\n' "$own"
done ||:
done >> depends

Expand Down

0 comments on commit 33c83ea

Please sign in to comment.