-
Notifications
You must be signed in to change notification settings - Fork 0
/
xinst_parse_xbps
executable file
·28 lines (23 loc) · 1.05 KB
/
xinst_parse_xbps
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
#!/bin/sh
input=$(cat; echo E)
input=${input%E}
field() {
echo "$input" | grep "^$*:"
}
value() {
cat | cut -d ':' -f 2 | sed 's/^\s//g'
}
arch=$(field 'architecture' | value)
installed_size=$(field 'installed_size' | value)
license=$(field 'license' | value)
name=$(field 'pkgname' | value)
desc=$(field 'short_desc' | value)
version=$(field 'pkgver' | value)
# escape : character that's also used as delimiter
homepage=$(field 'homepage' | sed -E 's/(https?):/\1<colon>/' | value | sed -E 's/(https?)<colon>/\1:/')
# from to remove last remove first
run_depends=$(echo "$input" | awk '/run_depends/,/shlib-requires|short_desc/' | head --lines=-1 | tail --lines=+2 | sed '1 s/\s//')
shlib_requires=$(echo "$input" | awk '/shlib-requires/,/short_desc/' | head --lines=-1)
depends=$(printf "%s\n%s" "$run_depends" "$shlib_requires" | sed 's/\s/ /g' | sed 's/shlib-requires:/Required libraries:/')
export arch installed_size license name desc version homepage depends
xinst_display