Compare commits
11 Commits
Author | SHA1 | Date |
---|---|---|
Leonid Pliushch | db3a7d3d7b | |
Leonid Pliushch | 99aa49cdfd | |
Leonid Pliushch | c0afb9d22d | |
Lucy Phipps | 5e163c1518 | |
Lucy Phipps | 83d3c35496 | |
Leonid Pliushch | e141b80b6f | |
Lucy Phipps | c1a702eeb7 | |
Lucy Phipps | 074df540d7 | |
Lucy Phipps | 8fdd508949 | |
Lucy Phipps | 96a9fd100a | |
Lucy Phipps | 9afbbb72de |
86
README.md
86
README.md
|
@ -1,3 +1,58 @@
|
|||
# Deprecation notice
|
||||
|
||||
This project is deprecated in favor of `apt-file` utility. Package `whatprovides` and database file will be removed.
|
||||
|
||||
You can install `apt-file` package with next command:
|
||||
```
|
||||
pkg install apt-file
|
||||
```
|
||||
|
||||
Depending on Termux version (< 0.118), you may need to fix permission of one file in $PREFIX (known issue):
|
||||
```
|
||||
chmod +x $PREFIX/lib/apt/apt-helper
|
||||
```
|
||||
|
||||
Usage example:
|
||||
```
|
||||
~ $ apt-file update
|
||||
~ $ apt-file list termux-tools
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/chsh
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/cmd
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/dalvikvm
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/df
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/getprop
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/ip
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/logcat
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/login
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/mount
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/ping
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/ping6
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/pkg
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/pm
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/settings
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/su
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/termux-change-repo
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/termux-fix-shebang
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/termux-info
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/termux-open
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/termux-open-url
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/termux-reload-settings
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/termux-reset
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/termux-setup-storage
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/termux-wake-lock
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/termux-wake-unlock
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/top
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/umount
|
||||
termux-tools: /data/data/com.termux/files/usr/bin/xdg-open
|
||||
termux-tools: /data/data/com.termux/files/usr/etc/motd
|
||||
termux-tools: /data/data/com.termux/files/usr/etc/profile.d/init-termux-properties.sh
|
||||
termux-tools: /data/data/com.termux/files/usr/share/doc/termux-tools/LICENSE
|
||||
termux-tools: /data/data/com.termux/files/usr/share/examples/termux/termux.properties
|
||||
termux-tools: /data/data/com.termux/files/usr/share/man/man1/termux.1.gz
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
# whatprovides
|
||||
yum --whatprovides utility for termux.
|
||||
|
||||
|
@ -27,37 +82,22 @@ make install
|
|||
|
||||
```sh
|
||||
$ whatprovides -p aapt
|
||||
aapt: /.
|
||||
aapt: /data
|
||||
aapt: /data/data
|
||||
aapt: /data/data/com.termux
|
||||
aapt: /data/data/com.termux/files
|
||||
aapt: /data/data/com.termux/files/usr
|
||||
aapt: /data/data/com.termux/files/usr/share
|
||||
aapt: /data/data/com.termux/files/usr/share/aapt
|
||||
aapt: /data/data/com.termux/files/usr/share/aapt/android.jar
|
||||
aapt: /data/data/com.termux/files/usr/share/doc
|
||||
aapt: /data/data/com.termux/files/usr/share/doc/aapt
|
||||
aapt: /data/data/com.termux/files/usr/lib
|
||||
aapt: /data/data/com.termux/files/usr/lib/libandroid-cutils.so
|
||||
aapt: /data/data/com.termux/files/usr/lib/libandroid-ziparchive.so
|
||||
aapt: /data/data/com.termux/files/usr/lib/libandroid-base.so
|
||||
aapt: /data/data/com.termux/files/usr/lib/libandroid-fw.so
|
||||
aapt: /data/data/com.termux/files/usr/lib/libandroid-utils.so
|
||||
aapt: /data/data/com.termux/files/usr/bin
|
||||
aapt: /data/data/com.termux/files/usr/bin/aapt
|
||||
aapt: /data/data/com.termux/files/usr/bin/zipalign
|
||||
aapt: /data/data/com.termux/files/usr/lib/libandroid-base.so
|
||||
aapt: /data/data/com.termux/files/usr/lib/libandroid-cutils.so
|
||||
aapt: /data/data/com.termux/files/usr/lib/libandroid-fw.so
|
||||
aapt: /data/data/com.termux/files/usr/lib/libandroid-utils.so
|
||||
aapt: /data/data/com.termux/files/usr/lib/libandroid-ziparchive.so
|
||||
aapt: /data/data/com.termux/files/usr/share/aapt/android.jar
|
||||
aapt: /data/data/com.termux/files/usr/share/doc/aapt/LICENSE
|
||||
```
|
||||
[![asciicast](https://cdn.jsdelivr.net/gh/termux/whatprovides@master/static/screenshot.jpg)](https://asciinema.org/a/373670)
|
||||
[Asciinema preview ](https://asciinema.org/a/373670)
|
||||
|
||||
* search for files. Have you ever used `dpkg -S filepath`.
|
||||
Here you need to use like `whatprovides filepath`.
|
||||
You can search for any files which even not exist in your termux.
|
||||
it will show you which package provide that file.
|
||||
```sh
|
||||
$ whatprovides $PREFIX/bin/aapt
|
||||
aapt: data/data/com.termux/files/usr/bin/aapt
|
||||
|
||||
$ whatprovides $PREFIX/share/aapt
|
||||
aapt: /data/data/com.termux/files/usr/share/aapt
|
||||
```
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 295 KiB |
|
@ -6,12 +6,17 @@
|
|||
|
||||
set -e -u
|
||||
|
||||
: "${TERMUX_PREFIX:="/data/data/com.termux/files/usr"}"
|
||||
|
||||
list_files() {
|
||||
dpkg-deb -c "${1}" | grep -o "/data/data/com\.termux/files/.\+" \
|
||||
| sed -E 's@(.*) ->..*@\1@g;s@/$@@g' \
|
||||
| xargs -rd\\n realpath -sm --relative-base="$TERMUX_PREFIX" --
|
||||
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)?)?)?')
|
||||
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() {
|
||||
|
|
62
whatprovides
62
whatprovides
|
@ -3,13 +3,13 @@ set -e
|
|||
|
||||
SCRIPT_NAME=$(basename "$(realpath "$0")")
|
||||
DB_PATH="/data/data/com.termux/files/usr/var/lib/whatprovides/whatprovides.db"
|
||||
DB_UPDATES_URL="https://dl.bintray.com/termux/metadata/whatprovides-db/whatprovides.db.gz"
|
||||
DB_UPDATES_URL="https://packages.termux.org/whatprovides/whatprovides.db.gz"
|
||||
|
||||
show_usage () {
|
||||
{
|
||||
echo
|
||||
echo "Usage: $SCRIPT_NAME [-u] path/to/file"
|
||||
echo " $SCRIPT_NAME -p [-u] package"
|
||||
echo "Usage: $SCRIPT_NAME [-u|-U] path/to/file"
|
||||
echo " $SCRIPT_NAME -p [-u|-U] package"
|
||||
echo
|
||||
echo "Find out packages using specific files."
|
||||
echo
|
||||
|
@ -22,6 +22,8 @@ show_usage () {
|
|||
echo
|
||||
echo " -u Update the database."
|
||||
echo
|
||||
echo " -U Redownload the database even if it's not updated."
|
||||
echo
|
||||
echo " -q Quiet mode. Suppress informational messages."
|
||||
echo
|
||||
} >&2
|
||||
|
@ -35,26 +37,36 @@ update_database() {
|
|||
rm -f "${DB_PATH}.gz"
|
||||
fi
|
||||
|
||||
if ! ${FORCE_UPDATE} && [ -e "${DB_PATH}" ]; then
|
||||
NEWER=(--time-cond "${DB_PATH}")
|
||||
else
|
||||
NEWER=()
|
||||
fi
|
||||
|
||||
if ! ${QUIET}; then
|
||||
echo "[*] Downloading the new database..." >&2
|
||||
echo >&2
|
||||
|
||||
curl --fail --retry 3 --retry-connrefused --retry-delay 1 --location \
|
||||
--output "${DB_PATH}.gz" "${DB_UPDATES_URL}"
|
||||
"${NEWER[@]}" --output "${DB_PATH}.gz" "${DB_UPDATES_URL}"
|
||||
|
||||
echo >&2
|
||||
echo "[*] Installing..." >&2
|
||||
else
|
||||
curl --silent --fail --retry 3 --retry-connrefused --retry-delay 1 \
|
||||
--location --output "${DB_PATH}.gz" "${DB_UPDATES_URL}"
|
||||
--location "${NEWER[@]}" --output "${DB_PATH}.gz" "${DB_UPDATES_URL}"
|
||||
fi
|
||||
|
||||
rm -f "${DB_PATH}"
|
||||
zcat "${DB_PATH}.gz" > "${DB_PATH}"
|
||||
rm -f "${DB_PATH}.gz"
|
||||
|
||||
if ! ${QUIET}; then
|
||||
echo "[*] Finished." >&2
|
||||
if [ -e "${DB_PATH}.gz" ]; then
|
||||
if ! ${QUIET}; then
|
||||
echo "[*] Installing..." >&2
|
||||
fi
|
||||
zcat "${DB_PATH}.gz" > "${DB_PATH}"
|
||||
rm -f "${DB_PATH}.gz"
|
||||
if ! ${QUIET}; then
|
||||
echo "[*] Finished." >&2
|
||||
fi
|
||||
elif ! ${QUIET}; then
|
||||
echo "[*] No update done." >&2
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -70,13 +82,22 @@ check_database() {
|
|||
|
||||
REVERSE_MODE=false
|
||||
DO_UPDATE=false
|
||||
FORCE_UPDATE=false
|
||||
QUIET=false
|
||||
while (($# > 0)); do
|
||||
case "$1" in
|
||||
-h) show_usage; exit 0;;
|
||||
-p) REVERSE_MODE=true;;
|
||||
-q) QUIET=true;;
|
||||
-u) DO_UPDATE=true;;
|
||||
-U) FORCE_UPDATE=true;& # fall-through
|
||||
-u)
|
||||
if ${DO_UPDATE}; then
|
||||
echo "-u and -U are mutually exclusive." >&2
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
DO_UPDATE=true
|
||||
;;
|
||||
-*)
|
||||
echo >&2
|
||||
echo "Unknown option '$1'." >&2
|
||||
|
@ -116,9 +137,17 @@ if ${REVERSE_MODE}; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
sqlite3 "${DB_PATH}" \
|
||||
if ! sqlite3 "${DB_PATH}" \
|
||||
"SELECT owned_file FROM 'whatprovides' WHERE package_name == '${1}' ORDER BY owned_file" \
|
||||
| awk "NR == 1 { print \"${1}: /.\\n${1}: /data\\n${1}: /data/data\\n${1}: /data/data/com.termux\\n${1}: /data/data/com.termux/files\\n${1}: ${PREFIX}\" } { print \"${1}: ${PREFIX}/\"\$0 }"
|
||||
| awk "{ if (substr(\$0, 1, 1) == \"/\") print \"${1}: \"\$0; else print \"${1}: ${PREFIX}/\"\$0 } END { if (NR == 0) exit 1 }"
|
||||
then
|
||||
{
|
||||
echo
|
||||
echo "Error: package '$1' is not found."
|
||||
echo
|
||||
} >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
NEWPREFIX=
|
||||
FILE="$(realpath -sm "$1")"
|
||||
|
@ -141,8 +170,9 @@ else
|
|||
NEWPREFIX="${PREFIX}/"
|
||||
fi # else FILE is entirely separate from PREFIX (unlikely to be in DB)
|
||||
|
||||
FILE_ESC="${FILE//\'/\'\'}"
|
||||
if ! sqlite3 "${DB_PATH}" \
|
||||
"SELECT package_name FROM 'whatprovides' WHERE owned_file == '${FILE//\'/\'\'}' ORDER BY package_name" \
|
||||
"SELECT DISTINCT package_name FROM 'whatprovides' WHERE owned_file == '${FILE_ESC}' OR substr(owned_file, 1, ${#FILE} +1) == '${FILE_ESC}/' ORDER BY package_name" \
|
||||
| awk "{ print \$0\": ${NEWPREFIX}${FILE}\" } END { if (NR == 0) exit 1 }"
|
||||
then
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue