update scripts/bin/update-whatprovides-db

This commit is contained in:
Leonid Pliushch 2020-11-22 17:25:25 +00:00
parent 4e9750557c
commit 34f4564b37
1 changed files with 10 additions and 3 deletions

View File

@ -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() {