termux-packages/packages/termux-tools/pkg

47 lines
1.1 KiB
Plaintext
Raw Normal View History

2017-02-17 23:13:49 +01:00
#!/data/data/com.termux/files/usr/bin/sh
set -e -u
show_help() {
echo 'Usage: pkg command [arguments]'
2017-02-17 23:13:49 +01:00
echo ''
echo 'A tool for managing packages. Commands:'
echo ''
echo ' files <packages>'
echo ' install <packages>'
2017-02-17 23:13:49 +01:00
echo ' list-all'
echo ' list-installed'
echo ' reinstall <packages>'
2017-02-17 23:13:49 +01:00
echo ' search <query>'
echo ' show <packages>'
echo ' uninstall <packages>'
2017-02-17 23:13:49 +01:00
echo ' upgrade'
exit 1
}
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
f*) dpkg -L $@;;
h*) show_help;;
add|i*) assert_not_root; apt update; apt install $@;;
list-a*) apt list $@;;
list-i*) apt list --installed $@;;
rei*) assert_not_root; apt install --reinstall $@;;
se*) assert_not_root; apt update; apt search $@;;
sh*) apt show $@;;
un*|rem*|rm|del*) assert_not_root; apt remove $@;;
up*) assert_not_root; apt update; apt full-upgrade $@;;
*) echo "Unknown command: '$CMD' (run 'pkg help' for usage information)";;
2017-02-17 23:13:49 +01:00
esac