Naposledy aktivní 1701126077

a tiny wrapper for xbps utils

Revize 343977097a223bb06c8d3321e555c458364629e6

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