wok view tazbb/stuff/tazbb @ rev 4963

tazbb: check meta flavors for refresh
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Feb 22 16:31:06 2010 +0100 (2010-02-22)
parents 169dee0cf4c5
children c40252b88f47
line source
1 #!/bin/sh
2 # Tazbb - SliTaz Build Bot.
3 # System wide config file: /etc/slitaz/tazbb.conf
4 #
5 # Tazbb is a tool to automate package building, it can be run manually
6 # or via a cron job. On SliTaz build host, tazbb is run in a chroot env.
7 #
8 # (c) 2009 SliTaz GNU/Linux project - GNU gpl v3
9 #
11 # Include config file or exit if no file found.
12 if [ -f "./tazbb.conf" ]; then
13 . ./tazbb.conf
14 elif [ -f "/etc/slitaz/tazbb.conf" ]; then
15 . /etc/slitaz/tazbb.conf
16 else
17 echo -e "\nNo config file found: tazbb.conf...\n" && exit 0
18 fi
20 # Tazbb is only for root.
21 if test $(id -u) != 0 ; then
22 echo -e "\nYou must be root to run: `basename $0`.\n" && exit 0
23 fi
25 # Let tazbb finish is work and make sure needed files exist.
26 if [ -f $LOCK_FILE ]; then
27 case $1 in
28 usage|list-*|*block)
29 continue ;;
30 *)
31 echo -e "\nTazbb is already running and locked...\n"
32 exit 0 ;;
33 esac
34 else
35 mkdir -p $DB_DIR $LOG_DIR
36 touch $LOCK_FILE $DB_DIR/blocked
37 fi
39 # Set KERNEL variable
40 if [ -s $BUILD_WOK/linux/receipt ]; then
41 . $BUILD_WOK/linux/receipt
42 KERNEL=$VERSION
43 fi
45 usage()
46 {
47 echo -e "\nSliTaz developers and build host tool\n
48 \033[1mUsage: \033[0m `basename $0` [command] [--option]
49 \033[1mCommands: \033[0m\n
50 usage Print this short usage and command list.
51 list-pkgs List last cooked packages with date.
52 report Run in report mode and dont cook anything [--verbose].
53 cook Cook, install and log a single package build.
54 cook-all Cook all missing, modified or unbuilt packages.
55 cook-commit Cook all packages affected by a commit in the last update.
56 test-pkgs Execute a test suite on all packages [--verbose].
57 [un]block Block or unblock a package to skip or enable building.
58 mail Send mail to package maintainer with tazbbmail.
59 clean-up Remove old packages [--verbose|--dry-run].
60 clean-log Remove all generated build log files.\n"
61 }
63 status()
64 {
65 local CHECK=$?
66 echo -en "\033[70G"
67 if [ $CHECK = 0 ]; then
68 echo "Done"
69 else
70 echo "Failed"
71 fi
72 return $CHECK
73 }
75 top_summary()
76 {
77 cat > $DB_DIR/summary << _EOT_
78 Update : `date`
79 Revision : $NEW_REV (<a href="$HG_URL/log/$NEW_REV">changelog</a>)
80 _EOT_
81 }
83 packages_summary()
84 {
85 if ! grep -q "^Packages" $DB_DIR/summary; then
86 cat >> $DB_DIR/summary << _EOT_
87 Packages : `ls $BUILD_WOK | wc -l` in the wok, `cat $DB_DIR/cooklist | wc -l` to cook, \
88 `cat $DB_DIR/blocked | wc -l` blocked, `cat $DB_DIR/corrupted | wc -l` corrupted
89 _EOT_
90 fi
91 }
93 packages_summary_update()
94 {
95 sed -i s/"[0-9]* in the wok"/"`ls $BUILD_WOK | wc -l` in the wok"/ \
96 $DB_DIR/summary
97 sed -i s/"[0-9]* to cook"/"`cat $DB_DIR/cooklist | wc -l` to cook"/ \
98 $DB_DIR/summary
99 sed -i s/"[0-9]* blocked"/"`cat $DB_DIR/blocked | wc -l` blocked"/ \
100 $DB_DIR/summary
101 sed -i s/"[0-9]* corrupted"/"`cat $DB_DIR/corrupted | wc -l` corrupted"/ \
102 $DB_DIR/summary
103 }
105 list_packages()
106 {
107 cd $PACKAGES_REPOSITORY
108 ls -1t *.tazpkg | head -20 | \
109 while read file
110 do
111 echo -n $(stat -c '%y' $PACKAGES_REPOSITORY/$file | cut -d. -f1)
112 echo " $file"
113 done
114 }
116 show_report()
117 {
118 echo "Cooklist"
119 echo "================================================================================"
120 cat $DB_DIR/cooklist && echo ""
121 echo "Packlist"
122 echo "================================================================================"
123 cat $DB_DIR/packlist && echo ""
124 echo "Blocked"
125 echo "================================================================================"
126 cat $DB_DIR/blocked && echo ""
127 echo ""
128 }
130 # URL encoding
131 escape()
132 {
133 echo $1 | sed -e 's/+/%2B/g' -e 's|/|%2F|g' -e 's/:/%3A/g'
134 }
136 update_wok()
137 {
138 local forced
139 forced=""
140 echo ""
141 echo "(updating flavors)" > $DB_DIR/running
142 cd $HG_FLAVORS
143 LAST_REV=`hg head --template '{rev}\n'`
144 hg pull && hg update
145 NEW_REV=`hg head --template '{rev}\n'`
146 if [ "$NEW_REV" != "$LAST_REV" ]; then
147 size=`du -sh $HG_FLAVORS | awk '{ print $1 }'`
148 echo -n "Copying Hg flavors to the build flavors ($size)... "
149 cp -a $HG_FLAVORS/* $BUILD_FLAVORS
150 cp -a $HG_FLAVORS/.hg $BUILD_FLAVORS
151 echo -e "Done\n"
152 forced="yes"
153 fi
154 echo "(updating wok)" > $DB_DIR/running
155 cd $HG_WOK
156 LAST_REV=`hg head --template '{rev}\n'`
157 hg pull && hg update
158 NEW_REV=`hg head --template '{rev}\n'`
159 # Gen a new summary and link last revision for the web interface.
160 echo -e "\nHg wok : $HG_WOK ($NEW_REV)"
161 echo -e "Build wok : $BUILD_WOK ($LAST_REV)\n"
162 top_summary
163 # Copy Hg wok if new revision or exit to stop process since nothing
164 # have change (--forced can be used).
165 if [ "$NEW_REV" != "$LAST_REV" ]; then
166 size=`du -sh $HG_WOK | awk '{ print $1 }'`
167 echo -n "Copying Hg wok to the build wok ($size)... "
168 #rsync -r -n -t $HG_WOK/ $BUILD_WOK/
169 cp -a $HG_WOK/* $BUILD_WOK
170 cp -a $HG_WOK/.hg $BUILD_WOK
171 echo -e "Done\n"
172 else
173 if [ "$1" = "cook-all" ] || [ "$1" = "cook-commit" ]; then
174 if [ "$2" != "--forced" -a -z "$forced" ]; then
175 echo -e "Nothing to cook...\n"
176 packages_summary
177 rm -f $LOCK_FILE && exit 0
178 fi
179 fi
180 fi
181 }
183 # Running 'tazbb report' should not pack anything and --verbose option
184 # can be used to display more messages.
185 check_flavors()
186 {
187 # Clean up last results.
188 rm -f $DB_DIR/packlist && touch $DB_DIR/packlist
189 echo ""
190 echo "Checking all files in: $HG_FLAVORS"
191 echo "================================================================================"
192 echo "(checking flavors)" > $DB_DIR/running
193 for flavor in $(cd $HG_FLAVORS ; ls)
194 do
195 [ "$2" = "--verbose" ] && echo "Flavor : $flavor"
196 if [ ! -s $PACKAGES_REPOSITORY/$flavor.flavor ]; then
197 echo $flavor >> $DB_DIR/packlist
198 [ "$1" = "report" ] && echo "Missing : $flavor"
199 echo "Missing flavor : $flavor" >> $DB_DIR/report
200 continue
201 fi
202 for i in $(find $HG_FLAVORS/$flavor -type f); do
203 [ $PACKAGES_REPOSITORY/$flavor.flavor -nt \
204 $i ] && continue
205 echo $flavor >> $DB_DIR/packlist
206 [ "$1" = "report" ] && echo "Refresh : $flavor for $i"
207 echo "Refresh flavor : $flavor" >> $DB_DIR/report
208 continue 2
209 done
210 [ -s $HG_FLAVORS/$flavor/packages.list ] &&
211 for i in $(cat $HG_FLAVORS/$flavor/packages.list); do
212 if [ ! -d $BUILD_WOK/$i ]; then
213 [ "$1" = "report" ] &&
214 echo "Fix flavor for $i: $flavor"
215 echo "Fix flavor for $i: $flavor" >> $DB_DIR/report
216 continue
217 fi
218 [ $PACKAGES_REPOSITORY/$flavor.flavor -nt \
219 $BUILD_WOK/$i/taz ] && continue
220 echo $flavor >> $DB_DIR/packlist
221 [ "$1" = "report" ] && echo "Repack : $flavor for $i"
222 echo "Repack flavor : $flavor" >> $DB_DIR/report
223 continue 2
224 done
225 done
227 # Check for meta flavors
228 for flavor in $(cd $HG_FLAVORS ; ls)
229 do
230 grep -q ^ROOTFS_SELECTION $HG_FLAVORS/$flavor/receipt || continue
231 . $HG_FLAVORS/$flavor/receipt
232 set -- $ROOTFS_SELECTION
233 if [ $PACKAGES_REPOSITORY/$2.flavor -nt \
234 $PACKAGES_REPOSITORY/$flavor.flavor ]; then
235 echo $flavor >> $DB_DIR/packlist
236 [ "$1" = "report" ] && echo "Refresh : $flavor for $2"
237 echo "Refresh meta flavor : $flavor" >> $DB_DIR/report
238 continue
239 fi
240 if grep -q ^$2$ $DB_DIR/packlist ; then
241 echo $flavor >> $DB_DIR/packlist
242 [ "$1" = "report" ] && echo "Repack : $flavor for $2"
243 echo "Repack meta flavor : $flavor" >> $DB_DIR/report
244 continue
245 fi
246 done
247 }
249 # Here we pack all flavors found in the packlist.
250 pack_flavors()
251 {
252 [ -s $DB_DIR/packlist ] || return
253 [ $PACKAGES_REPOSITORY/packages.list -nt /var/lib/tazpkg/packages.list ] &&
254 cp -a $PACKAGES_REPOSITORY/packages.list /var/lib/tazpkg/packages.list
255 cd $PACKAGES_REPOSITORY
256 for flavor in $(cat $DB_DIR/packlist)
257 do
258 tazlito pack-flavor $flavor
259 # Remove flavor from the packlist and empty lines for HTML <pre>.
260 sed -i /"^$flavor$"/d $DB_DIR/packlist
261 sed -i '/^$/d' $DB_DIR/packlist
262 done
263 cd - > /dev/null
264 }
266 # Running 'tazbb report' should not cook anything and --verbose option
267 # can be used to display more messages.
268 check_wok()
269 {
270 # Clean up last results.
271 rm -f $DB_DIR/cooklist && touch $DB_DIR/cooklist
272 rm -f $DB_DIR/report && touch $DB_DIR/report
273 rm -f $DB_DIR/unbuilt && touch $DB_DIR/unbuilt
274 echo "Checking all files in: $HG_WOK"
275 echo "================================================================================"
276 echo "(checking wok)" > $DB_DIR/running
277 for pkg in $HG_WOK/*
278 do
279 EXTRAVERSION=""
280 WANTED=""
281 . $pkg/receipt
282 [ "$2" = "--verbose" ] && echo "Package : $PACKAGE"
283 # Skip blocked packages.
284 if grep -qs "^$PACKAGE$" $DB_DIR/blocked; then
285 echo "Blocked : $PACKAGE ($VERSION)" && continue
286 fi
288 # Some packages may compute VERSION at cook time (bristuff)
289 if grep -q ^get_version $pkg/receipt; then
290 . $BUILD_WOK/$PACKAGE/taz/*/receipt
291 fi
293 # First check if package exit. Package naming _must_ be in the form of:
294 # $PACKAGE-$VERSION or $PACKAGE-${VERSION}$EXTRAVERSION (Kernel string).
295 if [ ! -f $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg ]; then
296 [ -z "$EXTRAVERSION" ] && EXTRAVERSION="_$KERNEL"
297 if [ ! -f $PACKAGES_REPOSITORY/$PACKAGE-${VERSION}$EXTRAVERSION.tazpkg ]; then
298 [ "$1" = "report" ] && echo "Missing : $PACKAGE ($VERSION)"
299 echo "Missing : $PACKAGE ($VERSION)" >> $DB_DIR/report
300 echo "$PACKAGE" >> $DB_DIR/cooklist
301 fi
302 else
303 # Check if package is up-to-date.
304 PKG_DATE=`date -u -r $PACKAGES_REPOSITORY/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg '+%Y%m%d%H%M'`
305 for file in `find $pkg -type f`
306 do
307 FILE_DATE=`date -u -r $file '+%Y%m%d%H%M'`
308 [ "$2" = "--verbose" ] && echo " -> Checking: $file"
309 if [ "$FILE_DATE" -gt "$PKG_DATE" ] && ! grep -q $PACKAGE $DB_DIR/cooklist; then
310 [ "$1" = "report" ] && echo "Refresh : $PACKAGE ($VERSION)"
311 echo "Refresh : $PACKAGE ($VERSION)" >> $DB_DIR/report
312 echo "$PACKAGE" >> $DB_DIR/cooklist
313 fi
314 done
315 fi
316 # Now check if package is built and not already in the list.
317 if [ ! -d $BUILD_WOK/$PACKAGE/taz ] && ! grep -q $PACKAGE $DB_DIR/cooklist; then
318 [ "$1" = "report" ] && echo "Unbuilt : $PACKAGE ($VERSION)"
319 echo "Unbuilt : $PACKAGE ($VERSION)" >> $DB_DIR/report
320 echo "$PACKAGE" >> $DB_DIR/cooklist
321 fi
322 # Rebuild unbuilt packages list with link to log file. This list
323 # is also generated by cook_inslall to have real time stats.
324 if [ ! -d $BUILD_WOK/$PACKAGE/taz ]; then
325 echo "<a href=\"log.php?package=$(escape $PACKAGE)\">$PACKAGE</a>" \
326 >> $DB_DIR/unbuilt
327 fi
328 done
329 packages_summary
330 }
332 # Create a new cooklist and summary (dont modify report) so 'tazbb cook-commit'
333 # can cook last changes.
334 check_commit()
335 {
336 echo "(checking commit)" > $DB_DIR/running
337 cd $HG_WOK
338 # Clean up last results.
339 rm -f $DB_DIR/cooklist && touch $DB_DIR/cooklist
340 # Get the name of modified packages by the revision range. +1 last
341 # commit was build by the previous build.
342 LAST_REV=$(($LAST_REV+1))
343 echo -e "Will cook from revision $LAST_REV to $NEW_REV\n"
344 for file in `hg log --rev=$LAST_REV:$NEW_REV --template '{files}\n'`
345 do
346 pkg=`echo $file | cut -d "/" -f 1`
347 if ! grep -q ^$pkg$ $DB_DIR/cooklist; then
348 . $pkg/receipt
349 echo "Commit : $PACKAGE ($VERSION)" >> $DB_DIR/report
350 echo "$PACKAGE" >> $DB_DIR/cooklist
351 fi
352 done
353 packages_summary
354 }
356 # Cook one package
357 cook_package()
358 {
359 EXTRAVERSION=""
360 DEPENDS=""
361 BUILD_DEPENDS=""
362 SOURCE=""
363 WANTED=""
364 echo "(cooking <a href=\"log.php?package=$(escape $pkg)\">$pkg</a>)" > $DB_DIR/running
365 tazwok clean $pkg
366 script -c "echo 'install' | tazwok cook $pkg" $LOG_DIR/$pkg.log
367 # Install new package (important for new shared libs). Note
368 # that tests are done separatly with 'test_packages' and should
369 # be done by tazwok.
370 if [ -f $BUILD_WOK/$pkg/taz/*/receipt ]; then
371 . $BUILD_WOK/$pkg/taz/*/receipt
372 echo "(installing $PACKAGE-${VERSION}$EXTRAVERSION.tazpkg)" \
373 > $DB_DIR/running
374 yes | tazpkg install \
375 $PACKAGES_REPOSITORY/$PACKAGE-${VERSION}$EXTRAVERSION.tazpkg \
376 --forced
377 return 0
378 fi
379 return 1
380 }
382 # Sort list according WANTED and BUILD_DEPENDS
383 sort_cook_list()
384 {
385 sort | while read pkg; do
386 echo -n "$pkg"
387 WANTED=""
388 BUILD_DEPENDS=""
389 . $BUILD_WOK/$pkg/receipt
390 MISSING=""
391 for i in $WANTED $BUILD_DEPENDS ; do
392 if [ ! -f $BUILD_WOK/$i/taz/*/receipt ]; then
393 case " $MISSING " in
394 *\ $i\ *);;
395 *) echo -n " $i";;
396 esac
397 MISSING="$MISSING $i"
398 fi
399 done
400 echo ""
401 done | awk '
402 function show(name)
403 {
404 print name;
405 got[name]++;
406 if (revdepcnt[name] > 0)
407 for (i = split(revdep[name], pkg, " "); i > 0; i--)
408 if (--depcnt[pkg[i]] == 0) show(pkg[i]);
409 }
411 {
412 if ($2 == "") show($1);
413 else {
414 depcnt[$1] = NF - 1;
415 unres = unres " " $1;
416 for (i = 2; i <= NF; i++) {
417 if (got[$i] > 0) continue;
418 revdepcnt[$i]++;
419 revdep[$i] = revdep[$i] " " $1;
420 }
421 }
422 }
423 END {
424 for (i = split(unres, pkg, " "); i > 0; i--)
425 if (depcnt[pkg[i]] > 0) print pkg[i];
426 }
427 '
428 }
430 # Here we cook all packages found in the cooklist.
431 cook_install()
432 {
433 echo "" > $DB_DIR/unbuilt
434 for pkg in `cat $DB_DIR/cooklist | sort_cook_list`
435 do
436 if ! cook_package $pkg; then
437 # Link to build log.
438 echo "<a href=\"log.php?package=$(escape $pkg)\">$pkg</a>" >> \
439 $DB_DIR/unbuilt
440 fi
441 # Remove package from the cooklist and empty lines for HTML <pre>.
442 sed -i /"^$pkg$"/d $DB_DIR/cooklist
443 sed -i '/^$/d' $DB_DIR/cooklist
444 packages_summary_update
445 done
446 }
448 # Remove old packages in the build wok and clean pkgs repository. The
449 # Hg wok is copied into the build wok so packages removed by hg must be
450 # removed. To remove old packages in the repository we look into the
451 # build wok and dont remove unbuilt packages. Clean-up will also remove
452 # all corrupted packages.
453 clean_up()
454 {
455 touch $DB_DIR/removed
456 echo -e "\nCleaning the build wok, old and corrupted packages...\n"
457 echo "(cleaning)" > $DB_DIR/running
458 for pkg in `ls $BUILD_WOK`
459 do
460 if [ ! -d $HG_WOK/$pkg ]; then
461 case $2 in
462 --dry-run)
463 echo "Removing directory : $pkg" ;;
464 --verbose)
465 echo "Removing directory : $pkg"
466 rm -rf $BUILD_WOK/$pkg ;;
467 *)
468 rm -rf $BUILD_WOK/$pkg ;;
469 esac
470 fi
471 done
472 # Build a packages list with EXTRAVERSION so we can grep into it.
473 rm -f $DB_DIR/packaged && touch $DB_DIR/packaged
474 for receipt in $BUILD_WOK/*/taz/*/receipt
475 do
476 EXTRAVERSION=""
477 . $receipt
478 echo "$PACKAGE-${VERSION}$EXTRAVERSION.tazpkg" >> $DB_DIR/packaged
479 done
480 for pkg in `cd $PACKAGES_REPOSITORY && ls *.tazpkg`
481 do
482 if ! grep -q "^$pkg$" $DB_DIR/packaged; then
483 case $2 in
484 --dry-run)
485 echo "Removing package : $pkg" ;;
486 --verbose)
487 echo "Removing package : $pkg"
488 echo "$pkg" >> $DB_DIR/removed
489 rm -f $PACKAGES_REPOSITORY/$pkg ;;
490 *)
491 echo "$pkg" >> $DB_DIR/removed
492 rm -f $PACKAGES_REPOSITORY/$pkg ;;
493 esac
494 fi
495 done
496 # Remove all corrupted packages
497 for pkg in `cat $DB_DIR/corrupted | awk '{ print $3 }'`
498 do
499 case $2 in
500 --dry-run)
501 echo "Removing corrupted: $pkg" ;;
502 --verbose)
503 echo "Removing corrupted: $pkg"
504 echo "$pkg" >> $DB_DIR/removed
505 rm -rf $PACKAGES_REPOSITORY/$pkg ;;
506 *)
507 echo "$pkg" >> $DB_DIR/removed
508 rm -rf $PACKAGES_REPOSITORY/$pkg ;;
509 esac
510 done
511 echo ""
512 # Keep the 20 last removed packages list.
513 cat $DB_DIR/removed | tail -n 20 > /tmp/removed.tail
514 mv -f /tmp/removed.tail $DB_DIR/removed
515 }
517 blocked_urls()
518 {
519 rm -f $DB_DIR/blocked.urls
520 for pkg in `cat $DB_DIR/blocked`
521 do
522 if [ -f $LOG_DIR/$pkg.log ]; then
523 echo "<a href=\"log.php?package=$(escape $pkg)\">$pkg</a>" >> \
524 $DB_DIR/blocked.urls
525 else
526 echo "$pkg" >> $DB_DIR/blocked.urls
527 fi
528 done
529 }
531 # 4k, not a meta or a get-* package and no files = buggy package
532 test_packages()
533 {
534 echo -e "\nTesting all packages in: $PACKAGES_REPOSITORY"
535 echo "================================================================================"
536 echo "(testing packages)" > $DB_DIR/running
537 rm -f $DB_DIR/corrupted && touch $DB_DIR/corrupted
538 for pkg in $PACKAGES_REPOSITORY/*.tazpkg
539 do
540 tmp=/tmp/bb-test.$$
541 CATEGORY=""
542 if du $pkg | grep -qw '^4' && ! echo `basename $pkg` | grep -q '^get-'; then
543 mkdir -p $tmp && cd $tmp
544 cpio -i receipt >/dev/null 2>&1 < $pkg
545 . ./receipt
546 if [ "$CATEGORY" != "meta" ]; then
547 [ "$2" = "--verbose" ] && echo "Testing: $PACKAGE"
548 cpio -i fs.cpio.gz fs.cpio.lzma >/dev/null 2>&1 < $pkg
549 if [ ! -f fs.cpio.gz -a ! -f fs.cpio.lzma ]; then
550 echo "Missing filesystem `basename $pkg`"
551 if [ -f $LOG_DIR/$PACKAGE.log ];then
552 echo "Missing filesystem `basename $pkg` <a href=\"log.php?package=$(escape $PACKAGE)\">Log</a>" \
553 >> $DB_DIR/corrupted
554 else
555 echo "Missing filesystem `basename $pkg`" \
556 >> $DB_DIR/corrupted
557 fi
558 else
559 ( zcat fs.cpio.gz 2> /dev/null || \
560 unlzma -c fs.cpio.lzma ) | \
561 cpio -id >/dev/null 2>&1
562 files=`find fs -type f -o -type l`
563 if [ -z "$files" ]; then
564 echo "Empty filesystem `basename $pkg`"
565 if [ -f $LOG_DIR/$PACKAGE.log ]; then
566 echo "Empty filesystem `basename $pkg` <a href=\"log.php?package=$(escape $PACKAGE)\">Log</a>" \
567 >> $DB_DIR/corrupted
568 else
569 echo "Empty filesystem `basename $pkg`" \
570 >> $DB_DIR/corrupted
571 fi
572 fi
573 fi
574 fi
575 cd .. && rm -rf $tmp
576 fi
577 done
578 packages_summary_update
579 echo ""
580 }
582 # Generate flavor list
583 gen_flavor_list()
584 {
585 cd $PACKAGES_REPOSITORY
586 noheader=""
587 for i in *.flavor; do
588 tazlito show-flavor $i --brief $noheader
589 noheader="--noheader"
590 done > flavors.list
591 cd - > /dev/null
592 }
594 case "$1" in
595 list-pkgs)
596 # List last cooked packages.
597 list_packages ;;
598 report)
599 # Run in report mode. If an update is done we must cook-all to
600 # rebuild all updated packages.
601 [ "$2" == "--update" ] && update_wok $@ || echo ""
602 check_wok $@
603 check_flavors $@
604 test_packages $@
605 show_report ;;
606 cook)
607 # Cook, install and log a single package build.
608 if [ -z $2 ]; then
609 echo "Please specify a package on the command line."
610 rm -f $LOCK_FILE && exit 0
611 fi
612 pkg=$2
613 echo "Starting to cook and install: $pkg"
614 if ! cook_package $pkg; then
615 echo "Unable to install: $pkg"
616 fi ;;
617 cook-all)
618 # Update wok, gen report (with cooklist), cook all packages, test,
619 # clean, gen new report and lists.
620 update_wok $@
621 check_wok $@
622 cook_install
623 test_packages $@
624 clean_up $@
625 check_wok $@
626 echo "(generating lists)" > $DB_DIR/running
627 tazwok gen-list --text
628 check_flavors $@
629 pack_flavors
630 gen_flavor_list
631 echo "" ;;
632 cook-commit)
633 # Cook all packages affected by the last commits in the wok.
634 # Clean up is done only by cook-all to avoid rebuild of corrupted
635 # packages on each commit.
636 update_wok $@
637 check_commit
638 cook_install
639 test_packages $@
640 check_wok $@
641 echo "(generating lists)" > $DB_DIR/running
642 tazwok gen-list --text
643 check_flavors $@
644 pack_flavors
645 gen_flavor_list
646 echo "" ;;
647 block)
648 # Add a pkg name to the list of blocked packages.
649 echo ""
650 if grep -qs "^$2$" $DB_DIR/blocked; then
651 echo -e "$2 is already in the blocked packages list."
652 else
653 echo -n "Adding $2 to : $DB_DIR/blocked... "
654 echo "$2" >> $DB_DIR/blocked && echo "Done"
655 if grep -q "^$2$" $DB_DIR/cooklist; then
656 echo -n "Removing $2 from : $DB_DIR/cooklist... "
657 sed -i /"^$2$"/d $DB_DIR/cooklist && echo "Done"
658 packages_summary_update
659 fi
660 fi
661 blocked_urls
662 echo "" ;;
663 unblock)
664 # Remove a pkg name from the list of blocked packages.
665 echo ""
666 if grep -qs "^$2$" $DB_DIR/blocked; then
667 echo -n "Removing $2 from : $DB_DIR/blocked... "
668 sed -i /"^$2$"/d $DB_DIR/blocked
669 sed -i '/^$/d' $DB_DIR/blocked && echo "Done"
670 echo -n "Adding $2 to : $DB_DIR/cooklist... "
671 echo "$2" >> $DB_DIR/cooklist && echo "Done"
672 packages_summary_update
673 else
674 echo -e "$2 is not in the blocked packages list."
675 fi
676 blocked_urls
677 echo "" ;;
678 test-pkgs)
679 # Start a test suite on all builded packages.
680 test_packages $@ ;;
681 test-suite)
682 # Start a test suite on all builded package and the wok using
683 # the great 'tazwok check'.
684 #
685 # test_packages > $LOG_DIR/test-suite.log
686 # tazwok check >> $LOG_DIR/test-suite.log
687 #
688 test_packages $@
689 script -c "tazwok check" $LOG_DIR/test-suite.log ;;
690 mail)
691 # Tazbbmail Pythom script wrapper.
692 PACKAGE=$2
693 tazbbmail $PACKAGE ;;
694 clean-up)
695 # Remove old packages and generate new packages lists.
696 update_wok $@
697 clean_up $@
698 packages_summary_update
699 [ "$2" != "--dry-run" ] && tazwok gen-list --text ;;
700 clean-log)
701 logs=`ls $LOG_DIR | wc -l`
702 echo -n "Cleaning: $LOG_DIR... "
703 rm -rf $LOG_DIR/*
704 echo "$logs log removed" ;;
705 *)
706 usage ;;
707 esac
709 echo "" > $DB_DIR/running
710 rm -f $LOCK_FILE
712 exit 0