summaryrefslogtreecommitdiffstats
path: root/bin/reproducible_schedule_on_demand.sh
blob: 6ae4af1984b5dd2c32ba3913f197efeead702497 (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
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
#!/bin/bash

# Copyright 2014 Holger Levsen <holger@layer-acht.org>
#         © 2015 Mattia Rizzolo <mattia@mapreri.org>
# released under the GPLv=2

DEBUG=false
. /srv/jenkins/bin/common-functions.sh
common_init "$@"

# common code defining db access
. /srv/jenkins/bin/reproducible_common.sh

#
# main
#
set +x
SUITE="$1"
shift
if [ "$SUITE" = "sid" ] ; then
	echo "WARNING: sid has been renamed to unstable."
	SUITE=unstable
fi

case "$1" in
	"artifacts")
		ARTIFACTS=1
		NOTIFY=true
		shift
		printf "\nThe artifacts of the build(s) will be saved to the location mentioned at the end of the build log(s).\n\n"
		;;
	"notify")
		ARTIFACTS=0
		NOTIFY=true
		shift
		printf "\nThe IRC channel will be notified once the build(s) finished.\n\n"
		;;
	*)
		ARTIFACTS=0
		NOTIFY=''
		;;
esac

CANDIDATES="$@"
if [ ${#} -gt 50 ] && $NOTIFY ; then
	echo
	figlet "No."
	echo "Do not schedule more than 50 packages with notification. If you really really need to spam the IRC channel this much, use a loop to achieve that. Exiting."
	echo
	exit 1
fi
check_candidates
if [ ${#PACKAGE_IDS} -gt 256 ] ; then
	BLABLABLA="✂…"
fi
ACTION="manually rescheduled"
if [ -n "${BUILD_URL:-}" ] ; then
	ACTION="rescheduled by $BUILD_URL"
fi
MESSAGE="$TOTAL $PACKAGES_TXT $ACTION in $SUITE: ${PACKAGES_NAMES:0:256}$BLABLABLA"
if [ $ARTIFACTS -eq 1 ] ; then
	MESSAGE="$MESSAGE - artifacts will be preserved."
elif [ "$NOTIFY" = "true" ] ; then
	MESSAGE="$MESSAGE - notification once finished."
fi

# finally
schedule_packages $PACKAGE_IDS
echo
echo "$MESSAGE"
if [ -z "${BUILD_URL:-}" ] && [ $TOTAL -ne 0 ] ; then
	kgb-client --conf /srv/jenkins/kgb/debian-reproducible.conf --relay-msg "$MESSAGE"
fi
echo "============================================================================="
echo "The following $TOTAL source $PACKAGES_TXT $ACTION for $SUITE: $PACKAGES_NAMES"
echo "============================================================================="
echo