2019-09-19 22:41:31 +02:00
|
|
|
#!/bin/sh
|
2017-02-17 23:13:49 +01:00
|
|
|
set -e -u
|
|
|
|
|
|
|
|
show_help() {
|
2017-10-01 21:42:37 +02:00
|
|
|
echo 'Usage: pkg command [arguments]'
|
2017-02-17 23:13:49 +01:00
|
|
|
echo ''
|
|
|
|
echo 'A tool for managing packages. Commands:'
|
|
|
|
echo ''
|
2017-03-10 15:34:17 +01:00
|
|
|
echo ' files <packages>'
|
|
|
|
echo ' install <packages>'
|
2017-02-17 23:13:49 +01:00
|
|
|
echo ' list-all'
|
|
|
|
echo ' list-installed'
|
2017-03-10 15:34:17 +01:00
|
|
|
echo ' reinstall <packages>'
|
2017-02-17 23:13:49 +01:00
|
|
|
echo ' search <query>'
|
2017-03-10 15:34:17 +01:00
|
|
|
echo ' show <packages>'
|
|
|
|
echo ' uninstall <packages>'
|
2017-02-17 23:13:49 +01:00
|
|
|
echo ' upgrade'
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2019-11-10 15:29:05 +01:00
|
|
|
check_pkgcache() {
|
|
|
|
if [ -z "$(find @TERMUX_PREFIX@/var/cache/apt/pkgcache.bin -mmin -5)" ]; then
|
|
|
|
apt update
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ $# = 0 ]; then
|
|
|
|
show_help
|
|
|
|
fi
|
|
|
|
|
2017-02-17 23:13:49 +01:00
|
|
|
CMD="$1"
|
|
|
|
shift 1
|
|
|
|
|
|
|
|
case "$CMD" in
|
2019-05-06 22:22:47 +02:00
|
|
|
f*) dpkg -L "$@";;
|
2017-03-10 15:22:44 +01:00
|
|
|
h*) show_help;;
|
2019-11-13 15:38:40 +01:00
|
|
|
add|i*) check_pkgcache; apt install "$@";;
|
2019-05-06 22:22:47 +02:00
|
|
|
list-a*) apt list "$@";;
|
|
|
|
list-i*) apt list --installed "$@";;
|
2019-11-13 15:38:40 +01:00
|
|
|
rei*) apt install --reinstall "$@";;
|
|
|
|
se*) check_pkgcache; apt search "$@";;
|
2019-05-06 22:22:47 +02:00
|
|
|
sh*) apt show "$@";;
|
2019-11-13 15:38:40 +01:00
|
|
|
un*|rem*|rm|del*) apt remove "$@";;
|
|
|
|
up*) apt update; apt full-upgrade "$@";;
|
2019-11-10 15:29:05 +01:00
|
|
|
*) echo "Unknown command: '$CMD' (run 'pkg help' for usage information)"; exit 1;;
|
2017-02-17 23:13:49 +01:00
|
|
|
esac
|