2017-02-17 23:13:49 +01:00
|
|
|
#!/data/data/com.termux/files/usr/bin/sh
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2018-06-11 09:20:03 +02:00
|
|
|
assert_not_root() {
|
|
|
|
if [ $(id -u) -eq 0 ]
|
|
|
|
then
|
|
|
|
echo "This must NOT be run as root as it will break your environment (root will be required for nearly everything due to changed file permissions)"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-02-17 23:13:49 +01:00
|
|
|
if [ $# = 0 ]; then show_help; fi
|
|
|
|
CMD="$1"
|
|
|
|
shift 1
|
|
|
|
|
|
|
|
case "$CMD" in
|
2017-03-10 15:34:17 +01:00
|
|
|
f*) dpkg -L $@;;
|
2017-03-10 15:22:44 +01:00
|
|
|
h*) show_help;;
|
2018-06-11 09:20:03 +02:00
|
|
|
add|i*) assert_not_root; apt update; apt install $@;;
|
2017-03-10 15:22:44 +01:00
|
|
|
list-a*) apt list $@;;
|
|
|
|
list-i*) apt list --installed $@;;
|
2019-04-16 17:59:53 +02:00
|
|
|
rei*) assert_not_root; apt install --reinstall $@;;
|
2018-06-11 09:20:03 +02:00
|
|
|
se*) assert_not_root; apt update; apt search $@;;
|
2017-03-10 15:22:44 +01:00
|
|
|
sh*) apt show $@;;
|
2018-06-11 09:20:03 +02:00
|
|
|
un*|rem*|rm|del*) assert_not_root; apt remove $@;;
|
|
|
|
up*) assert_not_root; apt update; apt full-upgrade;;
|
2017-10-01 21:42:37 +02:00
|
|
|
*) echo "Unknown command: '$CMD' (run 'pkg help' for usage information)";;
|
2017-02-17 23:13:49 +01:00
|
|
|
esac
|
|
|
|
|