rev |
line source |
pankso@4
|
1 #!/bin/sh
|
pankso@4
|
2 #
|
pankso@383
|
3 # SliTaz Build Bot. The Cooker is a tool to automate and test SliTaz package
|
pankso@383
|
4 # building. Please read the Cookbook documentation for more information
|
paul@54
|
5 # and discuss with the AUTHORS before adding anything here. PS: no translations
|
paul@495
|
6 # here since it's not an end user tool and it's not useful. All devs should
|
pankso@4
|
7 # at least understand basic English.
|
pankso@4
|
8 #
|
al@728
|
9
|
pankso@431
|
10 . /usr/lib/slitaz/libcook.sh
|
pankso@4
|
11
|
pankso@49
|
12 # Set pkg name and use same wok as cook.
|
pankso@49
|
13 pkg="$2"
|
pankso@4
|
14 wok="$WOK"
|
pankso@4
|
15
|
pankso@81
|
16 # PID file.
|
pankso@81
|
17 pidfile='/var/run/cooker.pid'
|
pankso@81
|
18
|
pankso@4
|
19 #
|
pankso@4
|
20 # Functions
|
pankso@4
|
21 #
|
pankso@4
|
22
|
pankso@4
|
23 usage() {
|
al@728
|
24 cat <<EOT
|
pankso@4
|
25
|
al@942
|
26 Usage: cooker [<command>] [<options>]
|
pankso@4
|
27
|
al@942
|
28 Commands with <options>:
|
al@942
|
29 -u | usage Display this short usage.
|
al@942
|
30 -s | setup Setup the Cooker environment.
|
al@942
|
31 setup-cron [<hours>] Setup a cron job for the Cooker.
|
al@942
|
32 check-cron Check Cooker cron job.
|
al@942
|
33 arch-db Create host arch packages DB.
|
al@942
|
34 -n | note <note_text> Add a note to the cooknotes.
|
al@942
|
35 -ns | notes Display all the cooknotes.
|
al@942
|
36 -b | block <package> Block a package so cook will skip it.
|
al@942
|
37 -ub | unblock <package> Unblock a blocked package.
|
al@942
|
38 -R | reverse <package> Cook all reverse dependencies for a package.
|
al@942
|
39 -p | pkg <package> Same as 'cook pkg' but with cooker log.
|
al@942
|
40 -f | flavor <flavor_name> Cook all packages of a flavor.
|
al@942
|
41 -l | list <list_file> Cook all packages in the given list.
|
al@942
|
42 -c | cat <category> Cook all packages of a category.
|
al@942
|
43 -r | rev <rev_number> Cook packages of a specific revision.
|
al@942
|
44 -a | all Find and cook all unbuilt packages.
|
al@942
|
45 -T | tasks List existing cooker tasks.
|
al@942
|
46 -t | task <task> Executing specified task.
|
al@957
|
47 -o | outgoing Find changes in wok that we can move to wok-hg.
|
al@1040
|
48 autodeps Find dependencies for all packages in wok.
|
pankso@4
|
49
|
pankso@4
|
50 EOT
|
pankso@4
|
51 exit 0
|
pankso@4
|
52 }
|
pankso@4
|
53
|
al@728
|
54
|
paul@54
|
55 # Some messages occur in activity but log verbose output when checking for commits
|
pankso@14
|
56 # into a log file.
|
al@728
|
57
|
pankso@14
|
58 log_commits() {
|
al@931
|
59 sed '/^.\//d' | sed '/^.hg/d' | tee -a $LOGS/commits.log
|
pankso@14
|
60 }
|
pankso@14
|
61
|
al@728
|
62
|
pankso@81
|
63 # Clean up before exit when check and cook commits finish.
|
al@728
|
64
|
pankso@81
|
65 clean_exit() {
|
al@728
|
66 rm -f $command; touch $command
|
pascal@766
|
67 [ "$previous_command" ] && ps | grep -q "${previous_command/:/ }" &&
|
pascal@766
|
68 echo -n "$previous_command" > $command
|
pankso@81
|
69 rm -f $pidfile
|
pankso@14
|
70 }
|
pankso@14
|
71
|
al@728
|
72
|
pankso@35
|
73 # Summary for commits.
|
al@728
|
74
|
pankso@35
|
75 commits_summary() {
|
pankso@35
|
76 msg="from revision $cur to $new"
|
pankso@35
|
77 [ "$new" == "$cur" ] && msg="revision $new"
|
pankso@35
|
78 echo "Will cook $msg"
|
pankso@35
|
79 separator
|
al@942
|
80 title "Summary for commits"
|
pankso@35
|
81 echo "Hg wok revision : $cur"
|
pankso@35
|
82 echo "Pulled revision : $new"
|
al@728
|
83 echo "Check date : $(date '+%F %T')"
|
pankso@35
|
84 }
|
pankso@35
|
85
|
al@728
|
86
|
al@942
|
87 # Return all the names of packages bundled in this receipt
|
al@942
|
88
|
al@942
|
89 all_names() {
|
al@942
|
90 local split=" $SPLIT "
|
al@942
|
91 unset SPLIT
|
al@942
|
92 . $wok/$pkg/receipt
|
al@942
|
93
|
al@942
|
94 if ! head -n1 $WOK/$pkg/receipt | fgrep -q 'v2'; then
|
al@942
|
95 # For receipts v1: $SPLIT may present in the $WANTED package,
|
al@942
|
96 # but split packages have their own receipts
|
al@942
|
97 echo $PACKAGE
|
al@942
|
98 elif [ "${split/ $PACKAGE /}" != "$split" ]; then
|
al@942
|
99 echo $SPLIT
|
al@942
|
100 else
|
al@942
|
101 echo $PACKAGE $SPLIT
|
al@942
|
102 fi
|
al@942
|
103 }
|
al@942
|
104
|
al@942
|
105
|
paul@54
|
106 # Scan packages build deps and fill up cookorder list.
|
al@728
|
107
|
pankso@4
|
108 cook_order_scan() {
|
al@942
|
109 rm -f $cookorder $cookorder.split
|
al@942
|
110 touch $cookorder $cookorder.split
|
al@942
|
111
|
al@942
|
112 # Make combined split table: beginning from actual information with fresh
|
al@942
|
113 # commits. Example:
|
al@942
|
114 # freetype freetype freetype-dev
|
al@942
|
115 # harfbuzz harfbuzz harfbuzz-apps harfbuzz-dev
|
al@942
|
116 while read pkg; do
|
al@942
|
117 echo "$pkg $(all_names)" >> $cookorder.split
|
al@942
|
118 done < $cooklist
|
al@942
|
119 cat $cache/split.db >> $cookorder.split
|
al@942
|
120
|
al@942
|
121 maxlen=$(wc -L < $cooklist)
|
al@942
|
122
|
al@931
|
123 while read pkg; do
|
pascal@273
|
124 unset WANTED BUILD_DEPENDS
|
pankso@14
|
125 . $wok/$pkg/receipt
|
al@942
|
126 bdeps=$(
|
al@942
|
127 # Substitite each package of BUILD_DEPENDS list by the "main"
|
al@942
|
128 # receipt which builds this package. Example:
|
al@942
|
129 # BUILD_DEPENDS="freetype-dev harfbuzz-dev" -> bdeps="freetype harfbuzz"
|
al@942
|
130 for i in $BUILD_DEPENDS; do
|
al@942
|
131 main="$(awk -F$'\t' -vi="$i" '{
|
al@942
|
132 if (index(" " $2 " ", i)) {print $1; exit}
|
al@942
|
133 }' $cookorder.split)"
|
al@942
|
134 echo ${main:-$i}
|
al@942
|
135 done
|
al@942
|
136 )
|
pankso@29
|
137 # The :: is for web interface color.
|
al@942
|
138 bdeps=$(echo $WANTED $bdeps | tr '\n' ' ')
|
al@942
|
139 printf "%-${maxlen}s :: %s\n" "$pkg" "$bdeps"
|
al@942
|
140 for dep in $bdeps; do
|
pankso@4
|
141 if grep -q "^$dep$" $cooklist; then
|
pankso@4
|
142 if ! grep -q "^$dep$" $cookorder; then
|
pankso@4
|
143 echo "$dep" >> $cookorder
|
pankso@4
|
144 fi
|
pankso@4
|
145 fi
|
pankso@4
|
146 done
|
al@931
|
147 done < $cooklist
|
pankso@383
|
148
|
paul@54
|
149 # Append unordered packages to cookorder.
|
al@931
|
150 while read pkg; do
|
pankso@4
|
151 if ! grep -q "^$pkg$" $cookorder; then
|
pankso@4
|
152 echo "$pkg" >> $cookorder
|
pankso@4
|
153 fi
|
al@931
|
154 done < $cooklist
|
pankso@4
|
155 }
|
pankso@4
|
156
|
al@728
|
157
|
paul@54
|
158 # Scan and rescan until the cooklist is ordered then handle WANTED.
|
al@728
|
159
|
pankso@4
|
160 cook_order() {
|
pankso@4
|
161 time=$(date +%s)
|
pankso@4
|
162 scan=0
|
al@942
|
163 rm -rf $cache/cookorder.d
|
al@942
|
164 mkdir -p $cache/cookorder.d
|
pankso@4
|
165
|
pankso@4
|
166 # Keep an original cooklist so we do a diff when ordering is finished.
|
pankso@4
|
167 cp -f $cooklist $cooklist.0
|
al@728
|
168 echo 'cookorder' > $command
|
al@942
|
169 title 'Initial Cooker order scan'
|
pankso@4
|
170 cook_order_scan
|
pankso@383
|
171
|
pankso@4
|
172 # Diff between the cooklist and new ordered list ? So copy the last
|
pankso@4
|
173 # cookorder to cooklist and rescan it.
|
al@728
|
174 while /bin/true; do
|
al@942
|
175 if ! cmp -s $cooklist $cookorder; then
|
pankso@4
|
176 scan=$(($scan + 1))
|
al@942
|
177 title "Diff scan: $scan"
|
al@942
|
178
|
al@942
|
179 md5stamp=$(md5sum $cookorder | cut -d' ' -f1)
|
al@942
|
180 if [ -e "$cache/cookorder.d/$md5stamp" ]; then
|
al@942
|
181 newline
|
al@942
|
182 echo 'A dependency loop was detected. Interrupting the cookorder.'
|
al@942
|
183 break
|
al@942
|
184 fi
|
al@942
|
185 touch $cache/cookorder.d/$md5stamp
|
al@942
|
186
|
pankso@4
|
187 mv -f $cookorder $cooklist
|
pankso@4
|
188 cook_order_scan
|
al@942
|
189
|
pankso@4
|
190 else
|
pankso@4
|
191 break
|
pankso@4
|
192 fi
|
pankso@4
|
193 done
|
al@942
|
194 # Clean
|
al@942
|
195 rm -rf $cache/cookorder.d; rm $cookorder.split
|
pankso@4
|
196
|
paul@647
|
197 # Keep a diff between submitted cooklist and the ordered.
|
pankso@4
|
198 diff $cooklist.0 $cooklist > $cooklist.diff
|
al@942
|
199 rm -f $cookorder $cooklist.0
|
pankso@4
|
200
|
pankso@107
|
201 # Scan finished: append pkg to WANTED or leave it in the ordered cooklist.
|
paul@214
|
202 # TODO: grep the line number to get pkg position and keep it higher.
|
al@942
|
203 title 'Handle WANTED package'
|
al@931
|
204 while read pkg; do
|
pankso@4
|
205 unset WANTED
|
pankso@14
|
206 . $wok/$pkg/receipt
|
al@728
|
207 for wanted in $WANTED; do
|
pascal@291
|
208 echo "$pkg :: $wanted"
|
pascal@291
|
209 if grep -q ^${wanted}$ $cooklist; then
|
al@931
|
210 sed -i -e "/^$pkg$/d" \
|
pascal@291
|
211 -e "/^$wanted$/ a $pkg" $cooklist
|
pankso@107
|
212 fi
|
pascal@291
|
213 done
|
al@931
|
214 done < $cooklist
|
pankso@4
|
215
|
pankso@4
|
216 # Show ordered cooklist
|
al@942
|
217 title 'Cooklist order'
|
pankso@4
|
218 cat $cooklist
|
pankso@4
|
219 separator
|
al@728
|
220
|
pankso@4
|
221 time=$(($(date +%s) - $time))
|
al@931
|
222 pkgs=$(wc -l < $cooklist)
|
al@942
|
223 title 'Summary for cookorder'
|
al@728
|
224 cat <<EOT
|
pankso@4
|
225 Ordered packages : $pkgs
|
pankso@4
|
226 Scans executed : $scan
|
pankso@4
|
227 Scan duration : ${time}s
|
pankso@4
|
228 EOT
|
al@728
|
229 separator
|
al@728
|
230
|
al@728
|
231 rm -f $command
|
pankso@4
|
232 }
|
pankso@4
|
233
|
al@728
|
234
|
pankso@14
|
235 # Remove blocked (faster this way than grepping before).
|
al@728
|
236
|
pankso@14
|
237 strip_blocked() {
|
al@931
|
238 while read pkg; do
|
al@931
|
239 sed -i "/^${pkg}$/d" $cooklist
|
al@931
|
240 done < $blocked
|
al@931
|
241 sed -i '/^$/d' $cooklist
|
pankso@14
|
242 }
|
pankso@14
|
243
|
al@728
|
244
|
paul@54
|
245 # Use in default mode and with all cmd.
|
al@728
|
246
|
pankso@4
|
247 cook_commits() {
|
pankso@4
|
248 if [ -s "$commits" ]; then
|
al@931
|
249 while read pkg; do
|
pascal@765
|
250 ps | grep -q "cook $pkg$" && continue
|
pankso@14
|
251 echo "cook:$pkg" > $command
|
pankso@394
|
252 cook $pkg || broken
|
al@931
|
253 sed -i "/^${pkg}$/d" $commits
|
al@931
|
254 done < $commits
|
pankso@4
|
255 fi
|
pankso@4
|
256 }
|
pankso@4
|
257
|
al@728
|
258
|
paul@54
|
259 # Cook all packages in a cooklist.
|
al@728
|
260
|
pankso@14
|
261 cook_list() {
|
al@931
|
262 while read pkg; do
|
pascal@765
|
263 ps | grep -q "cook $pkg$" && continue
|
pankso@79
|
264 cook $pkg || broken
|
al@931
|
265 sed -i "/^${pkg}$/d" $cooklist
|
al@931
|
266 done < $cooklist
|
pankso@14
|
267 }
|
pankso@14
|
268
|
al@728
|
269
|
paul@388
|
270 # Create a arch.$ARCH file for each package cooked for the target host
|
pankso@383
|
271 # architecture
|
pankso@383
|
272 #
|
al@931
|
273 # The deal: we don't want all packages handled by cooker commands and stats,
|
al@931
|
274 # since we don't cross compile all packages for each arch but only a set of
|
paul@388
|
275 # packages to provide one full featured desktop, servers and goodies useful
|
pankso@383
|
276 # for the host system.
|
pankso@383
|
277 #
|
al@728
|
278
|
pankso@383
|
279 arch_db() {
|
pankso@383
|
280 count=0
|
pankso@391
|
281 echo "Cleaning packages DB : arch.$ARCH"
|
pankso@390
|
282 rm -f $wok/*/arch.$ARCH && cd $wok
|
pankso@383
|
283 echo "Creating $ARCH packages DB..."
|
al@728
|
284 for pkg in *; do
|
al@1132
|
285 [ -e $wok/$pkg/.hidden ] && continue
|
pascal@800
|
286 [ -s $wok/$pkg/receipt ] || continue
|
pascal@693
|
287 HOST_ARCH=
|
pascal@693
|
288 . $wok/$pkg/receipt
|
pascal@693
|
289 if [ -n "$HOST_ARCH" ]; then
|
pankso@678
|
290 if $(echo "$HOST_ARCH" | egrep -q "$ARCH|any"); then
|
pankso@678
|
291 count=$(($count + 1))
|
pankso@678
|
292 echo "Adding: $pkg"
|
pankso@678
|
293 touch $pkg/arch.$ARCH
|
pankso@678
|
294 fi
|
pankso@678
|
295 unset HOST_ARCH
|
pankso@678
|
296 else
|
al@1133
|
297 # HOST_ARCH not set --> package is suitable for current ARCH
|
al@1032
|
298 count=$(($count + 1))
|
al@1032
|
299 echo "Adding: $pkg"
|
al@1032
|
300 touch $pkg/arch.$ARCH
|
pankso@383
|
301 fi
|
pankso@383
|
302 done
|
pankso@391
|
303 echo "Packages for $ARCH : $count"
|
pankso@383
|
304 }
|
pankso@383
|
305
|
al@728
|
306
|
al@957
|
307 # Compare wok and wok-hg file $1, display signs:
|
al@957
|
308 # '+' file added, '-' file removed, '~' file changed, '=' file not changed
|
al@957
|
309
|
al@957
|
310 compare_wok_file() {
|
al@957
|
311 local f1='n' f2='n' # n: not exists, e: exists
|
al@957
|
312 [ -e "$wok/$1" ] && f1='e'
|
al@957
|
313 [ -e "$wok-hg/$1" ] && f2='e'
|
al@957
|
314 case "$f1$f2" in
|
al@957
|
315 en) echo "+ $1";;
|
al@957
|
316 ne) [ -n "$del" ] && echo "- $1";;
|
al@957
|
317 ee)
|
al@957
|
318 if cmp -s "$wok/$1" "$wok-hg/$1"; then
|
al@957
|
319 [ -n "$eq" ] && echo "= $1"
|
al@957
|
320 else
|
al@957
|
321 echo "~ $1"
|
al@957
|
322 fi
|
al@957
|
323 ;;
|
al@957
|
324 esac
|
al@957
|
325 }
|
al@957
|
326
|
al@957
|
327
|
al@957
|
328 # Compare wok and wok-hg folder $1; process only:
|
al@957
|
329 # receipt, description.*txt, all files in the stuff folder
|
al@957
|
330
|
al@957
|
331 compare_wok_folder() {
|
al@957
|
332 IFS=$'\n'
|
al@957
|
333 {
|
al@957
|
334 for i in $wok $wok-hg; do
|
al@957
|
335 ls $i/$1/receipt 2>/dev/null
|
al@957
|
336 ls $i/$1/description.*txt 2>/dev/null
|
al@957
|
337 [ -d $i/$1/stuff ] && find $i/$1/stuff -type f
|
al@957
|
338 done
|
al@957
|
339 } | sed "s|$wok/$1/||; s|$wok-hg/$1/||" | sort -u | \
|
al@957
|
340 while read file; do
|
al@957
|
341 compare_wok_file "$1/$file"
|
al@957
|
342 done
|
al@957
|
343 }
|
al@957
|
344
|
al@957
|
345
|
al@957
|
346 # Compare entire wok
|
al@957
|
347
|
al@957
|
348 compare_wok() {
|
al@957
|
349 {
|
al@957
|
350 cd $wok; ls
|
al@957
|
351 cd $wok-hg; ls
|
al@957
|
352 } | sort -u | \
|
al@957
|
353 while read folder; do
|
al@957
|
354 result="$(compare_wok_folder $folder)"
|
al@957
|
355 [ -n "$result" ] && echo -e "$result\n"
|
al@957
|
356 done
|
al@957
|
357 }
|
al@957
|
358
|
al@957
|
359
|
pankso@4
|
360 #
|
pankso@4
|
361 # Commands
|
pankso@4
|
362 #
|
al@728
|
363
|
al@933
|
364 previous_command="$(cat $command 2>/dev/null)"
|
pankso@4
|
365 case "$1" in
|
pankso@31
|
366 usage|help|-u|-h)
|
pankso@4
|
367 usage ;;
|
al@728
|
368
|
pankso@31
|
369 setup|-s)
|
pankso@4
|
370 # Setup the Cooker environment.
|
al@942
|
371 title 'Setting up the Cooker'
|
pankso@349
|
372 mkdir -p $CACHE
|
pankso@31
|
373 echo "Cooker setup using: $SLITAZ" | log
|
al@728
|
374 for pkg in $SETUP_PKGS mercurial rsync tazlito; do
|
pankso@4
|
375 [ ! -d "$INSTALLED/$pkg" ] && tazpkg get-install $pkg
|
pankso@4
|
376 done
|
pankso@4
|
377 mkdir -p $SLITAZ && cd $SLITAZ
|
al@728
|
378 if [ -d "${wok}-hg" ]; then
|
al@728
|
379 echo -e 'Hg wok already exists.\n'
|
al@728
|
380 exit 1
|
al@728
|
381 fi
|
al@728
|
382 if [ -d "$wok" ]; then
|
al@728
|
383 echo -e 'Build wok already exists.\n'
|
al@728
|
384 exit 1
|
al@728
|
385 fi
|
pankso@4
|
386
|
pankso@4
|
387 # Directories and files
|
pankso@4
|
388 echo "mkdir's and touch files in: $SLITAZ"
|
pankso@311
|
389 mkdir -p $PKGS $LOGS $FEEDS $CACHE $SRC
|
al@728
|
390 for f in $activity $blocked $broken $commits $cooklist $command; do
|
pankso@4
|
391 touch $f
|
pankso@4
|
392 done
|
pankso@14
|
393 hg clone $WOK_URL ${wok}-hg || exit 1
|
pankso@60
|
394 [ -d "$flavors" ] || hg clone $FLAVORS_URL flavors
|
pankso@4
|
395 cp -a ${wok}-hg $wok
|
al@942
|
396 footer ;;
|
al@728
|
397
|
pankso@383
|
398 arch-db)
|
pankso@383
|
399 # Manually create arch packages DB.
|
pankso@383
|
400 arch_db ;;
|
al@728
|
401
|
pankso@341
|
402 setup-cron)
|
pankso@341
|
403 # Create cron job for the cooker.
|
pankso@341
|
404 [ "$2" ] || hours=2
|
pankso@341
|
405 if [ ! -f "$crontabs" ]; then
|
pankso@341
|
406 mkdir -p /var/spool/cron/crontabs
|
pankso@341
|
407 fi
|
pankso@341
|
408 if ! fgrep -q /usr/bin/cooker $crontabs; then
|
al@931
|
409 cat > $crontabs <<EOT
|
pascal@760
|
410 # Run SliTaz Cooker every $hours hours
|
pascal@777
|
411 59 */$hours * * * touch $CACHE/cooker-request
|
pascal@760
|
412 */5 * * * * [ $CACHE/cooker-request -nt $CACHE/activity ] && /usr/bin/cooker --output=html
|
pascal@777
|
413 */5 * * * * [ -z "$(pidof cooker)" ] && [ -s $CACHE/recook-packages ] && /usr/bin/cooker list $CACHE/recook-packages
|
pascal@760
|
414 EOT
|
pascal@773
|
415 touch $CACHE/cooker-request $CACHE/recook-packages
|
pascal@773
|
416 chmod 666 $CACHE/cooker-request $CACHE/recook-packages
|
pankso@341
|
417 killall crond 2>/dev/null && /etc/init.d/crond start
|
pankso@341
|
418 fi ;;
|
al@728
|
419
|
pankso@341
|
420 check-cron)
|
al@728
|
421 if [ ! -f "$crontabs" ]; then
|
al@728
|
422 echo "There is no $crontabs here. Use setup-cron option."
|
al@728
|
423 exit 1
|
al@728
|
424 fi
|
pankso@341
|
425 fgrep /usr/bin/cooker $crontabs ;;
|
al@728
|
426
|
pankso@31
|
427 note|-n)
|
al@728
|
428 # Blocked a pkg and want others to know why? Post a note!
|
al@728
|
429 [ -n "$2" ] && echo "$(date '+%F %R') : $2" >> $cooknotes ;;
|
al@728
|
430
|
pankso@31
|
431 notes|-ns)
|
pankso@29
|
432 # View cooknotes.
|
al@942
|
433 title 'Cooknotes'
|
pankso@29
|
434 cat $cooknotes
|
al@942
|
435 footer ;;
|
al@728
|
436
|
pankso@49
|
437 block|-b)
|
pankso@49
|
438 # Block a package.
|
pankso@49
|
439 [ "$pkg" ] && cook $pkg --block ;;
|
al@728
|
440
|
pankso@49
|
441 unblock|-ub)
|
pankso@49
|
442 # Unblock a package.
|
pankso@49
|
443 [ "$pkg" ] && cook $pkg --unblock ;;
|
al@728
|
444
|
pankso@31
|
445 reverse|-r)
|
paul@54
|
446 # Cook all reverse dependencies for a package. This command lets us
|
paul@54
|
447 # control the Cooker manually for commits that will cook a lot of packages.
|
pankso@14
|
448 #
|
al@728
|
449 # Use hg commit? Ex: hg commit -m "Message bla bla | cooker:reverse"
|
pankso@14
|
450 #
|
al@728
|
451 if [ ! -d "$wok/$pkg" ]; then
|
al@728
|
452 echo -e "\nNo package $2 found.\n"
|
al@728
|
453 exit 0
|
al@728
|
454 fi
|
al@728
|
455 rm -f $cooklist; touch $cooklist
|
al@942
|
456 title "Reverse cooklist for: $pkg"
|
al@728
|
457
|
al@728
|
458 cd $wok
|
al@728
|
459 for rev in *; do
|
pascal@800
|
460 [ -s $wok/$rev/receipt ] || continue
|
al@728
|
461 unset WANTED DEPENDS BUILD_DEPENDS; . $wok/$rev/receipt
|
pascal@273
|
462 if echo "$WANTED $DEPENDS $BUILD_DEPENDS" | fgrep -q $pkg; then
|
pankso@32
|
463 echo "$rev" | tee -a $cooklist
|
pankso@4
|
464 fi
|
al@728
|
465 done
|
al@942
|
466 footer "Reverse dependencies found: $(wc -l < $cooklist)"
|
pankso@32
|
467 strip_blocked
|
pankso@32
|
468 cook_order | tee $LOGS/cookorder.log
|
pankso@32
|
469 cook_list ;;
|
al@728
|
470
|
pankso@31
|
471 pkg|-p)
|
al@1126
|
472 # Same as 'cook pkg'.
|
pascal@765
|
473 ps | grep -q "cook $pkg$" && echo 'Already running' && continue
|
pankso@394
|
474 cook $pkg || broken
|
pankso@81
|
475 clean_exit ;;
|
al@728
|
476
|
pankso@31
|
477 cat|-c)
|
pankso@4
|
478 # Cook all packages of a category.
|
pankso@31
|
479 cat="$2"
|
al@728
|
480 rm -f $cooklist; touch $cooklist
|
al@728
|
481
|
al@728
|
482 cd $wok
|
al@728
|
483 for pkg in *; do
|
pascal@800
|
484 [ -s $pkg/receipt ] || continue
|
al@728
|
485 unset CATEGORY; . $pkg/receipt
|
pankso@4
|
486 [ "$CATEGORY" == "$cat" ] && echo $pkg >> $cooklist
|
pankso@4
|
487 done
|
pankso@14
|
488 strip_blocked
|
pankso@14
|
489 cook_order | tee $LOGS/cookorder.log
|
pankso@26
|
490 cook_list ;;
|
al@728
|
491
|
pankso@31
|
492 flavor|-f)
|
pankso@21
|
493 # Cook all packages of a flavor.
|
pankso@31
|
494 name="$2"
|
al@728
|
495 if [ ! -d "$flavors/$name" ]; then
|
al@728
|
496 echo -e "\nSpecified flavor does not exist: $name\n"
|
al@728
|
497 exit 1
|
al@728
|
498 fi
|
al@728
|
499 if [ -d "$flavors/.hg" ]; then
|
al@728
|
500 cd $flavors; hg pull -u
|
al@728
|
501 fi
|
al@728
|
502 list="$flavors/$name/packages.list"
|
pankso@21
|
503 cp -a $list $cooklist
|
pankso@21
|
504 strip_blocked
|
pankso@21
|
505 cook_order | tee $LOGS/cookorder.log
|
pankso@32
|
506 cook_list ;;
|
al@728
|
507
|
pankso@31
|
508 list|-l)
|
paul@54
|
509 # Cook a list of packages given in argument.
|
pankso@31
|
510 list="$2"
|
al@728
|
511 if [ ! -f "$list" ]; then
|
al@728
|
512 echo -e "\nSpecified list does not exist: $list\n"
|
al@728
|
513 exit 1
|
al@728
|
514 fi
|
pascal@774
|
515 cat $list >> $cooklist
|
pascal@774
|
516 echo -n > $list
|
pankso@26
|
517 strip_blocked
|
pankso@98
|
518 cook_order | tee $LOGS/cookorder.log
|
pankso@98
|
519 cook_list ;;
|
al@728
|
520
|
pankso@79
|
521 rev|-r)
|
pankso@79
|
522 # Cook or recook a specific Hg revision.
|
pankso@79
|
523 rev="$2"
|
pankso@79
|
524 [ "$rev" ] || exit 0
|
al@728
|
525 rm -f $cooklist; touch $cooklist
|
al@728
|
526
|
pankso@79
|
527 cd $wok
|
al@728
|
528 for pkg in $(hg log --rev=$rev --template "{files}"); do
|
al@728
|
529 echo "$pkg" | cut -d/ -f1 >> $cooklist
|
pankso@79
|
530 done
|
pankso@79
|
531 strip_blocked
|
pankso@26
|
532 cook_order | tee $LOGS/cookorder.log
|
pankso@26
|
533 cook_list ;;
|
al@728
|
534
|
pankso@31
|
535 all|-a)
|
pankso@4
|
536 # Try to build all unbuilt packages except blocked's.
|
al@728
|
537 echo 'cooker:all' > $command
|
al@728
|
538 rm -f $cooklist; touch $cooklist
|
al@942
|
539 title 'Cooker cooklist'
|
pankso@383
|
540
|
pankso@118
|
541 # Find all unbuilt packages. Get EXTRAVERSION from packed receipt
|
paul@132
|
542 # if it exists since extra version is added when packing the package.
|
al@728
|
543 echo 'Searching for all unbuilt packages' | log
|
al@728
|
544
|
al@728
|
545 cd $wok
|
al@728
|
546 for pkg in *; do
|
pascal@800
|
547 [ -s $pkg/receipt ] || continue
|
pankso@118
|
548 unset EXTRAVERSION
|
pankso@4
|
549 . $pkg/receipt
|
pankso@118
|
550 [ -f "$pkg/taz/$PACKAGE-$VERSION/receipt" ] && \
|
pankso@118
|
551 . $pkg/taz/$PACKAGE-$VERSION/receipt
|
al@728
|
552 if [ ! -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ]; then
|
al@728
|
553 echo $pkg; echo $pkg >> $cooklist
|
pankso@118
|
554 fi
|
pankso@4
|
555 done
|
pankso@14
|
556 strip_blocked
|
pankso@99
|
557 cook_order | tee $LOGS/cookorder.log
|
al@1090
|
558 echo "Receipts or stuff changed: $(wc -l < $cooklist)" | log
|
pankso@79
|
559 cook_list ;;
|
al@728
|
560
|
al@942
|
561 tasks|-T)
|
al@942
|
562 # List existing cooker tasks
|
al@942
|
563 [ ! -d "$tasks" ] && echo 'There are no tasks.' && exit 0
|
al@942
|
564 title 'Cooker tasks list'
|
al@942
|
565 last=$(ls $tasks | tail -n1)
|
al@942
|
566 for task in $(ls $tasks); do
|
al@942
|
567 . $tasks/$task
|
al@942
|
568 echo "Task name : $task"
|
al@942
|
569 echo "Description : $DESC"
|
al@942
|
570 separator $([ $task != $last ] && echo '-')
|
al@942
|
571 done
|
al@942
|
572 newline ;;
|
al@942
|
573
|
al@942
|
574 task|-t)
|
al@942
|
575 # Executing specified task
|
al@942
|
576 task="$2"
|
al@942
|
577 title "Executing cooker task: $task"
|
al@942
|
578 . $tasks/$task; task
|
al@942
|
579 footer "Task $task finished" ;;
|
al@942
|
580
|
al@957
|
581 outgoing|-o)
|
al@957
|
582 # Find changes in wok that we can move to wok-hg
|
al@957
|
583 compare_wok
|
al@957
|
584 ;;
|
al@957
|
585
|
al@1040
|
586 autodeps)
|
al@1040
|
587 # Find dependencies for all packages in wok
|
al@1040
|
588 cd $WOK
|
al@1040
|
589 for pkg in *; do
|
al@1040
|
590 cook $pkg --deps --quiet
|
al@1040
|
591 done | tee $cache/autodeps
|
al@1040
|
592 ;;
|
al@1040
|
593
|
pankso@4
|
594 *)
|
pankso@81
|
595 # Default is to cook all commits if not yet running.
|
al@728
|
596 [ -n "$1" ] && usage
|
slaxemulator@489
|
597 cooklist=$commits
|
pankso@81
|
598 if [ -f "$pidfile" ]; then
|
slaxemulator@488
|
599 pid=$(cat $pidfile)
|
pascal@274
|
600 if [ -s /proc/$pid/status ]; then
|
al@728
|
601 echo -e "\nStill cooking latest commits with pid:"
|
al@728
|
602 echo -e " $pid\n"
|
al@728
|
603 exit 0
|
pascal@274
|
604 fi
|
pascal@274
|
605 rm -f "$pidfile"
|
pankso@81
|
606 fi
|
pankso@81
|
607
|
pankso@81
|
608 # Start and get a PID file.
|
pankso@14
|
609 rm -f $LOGS/commits.log
|
slaxemulator@486
|
610 newline
|
al@728
|
611 echo 'Checking for commits' | log_commits
|
pankso@14
|
612 separator | tee -a $LOGS/commits.log
|
pankso@383
|
613
|
pankso@82
|
614 echo $$ > $pidfile
|
pankso@233
|
615 trap 'echo -e "\nCooker stopped: PID $$\n" && \
|
pankso@233
|
616 rm -f $pidfile $command && exit 1' INT TERM
|
pankso@383
|
617
|
pankso@82
|
618 echo "Cooker PID : $$" | log_commits
|
al@728
|
619 echo "Cooker date : $(date '+%F %T')" | log_commits
|
pankso@383
|
620
|
paul@132
|
621 # Get revisions. Here we have 2 echoes since we want a msg on screen,
|
paul@132
|
622 # in commits log and activity DB without a space before.
|
pankso@60
|
623 cd $wok || exit 1
|
pankso@4
|
624 cur=$(hg head --template '{rev}\n')
|
pankso@82
|
625 echo "Updating wok : ${wok}-hg (rev $cur)" | log_commits
|
pankso@82
|
626 echo "Updating wok: ${wok}-hg" | log
|
al@728
|
627 echo 'hg:pull' > $command
|
al@728
|
628 cd $wok-hg; hg pull -u | log_commits
|
pankso@4
|
629 new=$(hg head --template '{rev}\n')
|
paul@168
|
630 # Store last rev to be used by CGI so it doesn't need to call hg head
|
pankso@164
|
631 # on each load.
|
slaxemulator@488
|
632 echo "$new" > $wokrev
|
pankso@383
|
633
|
paul@54
|
634 # Sync build wok with rsync so we don't take care about removing old
|
pankso@4
|
635 # files as before.
|
pankso@4
|
636 if [ "$new" -gt "$cur" ]; then
|
pankso@4
|
637 echo "Changes found from: $cur to $new" | log
|
al@728
|
638 echo 'Syncing build wok with Hg wok...' | log_commits
|
al@728
|
639 rsync -r -t -c -l -u -v -D -E $wok-hg/ $wok/ | \
|
al@931
|
640 sed '/^$/d' | log_commits
|
pankso@4
|
641 else
|
pankso@13
|
642 echo "No revision changes: $cur vs $new" | log
|
pankso@14
|
643 separator | log_commits
|
al@728
|
644 clean_exit; newline
|
al@728
|
645 exit 0
|
pankso@4
|
646 fi
|
pankso@383
|
647
|
pankso@35
|
648 # Get and display modifications.
|
al@728
|
649 cd $wok-hg
|
pankso@110
|
650 commits_summary | log_commits
|
pankso@14
|
651 cur=$(($cur + 1))
|
al@728
|
652 rm -f $commits.tmp; touch $commits.tmp
|
al@728
|
653 for rev in $(seq $cur $new); do
|
al@728
|
654 for file in $(hg log --rev=$rev --template "{files}"); do
|
al@728
|
655 pkg=$(echo $file | cut -d/ -f1)
|
pankso@36
|
656 desc=$(hg log --rev=$rev --template "{desc}" $file)
|
paul@388
|
657 echo "Committed package : $pkg - $desc" | log_commits
|
pankso@80
|
658 echo $pkg >> $commits.tmp
|
pankso@4
|
659 done
|
pankso@4
|
660 done
|
pankso@248
|
661
|
pankso@248
|
662 # We may have deleted packages and files in stuff/. Remove it and
|
pankso@248
|
663 # clean DB as well as log file.
|
pankso@248
|
664 cd $wok
|
al@728
|
665 for pkg in *; do
|
al@1133
|
666 if [ ! -d "$wok-hg/$pkg" -o -e "$wok-hg/$pkg/.hidden" ]; then
|
pankso@248
|
667 echo "Removing package: $pkg" | log_commits
|
pascal@799
|
668 if [ -s $wok/$pkg/receipt ]; then
|
pascal@799
|
669 . $wok/$pkg/receipt
|
pascal@799
|
670 rm -f $PKGS/$PACKAGE-$VERSION*
|
pascal@799
|
671 fi
|
pascal@799
|
672 rm -rf $wok/$pkg $LOGS/$pkg.log
|
al@931
|
673 sed -i "/^${pkg}$/d" $blocked $broken $commits.tmp
|
al@1117
|
674 sed -i "/^$pkg\t/d" $PKGS/packages-$ARCH.info
|
al@989
|
675 sed -i "/^$pkg:/d" $cache/files.list
|
al@1126
|
676 sed -i "/^$pkg\t/d" $cache/badges
|
pankso@248
|
677 fi
|
al@921
|
678 if [ -d "$wok/$pkg/stuff" ]; then
|
al@921
|
679 if [ ! -d "$wok-hg/$pkg/stuff" ]; then
|
al@921
|
680 echo "Removing stuff: $pkg/stuff" | log_commits
|
al@922
|
681 rm -rf $wok/$pkg/stuff
|
al@921
|
682 else
|
al@922
|
683 for stuff_file in $(cd $wok/$pkg/stuff; find \( -type f -o -type l \) | sed 's|^\./||'); do
|
al@921
|
684 if [ ! -f "$wok-hg/$pkg/stuff/$stuff_file" -a \
|
al@921
|
685 ! -h "$wok-hg/$pkg/stuff/$stuff_file" ]; then
|
al@921
|
686 echo "Removing file from stuff: $wok/$pkg/stuff/$stuff_file" | log_commits
|
al@922
|
687 rm -f $wok/$pkg/stuff/$stuff_file
|
al@922
|
688 rmdir --parents --ignore-fail-on-non-empty $(dirname "$wok/$pkg/stuff/$stuff_file")
|
al@921
|
689 fi
|
al@921
|
690 done
|
al@921
|
691 fi
|
al@921
|
692 fi
|
pankso@248
|
693 done
|
pankso@383
|
694
|
paul@54
|
695 # Keep previous commit and discard duplicate lines
|
al@931
|
696 cat $commits $commits.tmp | sed '/^$/d' > $commits.new
|
al@728
|
697 uniq $commits.new > $commits; rm $commits.*
|
pankso@383
|
698
|
paul@388
|
699 # Handle cross compilation. Create arch packages DB and remove pkgs
|
pankso@383
|
700 # not cooked for this arch from the commits list.
|
pankso@677
|
701 arch_db
|
al@931
|
702 while read pkg; do
|
pankso@677
|
703 if [ ! -f "$wok/$pkg/arch.$ARCH" ]; then
|
pankso@677
|
704 echo "Cooker arch : skip $pkg (not included in: $ARCH)" | \
|
pankso@677
|
705 log_commits
|
al@931
|
706 sed -i "/^${pkg}$/d" $commits
|
pankso@677
|
707 else
|
pankso@677
|
708 echo "Cooker arch : $ARCH" | log_commits
|
pankso@677
|
709 fi
|
al@931
|
710 done < $commits
|
al@728
|
711
|
al@988
|
712 # Re-create split database
|
al@988
|
713 cook splitdb
|
al@988
|
714
|
pankso@383
|
715 # Stats
|
al@931
|
716 pkgs=$(wc -l < $commits)
|
pankso@100
|
717 echo "Packages to cook: $pkgs" | log
|
pankso@109
|
718 echo "Packages to cook : $pkgs" | log_commits
|
pankso@35
|
719 separator | log_commits
|
slaxemulator@486
|
720 newline
|
al@1090
|
721 # Just update the wok on --update, don't cook any package
|
al@1090
|
722 if [ -z "$update" ]; then
|
al@1090
|
723 strip_blocked
|
al@1090
|
724 cook_order | tee $LOGS/cookorder.log
|
al@1090
|
725 cook_commits
|
al@1090
|
726 fi
|
pankso@81
|
727 clean_exit ;;
|
pankso@4
|
728 esac
|
pankso@4
|
729
|
pankso@4
|
730 exit 0
|