From 34f4564b373ff9b7a875050c27925a728c1802f7 Mon Sep 17 00:00:00 2001 From: Leonid Pliushch Date: Sun, 22 Nov 2020 17:25:25 +0000 Subject: [PATCH] update scripts/bin/update-whatprovides-db --- scripts/bin/update-whatprovides-db | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/bin/update-whatprovides-db b/scripts/bin/update-whatprovides-db index a542b9effa..6e5b9016b0 100755 --- a/scripts/bin/update-whatprovides-db +++ b/scripts/bin/update-whatprovides-db @@ -3,7 +3,7 @@ ## Script that generates or updates a Whatprovides ## database for Termux. ## -## Copy of https://github.com/termux/whatprovides/blob/96a9fd100a84af1bf2fd3fbeedbaab082381f5e8/update-whatprovides-db.sh +## Copy of https://github.com/termux/whatprovides/blob/83d3c354961ab84c35441e9c7653d1604f1ea72c/update-whatprovides-db.sh ## but edited for special use in termux-packages. ## @@ -12,9 +12,16 @@ set -e -u DEBS_DIR_PATH=$(realpath "$(dirname "$0")/../../debs") list_files() { - dpkg-deb --fsys-tarfile "${1}" | tar -t | cut -b2- \ + FILES=$(dpkg-deb --fsys-tarfile "${1}" | tar -t | cut -b2- \ | xargs -rd\\n realpath -sm --relative-base="/data/data/com.termux/files/usr" -- \ - | grep -vEx '[./]|/data(/data(/com\.termux(/files)?)?)?' + | grep -vEx '[./]|/data(/data(/com\.termux(/files)?)?)?') + SORTKEYS='-k1,1' + MAXKEY=$(awk -F/ 'BEGIN { x=0 } { if (NF > x) x = NF } END { print x }' <<< "${FILES}") + for ((x=2; x<=$MAXKEY; x++)); do + SORTKEYS="$SORTKEYS -k$x,$x" + done + sort -t/ $SORTKEYS <<< "$FILES" \ + | awk 'NR == 1 { p=$0; next } substr($0, 1, length(p) +1 ) != p"/" { print p } { p=$0 } END { print p }' } write_sql_script() {