~kaction/config

ref: milestone/1 config/src/libexec/debomatic-follow -rwxr-xr-x 1.9 KiB
8f4e28c9 — Dmitry Bogatov vim: drop custom implementation of snippets 2 years ago
                                                                                
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/sh -eux
readonly arch=amd64
readonly CACHE_DIR="${HOME}/.cache/debomatic-follow"
mkdir -p "${CACHE_DIR}"

commit=$(git log --format=%h -1 HEAD)
name=$(dpkg-parsechangelog -SSource)
version=$(dpkg-parsechangelog -SVersion)
# Epoch is pain.
version=$(printf '%s' "${version}" | sed 's/^[1-9]://')

workdir="${CACHE_DIR}/${name}/${commit}"
error () { printf '%s/%s: %s\n' "${name}" "${version}" "$*" >&2; exit 1; }

mkdir -p "${workdir}"
cd "${workdir}"

url="http://debomatic-amd64.debian.net/debomatic/unstable/pool"
url="${url}/${name}_${version}+${commit}"
url="${url}/${name}_${version}+${commit}"

tick=30
while ! wget -q "${url}.json" -O json ; do
	tick=$((tick - 1))
	sleep 1
	if [ "${tick}" = 0 ] ; then
		error "json file did not appear"
	fi
done

# Download json file again and again, until it get 'success' field
while : ; do
	success=$(jq .success < json)
	case "${success}" in
	(null)
		sleep 2
		wget -S -q "${url}.json" -O json
		;;
	(true)
		build_status=OK
		break
		;;
	(false)
		build_status=FAIL
		break
		;;
	(*)
		error "unexpected value of success field: ${success}"
	esac
done

target="${name}/${version}+${commit}"

wget -q -O buildlog "${url}_${arch}.build"
mail $USER -s "[${build_status}] Build log for ${target}" < buildlog

if [ "${build_status}" = OK ] ; then
	wget -q -O contents "${url}.contents"
	wget -q -O lintian "${url}.lintian"
	wget -q -O piuparts "${url}.piuparts"

	grep -v '^N:' lintian  > lintian.short
	mv lintian lintian.long
	cat lintian.short lintian.long > lintian

	lintian_status=OK
	if grep -Eq '^(E|W):' lintian ; then
		lintian_status=FAIL
	fi

	piuparts_status=FAIL
	if grep -q 'PASS: All tests.' piuparts ; then
		piuparts_status=OK
	fi

	mail $USER -s "Contents report for ${target}" < contents
	mail $USER -s "[${lintian_status}] Lintian report for ${target}" < lintian
	mail $USER -s "[${piuparts_status}] Piuparts report for ${target}" < piuparts
fi