rebranded, added vbm slim (termux) version etc...
This commit is contained in:
parent
6d7c4835e3
commit
c3dc70e210
|
@ -0,0 +1,20 @@
|
|||
PREFIX_BIN ?= /bin
|
||||
PREFIX_BASHC ?= /usr/share/bash-completion/completions
|
||||
|
||||
.PHONY: all
|
||||
all:
|
||||
@echo 'nothing to do'
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
cp vbm.sh $(PREFIX_BIN)/vbm
|
||||
cp bash-completion/completions/vbm $(PREFIX_BASHC)/vbm
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall:
|
||||
rm -f $(PREFIX_BIN)/vbm
|
||||
rm -f $(PREFIX_BASHC)/vbm
|
||||
|
||||
.PHONY: check
|
||||
check:
|
||||
which vbm
|
132
README.md
132
README.md
|
@ -1,8 +1,84 @@
|
|||
# vpm - An XBPS package management helper for VoidLinux
|
||||
### Changed name from vpm to vbm
|
||||
|
||||
# vbm - An XBPS package management helper for vb aka Void GNU/Linux
|
||||
version 1.0
|
||||
|
||||
`vbm` is a simple to use, daily-driver enhancement to the awesome XBPS (X Binary
|
||||
Package System), initially designed as a helper tool for use with VoidLinux.
|
||||
Feel free to think "Void Package Management" or something if it helps you
|
||||
remember its name, but please note that it's NOT a "package manager" in the
|
||||
nitpickers understanding of the word - especially vbm shouldn't be confused with
|
||||
XBPS - vbm is just an addon helper tool for XBPS to make your life easier.
|
||||
That's it.
|
||||
|
||||
# better then screenshots
|
||||
|
||||
vbm...
|
||||
|
||||
[![asciicast](https://asciinema.org/a/476068.svg)](https://asciinema.org/a/476068)
|
||||
|
||||
# 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 vpm
|
||||
help. It has been said that vpm will ease the transition from Debian's APT, and
|
||||
some other user-friendly repository/package-managers.
|
||||
|
||||
# Dependencies
|
||||
|
||||
vbm requires BASH, the Bourne Again SHell, which should be installed by default
|
||||
on a new VoidLinux system. You also will need git and xcheckrestart both provided
|
||||
by xtools package to obtain a clone of the vbm repository.
|
||||
(see "Installation" section, below).
|
||||
|
||||
Or you can just grab vbm and paste it anywhere in your system.
|
||||
|
||||
# Installation
|
||||
|
||||
### (optional - needed for xcheckrestart functions)
|
||||
|
||||
### Install xtools via `xbps-install`
|
||||
|
||||
xbps-install -S xtools
|
||||
|
||||
### 1. Clone vbm repository
|
||||
|
||||
git clone https://codeberg.org/oSoWoSo/vbm.git
|
||||
|
||||
### 3. Enter the cloned repo and run:
|
||||
|
||||
sudo make install
|
||||
|
||||
### 3a. Remove vbm
|
||||
|
||||
If you want to remove vbm, just use make to remove it. Make sure you are in the cloned directory first, then run:
|
||||
|
||||
sudo make uninstall
|
||||
|
||||
or simply
|
||||
|
||||
vbm remove vbm :)
|
||||
|
||||
# ZOMG! PONIES!!111
|
||||
|
||||
Rainbows and unicorns, indeed. If you like colorized output, please see the
|
||||
--color=true option, too! All vbm options try to have human readable and easy to
|
||||
remember syntax, no --long-option-with-multiple-complex-words, no need to even
|
||||
prefix arguments with --, vbm just tries to do its best it can to understand the
|
||||
user (there are some command-line-switches, though, see vbm help).
|
||||
|
||||
Also vbm will ask for password if needed.
|
||||
|
||||
# License
|
||||
|
||||
vbm is released under the terms of the GNU General Public License,
|
||||
Version 3. See the LICENSE file for further information.
|
||||
|
||||
```
|
||||
Copyright (c) 2016: Armin Jenewein <vpm@m2m.pm>
|
||||
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
|
@ -15,48 +91,18 @@ GNU General Public License for more details.
|
|||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
```
|
||||
|
||||
# License
|
||||
vpm is released under the terms of the GNU General Public License,
|
||||
Version 3. See the LICENSE file for further information.
|
||||
|
||||
# About (What is vpm?)
|
||||
vpm is a simple to use, daily-driver enhancement to the awesome XBPS (X Binary Package System), initially designed as a helper tool for use with VoidLinux. Feel free to think "Void Package Management" or something if it helps you remember its name, but please note that it's NOT a "package manager" in the nitpickers understanding of the word - especially vpm shouldn't be confused with XBPS - vpm is just an addon helper tool for XBPS to make your life easier. That's it.
|
||||
|
||||
# Screenshots
|
||||
|
||||
Screenshot of a (not so) recent (anymore) vpm release:
|
||||
|
||||
![alt tag](https://raw.githubusercontent.com/netzverweigerer/vpm/master/screenshots/vpm.png)
|
||||
|
||||
Screenshot of vpm in full effect:
|
||||
|
||||
![alt tag](https://raw.githubusercontent.com/netzverweigerer/vpm/master/screenshots/vpm2.png)
|
||||
|
||||
# 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 vpm 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. If you like colorized output, please see the --color=true option, too! All vpm options 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).
|
||||
|
||||
# Dependencies
|
||||
vpm requires BASH, the Bourne Again SHell, which should be installed by default on a new VoidLinux system. You also will need git to obtain a clone of the vpm GitHub repository (see "Installation" section, below).
|
||||
|
||||
# Installation
|
||||
Installing vpm should be as easy as following the simple following steps:
|
||||
|
||||
1. Install git via xbps-install
|
||||
|
||||
$ xbps-install -S git
|
||||
|
||||
2. Clone vpm repository
|
||||
|
||||
$ git clone git@github.com:netzverweigerer/vpm.git
|
||||
|
||||
I'm not covering how to put vpm into a place that is in your $PATH as I can't give general UNIX administration support in this README.
|
||||
|
||||
# Author
|
||||
vpm was written by Armin Jenewein (GitHub: @netzverweigerer) <vpm@m2m.pm>
|
||||
# Authors
|
||||
|
||||
- https://github.com/netzverweigerer/vpm - vpm was written by Armin Jenewein <vpm@m2m.pm>
|
||||
- https://github.com/bahamas10/vpm - forked by Dave Eddy <dave@daveeddy.com>
|
||||
- https://codeberg.org/oSoWoSo/vbm - and this fork by zenobit <zen@osowoso.xyz>
|
||||
|
||||
# Mirrors
|
||||
|
||||
- repos mirrored at:
|
||||
- 'https://github.com/oSoWoSo/vbm'
|
||||
- 'https://gitlab.com/linux15/void/vbm'
|
||||
- 'https://git.disroot.org/oSoWoSo/vbm'
|
||||
- more mirrors will come...
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
|||
source /usr/share/bash-completion/completions/xbps
|
||||
|
||||
_vpm()
|
||||
_vbm()
|
||||
{
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
@ -10,7 +10,7 @@ _vpm()
|
|||
listrepos
|
||||
repolist
|
||||
addrepo
|
||||
info
|
||||
about
|
||||
filelist
|
||||
deps
|
||||
reverse
|
||||
|
@ -29,7 +29,7 @@ _vpm()
|
|||
autoremove
|
||||
help
|
||||
helppager'
|
||||
local all_pkgs='info|in|filelist|fl|deps|reverse|rv|search|s|install|i|devinstall|di'
|
||||
local all_pkgs='about|a|filelist|fl|deps|reverse|rv|search|s|install|i|devinstall|di'
|
||||
local installed_pkgs='listalternatives|la|setalternative|sa|reconfigure|rc|forceinstall|fi|remove|rm|removerecursive|rc'
|
||||
|
||||
if [[ $prev == @($1) ]]; then
|
||||
|
@ -39,5 +39,6 @@ _vpm()
|
|||
elif [[ $prev == @($installed_pkgs) ]]; then
|
||||
COMPREPLY=( $(compgen -W '$(_xbps_installed_packages)' -- "$cur") )
|
||||
fi
|
||||
|
||||
} &&
|
||||
complete -F _vpm vpm
|
||||
complete -F _vbm vbm
|
|
@ -0,0 +1,3 @@
|
|||
function S --description 'alias S vbm S'
|
||||
vbm S $argv;
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
function a --description 'alias a vbm a'
|
||||
vbm a $argv;
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
function i --description 'alias i vbm i'
|
||||
vbm i $argv;
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
function s --description 'alias s vbm s'
|
||||
vbm s $argv;
|
||||
end
|
Binary file not shown.
Before Width: | Height: | Size: 171 KiB |
Binary file not shown.
Before Width: | Height: | Size: 453 KiB |
|
@ -0,0 +1,735 @@
|
|||
#!/bin/bash
|
||||
# vim: ft=sh ts=2 sw=2 sts=2 et
|
||||
|
||||
# vbm - vb-linux management utility for
|
||||
# XBPS, the X Binary Package System
|
||||
# original author: Armin Jenewein <a@m2m.pm>, GitHub: @netzverweigerer
|
||||
# a lot used from: Dave Eddy <dave@daveeddy.com>, GitHub: @bahamas10
|
||||
# this fork: zenobit <zen@osowoso.xyz>, codeberg.org: @oSoWoSo
|
||||
# For more information about XBPS, see:
|
||||
# https://github.com/voidlinux/xbps
|
||||
|
||||
# Released under the terms of the GNU general public license, version 3+
|
||||
# see LICENSE file for license information.
|
||||
|
||||
# set version number
|
||||
version="1.0"
|
||||
# enable verbosity, by default
|
||||
verbose=true
|
||||
# program name
|
||||
progname=${0##*/}
|
||||
|
||||
# VBM color definitions
|
||||
numcolorok=2
|
||||
numcolorfail=1
|
||||
numcolorlogo=2
|
||||
numcolorheader=3
|
||||
numcolortext=4
|
||||
numcolorgray=8
|
||||
numcolorpkgcount=7
|
||||
numcolordarkgray=11
|
||||
numcolorbrackets=1
|
||||
|
||||
# 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)
|
||||
;;
|
||||
off)
|
||||
colorbrackets=
|
||||
colordarkgray=
|
||||
colorfail=
|
||||
colorgray=
|
||||
colorheader=
|
||||
colorlogo=
|
||||
colorok=
|
||||
colorpkgcount=
|
||||
colortext=
|
||||
colorreset=
|
||||
unset COLORS
|
||||
declare -A COLORS
|
||||
;;
|
||||
*)
|
||||
rmsg 255 "unknown color option: '$opt'"
|
||||
exit 255
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# print the logo with brackets colorized
|
||||
getlogo() {
|
||||
printf '%s[%s%s%s]%s' \
|
||||
"$colorbrackets" \
|
||||
"$colorlogo" "$progname" \
|
||||
"$colorbrackets" \
|
||||
"$colorreset"
|
||||
}
|
||||
|
||||
# prints a message (with vbm-prefix)
|
||||
msg() {
|
||||
local logo=$(getlogo)
|
||||
local newline=true
|
||||
|
||||
if [[ $1 == '-n' ]]; then
|
||||
newline=false
|
||||
shift
|
||||
fi
|
||||
|
||||
printf '%s %s%s%s' "$logo" "$colortext" "$*" "$colorreset"
|
||||
$newline && echo
|
||||
}
|
||||
|
||||
# rmsg - same (but colorized based on return status passed via $1)
|
||||
rmsg() {
|
||||
local code=$1
|
||||
shift
|
||||
|
||||
local logo=$(getlogo)
|
||||
local statuscolor
|
||||
|
||||
if ((code == 0)); then
|
||||
statuscolor=$colorok
|
||||
else
|
||||
statuscolor=$colorfail
|
||||
fi
|
||||
|
||||
printf '%s %s%s%s\n' "$logo" "$statuscolor" "$*" "$colorreset"
|
||||
}
|
||||
|
||||
banner() {
|
||||
echo -n "$colorlogo"
|
||||
echo ' __ __/|__ _ __ '
|
||||
printf " \\ V / '_ \\ ' \ "
|
||||
echo -n "$colorgray"
|
||||
echo " $progname - XBPS package management helper"
|
||||
echo -n "$colorlogo"
|
||||
echo -n ' \_/|_,__/_|_|_\'
|
||||
echo -n "$colorgray"
|
||||
echo ' Source: https://codeberg.org/oSoWoSo/vbm'
|
||||
echo -n "$colorlogo"
|
||||
echo -n "$colorreset"
|
||||
}
|
||||
|
||||
version() {
|
||||
banner
|
||||
echo
|
||||
msg "${colorpkgcount}$progname - Version: $version (GPLv3+)"
|
||||
msg "${colorpkgcount}original author: Armin Jenewein <a@m2m.pm>"
|
||||
msg "https://github.com/netzverweigerer/vpm"
|
||||
msg "${colorpkgcount}a lot used from: Dave Eddy <dave@daveeddy.com>"
|
||||
msg "https://github.com/bahamas10/vpm"
|
||||
msg "${colorpkgcount}this fork: zenobit <zen@osowoso.xyz>"
|
||||
msg "https://codeberg.org/oSoWoSo/vbm"
|
||||
msg "${colorpkgcount}XBPS version: $(xbps-query -v --version | sed 's/GIT: UNSET//')"
|
||||
}
|
||||
|
||||
# check if we have UID 0, exit otherwise
|
||||
rootcheck() {
|
||||
if [[ $EUID -gt 0 ]]; then
|
||||
msg "$(tput setaf 1)This operation needs super-user privileges.$(tput sgr 0)"
|
||||
SUDO=sudo
|
||||
else
|
||||
SUDO=''
|
||||
fi
|
||||
}
|
||||
|
||||
t() {
|
||||
if [[ -n $show_translations ]]; then
|
||||
tput setaf 242
|
||||
echo ' ' "$@"
|
||||
echo
|
||||
tput setaf 109
|
||||
fi
|
||||
}
|
||||
|
||||
wrapcommand() {
|
||||
local cmd ret
|
||||
cmd=("$@")
|
||||
|
||||
echo "$colortext(${cmd[*]}):$colorreset"
|
||||
|
||||
"${cmd[@]}"
|
||||
ret=$?
|
||||
|
||||
rmsg "$ret" "[${cmd[*]}], return code was: $ret"
|
||||
exit "$ret"
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo
|
||||
version
|
||||
echo
|
||||
echo "${colorheader}USAGE:
|
||||
${colorpkgcount}${progname} ${colortext}[OPTIONS] ${colorok}[SUBCOMM${colorfail}ANDS] ${colorpkgcount}[<ARGS>]
|
||||
|
||||
${colorheader} OPTIONS :
|
||||
${colortext}--color=<yes|no|auto> ${colorgray}Enable/Disable colorized output (default: auto)
|
||||
${colortext}--help ${colorgray}(same as: help) show usage
|
||||
${colortext}--slim ${colorgray}(same as: slim) show usage for small screens
|
||||
${colortext}--help-pager ${colorgray}(same as: helppager)
|
||||
${colortext}--show-translations ${colorgray}Show ${colorpkgcount}XBPS${colorgray} command translations for $colorpkgcount$progname$colorgray sub-commands
|
||||
${colortext}--verbose ${colorgray}Show ${colorpkgcount}XBPS${colorgray} command translations during execution
|
||||
|
||||
${colorheader} SUBCOMMANDS :
|
||||
${colorok}(long) ${colorfail}(short)${colorpkgcount} <ARGS>"
|
||||
echo " ${colorok}sync ${colorfail}(S) ${colorgray}Synchronize remote repository data"
|
||||
t "xbps-install -S"
|
||||
echo " ${colorok}update ${colorfail}(u) ${colorgray}Update the system"
|
||||
t "xbps-install -Suv"
|
||||
echo " ${colorok}search ${colorfail}(s) ${colorpkgcount}<pkg> ${colorgray}Search for package"
|
||||
t "xbps-query -v -Rs"
|
||||
echo " ${colorok}syncsearch ${colorfail}(Ss) ${colorgray}Fetch repodata and search for package"
|
||||
t "xbps-query -v -MRs"
|
||||
echo " ${colorok}about ${colorfail}(a) ${colorpkgcount}<pkg> ${colorgray}Show information about <package>"
|
||||
t "xbps-query -v -R"
|
||||
echo " ${colorok}install ${colorfail}(i) ${colorpkgcount}<pkg(s)> ${colorgray}Install <package(s)>"
|
||||
t "xbps-install"
|
||||
echo " ${colorok}remove ${colorfail}(rm) ${colorpkgcount}<pkg(s)> ${colorgray}Remove <package(s)> from the system"
|
||||
t "xbps-remove -v "
|
||||
echo " ${colorok}filelist ${colorfail}(fl) ${colorpkgcount}<pkg> ${colorgray}Show file-list of <package>"
|
||||
t "xbps-query -v -R -f"
|
||||
echo " ${colorok}deps ${colorfail}(d) ${colorpkgcount}<pkg> ${colorgray}Show dependencies for <package>"
|
||||
t "xbps-query -v -R -x"
|
||||
echo " ${colorok}reverse ${colorfail}(rd) ${colorpkgcount}<pkg> ${colorgray}Show reverse dependendies of <package>"
|
||||
t "xbps-query -v -R -X"
|
||||
echo " ${colorok}searchlib ${colorfail}(sl) ${colorpkgcount}<pkg> ${colorgray}Search for package (64bit only)"
|
||||
t "xbps-query -v -Rs"
|
||||
echo " ${colorok}searchfile ${colorfail}(sf) ${colorpkgcount}<file> ${colorgray}Search for package containing <file> (local)"
|
||||
t "xbps-query -v -o \"*/$1\""
|
||||
echo " ${colorok}whatprovides ${colorfail}(wp) ${colorpkgcount}<file> ${colorgray}Search for package containing <file>"
|
||||
t "xlocate ${colorpkgcount}<pkg>"
|
||||
echo " ${colorok}list ${colorfail}(ls) ${colorgray}List installed packages"
|
||||
t "xbps-query -v -l"
|
||||
echo " ${colorok}listw ${colorfail}(lw) ${colorgray}List installed packages without their version"
|
||||
t "xbps-query -l | awk '{ print $2 }' | xargs -n1 xbps-uhelper getpkgname"
|
||||
echo " ${colorok}listalternatives ${colorfail}(la) ${colorgray}List alternative candidates"
|
||||
t "xbps-alternatives -l"
|
||||
echo " ${colorok}listrepos ${colorfail}(lr) ${colorgray}List configured repositories"
|
||||
echo " ${colorok}repolist ${colorfail}(rl) ${colorgray}Alias for listrepos"
|
||||
t "xbps-query -v -L"
|
||||
echo " ${colorok}addrepo ${colorfail}(ad) ${colorpkgcount}<ARGS> ${colorgray}Add an additional repository"
|
||||
t "xbps-install ${colorpkgcount}<ARGS>"
|
||||
echo " ${colorok}devinstall ${colorfail}(di) ${colorpkgcount}<pkg(s)> ${colorgray}Install <package>${colorgray} and devel-<package(s)>"
|
||||
t "xbps-install <package> <package>${colorgray}-devel"
|
||||
echo " ${colorok}reconfigure ${colorfail}(rc) ${colorpkgcount}<pkg> ${colorgray}Re-configure installed <package>"
|
||||
t "xbps-reconfigure -v"
|
||||
echo " ${colorok}forceinstall ${colorfail}(fi) ${colorpkgcount}<pkg(s)> ${colorgray}Force installation of <package(s)>"
|
||||
t "xbps-install -f"
|
||||
echo " ${colorok}setalternative ${colorfail}(sa) ${colorpkgcount}<pkg(s)> ${colorgray}Set alternative for <package>"
|
||||
t "xbps-alternatives -s"
|
||||
echo " ${colorok}removerecursive ${colorfail}(rr) ${colorpkgcount}<pkg(s)> ${colorgray}Remove package(s) with dependencies"
|
||||
t "xbps-remove -v -R"
|
||||
echo " ${colorok}cleanup ${colorfail}(cl) ${colorgray}Remove obsolete packages in cachedir"
|
||||
t "xbps-remove -v -O"
|
||||
echo " ${colorok}autoremove ${colorfail}(ar) ${colorgray}Remove orphaned packages"
|
||||
t "xbps-remove -v -o"
|
||||
echo
|
||||
echo "${colorpkgcount}XBPS${colorheader} COMPATIBILITY COOLNESS:"
|
||||
echo -n "$colorgray"
|
||||
f=(/usr/sbin/xbps-*)
|
||||
echo "$colorpkgcount$progname$colorgray also understands all unknown ${colorpkgcount}XBPS${colorgray} sub-commands, too:"
|
||||
echo -n "Example: "
|
||||
selected=${f[$RANDOM % ${#f[@]}]}
|
||||
echo "$colorpkgcount$progname$colorok ${selected##*-}$colorreset ${colorpkgcount}<ARGS> $colorgray- see also: /usr/sbin/xbps-*"
|
||||
echo -n "$colorreset"
|
||||
}
|
||||
|
||||
usage_slim() {
|
||||
echo
|
||||
version
|
||||
echo
|
||||
echo "${colorheader}USAGE:
|
||||
${colorpkgcount}${progname} ${colortext}[OPTIONS] ${colorok}[SUBCOMM${colorfail}ANDS] ${colorpkgcount}[<ARGS>]
|
||||
|
||||
${colorheader}OPTIONS :
|
||||
${colortext}--color=<yes|no|auto>
|
||||
${colorgray}Enable/Disable colorized output (default: auto)
|
||||
${colortext}--help
|
||||
${colorgray}(same as: help) show usage
|
||||
${colortext}--slim
|
||||
${colorgray}(same as: slim) show usage for small screens
|
||||
${colortext}--help-pager
|
||||
${colorgray}(same as: helppager)
|
||||
${colortext}--show-translations
|
||||
${colorgray}Show ${colorpkgcount}XBPS${colorgray} command translations for $colorpkgcount$progname$colorgray sub-commands
|
||||
${colortext}--verbose
|
||||
${colorgray}Show ${colorpkgcount}XBPS${colorgray} command translations during execution
|
||||
|
||||
${colorheader} SUBCOMMANDS :
|
||||
${colorok}(long) ${colorfail}(short)${colorpkgcount} <ARGS>
|
||||
${colorok}about ${colorfail}(a) ${colorpkgcount}<pkg>
|
||||
${colorgray}Show information about <package>"
|
||||
t "xbps-query -v -R"
|
||||
echo "${colorok}filelist ${colorfail}(fl) ${colorpkgcount}<pkg>
|
||||
${colorgray}Show file-list of <package>"
|
||||
t "xbps-query -v -R -f"
|
||||
echo "${colorok}deps ${colorfail}(d) ${colorpkgcount}<pkg>
|
||||
${colorgray}Show dependencies for <package>"
|
||||
t "xbps-query -v -R -x"
|
||||
echo "${colorok}reverse ${colorfail}(rd) ${colorpkgcount}<pkg>
|
||||
${colorgray}Show reverse dependendies of <package>"
|
||||
t "xbps-query -v -R -X"
|
||||
echo "${colorok}search ${colorfail}(s) ${colorpkgcount}<pkg>
|
||||
${colorgray}Search for package"
|
||||
t "xbps-query -v -Rs"
|
||||
echo "${colorok}searchlib ${colorfail}(sl) ${colorpkgcount}<pkg>
|
||||
${colorgray}Search for package (64bit only)"
|
||||
t "xbps-query -v -Rs"
|
||||
echo "${colorok}searchfile ${colorfail}(sf) ${colorpkgcount}<file>
|
||||
${colorgray}Search for package containing <file> (local)"
|
||||
t "xbps-query -v -o \"*/$1\""
|
||||
echo "${colorok}whatprovides ${colorfail}(wp) ${colorpkgcount}<file>
|
||||
${colorgray}Search for package containing <file>"
|
||||
t "xlocate ${colorpkgcount}<pkg>"
|
||||
echo "${colorok}list ${colorfail}(ls)
|
||||
${colorgray}List installed packages"
|
||||
t "xbps-query -v -l"
|
||||
echo "${colorok}listw ${colorfail}(lw)
|
||||
${colorgray}List installed packages without version"
|
||||
t "xbps-query -l | awk '{ print $2 }' | xargs -n1 xbps-uhelper getpkgname"
|
||||
echo "${colorok}listalternatives ${colorfail}(la)
|
||||
${colorgray}List alternative candidates"
|
||||
t "xbps-alternatives -l"
|
||||
echo "${colorok}listrepos ${colorfail}(lr)
|
||||
${colorgray}List configured repositories"
|
||||
echo "${colorok}repolist ${colorfail}(rl)
|
||||
${colorgray}Alias for listrepos"
|
||||
t "xbps-query -v -L"
|
||||
echo "${colorok}sync ${colorfail}(S)
|
||||
${colorgray}Synchronize remote repository data"
|
||||
t "xbps-install -S"
|
||||
echo "${colorok}update ${colorfail}(u)
|
||||
${colorgray}Update the system"
|
||||
t "xbps-install -Suv"
|
||||
echo "${colorok}addrepo ${colorfail}(ad) ${colorpkgcount}<ARGS>
|
||||
${colorgray}Add an additional repository"
|
||||
t "xbps-install ${colorpkgcount}<ARGS>"
|
||||
echo "${colorok}install ${colorfail}(i) ${colorpkgcount}<pkg(s)>
|
||||
${colorgray}Install <package(s)>"
|
||||
t "xbps-install"
|
||||
echo "${colorok}devinstall ${colorfail}(di) ${colorpkgcount}<pkg(s)>
|
||||
${colorgray}Install <package> and devel-<package>(s)"
|
||||
t "xbps-install <package> <package>-devel"
|
||||
echo "${colorok}reconfigure ${colorfail}(rc) ${colorpkgcount}<pkg>
|
||||
${colorgray}Re-configure installed <package>"
|
||||
t "xbps-reconfigure -v"
|
||||
echo "${colorok}forceinstall ${colorfail}(fi) ${colorpkgcount}<pkg(s)>
|
||||
${colorgray}Force installation of <package(s)>"
|
||||
t "xbps-install -f"
|
||||
echo "${colorok}setalternative ${colorfail}(sa) ${colorpkgcount}<pkg(s)>
|
||||
${colorgray}Set alternative for <package>"
|
||||
t "xbps-alternatives -s"
|
||||
echo "${colorok}remove ${colorfail}(rm) ${colorpkgcount}<pkg(s)>
|
||||
${colorgray}Remove <package(s)>${colorgray} from the system"
|
||||
t "xbps-remove -v "
|
||||
echo "${colorok}removerecursive ${colorfail}(rr) ${colorpkgcount}<pkg(s)>
|
||||
${colorgray}Remove package(s) with dependencies"
|
||||
t "xbps-remove -v -R"
|
||||
echo "${colorok}cleanup ${colorfail}(cl)
|
||||
${colorgray}Remove obsolete packages in cachedir"
|
||||
t "xbps-remove -v -O"
|
||||
echo "${colorok}autoremove ${colorfail}(ar)
|
||||
${colorgray}Remove orphaned packages"
|
||||
t "xbps-remove -v -o"
|
||||
echo "$colorheader"
|
||||
echo "${colorpkgcount}XBPS${colorgray} COMPATIBILITY COOLNESS:"
|
||||
echo -n "$colorgray"
|
||||
f=(/usr/sbin/xbps-*)
|
||||
echo "$colorpkgcount$progname$colorgray understands ${colorpkgcount}XBPS${colorgray} sub-commands"
|
||||
echo -n "Example: "
|
||||
selected=${f[$RANDOM % ${#f[@]}]}
|
||||
echo "$colorpkgcount$progname$colorok ${selected##*-}$colorreset ${colorpkgcount}<ARGS> $colorgray
|
||||
see also: /usr/sbin/xbps-*$colorreset"
|
||||
}
|
||||
|
||||
setcolors auto
|
||||
case "$1" in
|
||||
--color=true|--color=yes|--color=on)
|
||||
setcolors on
|
||||
shift
|
||||
;;
|
||||
--color=auto)
|
||||
setcolors auto
|
||||
shift
|
||||
;;
|
||||
--color=false|--color=off|--color=no)
|
||||
setcolors off
|
||||
shift
|
||||
;;
|
||||
--verbose=true)
|
||||
shift
|
||||
verbose=true
|
||||
;;
|
||||
--show-translations)
|
||||
shift
|
||||
show_translations=1
|
||||
;;
|
||||
--help)
|
||||
shift
|
||||
usage
|
||||
exit 255
|
||||
;;
|
||||
--slim)
|
||||
shift
|
||||
usage_slim
|
||||
;;
|
||||
--help-pager)
|
||||
shift
|
||||
"$0" --color=off --help | less
|
||||
;;
|
||||
--*)
|
||||
msg "Unknown option: $1 (try: $progname --help)"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ -z $1 ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cmd=$1
|
||||
if [[ $arg =~ --.* ]]; then
|
||||
cmd=${arg:2}
|
||||
fi
|
||||
shift
|
||||
|
||||
case "$cmd" in
|
||||
|
||||
about|a)
|
||||
wrapcommand xbps-query -v -R "$@"
|
||||
;;
|
||||
|
||||
filelist|fl|listfiles)
|
||||
wrapcommand xbps-query -v -R -f "$@"
|
||||
;;
|
||||
|
||||
deps|dep|dependencies|d)
|
||||
wrapcommand xbps-query -v -R -x "$@"
|
||||
;;
|
||||
|
||||
reverse|rd)
|
||||
msg "Reverse dependencies for $* "
|
||||
wrapcommand xbps-query -v -R -X "$@"
|
||||
;;
|
||||
|
||||
searchfile|sf)
|
||||
msg 'searchfile '
|
||||
wrapcommand xbps-query -v -o "*/$1"
|
||||
;;
|
||||
|
||||
remotesearchfile|rsf)
|
||||
msg 'remotesearchfile '
|
||||
wrapcommand xbps-query -R -v -o "*/$1"
|
||||
;;
|
||||
|
||||
list|ls)
|
||||
msg 'Installed packages: '
|
||||
|
||||
count=0
|
||||
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)
|
||||
;;
|
||||
|
||||
listw|lw)
|
||||
xbps-query -l | awk '{ print $2 }' | xargs -n1 xbps-uhelper getpkgname
|
||||
;;
|
||||
|
||||
listalternative|listalternatives|la)
|
||||
wrapcommand xbps-alternatives -l "$@"
|
||||
;;
|
||||
|
||||
setalternative|setalternatives|sa)
|
||||
rootcheck
|
||||
wrapcommand xbps-alternatives -s "$@"
|
||||
echo
|
||||
;;
|
||||
|
||||
repolist|listrepos|rl|lr)
|
||||
code=0
|
||||
msg "Configured repositories (xbps-query -v -L): "
|
||||
|
||||
xbps-query -v -L
|
||||
ret=$?
|
||||
((ret == 0)) || code=1
|
||||
rmsg "$ret" "[xbps-query -v -L] return code: $ret"
|
||||
|
||||
echo
|
||||
|
||||
msg "Available sub-repositories (xbps-query -v -Rs void-repo): "
|
||||
xbps-query -v -Rs void-repo
|
||||
ret=$?
|
||||
((ret == 0)) || code=1
|
||||
rmsg "$ret" "[xbps-query -v -Rs void-repo] return code: $ret"
|
||||
|
||||
echo
|
||||
|
||||
msg "Use \"$progname addrepo <repository>\" to add a sub-repository."
|
||||
echo
|
||||
|
||||
exit "$code"
|
||||
;;
|
||||
|
||||
addrepo|ad)
|
||||
rootcheck
|
||||
echo
|
||||
if (($# < 1)); then
|
||||
rmsg 255 "ERROR: install: argument missing, try --help."
|
||||
exit 1
|
||||
fi
|
||||
code=0
|
||||
for repo in "$@"; do
|
||||
msg "Adding repository: $repo"
|
||||
$SUDO xbps-install "$repo"
|
||||
ret=$?
|
||||
((ret == 0)) || code=1
|
||||
rmsg "$ret" "[xbps-install $arg] return code: $ret"
|
||||
|
||||
msg "Synchronizing remote repository data (xbps-install -S): "
|
||||
$SUDO xbps-install -S
|
||||
ret=$?
|
||||
((ret == 0)) || code=1
|
||||
rmsg "$ret" "[xbps-install -S] return code: $ret"
|
||||
done
|
||||
|
||||
exit "$code"
|
||||
;;
|
||||
|
||||
sync|S)
|
||||
rootcheck
|
||||
msg 'Synchronizing remote repository data '
|
||||
echo
|
||||
wrapcommand "$SUDO" xbps-install -S "$@"
|
||||
;;
|
||||
|
||||
install|i)
|
||||
rootcheck
|
||||
if (($# < 1)); then
|
||||
rmsg 255 "ERROR: install: argument missing, try --help."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
msg "Installing packages: $* "
|
||||
echo
|
||||
wrapcommand "$SUDO" xbps-install "$@"
|
||||
;;
|
||||
|
||||
yesinstall)
|
||||
rootcheck
|
||||
if (($# < 1)); then
|
||||
rmsg 255 "ERROR: install: argument missing, try --help."
|
||||
exit 1
|
||||
fi
|
||||
msg "Installing packages (assumed yes): $* "
|
||||
echo
|
||||
wrapcommand "$SUDO" xbps-install -y "$@"
|
||||
;;
|
||||
|
||||
devinstall)
|
||||
rootcheck
|
||||
if (($# < 1)); then
|
||||
rmsg 255 "ERROR: devinstall: argument missing, try --help."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
args=("$@")
|
||||
code=0
|
||||
|
||||
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
|
||||
msg "Installing package: $arg (xbps-install $arg) ..."
|
||||
$SUDO xbps-install "$arg"
|
||||
ret=$?
|
||||
((ret == 0)) || code=1
|
||||
rmsg "$ret" "[xbps-install $arg] return code: $ret"
|
||||
|
||||
msg "installing devel package (${arg}-devel):"
|
||||
$SUDO xbps-install "${arg}-devel"
|
||||
ret=$?
|
||||
((ret == 0)) || code=1
|
||||
rmsg "$ret" "[xbps-install ${arg}-devel] return code: $ret"
|
||||
done
|
||||
|
||||
exit "$code"
|
||||
;;
|
||||
|
||||
forceinstall|fi)
|
||||
rootcheck
|
||||
msg "Force-Installing Package(s): $* "
|
||||
echo
|
||||
wrapcommand "$SUDO" xbps-install -f "$@"
|
||||
;;
|
||||
|
||||
remove|rm)
|
||||
rootcheck
|
||||
msg "Removing package(s): $* "
|
||||
echo
|
||||
wrapcommand "$SUDO" xbps-remove -v "$@"
|
||||
;;
|
||||
|
||||
removerecursive|rr)
|
||||
rootcheck
|
||||
msg "Removing package(s) recursively: $* "
|
||||
echo
|
||||
wrapcommand "$SUDO" xbps-remove -v -R "$@"
|
||||
;;
|
||||
|
||||
reconfigure|rc)
|
||||
rootcheck
|
||||
msg 'reconfigure: Re-configuring package(s) '
|
||||
echo
|
||||
wrapcommand "$SUDO" xbps-reconfigure -v "$@"
|
||||
;;
|
||||
|
||||
autoremove|ar)
|
||||
rootcheck
|
||||
msg 'autoremove: Removing orphaned packages '
|
||||
echo
|
||||
wrapcommand "$SUDO" xbps-remove -v -o
|
||||
;;
|
||||
|
||||
update|upgrade|up|u)
|
||||
rootcheck
|
||||
msg 'Running system update '
|
||||
echo
|
||||
$SUDO xbps-install -Suv
|
||||
if [[ $? == 16 ]]; then
|
||||
msg "$(tput setaf 1)Updating xbps $(tput sgr 0)"
|
||||
$SUDO xbps-install -u xbps
|
||||
wrapcommand "$SUDO" xbps-install -Suv
|
||||
else
|
||||
if [[ $? == 1 ]]; then
|
||||
msg 'Your system is up to date.'
|
||||
else
|
||||
msg $? 'Something goes wrong!'
|
||||
fi
|
||||
fi
|
||||
msg 'Checking if something need restart...'
|
||||
echo
|
||||
xcheckrestart
|
||||
;;
|
||||
|
||||
syncsearch|Ss)
|
||||
msg "Syncing and searching for: $* "
|
||||
wrapcommand xbps-query -v -MRs "$*"
|
||||
;;
|
||||
|
||||
search|s)
|
||||
msg "Searching for: $* "
|
||||
wrapcommand xbps-query -v -Rs "$*"
|
||||
;;
|
||||
|
||||
# TODO: instead of grep use proper command
|
||||
searchlib|sl)
|
||||
msg "Searching for: $* "
|
||||
wrapcommand xbps-query -v -Rs "$*" | grep -v 32bit
|
||||
;;
|
||||
|
||||
cleanup|clean|cl)
|
||||
msg 'Remove obsolete packages in cachedir '
|
||||
rootcheck
|
||||
echo
|
||||
wrapcommand "$SUDO" xbps-remove -v -O "$@"
|
||||
;;
|
||||
|
||||
h|help|-h|--help)
|
||||
usage
|
||||
;;
|
||||
|
||||
slim|--slim)
|
||||
usage_slim
|
||||
;;
|
||||
|
||||
helppager|help-pager|hp)
|
||||
pager=$PAGER
|
||||
if [[ -z $pager ]]; then
|
||||
if command -v less &>/dev/null; then
|
||||
pager=less
|
||||
else
|
||||
pager=more
|
||||
fi
|
||||
fi
|
||||
|
||||
"$0" --color=off help | $pager
|
||||
exit 0
|
||||
;;
|
||||
|
||||
version|v)
|
||||
version
|
||||
exit 0
|
||||
;;
|
||||
|
||||
whatprovides|wp)
|
||||
if ! command -v xlocate &>/dev/null; then
|
||||
rmsg 255 "xlocate not found. Try installing the xtools package."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
msg "relaying to xlocate - use xlocate -S to (re-)build cached DB. "
|
||||
wrapcommand xlocate "$@"
|
||||
;;
|
||||
|
||||
''|*)
|
||||
xbpscmd="xbps-$cmd"
|
||||
if ! command -v "$xbpscmd" &>/dev/null; then
|
||||
rmsg 255 "Unrecognized $progname subcommand: $cmd (and $xbpscmd does not exist) - Try: $progname help"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# xbps-<subcommand> found
|
||||
msg "relaying to ${colorpkgcount}XBPS${colorgray}: "
|
||||
wrapcommand "$xbpscmd" "$@"
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
# enjoy and make better if you can...
|
600
vpm
600
vpm
|
@ -1,600 +0,0 @@
|
|||
#!/bin/bash
|
||||
# vim: ft=sh ts=2 sw=2 sts=2 et
|
||||
|
||||
# vpm - void package management utility for
|
||||
# XBPS, the X Binary Package System
|
||||
# Copyright (c) 2016 Armin Jenewein <a@m2m.pm>, GitHub: @netzverweigerer
|
||||
# For more information about XBPS, see:
|
||||
# https://github.com/voidlinux/xbps
|
||||
|
||||
# Released under the terms of the GNU general public license, version 3+
|
||||
# see LICENSE file for license information.
|
||||
|
||||
# set version number
|
||||
version="1.3"
|
||||
|
||||
# disable verbosity, by default
|
||||
verbose=false
|
||||
|
||||
# VPM color definitions
|
||||
numcolorok=2
|
||||
numcolorfail=1
|
||||
numcolorlogo=5
|
||||
numcolorheader=3
|
||||
numcolortext=4
|
||||
numcolorgray=2
|
||||
numcolorpkgcount=8
|
||||
numcolordarkgray=11
|
||||
numcolorbrackets=6
|
||||
|
||||
progname=${0##*/}
|
||||
|
||||
# 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)
|
||||
;;
|
||||
off)
|
||||
colorbrackets=
|
||||
colordarkgray=
|
||||
colorfail=
|
||||
colorgray=
|
||||
colorheader=
|
||||
colorlogo=
|
||||
colorok=
|
||||
colorpkgcount=
|
||||
colortext=
|
||||
colorreset=
|
||||
unset COLORS
|
||||
declare -A COLORS
|
||||
;;
|
||||
*)
|
||||
rmsg 255 "unknown color option: '$opt'"
|
||||
exit 255
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# print the logo with brackets colorized
|
||||
getlogo () {
|
||||
printf '%s[%s%s%s]%s' \
|
||||
"$colorbrackets" \
|
||||
"$colorlogo" "$progname" \
|
||||
"$colorbrackets" \
|
||||
"$colorreset"
|
||||
}
|
||||
|
||||
# prints a message (with vpm-prefix)
|
||||
msg () {
|
||||
local logo=$(getlogo)
|
||||
|
||||
echo "$logo" "$colortext" "$@" "$colorreset"
|
||||
}
|
||||
|
||||
# rmsg - same (but colorized based on return status passed via $1)
|
||||
rmsg () {
|
||||
local code=$1
|
||||
shift
|
||||
|
||||
local logo=$(getlogo)
|
||||
local statuscolor
|
||||
|
||||
if ((code == 0)); then
|
||||
statuscolor=$colorok
|
||||
else
|
||||
statuscolor=$colorfail
|
||||
fi
|
||||
|
||||
echo "$logo" "$statuscolor" "$@" "$colorreset"
|
||||
}
|
||||
|
||||
banner () {
|
||||
echo -n "$colorlogo"
|
||||
echo ' __ ___ __ _ __ '
|
||||
|
||||
printf " \\ V / '_ \\ ' \ "
|
||||
echo -n "$colorgray"
|
||||
echo " $progname - void package management utility for XBPS"
|
||||
echo -n "$colorlogo"
|
||||
echo -n ' \_/| .__/_|_|_|'
|
||||
echo -n "$colorgray"
|
||||
echo ' GitHub: https://github.com/netzverweigerer/vpm'
|
||||
echo -n "$colorlogo"
|
||||
echo ' |/ '
|
||||
echo ' ´ '
|
||||
echo -n "$colorreset"
|
||||
}
|
||||
|
||||
version () {
|
||||
banner
|
||||
msg "$progname - Version: $version"
|
||||
msg "Copyright (c) 2016 Armin Jenewein <a@m2m.pm> (GPLv3+)"
|
||||
msg "XBPS version: $(xbps-query -v --version | sed 's/GIT: UNSET//')"
|
||||
}
|
||||
|
||||
# check if we have UID 0, exit otherwise
|
||||
rootcheck () {
|
||||
if [[ $EUID -gt 0 ]]; then
|
||||
msg "$progname: This operation needs super-user privileges."
|
||||
SUDO=sudo
|
||||
else
|
||||
SUDO=''
|
||||
fi
|
||||
}
|
||||
|
||||
t () {
|
||||
if [[ -n $show_translations ]]; then
|
||||
tput setaf 242
|
||||
echo ' ' "$@"
|
||||
echo
|
||||
tput setaf 109
|
||||
fi
|
||||
}
|
||||
|
||||
usage () {
|
||||
echo
|
||||
version
|
||||
echo
|
||||
echo -n "$colorheader"
|
||||
echo "USAGE: "
|
||||
echo -n "$colorgray"
|
||||
echo "$progname [OPTIONS] [SUBCOMMANDS] [<ARGS>]"
|
||||
echo
|
||||
echo -n "$colorheader"
|
||||
echo "OPTIONS: "
|
||||
echo -n "$colorgray"
|
||||
echo "--color=<yes|no|auto> - Enable/Disable colorized output (default: auto)"
|
||||
echo "--help - (same as: help)"
|
||||
echo "--help-pager - (same as: helppager)"
|
||||
echo "--show-translations - Show XBPS command translations for $progname sub-commands"
|
||||
echo "--verbose - Verbose mode (shows XBPS command translations during execution)"
|
||||
echo
|
||||
echo -n "$colorheader"
|
||||
echo "SUBCOMMANDS: "
|
||||
echo -n "$colorgray"
|
||||
echo "sync (sy) - Synchronize remote repository data"
|
||||
t "xbps-install -S"
|
||||
echo "update (up) - Update the system"
|
||||
t "xbps-install -Sduv"
|
||||
echo "listrepos (lr) - List configured repositories"
|
||||
echo "repolist (rl) - Alias for listrepos"
|
||||
t "xbps-query -v -L"
|
||||
echo "addrepo (ar) <ARGS> - Add an additional repository"
|
||||
t "xbps-install <ARGS>"
|
||||
echo "info (in) <pkg> - Show information about <package>"
|
||||
t "xbps-query-v -R"
|
||||
echo "filelist (fl) <pkg> - Show file-list of <package>"
|
||||
t "xbps-query -v -R -f"
|
||||
echo "deps <pkg> - Show dependencies for <package>"
|
||||
t "xbps-query -v -R -x"
|
||||
echo "reverse (rv) <pkg> - Show reverse dependendies of <package> (see man xbps-query)"
|
||||
t "xbps-query -v -R -X"
|
||||
echo "search (s) <name> - Search for package by <name>"
|
||||
t "xbps-query -v -Rs"
|
||||
echo "searchfile (sf) <file> - Search for package containing <file> (local)"
|
||||
t "xbps-query -v -o \"*/$1\""
|
||||
echo "list (ls) - List installed packages"
|
||||
t "xbps-query -v -l"
|
||||
echo "install (i) <pkg(s)> - Install <package(s)>"
|
||||
t "xbps-install -S"
|
||||
echo "devinstall (di) <pkg(s)> - Install <package> (and corresponding <package>-devel package(s))"
|
||||
t "xbps-install -S <package> <package>-devel"
|
||||
echo "listalternatives (la) - List alternative candidates"
|
||||
t "xbps-alternatives -l"
|
||||
echo "setalternative (sa) <pkg(s) - Set alternative for <package>"
|
||||
t "xbps-alternatives -s"
|
||||
echo "reconfigure (rc) <pkg> - Re-configure installed <package>"
|
||||
t "xbps-reconfigure -v"
|
||||
echo "forceinstall (fi) <pkg(s)> - Force installation of <package(s)>"
|
||||
t "xbps-install -f"
|
||||
echo "remove (rm) <package(s)) - Remove <package(s)> from the system"
|
||||
t "xbps-remove -v "
|
||||
echo "removerecursive (rr) <pkg(s)> - Recursively remove package(s) (and its dependencies)"
|
||||
t "xbps-remove -v -R"
|
||||
echo "cleanup (cl) - Clean up cache directory"
|
||||
t "xbps-remove -v -O"
|
||||
echo "autoremove (ar) - Remove orphaned packages"
|
||||
t "xbps-remove -v -O"
|
||||
echo "whatprovides (wp) <file> - Search for package containing <file>"
|
||||
t "xlocate <pkg>"
|
||||
echo "help - Show usage information"
|
||||
echo "helppager (hp) - Show usage information (will pipe output to less/more)"
|
||||
echo
|
||||
echo -n "$colorheader"
|
||||
echo "XBPS COMPATIBILITY COOLNESS:"
|
||||
echo -n "$colorgray"
|
||||
f=(/usr/sbin/xbps-*)
|
||||
echo "$progname also understands all unknown XBPS sub-commands, too:"
|
||||
echo -n "Example: "
|
||||
selected=${f[$RANDOM % ${#f[@]}]}
|
||||
echo "$progname ${selected##*-} <ARGS> - see also: /usr/sbin/xbps-*"
|
||||
echo
|
||||
echo -n "$colorreset"
|
||||
}
|
||||
|
||||
setcolors auto
|
||||
case "$1" in
|
||||
--color=true|--color=yes|--color=on)
|
||||
setcolors on
|
||||
shift
|
||||
;;
|
||||
--color=auto)
|
||||
setcolors auto
|
||||
shift
|
||||
;;
|
||||
--color=false|--color=off|--color=no)
|
||||
setcolors off
|
||||
shift
|
||||
;;
|
||||
--verbose=true)
|
||||
shift
|
||||
verbose=true
|
||||
;;
|
||||
--show-translations)
|
||||
shift
|
||||
show_translations=1
|
||||
;;
|
||||
--help)
|
||||
shift
|
||||
usage
|
||||
exit 255
|
||||
;;
|
||||
--help-pager)
|
||||
shift
|
||||
"$0" --color=off --help | less
|
||||
;;
|
||||
--*)
|
||||
msg "Unknown option: $1 (try: $progname --help)"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "$1" == "" ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
arg=$1
|
||||
|
||||
if [[ "$arg" =~ --.* ]]; then
|
||||
b=${arg:2}
|
||||
arg=$b
|
||||
fi
|
||||
|
||||
case "$arg" in
|
||||
info|in)
|
||||
shift
|
||||
msg "(xbps-query -v -R $@):"
|
||||
xbps-query -v -R "$@"
|
||||
ret=$?
|
||||
rmsg "$ret" "Execution finished (xbps-query -v -R $@), return code was: $ret"
|
||||
exit "$ret"
|
||||
;;
|
||||
|
||||
filelist|fl|listfiles)
|
||||
shift
|
||||
xbps-query -v -R -f "$@"
|
||||
ret=$?;
|
||||
if [[ $verbose == "true" ]]; then
|
||||
rmsg "$ret" "Execution finished (xbps-query -v -R -f \"*/$1\"), return code was: $ret"
|
||||
fi
|
||||
exit "$ret"
|
||||
;;
|
||||
|
||||
deps|dep|dependencies)
|
||||
shift
|
||||
xbps-query -v -R -x "$@"
|
||||
ret=$?
|
||||
rmsg "$ret" "Execution finished (xbps-query -v -R -x \"*/$1\"), return code was: $ret"
|
||||
exit "$ret"
|
||||
;;
|
||||
|
||||
reverse|rv)
|
||||
shift
|
||||
msg "Reverse dependencies for $@ (xbps-query -v -R $@):"
|
||||
xbps-query -v -R -X "$@"
|
||||
ret=$?
|
||||
msg "$ret" "Execution finished (xbps-query -v -R $@), return code was: $ret"
|
||||
exit "$ret"
|
||||
;;
|
||||
|
||||
searchfile|sf)
|
||||
shift
|
||||
msg "searchfile (xbps-query -v -o \"*/$1\"):"
|
||||
xbps-query -v -o "*/$1"
|
||||
ret=$?
|
||||
msg "$ret" "Execution finished (xbps-query -v -o \"*/$1\"), return code was: $ret"
|
||||
exit $ret
|
||||
;;
|
||||
|
||||
remotesearchfile|rsf)
|
||||
shift
|
||||
msg "remotesearchfile (xbps-query -R -v -o \"*/$1\"):"
|
||||
xbps-query -R -v -o "*/$1"
|
||||
ret=$?
|
||||
msg "$ret" "Execution finished (xbps-query -R -v -o \"*/$1\"), return code was: $ret"
|
||||
exit "$ret"
|
||||
;;
|
||||
|
||||
list|ls)
|
||||
shift
|
||||
msg "Installed packages: "
|
||||
|
||||
count=0
|
||||
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)
|
||||
;;
|
||||
|
||||
listalternative|listalternatives|la)
|
||||
xbps-alternatives -l "$@"
|
||||
ret=$?
|
||||
rmsg "$ret" "xbps-alternatives return code: $ret (xbps-alternatives -l $@)"
|
||||
;;
|
||||
|
||||
setalternative|setalternatives|sa)
|
||||
shift
|
||||
rootcheck
|
||||
$SUDO xbps-alternatives -s "$@"
|
||||
ret=$?
|
||||
rmsg "$ret" "xbps-alternatives return code: $ret (xbps-alternatives -s $@)"
|
||||
;;
|
||||
|
||||
repolist|listrepos|rl|lr)
|
||||
msg "Configured repositories (xbps-query -v -L): "
|
||||
xbps-query -v -L
|
||||
ret=$?
|
||||
rmsg "$ret" "[xbps-query -v -L] return code: $ret"
|
||||
shift
|
||||
echo
|
||||
msg "Available sub-repositories (xbps-query -v -Rs void-repo): "
|
||||
xbps-query -v -Rs void-repo
|
||||
ret=$?
|
||||
rmsg "$ret" "[xbps-query -v -Rs void-repo] return code: $ret"
|
||||
shift
|
||||
echo
|
||||
msg "Use \"$progname addrepo <repository>\" to add a sub-repository."
|
||||
echo
|
||||
;;
|
||||
|
||||
addrepo|ar)
|
||||
shift
|
||||
rootcheck
|
||||
for repo in "$@"; do
|
||||
msg "Adding repository: $repo"
|
||||
$SUDO xbps-install "$1"
|
||||
ret=$?
|
||||
rmsg "$ret" "[xbps-install $arg] return code: $ret"
|
||||
msg "Synchronizing remote repository data (xbps-install -S): "
|
||||
$SUDO xbps-install -S
|
||||
ret=$?
|
||||
rmsg "$ret" "[xbps-install -S] return code: $ret"
|
||||
shift
|
||||
done
|
||||
;;
|
||||
|
||||
sync|sy)
|
||||
shift
|
||||
rootcheck
|
||||
msg "Synchronizing remote repository data: (xbps-install -S):"
|
||||
$SUDO xbps-install -S
|
||||
ret=$?
|
||||
rmsg "$ret" "[xbps-install -S] return code: $ret"
|
||||
;;
|
||||
|
||||
install|i)
|
||||
shift
|
||||
rootcheck
|
||||
if [[ "$#" -lt 1 ]]; then
|
||||
msg "ERROR: install: argument missing, try --help."
|
||||
exit 1
|
||||
fi
|
||||
msg "Installing packages: $@ (xbps-install -S $@) ..."
|
||||
$SUDO xbps-install -S "$@"
|
||||
ret=$?
|
||||
rmsg "$ret" "[xbps-install -S $@] return code: $ret"
|
||||
;;
|
||||
|
||||
yesinstall)
|
||||
shift
|
||||
rootcheck
|
||||
if [[ "$#" -lt 1 ]]; then
|
||||
msg "ERROR: install: argument missing, try --help."
|
||||
exit 1
|
||||
fi
|
||||
msg "Installing packages: $@ (xbps-install -S $@) ..."
|
||||
$SUDO xbps-install -y -S "$@"
|
||||
ret=$?
|
||||
rmsg "$ret" "[xbps-install -S $@] return code: $ret"
|
||||
;;
|
||||
|
||||
devinstall)
|
||||
shift
|
||||
rootcheck
|
||||
if [[ "$#" -lt 1 ]]; then
|
||||
msg "ERROR: devinstall: argument missing, try --help."
|
||||
exit 1
|
||||
fi
|
||||
args=("$@")
|
||||
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) ..."
|
||||
$SUDO xbps-install -S "$arg"
|
||||
ret=$?
|
||||
rmsg "$ret" "[xbps-install -S $arg] return code: $ret"
|
||||
msg "installing devel package (${arg}-devel):"
|
||||
$SUDO xbps-install -S "${arg}-devel"
|
||||
ret=$?
|
||||
rmsg "$ret" "[xbps-install -S ${arg}-devel] return code: $ret"
|
||||
done
|
||||
;;
|
||||
|
||||
forceinstall|fi)
|
||||
shift
|
||||
rootcheck
|
||||
msg "Force-Installing Package(s): $@ (xbps-install -Sf $@)"
|
||||
$SUDO xbps-install -Sf "$@"
|
||||
ret=$?
|
||||
rmsg "$ret" "[xbps-install -Sf ${@}] return code: $ret"
|
||||
;;
|
||||
|
||||
remove|rm)
|
||||
shift
|
||||
rootcheck
|
||||
msg "Removing package(s): $@ (xbps-remove -v $@)"
|
||||
$SUDO xbps-remove -v "$@"
|
||||
ret=$?
|
||||
rmsg "$ret" "[xbps-remove -v ${@}] return code: $ret"
|
||||
;;
|
||||
|
||||
removerecursive|rr)
|
||||
shift
|
||||
rootcheck
|
||||
msg "Removing package(s) recursively: $@ (xbps-remove -v -R $@)"
|
||||
$SUDO xbps-remove -v -R "$@"
|
||||
ret=$?
|
||||
rmsg "$ret" "[xbps-remove -v -R ${@}] return code: $ret"
|
||||
;;
|
||||
|
||||
reconfigure|rc)
|
||||
shift
|
||||
rootcheck
|
||||
msg "reconfigure: Re-configuring package(s) (xbps-reconfigure -v $@):"
|
||||
$SUDO xbps-reconfigure -v "$@"
|
||||
ret=$?
|
||||
rmsg "$ret" "[xbps-reconfigure -v ${@}] return code: $ret"
|
||||
;;
|
||||
|
||||
autoremove|ar)
|
||||
shift
|
||||
rootcheck
|
||||
msg "autoremove: Removing orphaned packages (xbps-remove -v -o)"
|
||||
$SUDO xbps-remove -v -o
|
||||
ret=$?
|
||||
rmsg "$ret" "[xbps-remove -v -o] return code: $ret"
|
||||
;;
|
||||
|
||||
update|upgrade|up)
|
||||
shift
|
||||
rootcheck
|
||||
msg "Running system update (xbps-install -Suv)"
|
||||
$SUDO 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
|
||||
rmsg "$ret" "[xbps-install -Suv] return code: $ret"
|
||||
;;
|
||||
|
||||
search|s)
|
||||
shift
|
||||
msg "Searching for: $@ (xbps-query -v -Rs $@)"
|
||||
xbps-query -v -Rs "$@"
|
||||
ret=$?
|
||||
rmsg "$ret" "[xbps-query -v -Rs $@] return code: $ret"
|
||||
;;
|
||||
|
||||
cleanup|clean|cl)
|
||||
msg "Cleaning up packages (will remove orphaned packages) (xbps-remove -v -O $@)"
|
||||
shift
|
||||
rootcheck
|
||||
$SUDO xbps-remove -v -O "$@"
|
||||
ret=$?
|
||||
rmsg "$ret" "[xbps-remove -v -O $@] return code: $ret"
|
||||
;;
|
||||
|
||||
h|help|-h|--help)
|
||||
usage
|
||||
;;
|
||||
|
||||
helppager|help-pager|hp)
|
||||
if hash less >/dev/null 2>&1; then
|
||||
"$0" --color=off help | less
|
||||
else
|
||||
"$0" --color=off help | more
|
||||
fi
|
||||
;;
|
||||
|
||||
whatprovides|wp)
|
||||
shift
|
||||
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 "$@"
|
||||
else
|
||||
rmsg 255 "xlocate not found. Try installing the xtools package."
|
||||
fi
|
||||
;;
|
||||
|
||||
''|*)
|
||||
a="$1"
|
||||
if hash "xbps-${a}" >/dev/null 2>&1; then
|
||||
shift
|
||||
# xbps-<subcommand> found
|
||||
msg "relaying to XBPS: xbps-$a $@"
|
||||
"xbps-$a" "$@"
|
||||
ret=$?
|
||||
rmsg "$ret" "xbps-$a $@ return code: $ret"
|
||||
else
|
||||
rmsg 255 "Unrecognized $progname subcommand: $1 (and xbps-$1 does not exist) - Try: $progname help"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
exit 0
|
Loading…
Reference in New Issue