-
-
Save shizonic/5d15f589ca01622e2363cdef6d5adca3 to your computer and use it in GitHub Desktop.
my xbps helper script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
die() { | |
printf '\033[1;31m!>\033[m %s.\n' "$@" >&2 | |
exit 1 | |
} | |
log() { | |
printf '\033[1;32m=>\033[m %s.\n' "$@" | |
} | |
usage() { | |
printf "usage: %s [i|u|r|s|l|h|m|c|p|f|o|d|revdeps|show|orphan|fix] [pkg] [pkg] [pkg]\\n\\n" "$(basename "$0")" | |
printf "actions:\\n" | |
printf " => install: Install a package\\n" | |
printf " => update: Update all installed packages\\n" | |
printf " => remove: Remove pkg and dependencies\\n" | |
printf " => search: Search for packages by matching pkg, string or regex\\n" | |
printf " => list: List installed packages\\n" | |
printf " => hold: List packages on hold state\\n" | |
printf " => manual: List installed packages\\n" | |
printf " => clean: Remove all pkgs which are orphans\\n" | |
printf " => purge: Remove unused kernels and initramfs\\n" | |
printf " => files: Show package files for pkg\\n" | |
printf " => ownedby: Search for package files by matching string or regex\\n" | |
printf " => deps: Show dependencies for pkg\\n" | |
printf " => revdeps: Show reverse dependencies for pkg\\n" | |
printf " => show: Show information for pkg\\n" | |
printf " => orphan: List package orphans\\n" | |
printf " => fix: Fix package database entries\\n" | |
} | |
main() { | |
action="${1}" | |
shift "$(($# > 0 ? 1 : 0))" | |
case "${action}" in | |
i|install) | |
sudo xbps-install "${@}" | |
;; | |
u|update) | |
sudo xbps-install -Su | |
;; | |
r|remove) | |
sudo xbps-remove -R "${@}" | |
;; | |
s|search) | |
sudo xbps-query -Rs "${@}" | |
;; | |
l|list) | |
sudo xbps-query -l | |
;; | |
h|hold) | |
sudo xbps-query -H | |
;; | |
m|manual) | |
sudo xbps-query -m | |
;; | |
c|clean) | |
sudo xbps-remove -Oo | |
;; | |
p|purge) | |
sudo vkpurge rm all | |
;; | |
f|files) | |
sudo xbps-query -f "${@}" | |
;; | |
o|ownedby) | |
sudo xbps-query -o "${@}" | |
;; | |
d|deps) | |
sudo xbps-query -x "${@}" | |
;; | |
revdeps) | |
sudo xbps-query -X "${@}" | |
;; | |
show) | |
sudo xbps-query -S "${@}" | |
;; | |
orphan) | |
sudo xbps-query -O "${@}" | |
;; | |
fix) | |
sudo xbps-pkgdb -a | |
;; | |
help|-h|--help|'') | |
usage | |
;; | |
*) die "'xp ${action}' is not a valid command" ;; | |
esac | |
} | |
main "${@}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment