Committed at Wed Apr 20 23:41:24 UTC 2016 by armin@
gedöns Committed at Thu Apr 21 00:36:08 UTC 2016 by armin@ Committed at Thu Apr 21 19:34:47 UTC 2016 by armin@ Committed at Thu Apr 21 20:01:44 UTC 2016 by armin@ cleanup Committed at Thu Apr 21 20:32:19 UTC 2016 by armin@void changes changes Committed at Thu Apr 21 21:38:52 UTC 2016 by armin@ Committed at Thu Apr 21 21:47:06 UTC 2016 by armin@ Committed at Thu Apr 21 21:50:50 UTC 2016 by armin@ fix "list" command (thanks to duncaen for reporting this!) Committed at Thu Apr 21 22:30:43 UTC 2016 by armin@ Committed at Thu Apr 21 22:34:01 UTC 2016 by armin@ Committed at Thu Apr 21 22:34:59 UTC 2016 by armin@ Committed at Thu Apr 21 22:48:34 UTC 2016 by armin@ Committed at Thu Apr 21 22:51:52 UTC 2016 by armin@ Committed at Thu Apr 21 22:53:59 UTC 2016 by armin@ Committed at Thu Apr 21 22:57:22 UTC 2016 by armin@ Committed at Thu Apr 21 23:01:05 UTC 2016 by armin@ Committed at Thu Apr 21 23:28:43 UTC 2016 by armin@ Committed at Thu Apr 21 23:29:53 UTC 2016 by armin@ Committed at Thu Apr 21 23:34:22 UTC 2016 by armin@ Committed at Thu Apr 21 23:35:33 UTC 2016 by armin@ Committed at Thu Apr 21 23:36:26 UTC 2016 by armin@ Committed at Thu Apr 21 23:43:55 UTC 2016 by armin@
This commit is contained in:
parent
c2aa49812c
commit
8e58fc8b59
13
README.md
13
README.md
|
@ -1,4 +1,4 @@
|
|||
# vpm - a void package management utility
|
||||
# vpm - An XBPS package management helper for VoidLinux
|
||||
|
||||
Copyright (c) 2016: Armin Jenewein <vpm@m2m.pm>
|
||||
|
||||
|
@ -21,13 +21,16 @@ Screenshot of vpm in full effect:
|
|||
|
||||
![alt tag](https://raw.githubusercontent.com/netzverweigerer/vpm/master/screenshots/vpm2.png)
|
||||
|
||||
# Okay, great, but why re-invent the wheel, dude!?
|
||||
I personally think I don't, XBPS is hard to use and has a heavy learning curve thanks to its diversed toolchain and hard to remember commandline arguments. vpm tries to help. I wrote this as a personal educational project to improve my understanding of XBPS and VoidLinux, but I hope that others find this useful, too. vpm will also always show the actual xbps commands it translates its actions to, and also display the return codes.
|
||||
# Motivation to write vpm
|
||||
I initially found XBPS to have a steep learning-curve, so I wanted to ease the life of new VoidLinux users, and XBPS users in general. Please don't feel afraid to look up the corresponding XBPS commands it translates to, or use vpm --show-translations so you even see the translations already when using vpn help. It has been said that vpm will ease the transition from Debian's APT, and some other user-friendly repository/package-managers.
|
||||
|
||||
# ZOMG! PONIES!!111
|
||||
Rainbows and unicorns, indeed. But you can easily disable all colorization and fancyness, too, to use it in scripts. All otions have human readable and easy to remember syntax, no --long-option-with-multiple-complex-words, no need to even prefix arguments with --, vpm just tries to do its best it can to understand the user.
|
||||
Rainbows and unicorns, indeed. If you like colorized output, please see the --color=true option, too! All vpm otions try to have human readable and easy to remember syntax, no --long-option-with-multiple-complex-words, no need to even prefix arguments with --, vpm just tries to do its best it can to understand the user (there are some command-line-switches, though, see vpm help).
|
||||
|
||||
+ Author
|
||||
# Dependencies
|
||||
vpm requires BASH, the Bourne Again SHell. Use xbps-install -S bash if you don't have it installed, yet.
|
||||
|
||||
# Author
|
||||
vpm was written by Armin Jenewein (GitHub: @netzverweigerer) <vpm@m2m.pm>
|
||||
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 171 KiB |
Binary file not shown.
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 453 KiB |
242
vpm
242
vpm
|
@ -13,17 +13,41 @@ getversion () {
|
|||
|
||||
version="$(getversion)"
|
||||
|
||||
# set to "false" to permanently disable colors
|
||||
color=true
|
||||
# set to "true" to enable colorized output, or to "auto" to use auto-detection via $TERM
|
||||
color=auto
|
||||
|
||||
autocolor () {
|
||||
case "$TERM" in
|
||||
*256*color*)
|
||||
color=true
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
if [[ "$1" == "--color=auto" ]]; then
|
||||
shift
|
||||
autocolor
|
||||
fi
|
||||
|
||||
if [[ "$color" == "auto" ]]; then
|
||||
autocolor
|
||||
fi
|
||||
|
||||
# verbose mode
|
||||
verbose=false
|
||||
|
||||
case "$1" in
|
||||
"--color=false")
|
||||
color=false
|
||||
shift
|
||||
;;
|
||||
"--color=true")
|
||||
--color=true|--color=yes|--color=on)
|
||||
shift
|
||||
color=true
|
||||
shift
|
||||
;;
|
||||
--verbose=true)
|
||||
shift
|
||||
verbose=true
|
||||
;;
|
||||
--show-translations)
|
||||
shift
|
||||
show_translations=1
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@ -55,21 +79,28 @@ msg () {
|
|||
color sgr0
|
||||
}
|
||||
|
||||
if [[ "$UID" -gt 0 ]]; then
|
||||
msg "ERROR: ${0##*/} needs super-user privileges. Exiting."
|
||||
exit 255
|
||||
fi
|
||||
|
||||
|
||||
banner () {
|
||||
banner_fg=111
|
||||
banner_bg=142
|
||||
tput setaf $banner_fg
|
||||
color $banner_fg
|
||||
echo ' __ ___ __ _ __ '
|
||||
echo -n " \ V / '_ \ ' \ "
|
||||
tput setaf $banner_bg
|
||||
echo ' vpm - void package management utility'
|
||||
tput setaf $banner_fg
|
||||
color $banner_bg
|
||||
echo ' vpm - void package management utility for XBPS'
|
||||
color $banner_fg
|
||||
echo -n ' \_/| .__/_|_|_|'
|
||||
tput setaf $banner_bg
|
||||
color $banner_bg
|
||||
echo ' GitHub: https://github.com/netzverweigerer/vpm'
|
||||
tput setaf $banner_fg
|
||||
echo -n ' |/ '
|
||||
tput sgr0
|
||||
color $banner_fg
|
||||
echo ' |/ '
|
||||
echo ' ´ '
|
||||
color reset
|
||||
}
|
||||
|
||||
version () {
|
||||
|
@ -79,7 +110,7 @@ version () {
|
|||
color sgr0
|
||||
msg "vpm - Version: $version"
|
||||
msg "Copyright (c) 2016 Armin Jenewein <a@m2m.pm>"
|
||||
msg "XBPS version: $(xbps-query --version)"
|
||||
msg "XBPS version: $(xbps-query -v --version)"
|
||||
}
|
||||
|
||||
# extract versionstring appendix from given package name
|
||||
|
@ -92,6 +123,15 @@ extract_packagename () {
|
|||
echo "$1" | rev | cut -d"-" -f 2- | rev
|
||||
}
|
||||
|
||||
t () {
|
||||
if [[ "$show_translations" != "" ]]; then
|
||||
tput setaf 242
|
||||
echo " $@"
|
||||
echo
|
||||
tput setaf 109
|
||||
fi
|
||||
}
|
||||
|
||||
usage () {
|
||||
echo
|
||||
version
|
||||
|
@ -100,54 +140,75 @@ usage () {
|
|||
echo
|
||||
echo "USAGE: "
|
||||
color 101
|
||||
echo
|
||||
echo "vpm [OPTIONS] [SUBCMD] [<OPTIONS>] [<args>]"
|
||||
echo
|
||||
color 66
|
||||
echo
|
||||
echo "OPTIONS: "
|
||||
color 101
|
||||
echo
|
||||
echo "--color=<true/false> - Enable/Disable colorized output"
|
||||
echo "--color=<yes|no|auto> - Enable/Disable colorized output (default: no)"
|
||||
echo "--help - (same as: help)"
|
||||
echo "--show-translations - Show XBPS command translations for vpm sub-commands"
|
||||
echo "--verbose - Verbose mode (shows XBPS command translations during execution)"
|
||||
echo
|
||||
color 66
|
||||
echo
|
||||
echo -n "SUBCOMMANDS: "
|
||||
echo "(feel free to prefix them with --, vpm doesn't care.)"
|
||||
echo
|
||||
echo "SUBCOMMANDS: "
|
||||
color 109
|
||||
echo "sync - Synchronize remote repository data"
|
||||
t "xbps-install -S"
|
||||
echo "update - Update the system"
|
||||
t "xbps-install -Sduv"
|
||||
echo "repolist - List configured repositories"
|
||||
echo "listrepos - (same as: repolist)"
|
||||
echo "addrepo - Add an additional repository"
|
||||
t "xbps-query -v -L"
|
||||
echo "addrepo <args> - Add an additional repository"
|
||||
t "xbps-install <args>"
|
||||
echo "info <package> - Show information about <package>"
|
||||
t "xbps-query-v -R"
|
||||
echo "filelist <package> - Show file-list of <package>"
|
||||
echo "dependencies <package> - Show dependendies of <package>"
|
||||
t "xbps-query -v -R -f"
|
||||
echo "deps <package> - Show dependendies of <package>"
|
||||
t "xbps-query -v -R -x"
|
||||
echo "reverse <package> - Show reverse dependendies of <package>"
|
||||
t "xbps-query -v -R -X"
|
||||
echo "search <name> - Search for package by <name>"
|
||||
t "xbps-query -v -Rs"
|
||||
echo "searchfile <file> - Search for package containing <file>"
|
||||
t "xbps-query -v -R -o \"*/$1\""
|
||||
echo "list - List installed packages"
|
||||
t "xbps-query -v -l"
|
||||
echo "install <package> - Install <package>"
|
||||
t "xbps-install -S"
|
||||
echo "listalternatives - List alternative candiates"
|
||||
t "xbps-alternatives -l"
|
||||
echo "setalternative <package> - Set alternative for <package>"
|
||||
t "xbps-alternatives -s"
|
||||
echo "reconfigure <package> - Re-configure installed <package>"
|
||||
t "xbps-reconfigure -v"
|
||||
echo "forceinstall <package> - Force installation of <package>"
|
||||
t "xbps-install -f"
|
||||
echo "remove <package) - Remove <package>"
|
||||
t "xbps-remove -v "
|
||||
echo "removerecursive <package> - Recursively remove package (and its dependencies)"
|
||||
t "xbps-remove -v -R"
|
||||
echo "cleanup - Clean up cache directory"
|
||||
t "xbps-remove -v -O"
|
||||
echo "autoremove - Remove orphaned packages"
|
||||
t "xbps-remove -v -O"
|
||||
echo "help - Show usage information"
|
||||
echo
|
||||
color 66
|
||||
echo
|
||||
echo "XBPS COMPATIBILITY:"
|
||||
echo "XBPS COMPATIBILITY COOLNESS:"
|
||||
color 103
|
||||
f=(/usr/sbin/xbps-*)
|
||||
echo
|
||||
echo "vpm also understands xbps commands:"
|
||||
echo "vpm also understands all unknown XBPS sub-commands, too:"
|
||||
echo -n "Example: "
|
||||
selected=${f[$RANDOM % ${#f[@]}]}
|
||||
echo "${0##*/} ${selected##*-} <ARGS>"
|
||||
echo
|
||||
echo
|
||||
echo "${0##*/} ${selected##*-} <ARGS> - see also: /usr/sbin/xbps-*"
|
||||
echo
|
||||
color reset
|
||||
}
|
||||
|
||||
|
||||
|
@ -166,41 +227,44 @@ fi
|
|||
case "$arg" in
|
||||
info)
|
||||
shift
|
||||
msg "(xbps-query -R $@):"
|
||||
xbps-query -R "$@"
|
||||
ret=$?; msg "Execution finished (xbps-query -R $@), return code was: $ret"
|
||||
msg "(xbps-query -v -R $@):"
|
||||
xbps-query -v -R "$@"
|
||||
ret=$?; msg "Execution finished (xbps-query -v -R $@), return code was: $ret"
|
||||
exit $ret
|
||||
;;
|
||||
|
||||
filelist)
|
||||
shift
|
||||
xbps-query -R -f "$@"
|
||||
ret=$?; msg "Execution finished (xbps-query -R -f \"*/$1\"), return code was: $ret"
|
||||
xbps-query -v -R -f "$@"
|
||||
ret=$?;
|
||||
if [[ $verbose == "true" ]]; then
|
||||
msg "Execution finished (xbps-query -v -R -f \"*/$1\"), return code was: $ret"
|
||||
fi
|
||||
exit $ret
|
||||
;;
|
||||
|
||||
dependencies)
|
||||
deps|dependencies)
|
||||
shift
|
||||
xbps-query -R -x "$@"
|
||||
ret=$?; msg "Execution finished (xbps-query -R -x \"*/$1\"), return code was: $ret"
|
||||
xbps-query -v -R -x "$@"
|
||||
ret=$?; msg "Execution finished (xbps-query -v -R -x \"*/$1\"), return code was: $ret"
|
||||
exit $ret
|
||||
;;
|
||||
|
||||
reverse)
|
||||
shift
|
||||
msg "Reverse dependencies for $@ (xbps-query -R $@):"
|
||||
xbps-query -R -X "$@"
|
||||
ret=$?; msg "Execution finished (xbps-query -R $@), return code was: $ret"
|
||||
msg "Reverse dependencies for $@ (xbps-query -v -R $@):"
|
||||
xbps-query -v -R -X "$@"
|
||||
ret=$?; msg "Execution finished (xbps-query -v -R $@), return code was: $ret"
|
||||
exit $ret
|
||||
;;
|
||||
|
||||
searchfile)
|
||||
shift
|
||||
msg "searchfile: This might take a long time, please be patient..."
|
||||
msg "(xbps-query -R -o \"*/$1\"):"
|
||||
msg "(xbps-query -v -R -o \"*/$1\"):"
|
||||
sleep 1
|
||||
xbps-query -R -o "*/$1"
|
||||
ret=$?; msg "Execution finished (xbps-query -R -o \"*/$1\"), return code was: $ret"
|
||||
xbps-query -v -R -o "*/$1"
|
||||
ret=$?; msg "Execution finished (xbps-query -v -R -o \"*/$1\"), return code was: $ret"
|
||||
exit $ret
|
||||
;;
|
||||
|
||||
|
@ -208,32 +272,50 @@ case "$arg" in
|
|||
shift
|
||||
msg "Installed packages: "
|
||||
count=0
|
||||
xbps-query -l | while read line; do
|
||||
xbps-query -v -l | while read line; do
|
||||
let count=count+1
|
||||
pkgname="$(echo "$line" | cut -d" " -f 2 | xargs -0)"
|
||||
version="$(extract_versionstring "$pkgname")"
|
||||
pkg="$(extract_packagename "$pkgname")"
|
||||
tput setaf 32
|
||||
echo -e -n "($count) ${pkg} "
|
||||
tput setaf 244
|
||||
echo -e -n " [${version}] "
|
||||
tput setaf 241
|
||||
echo " [${pkgname}] "
|
||||
pkg="$(printf ${line#* } | xargs)"
|
||||
pkgname="$(printf '%s\n' "${pkg%-*}")"
|
||||
version="$(printf '%s\n' "${pkg##*-}")"
|
||||
color 38
|
||||
echo -n "$pkgname "
|
||||
color 241
|
||||
echo -n " ("
|
||||
color 106
|
||||
echo -n "$version"
|
||||
color 241
|
||||
echo -n ") "
|
||||
color 241
|
||||
echo -n " ["
|
||||
color 247
|
||||
echo -n "$pkg"
|
||||
color 241
|
||||
echo "]"
|
||||
color reset
|
||||
shift
|
||||
done
|
||||
;;
|
||||
|
||||
listalternative|listalternatives)
|
||||
xbps-alternatives -l "$@"
|
||||
;;
|
||||
|
||||
setalternative|setalternatives)
|
||||
shift
|
||||
xbps-alternatives -s "$@"
|
||||
;;
|
||||
|
||||
repolist|listrepos)
|
||||
msg "Configured repositories (xbps-query -L): "
|
||||
xbps-query -L
|
||||
msg "Configured repositories (xbps-query -v -L): "
|
||||
xbps-query -v -L
|
||||
shift
|
||||
echo
|
||||
msg "Available sub-repositories (xbps-query -Rs void-repo): "
|
||||
xbps-query -Rs void-repo
|
||||
msg "[xbps-query -Rs void-repo] return code: $?"
|
||||
msg "Available sub-repositories (xbps-query -v -Rs void-repo): "
|
||||
xbps-query -v -Rs void-repo
|
||||
msg "[xbps-query -v -Rs void-repo] return code: $?"
|
||||
shift
|
||||
echo
|
||||
msg "Use \"vpm addrepo <repository>\" to add a sub-repository."
|
||||
msg "Use \"${0##*/} addrepo <repository>\" to add a sub-repository."
|
||||
echo
|
||||
;;
|
||||
|
||||
|
@ -243,6 +325,9 @@ case "$arg" in
|
|||
msg "Adding repository: $1"
|
||||
xbps-install "$1"
|
||||
msg "[xbps-install $arg] return code: $?"
|
||||
msg "Synchronizing remote repository data (xbps-install -S): "
|
||||
xbps-install -S
|
||||
msg "[xbps-install -S] return code: $?"
|
||||
shift
|
||||
done
|
||||
;;
|
||||
|
@ -280,36 +365,48 @@ case "$arg" in
|
|||
|
||||
remove)
|
||||
shift
|
||||
msg "Removing package(s): $@ (xbps-remove $@)"
|
||||
xbps-remove "$@"
|
||||
msg "Removing package(s): $@ (xbps-remove -v $@)"
|
||||
xbps-remove -v "$@"
|
||||
;;
|
||||
|
||||
removerecursive)
|
||||
shift
|
||||
msg "Removing package(s) recursively: $@ (xbps-remove -v -R $@)"
|
||||
xbps-remove -v -R "$@"
|
||||
;;
|
||||
|
||||
reconfigure)
|
||||
shift
|
||||
msg "reconfigure: Re-configuring package(s) (xbps-reconfigure -v $@):"
|
||||
xbps-reconfigure -v "$@"
|
||||
;;
|
||||
|
||||
autoremove)
|
||||
shift
|
||||
msg "autoremove: Removing orphaned packages (xbps-remove -Q)"
|
||||
xbps-remove -O
|
||||
msg "autoremove: Removing orphaned packages (xbps-remove -v -Q)"
|
||||
xbps-remove -v -O
|
||||
msg "done."
|
||||
;;
|
||||
|
||||
update)
|
||||
shift
|
||||
msg "Running system update (xbps-install -Sduv)"
|
||||
msg "Running system update (xbps-install -Suv)"
|
||||
xbps-install -Suv
|
||||
msg "[xbps-install -Suv] return code: $?"
|
||||
;;
|
||||
|
||||
search)
|
||||
shift
|
||||
msg "Searching for: $@ (xbps-query -Rs $@)"
|
||||
xbps-query -Rs "$@"
|
||||
msg "[xbps-query -Rs $@] return code: $?"
|
||||
msg "Searching for: $@ (xbps-query -v -Rs $@)"
|
||||
xbps-query -v -Rs "$@"
|
||||
msg "[xbps-query -v -Rs $@] return code: $?"
|
||||
;;
|
||||
|
||||
cleanup)
|
||||
msg "Cleaning up packages (will remove orphaned packages) (xbps-remove -O $@)"
|
||||
msg "Cleaning up packages (will remove orphaned packages) (xbps-remove -v -O $@)"
|
||||
shift
|
||||
xbps-remove -O "$@"
|
||||
msg "[xbps-remove --D $@] return code: $?"
|
||||
xbps-remove -v -O "$@"
|
||||
msg "[xbps-remove -v --D $@] return code: $?"
|
||||
;;
|
||||
|
||||
help|-h|--help)
|
||||
|
@ -334,3 +431,4 @@ esac
|
|||
|
||||
exit 0
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue