vbm/vpm

601 lines
15 KiB
Plaintext
Raw Normal View History

2016-04-20 00:09:22 +02:00
#!/bin/bash
2018-08-28 19:52:32 +02:00
# vim: ft=sh ts=2 sw=2 sts=2 et
2016-04-20 05:03:54 +02:00
# vpm - void package management utility for
# XBPS, the X Binary Package System
2017-07-20 10:50:52 +02:00
# Copyright (c) 2016 Armin Jenewein <a@m2m.pm>, GitHub: @netzverweigerer
# For more information about XBPS, see:
# https://github.com/voidlinux/xbps
2016-04-20 05:03:54 +02:00
# Released under the terms of the GNU general public license, version 3+
# see LICENSE file for license information.
2017-07-20 10:50:52 +02:00
# VPM color definitions
2018-08-28 19:52:32 +02:00
numcolorok=2
numcolorfail=1
numcolorlogo=5
numcolorheader=3
numcolortext=4
numcolorgray=2
numcolorpkgcount=8
numcolordarkgray=11
numcolorbrackets=6
getversion () {
2018-08-28 19:52:32 +02:00
local fp=$(readlink -f "$0")
(cd "${fp%/*}" && \
git describe --all --debug --long --tags 2>/dev/null) || echo "UNKNOWN"
}
2016-04-20 05:03:54 +02:00
2018-08-28 19:52:32 +02:00
version=$(getversion)
progname=${0##*/}
verbose=false
2018-08-28 19:52:32 +02:00
# enable or disable colors based on the argument given, i.e.:
# setcolors on # colors on
# setcolors off # colors off
# setcolors auto # colors on or off depending on environment
declare -A COLORS
setcolors () {
local opt=$1
# determine if colors should be enabled or not
if [[ $opt == auto ]]; then
# if stdout is a TTY and the TERM looks like it supports color enable colors
if [[ -t 1 && $TERM == *color* ]]; then
opt='on'
else
opt='off'
fi
fi
case "$opt" in
on)
local i
for i in {1..11}; do
if [[ -n ${COLORS[$i]} ]]; then
continue
fi
COLORS[$i]=$(tput setaf "$i")
done
colorbrackets=${COLORS[$numcolorbrackets]}
colordarkgray=${COLORS[$numcolordarkgray]}
colorfail=${COLORS[$numcolorfail]}
colorgray=${COLORS[$numcolorgray]}
colorheader=${COLORS[$numcolorheader]}
colorlogo=${COLORS[$numcolorlogo]}
colorok=${COLORS[$numcolorok]}
colorpkgcount=${COLORS[$numcolorpkgcount]}
colortext=${COLORS[$numcolortext]}
colorreset=$(tput sgr0)
2016-04-21 00:24:16 +02:00
;;
2018-08-28 19:52:32 +02:00
off)
colorbrackets=
colordarkgray=
colorfail=
colorgray=
colorheader=
colorlogo=
colorok=
colorpkgcount=
colortext=
colorreset=
unset COLORS
declare -A COLORS
2016-04-21 00:24:16 +02:00
;;
*)
2018-08-28 19:52:32 +02:00
rmsg 255 "unknown color option: '$opt'"
exit 255
2016-04-21 00:24:16 +02:00
;;
esac
2018-08-28 19:52:32 +02:00
}
# print the logo with brackets colorized
getlogo () {
printf '%s[%s%s%s]%s' \
"$colorbrackets" \
"$colorlogo" "$progname" \
"$colorbrackets" \
"$colorreset"
2016-04-20 17:11:52 +02:00
}
# prints a message (with vpm-prefix)
2016-04-20 17:11:52 +02:00
msg () {
2018-08-28 19:52:32 +02:00
local logo=$(getlogo)
echo "$logo" "$colortext" "$@" "$colorreset"
2016-04-20 17:11:52 +02:00
}
# rmsg - same (but colorized based on return status passed via $1)
2016-12-03 18:44:23 +01:00
rmsg () {
2018-08-28 19:52:32 +02:00
local code=$1
shift
local logo=$(getlogo)
local statuscolor
if ((code == 0)); then
statuscolor=$colorok
2016-12-03 18:44:23 +01:00
else
2018-08-28 19:52:32 +02:00
statuscolor=$colorfail
2016-12-03 18:44:23 +01:00
fi
2018-08-28 19:52:32 +02:00
echo "$logo" "$statuscolor" "$@" "$colorreset"
2016-12-03 18:44:23 +01:00
}
2016-04-21 00:24:16 +02:00
banner () {
2018-08-28 19:52:32 +02:00
echo -n "$colorlogo"
echo ' __ ___ __ _ __ '
printf " \\ V / '_ \\ ' \ "
echo -n "$colorgray"
echo " $progname - void package management utility for XBPS"
echo -n "$colorlogo"
echo -n ' \_/| .__/_|_|_|'
2018-08-28 19:52:32 +02:00
echo -n "$colorgray"
echo ' GitHub: https://github.com/netzverweigerer/vpm'
2018-08-28 19:52:32 +02:00
echo -n "$colorlogo"
echo ' |/ '
echo ' ´ '
2018-08-28 19:52:32 +02:00
echo -n "$colorreset"
2016-04-21 00:24:16 +02:00
}
version () {
banner
2018-08-28 19:52:32 +02:00
msg "$progname - Version: $version"
msg "Copyright (c) 2016 Armin Jenewein <a@m2m.pm> (GPLv3+)"
2016-08-03 07:51:53 +02:00
msg "XBPS version: $(xbps-query -v --version | sed 's/GIT: UNSET//')"
2016-04-20 05:03:54 +02:00
}
2017-07-19 16:01:52 +02:00
# check if we have UID 0, exit otherwise
rootcheck () {
2018-08-28 19:52:32 +02:00
if [[ $EUID -gt 0 ]]; then
msg "ERROR: $progname: This operation needs super-user privileges. Exiting."
exit 255
fi
2017-07-19 16:01:52 +02:00
}
t () {
2018-08-28 19:52:32 +02:00
if [[ -n $show_translations ]]; then
tput setaf 242
2018-08-28 19:52:32 +02:00
echo ' ' "$@"
echo
tput setaf 109
fi
}
2016-04-20 01:08:33 +02:00
usage () {
2016-04-20 01:19:53 +02:00
echo
2016-04-20 05:03:54 +02:00
version
2016-04-20 01:19:53 +02:00
echo
2018-08-28 19:52:32 +02:00
echo -n "$colorheader"
2016-04-20 17:11:52 +02:00
echo "USAGE: "
2018-08-28 19:52:32 +02:00
echo -n "$colorgray"
echo "$progname [OPTIONS] [SUBCOMMANDS] [<ARGS>]"
echo
echo -n "$colorheader"
2016-04-20 01:08:33 +02:00
echo "OPTIONS: "
2018-08-28 19:52:32 +02:00
echo -n "$colorgray"
echo "--color=<yes|no|auto> - Enable/Disable colorized output (default: auto)"
2016-04-20 18:58:45 +02:00
echo "--help - (same as: help)"
echo "--help-pager - (same as: helppager)"
2018-08-28 19:52:32 +02:00
echo "--show-translations - Show XBPS command translations for $progname sub-commands"
echo "--verbose - Verbose mode (shows XBPS command translations during execution)"
2016-04-20 00:09:22 +02:00
echo
2018-08-28 19:52:32 +02:00
echo -n "$colorheader"
echo "SUBCOMMANDS: "
2018-08-28 19:52:32 +02:00
echo -n "$colorgray"
2016-04-20 00:09:22 +02:00
echo "sync - Synchronize remote repository data"
t "xbps-install -S"
2016-08-06 22:49:58 +02:00
echo "update (up) - Update the system"
t "xbps-install -Sduv"
2016-08-06 22:49:58 +02:00
echo "listrepos (lr) - List configured repositories"
echo "repolist (rl) - Alias for listrepos"
t "xbps-query -v -L"
2016-08-06 22:49:58 +02:00
echo "addrepo (ar) <ARGS> - Add an additional repository"
2016-04-22 20:43:08 +02:00
t "xbps-install <ARGS>"
2016-08-06 22:49:58 +02:00
echo "info <pkg> - Show information about <package>"
t "xbps-query-v -R"
2016-08-06 22:49:58 +02:00
echo "filelist (fl) <pkg> - Show file-list of <package>"
t "xbps-query -v -R -f"
2016-08-06 22:49:58 +02:00
echo "deps <pkg> - Show dependencies for <package>"
t "xbps-query -v -R -x"
2016-08-06 22:49:58 +02:00
echo "reverse (rv) <pkg> - Show reverse dependendies of <package> (see man xbps-query)"
t "xbps-query -v -R -X"
2016-08-06 22:49:58 +02:00
echo "search (s) <name> - Search for package by <name>"
t "xbps-query -v -Rs"
2016-08-06 22:49:58 +02:00
echo "searchfile (sf) <file> - Search for package containing <file> (local)"
t "xbps-query -v -o \"*/$1\""
2016-08-06 22:49:58 +02:00
echo "list (ls) - List installed packages"
t "xbps-query -v -l"
2016-08-06 22:49:58 +02:00
echo "install (i) <pkg(s)> - Install <package(s)>"
t "xbps-install -S"
2016-08-06 22:49:58 +02:00
echo "devinstall (di) <pkg(s)> - Install <package> (and corresponding <package>-devel package(s))"
t "xbps-install -S <package> <package>-devel"
2016-08-06 22:49:58 +02:00
echo "listalternatives (la) - List alternative candidates"
t "xbps-alternatives -l"
2016-08-06 22:49:58 +02:00
echo "setalternative (sa) <pkg(s) - Set alternative for <package>"
t "xbps-alternatives -s"
2016-08-06 22:49:58 +02:00
echo "reconfigure (rc) <pkg> - Re-configure installed <package>"
t "xbps-reconfigure -v"
2016-08-06 22:49:58 +02:00
echo "forceinstall (fi) <pkg(s)> - Force installation of <package(s)>"
t "xbps-install -f"
2016-04-22 02:15:35 +02:00
echo "remove <package(s)) - Remove <package(s)> from the system"
t "xbps-remove -v "
2016-08-06 22:49:58 +02:00
echo "removerecursive <pkg(s)> - Recursively remove package(s) (and its dependencies)"
t "xbps-remove -v -R"
2016-08-06 22:49:58 +02:00
echo "cleanup (cl) - Clean up cache directory"
t "xbps-remove -v -O"
2016-08-06 22:49:58 +02:00
echo "autoremove (ar) - Remove orphaned packages"
t "xbps-remove -v -O"
2017-05-22 14:47:05 +02:00
echo "whatprovides (wp) <file> - Search for package containing <file>"
t "xlocate <pkg>"
2016-04-20 02:08:29 +02:00
echo "help - Show usage information"
2016-08-06 22:49:58 +02:00
echo "helppager (hp) - Show usage information (will pipe output to less/more)"
2016-04-20 00:09:22 +02:00
echo
2018-08-28 19:52:32 +02:00
echo -n "$colorheader"
echo "XBPS COMPATIBILITY COOLNESS:"
2018-08-28 19:52:32 +02:00
echo -n "$colorgray"
f=(/usr/sbin/xbps-*)
2018-08-28 19:52:32 +02:00
echo "$progname also understands all unknown XBPS sub-commands, too:"
echo -n "Example: "
selected=${f[$RANDOM % ${#f[@]}]}
2018-08-28 19:52:32 +02:00
echo "$progname ${selected##*-} <ARGS> - see also: /usr/sbin/xbps-*"
echo
echo -n "$colorreset"
2016-04-20 00:09:22 +02:00
}
2018-08-28 19:52:32 +02:00
setcolors auto
case "$1" in
--color=true|--color=yes|--color=on)
2018-08-28 19:52:32 +02:00
setcolors on
shift
;;
--color=auto)
2018-08-28 19:52:32 +02:00
setcolors auto
shift
;;
--color=false|--color=off|--color=no)
2018-08-28 19:52:32 +02:00
setcolors off
shift
;;
--verbose=true)
shift
verbose=true
;;
--show-translations)
shift
show_translations=1
;;
--help)
shift
usage
exit 255
;;
--help-pager)
shift
2018-08-28 19:52:32 +02:00
"$0" --color=off --help | less
;;
--*)
2018-08-28 19:52:32 +02:00
msg "Unknown option: $1 (try: $progname --help)"
exit 1
;;
esac
2016-04-20 00:09:22 +02:00
if [[ "$1" == "" ]]; then
usage
2016-04-20 05:46:58 +02:00
exit 0
2016-04-20 00:09:22 +02:00
fi
2018-08-28 19:52:32 +02:00
arg=$1
2016-04-20 19:04:19 +02:00
if [[ "$arg" =~ --.* ]]; then
2018-08-28 19:52:32 +02:00
b=${arg:2}
arg=$b
2016-04-20 19:04:19 +02:00
fi
case "$arg" in
2016-12-03 18:44:23 +01:00
info|in)
2016-04-20 05:03:54 +02:00
shift
msg "(xbps-query -v -R $@):"
xbps-query -v -R "$@"
2016-12-03 18:44:23 +01:00
ret=$?
2018-08-28 19:52:32 +02:00
rmsg "$ret" "Execution finished (xbps-query -v -R $@), return code was: $ret"
exit "$ret"
2016-04-20 00:09:22 +02:00
;;
2016-04-20 02:08:29 +02:00
2016-12-03 18:44:23 +01:00
filelist|fl|listfiles)
2016-04-20 05:03:54 +02:00
shift
xbps-query -v -R -f "$@"
2018-08-28 19:52:32 +02:00
ret=$?;
if [[ $verbose == "true" ]]; then
2018-08-28 19:52:32 +02:00
rmsg "$ret" "Execution finished (xbps-query -v -R -f \"*/$1\"), return code was: $ret"
fi
2018-08-28 19:52:32 +02:00
exit "$ret"
2016-04-20 00:09:22 +02:00
;;
2016-04-20 02:08:29 +02:00
2016-12-06 12:04:33 +01:00
deps|dep|dependencies)
2016-04-20 05:03:54 +02:00
shift
xbps-query -v -R -x "$@"
2016-12-03 18:44:23 +01:00
ret=$?
2018-08-28 19:52:32 +02:00
rmsg "$ret" "Execution finished (xbps-query -v -R -x \"*/$1\"), return code was: $ret"
exit "$ret"
2016-04-20 00:09:22 +02:00
;;
2016-04-20 02:08:29 +02:00
2016-12-06 12:04:33 +01:00
reverse|rv)
2016-04-20 05:03:54 +02:00
shift
msg "Reverse dependencies for $@ (xbps-query -v -R $@):"
xbps-query -v -R -X "$@"
2016-12-03 18:44:23 +01:00
ret=$?
2018-08-28 19:52:32 +02:00
msg "$ret" "Execution finished (xbps-query -v -R $@), return code was: $ret"
exit "$ret"
2016-04-20 00:09:22 +02:00
;;
2016-04-20 02:08:29 +02:00
2016-12-06 12:04:33 +01:00
searchfile|sf)
2016-04-20 05:03:54 +02:00
shift
msg "searchfile (xbps-query -v -o \"*/$1\"):"
xbps-query -v -o "*/$1"
2016-12-03 18:44:23 +01:00
ret=$?
2018-08-28 19:52:32 +02:00
msg "$ret" "Execution finished (xbps-query -v -o \"*/$1\"), return code was: $ret"
2016-04-30 21:29:59 +02:00
exit $ret
;;
2016-12-06 12:04:33 +01:00
remotesearchfile|rsf)
2016-04-30 21:29:59 +02:00
shift
msg "remotesearchfile (xbps-query -R -v -o \"*/$1\"):"
xbps-query -R -v -o "*/$1"
2016-12-03 18:44:23 +01:00
ret=$?
2018-08-28 19:52:32 +02:00
msg "$ret" "Execution finished (xbps-query -R -v -o \"*/$1\"), return code was: $ret"
exit "$ret"
;;
2016-08-06 22:49:58 +02:00
list|ls)
2016-04-20 05:03:54 +02:00
shift
2016-04-20 17:11:52 +02:00
msg "Installed packages: "
2018-08-28 19:52:32 +02:00
2016-04-20 22:25:37 +02:00
count=0
2018-08-28 19:52:32 +02:00
while read -r _ pkg _; do
((count++))
pkgname=${pkg%-*}
version=${pkg##*-}
printf '%s%d %s%s %s (%s%s%s) [%s%s%s]%s\n' \
"$colorpkgcount" "$count" \
"$colortext" "$pkgname" \
"$colorbrackets" \
"$colorgray" "$version" \
"$colorbrackets" \
"$colordarkgray" "$pkg" \
"$colorbrackets" \
"$colorreset"
done < <(xbps-query -v -l)
2016-04-20 00:09:22 +02:00
;;
2016-04-20 02:08:29 +02:00
2016-12-06 12:04:33 +01:00
listalternative|listalternatives|la)
xbps-alternatives -l "$@"
ret=$?
2018-08-28 19:52:32 +02:00
rmsg "$ret" "xbps-alternatives return code: $ret (xbps-alternatives -l $@)"
;;
2016-12-06 12:04:33 +01:00
setalternative|setalternatives|sa)
shift
2017-07-19 16:01:52 +02:00
rootcheck
xbps-alternatives -s "$@"
ret=$?
2018-08-28 19:52:32 +02:00
rmsg "$ret" "xbps-alternatives return code: $ret (xbps-alternatives -s $@)"
;;
2016-12-06 12:04:33 +01:00
repolist|listrepos|rl|lr)
msg "Configured repositories (xbps-query -v -L): "
xbps-query -v -L
2016-12-03 18:44:23 +01:00
ret=$?
2018-08-28 19:52:32 +02:00
rmsg "$ret" "[xbps-query -v -L] return code: $ret"
2016-04-20 17:11:52 +02:00
shift
echo
msg "Available sub-repositories (xbps-query -v -Rs void-repo): "
xbps-query -v -Rs void-repo
2016-12-03 18:44:23 +01:00
ret=$?
2018-08-28 19:52:32 +02:00
rmsg "$ret" "[xbps-query -v -Rs void-repo] return code: $ret"
2016-04-20 17:11:52 +02:00
shift
echo
2018-08-28 19:52:32 +02:00
msg "Use \"$progname addrepo <repository>\" to add a sub-repository."
2016-04-20 17:11:52 +02:00
echo
;;
2016-12-06 12:04:33 +01:00
addrepo|ar)
2016-04-20 17:11:52 +02:00
shift
2017-07-19 16:01:52 +02:00
rootcheck
2018-08-28 19:52:32 +02:00
for repo in "$@"; do
msg "Adding repository: $repo"
xbps-install "$1"
ret=$?
rmsg "$ret" "[xbps-install $arg] return code: $ret"
msg "Synchronizing remote repository data (xbps-install -S): "
xbps-install -S
ret=$?
rmsg "$ret" "[xbps-install -S] return code: $ret"
shift
2016-04-20 17:11:52 +02:00
done
;;
2017-07-20 10:50:52 +02:00
2016-12-06 12:04:33 +01:00
sync|sy)
2017-07-19 16:01:52 +02:00
shift
rootcheck
2016-04-20 05:26:56 +02:00
msg "Synchronizing remote repository data: (xbps-install -S):"
2016-04-20 05:03:54 +02:00
xbps-install -S
2016-12-03 18:44:23 +01:00
ret=$?
2018-08-28 19:52:32 +02:00
rmsg "$ret" "[xbps-install -S] return code: $ret"
2016-04-20 00:09:22 +02:00
;;
2017-07-20 10:50:52 +02:00
2016-12-06 12:04:33 +01:00
install|i)
2018-08-28 19:52:32 +02:00
shift
rootcheck
if [[ "$#" -lt 1 ]]; then
msg "ERROR: install: argument missing, try --help."
exit 1
fi
msg "Installing packages: $@ (xbps-install -S $@) ..."
xbps-install -S "$@"
ret=$?
rmsg "$ret" "[xbps-install -S $@] return code: $ret"
2016-12-03 18:44:23 +01:00
;;
2017-07-20 10:50:52 +02:00
2016-12-03 18:44:23 +01:00
yesinstall)
shift
2017-07-19 16:01:52 +02:00
rootcheck
2018-08-28 19:52:32 +02:00
if [[ "$#" -lt 1 ]]; then
msg "ERROR: install: argument missing, try --help."
exit 1
fi
msg "Installing packages: $@ (xbps-install -S $@) ..."
xbps-install -y -S "$@"
2018-08-28 19:52:32 +02:00
ret=$?
rmsg "$ret" "[xbps-install -S $@] return code: $ret"
2016-04-20 00:09:22 +02:00
;;
2016-04-20 02:08:29 +02:00
devinstall)
2017-07-19 16:01:52 +02:00
shift
rootcheck
2018-08-28 19:52:32 +02:00
if [[ "$#" -lt 1 ]]; then
2017-07-19 16:01:52 +02:00
msg "ERROR: devinstall: argument missing, try --help."
exit 1
fi
2018-08-28 19:52:32 +02:00
args=("$@")
2017-07-19 16:01:52 +02:00
msg "devinstall: Packages will be installed one-by-one"
msg "Use \"forceinstall\" to override this if you know what you're doing."
msg "(Note: forceinstall won't install -devel packages)"
for arg in "${args[@]}"; do
let count=count+1
msg "Installing package: $arg (xbps-install -S $arg) ..."
xbps-install -S "$arg"
2018-08-28 19:52:32 +02:00
ret=$?
rmsg "$ret" "[xbps-install -S $arg] return code: $ret"
2017-07-19 16:01:52 +02:00
msg "installing devel package (${arg}-devel):"
xbps-install -S "${arg}-devel"
2018-08-28 19:52:32 +02:00
ret=$?
rmsg "$ret" "[xbps-install -S ${arg}-devel] return code: $ret"
2017-07-19 16:01:52 +02:00
done
;;
2016-12-06 12:04:33 +01:00
forceinstall|fi)
shift
2017-07-19 16:01:52 +02:00
rootcheck
msg "Force-Installing Package(s): $@ (xbps-install -Sf $@)"
xbps-install -Sf "$@"
2018-08-28 19:52:32 +02:00
ret=$?
rmsg "$ret" "[xbps-install -Sf ${@}] return code: $ret"
2016-04-20 00:09:22 +02:00
;;
2016-04-20 02:08:29 +02:00
2016-12-06 12:04:33 +01:00
remove|rm)
shift
2017-07-19 16:01:52 +02:00
rootcheck
msg "Removing package(s): $@ (xbps-remove -v $@)"
xbps-remove -v "$@"
2018-08-28 19:52:32 +02:00
ret=$?
rmsg "$ret" "[xbps-remove -v ${@}] return code: $ret"
2016-04-20 00:09:22 +02:00
;;
2016-04-20 02:08:29 +02:00
2016-12-06 12:04:33 +01:00
removerecursive|rr)
shift
2017-07-19 16:01:52 +02:00
rootcheck
msg "Removing package(s) recursively: $@ (xbps-remove -v -R $@)"
xbps-remove -v -R "$@"
2018-08-28 19:52:32 +02:00
ret=$?
rmsg "$ret" "[xbps-remove -v -R ${@}] return code: $ret"
;;
2016-12-06 12:04:33 +01:00
reconfigure|rc)
shift
2017-07-19 16:01:52 +02:00
rootcheck
msg "reconfigure: Re-configuring package(s) (xbps-reconfigure -v $@):"
xbps-reconfigure -v "$@"
2018-08-28 19:52:32 +02:00
ret=$?
rmsg "$ret" "[xbps-reconfigure -v ${@}] return code: $ret"
;;
2016-12-06 12:04:33 +01:00
autoremove|ar)
shift
2017-07-19 16:01:52 +02:00
rootcheck
msg "autoremove: Removing orphaned packages (xbps-remove -v -o)"
xbps-remove -v -o
2018-08-28 19:52:32 +02:00
ret=$?
rmsg "$ret" "[xbps-remove -v -o] return code: $ret"
2016-04-20 00:09:22 +02:00
;;
2016-04-20 02:08:29 +02:00
2016-08-06 22:49:58 +02:00
update|upgrade|up)
shift
2017-07-19 16:01:52 +02:00
rootcheck
msg "Running system update (xbps-install -Suv)"
xbps-install -Suv
ret=$?
if [[ $ret == 16 ]]; then
msg "Updating xbps (xbps-install -u xbps)"
xbps-install -u xbps
ret2=$?
rmsg "$ret2" "[xbps-install -u xbps] return code: $ret2"
exit 0
fi
2018-08-28 19:52:32 +02:00
rmsg "$ret" "[xbps-install -Suv] return code: $ret"
2016-04-20 00:09:22 +02:00
;;
2016-04-20 02:08:29 +02:00
2016-12-06 12:04:33 +01:00
search|s)
shift
msg "Searching for: $@ (xbps-query -v -Rs $@)"
xbps-query -v -Rs "$@"
ret=$?
2018-08-28 19:52:32 +02:00
rmsg "$ret" "[xbps-query -v -Rs $@] return code: $ret"
2016-04-20 00:09:22 +02:00
;;
2016-04-20 02:08:29 +02:00
2016-08-06 22:49:58 +02:00
cleanup|clean|cl)
msg "Cleaning up packages (will remove orphaned packages) (xbps-remove -v -O $@)"
shift
2017-07-19 16:01:52 +02:00
rootcheck
xbps-remove -v -O "$@"
ret=$?
2018-08-28 19:52:32 +02:00
rmsg "$ret" "[xbps-remove -v -O $@] return code: $ret"
2016-04-20 00:09:22 +02:00
;;
2016-04-20 02:08:29 +02:00
2016-08-06 22:49:58 +02:00
h|help|-h|--help)
usage
2016-04-20 00:09:22 +02:00
;;
2016-04-20 02:08:29 +02:00
2016-12-06 12:04:33 +01:00
helppager|help-pager|hp)
if hash less >/dev/null 2>&1; then
2018-08-28 19:52:32 +02:00
"$0" --color=off help | less
else
2018-08-28 19:52:32 +02:00
"$0" --color=off help | more
fi
;;
2017-05-22 14:47:05 +02:00
whatprovides|wp)
2017-07-19 16:01:52 +02:00
shift
2017-05-22 14:47:05 +02:00
if hash xlocate >/dev/null 2>&1; then
# set -x
# xlocate -S "$@"
msg "relaying to: \"xlocate $@\" - use xlocate -S to (re-)build cached DB."
xlocate "$@"
2017-07-20 10:50:52 +02:00
else
rmsg 255 "xlocate not found. Try installing the xtools package."
2017-05-22 14:47:05 +02:00
fi
;;
2016-04-20 00:09:22 +02:00
''|*)
a="$1"
if hash "xbps-${a}" >/dev/null 2>&1; then
shift
# xbps-<subcommand> found
2018-08-28 19:52:32 +02:00
msg "relaying to XBPS: xbps-$a $@"
"xbps-$a" "$@"
ret=$?
2018-08-28 19:52:32 +02:00
rmsg "$ret" "xbps-$a $@ return code: $ret"
else
2018-08-28 19:52:32 +02:00
rmsg 255 "Unrecognized $progname subcommand: $1 (and xbps-$1 does not exist) - Try: $progname help"
echo
exit 1
fi
2016-04-20 00:09:22 +02:00
;;
2016-04-20 02:08:29 +02:00
2016-04-20 00:09:22 +02:00
esac
2016-04-20 05:46:58 +02:00
exit 0