summary refs log tree commit diff
path: root/xpkg
blob: 13f34df32ceb1f307d99a329aa8f39650b9ca85c (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
#!/bin/bash
# xpkg [-RamOHDLvV] - convenient package lister

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

while getopts 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 -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"