summaryrefslogtreecommitdiffstats
path: root/bin/d-i_check_jobs.sh
blob: 0d96f4cd8da51260ae1273ae1454e7801f3bc8a2 (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/bin/bash

# Copyright 2012 Holger Levsen <holger@layer-acht.org>
# released under the GPLv=2

#
# default settings
#
#set -x
set -e
export LC_ALL=C
export http_proxy="http://localhost:3128"

#
# define some variables
#
URL="http://anonscm.debian.org/viewvc/d-i/trunk/.mrconfig?view=co"
FAIL=false
DI_BUILD_JOB_PATTERN=d-i_build_
DI_MANUAL_JOB_PATTERN=d-i_manual_
TMPFILE=$(mktemp)
JOB_TEMPLATES=$(mktemp)
PROJECT_JOBS=$(mktemp)

#
# check for missing d-i package build jobs
# for this, we compare referred git repos in .mrconfig against locally existing jenkins jobs
# 	(see http://wiki.debian.org/DebianInstaller/CheckOut)
#
echo "Scanning $URL for reffered git repos which have no jenkins job associated."
curl $URL > $TMPFILE 2>/dev/null
PACKAGES=$( grep git.debian.org/git/d-i $TMPFILE|cut -d "/" -f6-|cut -d " " -f1)
#
# check for each git repo if a jenkins job exists
#
for PACKAGE in $PACKAGES ; do
	if [ ! -d ~jenkins/jobs/${DI_BUILD_JOB_PATTERN}${PACKAGE} ] ; then
		echo "Warning: No build job '${DI_BUILD_JOB_PATTERN}${PACKAGE}'."
		FAIL=true
		#
		# prepare yaml bits
		#
		echo "      - '{name}_build_$PACKAGE':" >> $PROJECT_JOBS
		echo "         gitrepo: 'git://git.debian.org/git/d-i/$PACKAGE'" >> $PROJECT_JOBS
		echo "- job-template:" >> $JOB_TEMPLATES
		echo "    defaults: d-i-build" >> $JOB_TEMPLATES
		echo "    name: '{name}_build_$PACKAGE'" >> $JOB_TEMPLATES
	else
		echo "Ok: Job '${DI_BUILD_JOB_PATTERN}${PACKAGE}' exists."
	fi
done
#
# check for each job if there still is a git repo
#
for JOB in $(ls -1 ~jenkins/jobs/ | grep ${DI_BUILD_JOB_PATTERN}) ; do
	REPONAME=${JOB:10}
	grep -q git+ssh://git.debian.org/git/d-i/$REPONAME $TMPFILE || echo "Warning: Git repo $REPONAME not found in $URL, but job $JOB exists."
done 
# cleanup
rm $TMPFILE

#
# check for missing d-i manual language build jobs
#
# first the xml translations...
#
cd ~jenkins/jobs/d-i_manual/workspace/manual
IGNORE="build debian doc README scripts build-stamp doc-base-stamp po"
for DIRECTORY in * ; do
	for i in $IGNORE ; do
		if [ "$DIRECTORY" == "$i" ] ; then
			DIRECTORY=""
			break
		fi
	done
	if [ "$DIRECTORY" == "" ] ; then
		continue
	else
		# FIXME: turn this into a loop: pdf html
		#
		# html build job
		#
		if [ ! -d ~jenkins/jobs/${DI_MANUAL_JOB_PATTERN}${DIRECTORY}_html ] ; then
			echo "Warning: No build job '${DI_MANUAL_JOB_PATTERN}${DIRECTORY}_html'."
			FAIL=true
			#
			# prepare yaml bits
			#
			echo "      - '{name}_manual_${DIRECTORY}_html':" >> $PROJECT_JOBS
			echo "         lang: '$DIRECTORY'" >> $PROJECT_JOBS
			echo "         languagename: 'FIXME: $DIRECTORY'" >> $PROJECT_JOBS
			echo "- job-template:" >> $JOB_TEMPLATES
			echo "    defaults: d-i-manual-html" >> $JOB_TEMPLATES
			echo "    name: '{name}_manual_${DIRECTORY}_html'" >> $JOB_TEMPLATES
		fi
		#
		# pdf build job
		#
		if [ ! -d ~jenkins/jobs/${DI_MANUAL_JOB_PATTERN}${DIRECTORY}_pdf ] ; then
			echo "Warning: No build job '${DI_MANUAL_JOB_PATTERN}${DIRECTORY}_pdf'."
			FAIL=true
			#
			# prepare yaml bits
			#
			echo "      - '{name}_manual_${DIRECTORY}_pdf':" >> $PROJECT_JOBS
			echo "         lang: '$DIRECTORY'" >> $PROJECT_JOBS
			echo "         languagename: 'FIXME: $DIRECTORY'" >> $PROJECT_JOBS
			echo "- job-template:" >> $JOB_TEMPLATES
			echo "    defaults: d-i-manual-pdf" >> $JOB_TEMPLATES
			echo "    name: '{name}_manual_${DIRECTORY}_pdf'" >> $JOB_TEMPLATES
		fi
	fi
done
# FIXME: check for removed manuals (but with existing jobs) missing
#
# ...and now the translations kept in po files....
cd po
IGNORE="pot README"
for DIRECTORY in * ; do
	for i in $IGNORE ; do
		if [ "$DIRECTORY" == "$i" ] ; then
			DIRECTORY=""
			break
		fi
	done
	if [ "$DIRECTORY" == "" ] ; then
		continue
	else
		# FIXME: turn this into a loop: pdf html
		#
		# html build job
		#
		if [ ! -d ~jenkins/jobs/${DI_MANUAL_JOB_PATTERN}${DIRECTORY}_html_po2xml ] ; then
			echo "Warning: No build job '${DI_MANUAL_JOB_PATTERN}${DIRECTORY}_html_po2xml'."
			FAIL=true
			#
			# prepare yaml bits
			#
			echo "      - '{name}_manual_${DIRECTORY}_html':" >> $PROJECT_JOBS
			echo "         lang: '$DIRECTORY'" >> $PROJECT_JOBS
			echo "         languagename: 'FIXME: $DIRECTORY'" >> $PROJECT_JOBS
			echo "- job-template:" >> $JOB_TEMPLATES
			echo "    defaults: d-i-manual-html-po2xml" >> $JOB_TEMPLATES
			echo "    name: '{name}_manual_${DIRECTORY}_html'" >> $JOB_TEMPLATES
		fi
		#
		# pdf build job
		#
		if [ ! -d ~jenkins/jobs/${DI_MANUAL_JOB_PATTERN}${DIRECTORY}_pdf_po2xml ] ; then
			echo "Warning: No build job '${DI_MANUAL_JOB_PATTERN}${DIRECTORY}_pdf_po2xml'."
			FAIL=true
			#
			# prepare yaml bits
			#
			echo "      - '{name}_manual_${DIRECTORY}_pdf':" >> $PROJECT_JOBS
			echo "         lang: '$DIRECTORY'" >> $PROJECT_JOBS
			echo "         languagename: 'FIXME: $DIRECTORY'" >> $PROJECT_JOBS
			echo "- job-template:" >> $JOB_TEMPLATES
			echo "    defaults: d-i-manual-pdf-po2ml" >> $JOB_TEMPLATES
			echo "    name: '{name}_manual_${DIRECTORY}_pdf'" >> $JOB_TEMPLATES
		fi
	fi
done
# FIXME: check for removed manuals (but with existing jobs) missing

#
# fail this job if missing d-i jobs are detected
#
echo
if $FAIL ; then 
	figlet "Missing jobs!"
	echo
	echo "Add these job templates to job-cfg/d-i.yaml:"
	cat $JOB_TEMPLATES
	echo
	echo
	echo "Append this to the project definition in job-cfg/d-i.yaml:"
	cat $PROJECT_JOBS
	echo
	rm $JOB_TEMPLATES $PROJECT_JOBS
	exit 1
else
	figlet ok
fi