about summary refs log tree commit diff
path: root/xpkg
blob: 08002f7ac8090093396df6945cea90bc42bf4862 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
# xpkg [-RamOHDLvV] - convenient package lister

flags=
filter0='/^.[^i*].\? /d'
filter1='s/^...\? //'
filter2='s/-[^- ]* .*//'
mode="--search="

while getopts R:r:vVmOHDLa flag; do
	case "$flag" in
		D) exec comm -23 <(xpkg | sort) <(xpkg -a | sort);;
		L) mode="--regex -p repository -s /"; filter0='/:\/\//d';;
		r) flags="$flags -r $OPTARG";;
		R) flags="$flags -i --repository=$OPTARG";;
		m|O|H) mode="-$flag"; filter0=; filter1=; filter2='s/-[^-]*$//';;
		a) flags="$flags -R"; filter0=;;
		v) filter2='s/:\? .*//';;
		V) filter2=;;
		?) printf "Usage: %s [-RamOHvV]
  -R REPO  consider only packages from REPO
  -a       list all packages (default: only installed)
  -m	   list manual packages
  -O       list orphaned packages
  -H       list packages on hold
  -D       list installed packages not in repo
  -L       list installed packages not from remote repos
  -v       show version numbers
  -V       show version numbers and description
" $0 1>&2
		exit 1;;
	esac
done

xbps-query $flags $mode | sed "$filter0;$filter1;$filter2"