blob: dd58995da9b82df4d514939bcb152a5b43ac1260 (
plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/bin/sh
colorize_ver() {
color="${1:-3}"
perl -pe 's,(\d[\d.]+),\x1b[1;3'$color'm$1\x1b[0m,x'
}
sort_color() {
sort -V | colorize_ver
}
last_gh_commit() {
# only show latest commit
head -1 | sed 's,.*::Commit/\([^<]*\)</id>,\1,'
}
last_gh_tag() {
# only show latest commit
head -1 | sed 's,.*/v*\([^/]*\)</id.*,\1,'
}
format_repology() {
# the whole json file is on one line...
head -1 | jq -C |grep '"version"'|cut -d'"' -f4 |sort -uV
}
DIR=~/.ck4up
build="$( basename $( pwd ) )"
conf="$( grep -l "^$build " $DIR/*.conf )"
case "$conf" in
"") echo "can't find $build in $DIR/*.conf" 2>&1 ; exit 0 ;;
*" "*) echo "$build is in multiple configs: $conf" 2>&1; exit 0;;
*) ;;
esac
if grep -q "^$build .*github.*commits.atom" $conf; then
postproc="last_gh_commit"
elif grep -q "^$build .*github.*tags.atom" $conf ; then
postproc="last_gh_tag"
elif [ "$build" = "quark" ]; then
postproc="head -1"
elif [ "$conf" = "$DIR/repology.conf" ]; then
postproc="format_repology"
else
postproc="sort_color"
fi
ck4up -dk -f "$conf" "^$build\\s" | $postproc
source ./*.info
echo "===> VERSION=$VERSION" | colorize_ver 2
|