xb.sh
· 1.4 KiB · Bash
Bruto
#!/bin/sh
# very simple xbps wrapper
# don't doas or sudo unless it exists
if [ ! -z "$(type doas)" ]; then
ROOT_DOER="$(command -v doas)"
elif [ ! -z "$(type sudo)" ]; then
ROOT_DOER="$(command -v sudo)"
fi
# don't elevate as root
if [ $(id -u) -eq 0 ]; then
ROOT_DOER=""
fi
args=$(echo $@ | cut -d' ' -f2-)
case $1 in
# built-in user commands
alternatives | alt)
xbps-alternatives $args
;;
checkvers | cv)
xbps-checkvers $args
;;
create | c)
xbps-create $args
;;
dgraph | dg)
xbps-dgraph $args
;;
digest | d)
xbps-digest $args
;;
fbulk | fb)
xbps-fbulk $args
;;
fetch | f)
xbps-fetch $args
;;
pkgdb | p | pkg | db)
xbps-pkgdb $args
;;
query | q)
xbps-query $args
;;
rindex | ri)
xbps-rindex $args
;;
uchroot | uc)
xbps-uchroot $args
;;
uhelper | uh)
xbps-uhelper $args
;;
uunshare | uu)
xbps-uunshare $args
;;
# built-in root commands
install | i)
$ROOT_DOER xbps-install $args
;;
reconfigure | rc | recon)
$ROOT_DOER xbps-reconfigure $args
;;
remove | rm | r)
$ROOT_DOER xbps-remove $args
;;
# alias commands
update | upgrade | up)
$ROOT_DOER xbps-install -Su
;;
search | s)
xbps-query -Rs "$args"
;;
show | sh)
xbps-query -RS $args
;;
# external but relevant
whatprovides | wp | locate)
xlocate $args
;;
# help and such
-h)
# TODO: proper this
echo "Try one of these:"
find /usr/bin -iname "xbps-*" | cut -d'-' -f2-
;;
*)
echo "I dunno about xbps-$1, try again."
;;
esac
1 | #!/bin/sh |
2 | # very simple xbps wrapper |
3 | |
4 | # don't doas or sudo unless it exists |
5 | if [ ! -z "$(type doas)" ]; then |
6 | ROOT_DOER="$(command -v doas)" |
7 | elif [ ! -z "$(type sudo)" ]; then |
8 | ROOT_DOER="$(command -v sudo)" |
9 | fi |
10 | |
11 | # don't elevate as root |
12 | if [ $(id -u) -eq 0 ]; then |
13 | ROOT_DOER="" |
14 | fi |
15 | |
16 | args=$(echo $@ | cut -d' ' -f2-) |
17 | case $1 in |
18 | # built-in user commands |
19 | alternatives | alt) |
20 | xbps-alternatives $args |
21 | ;; |
22 | checkvers | cv) |
23 | xbps-checkvers $args |
24 | ;; |
25 | create | c) |
26 | xbps-create $args |
27 | ;; |
28 | dgraph | dg) |
29 | xbps-dgraph $args |
30 | ;; |
31 | digest | d) |
32 | xbps-digest $args |
33 | ;; |
34 | fbulk | fb) |
35 | xbps-fbulk $args |
36 | ;; |
37 | fetch | f) |
38 | xbps-fetch $args |
39 | ;; |
40 | pkgdb | p | pkg | db) |
41 | xbps-pkgdb $args |
42 | ;; |
43 | query | q) |
44 | xbps-query $args |
45 | ;; |
46 | rindex | ri) |
47 | xbps-rindex $args |
48 | ;; |
49 | uchroot | uc) |
50 | xbps-uchroot $args |
51 | ;; |
52 | uhelper | uh) |
53 | xbps-uhelper $args |
54 | ;; |
55 | uunshare | uu) |
56 | xbps-uunshare $args |
57 | ;; |
58 | # built-in root commands |
59 | install | i) |
60 | $ROOT_DOER xbps-install $args |
61 | ;; |
62 | reconfigure | rc | recon) |
63 | $ROOT_DOER xbps-reconfigure $args |
64 | ;; |
65 | remove | rm | r) |
66 | $ROOT_DOER xbps-remove $args |
67 | ;; |
68 | # alias commands |
69 | update | upgrade | up) |
70 | $ROOT_DOER xbps-install -Su |
71 | ;; |
72 | search | s) |
73 | xbps-query -Rs "$args" |
74 | ;; |
75 | show | sh) |
76 | xbps-query -RS $args |
77 | ;; |
78 | # external but relevant |
79 | whatprovides | wp | locate) |
80 | xlocate $args |
81 | ;; |
82 | # help and such |
83 | -h) |
84 | # TODO: proper this |
85 | echo "Try one of these:" |
86 | find /usr/bin -iname "xbps-*" | cut -d'-' -f2- |
87 | ;; |
88 | *) |
89 | echo "I dunno about xbps-$1, try again." |
90 | ;; |
91 | esac |
92 |