cookutils view cook @ rev 358

We may need LDFLAGS
author Christophe Lincoln <pankso@slitaz.org>
date Thu Apr 26 13:34:41 2012 +0200 (2012-04-26)
parents 4662001db93f
children 740cd63ddb41
line source
1 #!/bin/sh
2 #
3 # Cook - A tool to cook and generate SliTaz packages. Read the README
4 # before adding or modifing any code in cook!
5 #
6 # Copyright (C) SliTaz GNU/Linux - GNU gpl v3
7 # Author: Christophe Lincoln <pankso@slitaz.org>
8 #
10 [ -f "/etc/slitaz/cook.conf" ] && . /etc/slitaz/cook.conf
11 [ -f "cook.conf" ] && . ./cook.conf
13 # Share DB and status with the Cooker.
14 activity="$CACHE/activity"
15 command="$CACHE/command"
16 broken="$CACHE/broken"
17 blocked="$CACHE/blocked"
19 # Old style compatibility
20 SOURCES_REPOSITORY=$SRC
22 #
23 # Functions
24 #
26 usage() {
27 cat << EOT
29 $(echo -e "\033[1m$(gettext "Usage:")\033[0m") cook [package|command] [list|--option]
31 $(echo -e "\033[1m$(gettext "Commands:")\033[0m")
32 usage|help $(gettext "Display this short usage.")
33 setup $(gettext "Setup your build environment.")
34 test $(gettext "Test environment and cook a package.")
35 list-wok $(gettext "List packages in the wok.")
36 search $(gettext "Simple packages search function.")
37 new $(gettext "Create a new package with a receipt".)
38 list $(gettext "Cook a list of packages.")
39 clean-wok $(gettext "Clean-up all packages files.")
40 clean-src $(gettext "Clean-up all packages sources.")
41 pkgdb $(gettext "Create packages DB lists and flavors.")
43 $(echo -e "\033[1m$(gettext "Options:")\033[0m")
44 --clean|-c Cook : $(gettext "clean the package in the wok.")
45 --install|-i Cook : $(gettext "cook and install the package.")
46 --getsrc|-gs Cook : $(gettext "get the package source tarball.")
47 --block|-b Cook : $(gettext "Block a package so cook will skip it.")
48 --unblock|-ub Cook : $(gettext "Unblock a blocked package.")
49 --interactive|-x New : $(gettext "create a receipt interactively.")
50 --wok|-w Setup: $(gettext "clone the cooking wok from Hg repo.")
51 --stable Setup: $(gettext "clone the stable wok from Hg repo.")
52 --undigest Setup: $(gettext "clone the undigest wok from Hg repo.")
53 --flavors Pkgdb: $(gettext "create up-to-date flavors files.")
55 EOT
56 exit 0
57 }
59 # Be sure we're root.
60 check_root() {
61 [ $(id -u) != 0 ] && gettext -e "\nYou must be root to cook.\n\n" && exit 0
62 }
64 separator() {
65 echo "================================================================================"
66 }
68 status() {
69 echo -en "\\033[70G[ "
70 if [ $? = 0 ]; then
71 echo -en "\\033[1;32mOK"
72 else
73 echo -en "\\033[1;31mFailed"
74 fi
75 echo -e "\\033[0;39m ]"
76 }
78 # Log activities, we want first letter capitalized.
79 log() {
80 grep ^[A-Z] | \
81 sed s"#^[A-Z]\([^']*\)#$(date '+%Y-%m-%d %H:%M') : \0#" >> $activity
82 }
84 # We don't want these escapes in web interface.
85 clean_log() {
86 sed -i -e s'|\[70G\[ \[1;32m| |' \
87 -e s'|\[0;39m \]||' $LOGS/$pkg.log
88 }
90 # Log broken packages.
91 broken() {
92 if ! grep -q "^$pkg$" $broken; then
93 echo "$pkg" >> $broken
94 fi
95 }
97 # Be sure package exists in wok.
98 check_pkg_in_wok() {
99 if [ ! -d "$WOK/$pkg" ]; then
100 gettext -e "\nUnable to find package in the wok:"
101 echo -e " $pkg\n" && exit 1
102 fi
103 }
105 if_empty_value() {
106 if [ -z "$value" ]; then
107 gettext "QA: empty variable:"; echo -e " ${var}=\"\"\n"
108 exit 1
109 fi
110 }
112 # Initialize files used in $CACHE
113 init_db_files() {
114 gettext "Creating directories structure in:"; echo " $SLITAZ"
115 mkdir -p $WOK $PKGS $SRC $CACHE $LOGS
116 gettext "Creating DB files in:"; echo " $CACHE"
117 for f in $activity $command $broken $blocked
118 do
119 touch $f
120 done
121 }
123 # QA: check a receipt consistency before building.
124 receipt_quality() {
125 gettext -e "QA: checking package receipt...\n"
126 unset online
127 if ifconfig | grep -q -A 1 "^[a-z]*[0-9]" | fgrep 'addr:'; then
128 online="online"
129 fi
130 for var in PACKAGE VERSION CATEGORY SHORT_DESC MAINTAINER WEB_SITE
131 do
132 unset value
133 value="$(. $receipt ; eval echo \$$var)"
134 case "$var" in
135 PACKAGE|VERSION|SHORT_DESC)
136 if_empty_value ;;
137 CATEGORY)
138 [ -z "$value" ] && value="empty"
139 valid="base-system x-window utilities network graphics \
140 multimedia office development system-tools security games \
141 misc meta non-free"
142 if ! echo "$valid" | grep -q -w "$value"; then
143 gettext "QA: unknown category:"; echo -e " $value\n"
144 exit 1
145 fi ;;
146 WEB_SITE)
147 # We don't check WGET_URL since if dl is needed it will fail.
148 # Break also if we're not online. Here error is not fatal.
149 if_empty_value
150 [ -z "$online" ] || break
151 if ! busybox wget -T 12 -s $value 2>/dev/null; then
152 gettext "QA: Unable to reach:"; echo -e " $value"
153 fi ;;
154 esac
155 done
156 }
158 # Executed before sourcing a receipt.
159 unset_receipt() {
160 unset DEPENDS BUILD_DEPENDS WANTED EXTRAVERSION WGET_URL PROVIDE TARBALL
161 }
163 # Paths used in receipt and by cook itself.
164 set_paths() {
165 pkgdir=$WOK/$PACKAGE
166 src=$pkgdir/source/$PACKAGE-$VERSION
167 taz=$pkgdir/taz
168 pack=$taz/$PACKAGE-${VERSION}${EXTRAVERSION}
169 fs=$pack/fs
170 stuff=$pkgdir/stuff
171 install=$pkgdir/install
172 if [ "$WANTED" ]; then
173 wanted=${WANTED%% *}
174 src=$WOK/$wanted/source/$wanted-$VERSION
175 install=$WOK/$wanted/install
176 wanted_stuff=$WOK/$wanted/stuff
177 fi
178 # Kernel version is set from linux-api-headers since it is part of toolchain.
179 if [ -f "$INSTALLED/linux-api-headers/receipt" ]; then
180 kvers=$(grep ^VERSION= $INSTALLED/linux-api-headers/receipt | cut -d '"' -f 2)
181 fi
182 # Old way compatibility.
183 _pkg=$install
184 }
186 # Create source tarball when URL is a SCM.
187 create_tarball() {
188 gettext "Creating tarball: "; echo "$tarball"
189 if [ "$LZMA_SRC" ]; then
190 tar -c $pkgsrc | lzma e $SRC/$tarball -si || exit 1
191 else
192 tar cjf $tarball $pkgsrc || exit 1
193 mv $tarball $SRC && rm -rf $pkgsrc
194 fi
195 }
197 # Get package source. For SCM we are in cache so clone here and create a
198 # tarball here.
199 get_source() {
200 pwd=$(pwd)
201 pkgsrc=${SOURCE:-$PACKAGE}-$VERSION
202 tarball=$pkgsrc.tar.bz2
203 [ "$LZMA_SRC" ] && tarball=$pkgsrc.tar.lzma
204 case "$WGET_URL" in
205 http://*|ftp://*)
206 # Busybox Wget is better!
207 busybox wget -T 60 -c -O $SRC/$TARBALL $WGET_URL || \
208 (echo -e "ERROR: wget $WGET_URL" && exit 1) ;;
209 https://*)
210 wget -c --no-check-certificate -O $SRC/$TARBALL $WGET_URL || \
211 (echo -e "ERROR: wget $WGET_URL" && exit 1) ;;
212 hg*|mercurial*)
213 if $(echo "$WGET_URL" | fgrep -q "hg|"); then
214 url=${WGET_URL#hg|}
215 else
216 url=${WGET_URL#mercurial|}
217 fi
218 gettext -e "Getting source from Hg...\n"
219 echo "URL: $url"
220 gettext "Cloning to: "; echo "$pwd/$pkgsrc"
221 if [ "$BRANCH" ]; then
222 echo "Hg branch: $BRANCH"
223 hg clone $url --rev $BRANCH $pkgsrc || \
224 (echo "ERROR: hg clone $url --rev $BRANCH" && exit 1)
225 else
226 hg clone $url $pkgsrc || (echo "ERROR: hg clone $url" && exit 1)
227 fi
228 rm -rf $pkgsrc/.hg
229 create_tarball ;;
230 git*)
231 url=${WGET_URL#git|}
232 gettext -e "Getting source from Git...\n"
233 echo "URL: $url"
234 git clone $url $pkgsrc || (echo "ERROR: git clone $url" && exit 1)
235 if [ "$BRANCH" ]; then
236 echo "Git branch: $BRANCH"
237 cd $pkgsrc && git checkout $BRANCH && cd ..
238 fi
239 create_tarball ;;
240 cvs*)
241 url=${WGET_URL#cvs|}
242 mod=$PACKAGE
243 [ "$CVS_MODULE" ] && mod=$CVS_MODULE
244 gettext -e "Getting source from CVS...\n"
245 echo "URL: $url"
246 [ "$CVS_MODULE" ] && echo "CVS module: $mod"
247 gettext "Cloning to: "; echo "$pwd/$mod"
248 cvs -d:$url co $mod && mv $mod $pkgsrc
249 create_tarball ;;
250 svn*|subversion*)
251 if $(echo "$WGET_URL" | fgrep -q "svn|"); then
252 url=${WGET_URL#svn|}
253 else
254 url=${WGET_URL#subversion|}
255 fi
256 gettext -e "Getting source from SVN...\n"
257 echo "URL: $url"
258 if [ "$BRANCH" ]; then
259 echo t | svn co $url -r $BRANCH $pkgsrc
260 else
261 echo t | svn co $url $pkgsrc
262 fi
263 create_tarball ;;
264 *)
265 gettext -e "\nERROR: Unable to handle:"; echo -e " $WGET_URL \n" | \
266 tee -a $LOGS/$PACKAGE.log
267 exit 1 ;;
268 esac
269 }
271 # Extract source package.
272 extract_source() {
273 if [ ! -s "$SRC/$TARBALL" ]; then
274 local url
275 url="http://mirror.slitaz.org/sources/packages"
276 url=$url/${TARBALL:0:1}/$TARBALL
277 gettext "Getting source from mirror:"; echo " $url"
278 busybox wget -c -P $SRC $url || echo -e "ERROR: wget $url"
279 fi
280 gettext "Extracting:"; echo " $TARBALL"
281 case "$TARBALL" in
282 *.tar.gz|*.tgz) tar xzf $SRC/$TARBALL 2>/dev/null ;;
283 *.tar.bz2|*.tbz|*.tbz2) tar xjf $SRC/$TARBALL 2>/dev/null ;;
284 *.tar.lzma) tar xaf $SRC/$TARBALL ;;
285 *.tar) tar xf $SRC/$TARBALL ;;
286 *.zip|*.xpi) unzip -o $SRC/$TARBALL ;;
287 *.xz) unxz -c $SRC/$TARBALL | tar xf - ;;
288 *.Z) uncompress -c $SRC/$TARBALL | tar xf - ;;
289 *.rpm) rpm2cpio $SRC/$TARBALL | cpio -idm --quiet ;;
290 *.run) /bin/sh $SRC/$TARBALL $RUN_OPTS ;;
291 *) cp $SRC/$TARBALL $(pwd) ;;
292 esac
293 }
295 # Display cooked package summary.
296 summary() {
297 cd $WOK/$pkg
298 [ -d install ] && prod=$(du -sh install | awk '{print $1}' 2>/dev/null)
299 fs=$(du -sh taz/* | awk '{print $1}')
300 size=$(du -sh $PKGS/$pkg-${VERSION}*.tazpkg | awk '{print $1}')
301 files=$(cat taz/$pkg-*/files.list | wc -l)
302 cookdate=$(date "+%Y-%m-%d %H:%M")
303 sec=$time
304 div=$(( ($time + 30) / 60))
305 [ "$div" != 0 ] && min="~ ${div}m"
306 gettext "Summary for:"; echo " $PACKAGE $VERSION"
307 separator
308 [ "$prod" ] && echo "Produced : $prod"
309 cat << EOT
310 Packed : $fs
311 Compressed : $size
312 Files : $files
313 Cook time : ${sec}s $min
314 Cook date : $cookdate
315 $(separator)
316 EOT
317 }
319 # Display debugging error info.
320 debug_info() {
321 echo -e "\nDebug information"
322 separator
323 echo "Cook date: $(date '+%Y-%m-%d %H:%M')"
324 for error in \
325 ERROR "No package" "cp: can't" "can't open" "can't cd" \
326 "error:" "fatal error:"
327 do
328 fgrep "$error" $LOGS/$pkg.log
329 done
330 separator && echo ""
331 }
333 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
334 # so some packages need to copy these files with the receipt and genpkg_rules.
335 copy_generic_files()
336 {
337 # $LOCALE is set in cook.conf
338 if [ "$LOCALE" ]; then
339 if [ -d "$install/usr/share/locale" ]; then
340 mkdir -p $fs/usr/share/locale
341 for i in $LOCALE
342 do
343 if [ -d "$install/usr/share/locale/$i" ]; then
344 cp -a $install/usr/share/locale/$i $fs/usr/share/locale
345 fi
346 done
347 fi
348 fi
350 # Generic pixmaps copy can be disabled with GENERIC_PIXMAPS="no"
351 if [ "$GENERIC_PIXMAPS" != "no" ]; then
352 if [ -d "$install/usr/share/pixmaps" ]; then
353 mkdir -p $fs/usr/share/pixmaps
354 cp -a $install/usr/share/pixmaps/$PACKAGE.png \
355 $fs/usr/share/pixmaps 2>/dev/null || continue
356 cp -a $install/usr/share/pixmaps/$PACKAGE.xpm \
357 $fs/usr/share/pixmaps 2>/dev/null || continue
358 fi
360 # Custom or homemade PNG pixmap can be in stuff.
361 if [ -f "$stuff/$PACKAGE.png" ]; then
362 mkdir -p $fs/usr/share/pixmaps
363 cp -a $stuff/$PACKAGE.png $fs/usr/share/pixmaps
364 fi
365 fi
367 # Desktop entry (.desktop).
368 # Generic desktop entry copy can be disabled with GENERIC_MENUS="no"
369 if [ "$GENERIC_MENUS" != "no" ]; then
370 if [ -d "$install/usr/share/applications" ] && [ "$WANTED" == "" ]; then
371 cp -a $install/usr/share/applications $fs/usr/share
372 fi
373 fi
375 # Homemade desktop file(s) can be in stuff.
376 if [ -d "$stuff/applications" ]; then
377 mkdir -p $fs/usr/share
378 cp -a $stuff/applications $fs/usr/share
379 fi
380 if [ -f "$stuff/$PACKAGE.desktop" ]; then
381 mkdir -p $fs/usr/share/applications
382 cp -a $stuff/$PACKAGE.desktop $fs/usr/share/applications
383 fi
384 }
386 # Find and strip : --strip-all (-s) or --strip-debug on static libs as well
387 # as removing uneeded files like in Python packages.
388 strip_package()
389 {
390 gettext "Executing strip on all files..."
391 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
392 do
393 if [ -d "$dir" ]; then
394 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
395 fi
396 done
397 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
398 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
399 status
401 # Remove Python .pyc and .pyo from packages.
402 if echo "$PACKAGE $DEPENDS" | fgrep -q "python"; then
403 gettext "Removing Python compiled files..."
404 find $fs -type f -name "*.pyc" -delete 2>/dev/null
405 find $fs -type f -name "*.pyo" -delete 2>/dev/null
406 status
407 fi
409 # Remove Perl perllocal.pod and .packlist from packages.
410 if echo "$DEPENDS" | fgrep -q "perl"; then
411 gettext "Removing Perl compiled files..."
412 find $fs -type f -name "perllocal.pod" -delete 2>/dev/null
413 find $fs -type f -name ".packlist" -delete 2>/dev/null
414 status
415 fi
416 }
418 # Remove installed deps.
419 remove_deps() {
420 # Now remove installed build deps.
421 diff="$CACHE/installed.cook.diff"
422 if [ -s "$CACHE/installed.cook.diff" ]; then
423 deps=$(cat $diff | grep ^+[a-zA-Z0-9] | sed s/^+//)
424 nb=$(cat $diff | grep ^+[a-zA-Z0-9] | wc -l)
425 gettext "Build dependencies to remove:"; echo " $nb"
426 gettext "Removing:"
427 for dep in $deps
428 do
429 echo -n " $dep"
430 echo 'y' | tazpkg remove $dep >/dev/null
431 done
432 echo -e "\n"
433 # Keep the last diff for debug and info.
434 mv -f $CACHE/installed.cook.diff $CACHE/installed.diff
435 fi
436 }
438 # The main cook function.
439 cookit() {
440 echo "Cook: $PACKAGE $VERSION"
441 separator
442 set_paths
443 [ "$QA" ] && receipt_quality
444 cd $pkgdir
445 rm -rf install taz source
447 # Disable -pipe if less than 512Mb free RAM.
448 free=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
449 if [ "$free" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then
450 gettext -e "Disabling -pipe compile flag: $free RAM\n"
451 CFLAGS="${CFLAGS/-pipe}" && CFLAGS=$(echo "$CFLAGS" | tr -s ' ')
452 CXXFLAGS="${CXXFLAGS/-pipe}" && \
453 CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ')
454 fi
455 unset free
457 # Export flags and path to be used by make and receipt.
458 DESTDIR=$pkgdir/install
459 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS CONFIG_SITE LC_ALL=C LANG=C
460 #LDFLAGS
462 # Check for build deps and handle implicit depends of *-dev packages
463 # (ex: libusb-dev :: libusb).
464 rm -f $CACHE/installed.local $CACHE/installed.web $CACHE/missing.dep
465 touch $CACHE/installed.local $CACHE/installed.web
466 [ "$BUILD_DEPENDS" ] && gettext -e "Checking build dependencies...\n"
467 for dep in $BUILD_DEPENDS
468 do
469 implicit=${dep%-dev}
470 for i in $dep $implicit
471 do
472 if [ ! -f "$INSTALLED/$i/receipt" ]; then
473 # Try local package first. In some cases implicit doesn't exist, ex:
474 # libboost-dev exists but not libboost, so check if we got vers.
475 unset vers
476 vers=$(. $WOK/$i/receipt 2>/dev/null ; echo $VERSION)
477 if [ -f "$PKGS/$i-$vers.tazpkg" ]; then
478 echo $i-$vers.tazpkg >> $CACHE/installed.local
479 else
480 # Priority to package version in wok (maybe more up-to-date)
481 # than the mirrored one.
482 if [ "$vers" ]; then
483 if fgrep -q $i-$vers $DB/packages.list; then
484 echo $i >> $CACHE/installed.web
485 else
486 # So package exists in wok but not available.
487 gettext "Missing dep (wok/pkg):"; echo " $i $vers"
488 echo $i >> $CACHE/missing.dep
489 fi
490 else
491 # Package is not in wok but may be in repo.
492 if fgrep -q $i-$vers $DB/packages.list; then
493 echo $i >> $CACHE/installed.web
494 else
495 echo "ERROR: unknown dep $i" && exit 1
496 fi
497 fi
498 fi
499 fi
500 done
501 done
503 # Get the list of installed packages
504 cd $INSTALLED && ls -1 > $CACHE/installed.list
506 # Have we a missing build dep to cook ?
507 if [ -s "$CACHE/missing.dep" ] && [ "$AUTO_COOK" ]; then
508 gettext -e "Auto cook config is set : AUTO_COOK\n"
509 cp -f $LOGS/$PACKAGE.log $LOGS/$PACKAGE.log.$$
510 for i in $(uniq $CACHE/missing.dep)
511 do
512 (gettext "Building dep (wok/pkg) :"; echo " $i $vers") | \
513 tee -a $LOGS/$PACKAGE.log.$$
514 cook $i || (echo -e "ERROR: can't cook dep '$i'\n" && \
515 fgrep "remove: " $LOGS/$i.log && \
516 fgrep "Removing: " $LOGS/$i.log && echo "") | \
517 tee -a $LOGS/$PACKAGE.log.$$ && break
518 done
519 rm -f $CACHE/missing.dep
520 mv $LOGS/$PACKAGE.log.$$ $LOGS/$PACKAGE.log
521 fi
523 # QA: Exit on missing dep errors. We exit in both cases, if AUTO_COOK
524 # is enabled and cook fails we have ERROR in log, if no auto cook we have
525 # missing dep in cached file.
526 if fgrep -q "ERROR:" $LOGS/$pkg.log || [ -s "$CACHE/missing.dep" ]; then
527 [ -s "$CACHE/missing.dep" ] && nb=$(cat $CACHE/missing.dep | wc -l)
528 echo "ERROR: missing dep $nb" && exit 1
529 fi
531 # Install local packages.
532 cd $PKGS
533 for i in $(uniq $CACHE/installed.local)
534 do
535 gettext "Installing dep (pkg/local):"; echo " $i"
536 tazpkg install $i >/dev/null
537 done
539 # Install web or cached packages (if mirror is set to $PKGS we only
540 # use local packages).
541 for i in $(uniq $CACHE/installed.web)
542 do
543 gettext "Installing dep (web/cache):"; echo " $i"
544 tazpkg get-install $i >/dev/null
545 done
547 # If a cook failed deps are removed.
548 cd $INSTALLED && ls -1 > $CACHE/installed.cook && cd $CACHE
549 [ ! -s "installed.cook.diff" ] && \
550 busybox diff installed.list installed.cook > installed.cook.diff
551 deps=$(cat installed.cook.diff | grep ^+[a-zA-Z0-9] | wc -l)
553 # Get source tarball and make sure we have source dir named:
554 # $PACKAGE-$VERSION to be standard in receipts. Here we use tar.lzma
555 # tarball if it exists.
556 if [ "$WGET_URL" ] && [ ! -f "$SRC/$TARBALL" ]; then
557 if [ -f "$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
558 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
559 LZMA_SRC=""
560 else
561 get_source || exit 1
562 fi
563 fi
564 if [ ! "$WANTED" ] && [ "$TARBALL" ] && [ ! -d "$src" ]; then
565 mkdir -p $pkgdir/source/tmp && cd $pkgdir/source/tmp
566 if ! extract_source ; then
567 get_source
568 extract_source || exit 1
569 fi
570 if [ "$LZMA_SRC" ]; then
571 cd $pkgdir/source
572 if [ "$(ls -A tmp | wc -l)" -gl 1 ] || [ -f "$(echo tmp/*)" ]; then
573 mv tmp tmp-1 && mkdir tmp
574 mv tmp-1 tmp/${SOURCE:-$PACKAGE}-$VERSION
575 fi
576 if [ -d "tmp/${SOURCE:-$PACKAGE}-$VERSION" ]; then
577 cd tmp && tar -c * | lzma e $SRC/$TARBALL -si
578 fi
579 fi
580 cd $pkgdir/source/tmp
581 # Some archives are not well done and don't extract to one dir (ex lzma).
582 files=$(ls | wc -l)
583 [ "$files" == 1 ] && [ -d "$(ls)" ] && mv * ../$PACKAGE-$VERSION
584 [ "$files" == 1 ] && [ -f "$(ls)" ] && mkdir -p ../$PACKAGE-$VERSION && \
585 mv * ../$PACKAGE-$VERSION/$TARBALL
586 [ "$files" -gt 1 ] && mkdir -p ../$PACKAGE-$VERSION && \
587 mv * ../$PACKAGE-$VERSION
588 cd .. && rm -rf tmp
589 fi
591 # Execute receipt rules.
592 if grep -q ^compile_rules $receipt; then
593 echo "Executing: compile_rules"
594 echo "CFLAGS : $CFLAGS"
595 #echo "LDFLAGS : $LDFLAGS"
596 [ -d "$src" ] && cd $src
597 compile_rules $@ || exit 1
598 # Stay compatible with _pkg
599 [ -d "$src/_pkg" ] && mv $src/_pkg $install
600 # QA: compile_rules success so valid.
601 mkdir -p $install
602 else
603 # QA: No compile_rules so no error, valid.
604 mkdir -p $install
605 fi
606 separator && echo ""
607 }
609 # Cook quality assurance.
610 cookit_quality() {
611 if [ ! -d "$WOK/$pkg/install" ] && [ ! "$WANTED" ]; then
612 echo -e "ERROR: cook failed" | tee -a $LOGS/$pkg.log
613 fi
614 # ERROR can be echoed any time in cookit()
615 if fgrep -q ERROR: $LOGS/$pkg.log; then
616 debug_info | tee -a $LOGS/$pkg.log
617 rm -f $command && exit 1
618 fi
619 }
621 # Create the package. Wanted to use Tazpkg to create a tazpkg package at first,
622 # but it doesn't handle EXTRAVERSION.
623 packit() {
624 set_paths
625 echo "Pack: $PACKAGE $VERSION"
626 separator
627 if grep -q ^genpkg_rules $receipt; then
628 gettext -e "Executing: genpkg_rules\n"
629 set -e && cd $pkgdir && mkdir -p $fs
630 genpkg_rules || echo -e "\nERROR: genpkg_rules failed\n" >> \
631 $LOGS/$pkg.log
632 else
633 gettext "No packages rules: meta package"; echo
634 mkdir -p $fs
635 fi
637 # First QA check to stop now if genpkg_rules failed.
638 if fgrep -q ERROR: $LOGS/$pkg.log; then
639 exit 1
640 fi
642 cd $taz
643 for file in receipt description.txt
644 do
645 [ ! -f "../$file" ] && continue
646 gettext "Copying"; echo -n " $file..."
647 cp -f ../$file $pack && chown 0.0 $pack/$file && status
648 done
649 copy_generic_files
651 # Create files.list with redirecting find output.
652 gettext "Creating the list of files..." && cd $fs
653 find . -type f -print > ../files.list
654 find . -type l -print >> ../files.list
655 cd .. && sed -i s/'^.'/''/ files.list
656 status
658 # Strip and stuff files.
659 strip_package
661 # Md5sum of files.
662 gettext "Creating md5sum of files..."
663 while read file; do
664 [ -L "fs$file" ] && continue
665 [ -f "fs$file" ] || continue
666 case "$file" in
667 /lib/modules/*/modules.*|*.pyc) continue ;;
668 esac
669 md5sum "fs$file" | sed 's/ fs/ /'
670 done < files.list > md5sum
671 status
672 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum \
673 description.txt 2> /dev/null | awk \
674 '{ sz=$1 } END { print sz }')
676 # Build cpio archives.
677 gettext "Compressing the fs... "
678 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
679 rm -rf fs
680 status
681 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list \
682 md5sum description.txt 2> /dev/null | awk \
683 '{ sz=$1 } END { print sz }')
684 gettext "Updating receipt sizes..."
685 sed -i s/^PACKED_SIZE.*$// receipt
686 sed -i s/^UNPACKED_SIZE.*$// receipt
687 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
688 status
690 # Set extra version.
691 if [ "$EXTRAVERSION" ]; then
692 gettext "Updating receipt EXTRAVERSION: "; echo -n "$EXTRAVERSION"
693 sed -i s/^EXTRAVERSION.*$// receipt
694 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
695 status
696 fi
698 # Compress.
699 gettext "Creating full cpio archive... "
700 find . -print | cpio -o -H newc --quiet > \
701 ../$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg
702 status
703 gettext "Restoring original package tree... "
704 unlzma -c fs.cpio.lzma | cpio -idm --quiet
705 status
706 rm fs.cpio.lzma && cd ..
708 # QA and give info.
709 tazpkg=$(ls *.tazpkg)
710 packit_quality
711 separator && gettext "Package:"; echo -e " $tazpkg\n"
712 }
714 # Verify package quality and consistency.
715 packit_quality() {
716 #gettext "QA: Checking for broken link..."
717 #link=$(find $fs/usr -type l -follow)
718 #[ "$link" ] && echo -e "\nERROR: broken link in filesystem"
719 #status
721 # Exit if any error found in log file.
722 if fgrep -q ERROR: $LOGS/$pkg.log; then
723 rm -f $command && exit 1
724 fi
726 gettext "QA: Checking for empty package..."
727 files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l)
728 if [ "$files" == 0 ] && [ "$CATEGORY" != "meta" ]; then
729 echo -e "\nERROR: empty package"
730 rm -f $command && exit 1
731 else
732 # Ls sort by name so the first file is the one we want.
733 old=$(ls $PKGS/$pkg-*.tazpkg 2>/dev/null | head -n 1)
734 status
735 if [ -f "$old" ]; then
736 gettext "Removing old: $(basename $old)"
737 rm -f $old && status
738 fi
739 mv -f $pkgdir/taz/$pkg-*.tazpkg $PKGS
740 sed -i /^${pkg}$/d $broken
741 #gettext "Removing source tree..."
742 #rm -f $WOK/$pkg/source && status
743 fi
744 }
746 mkinstall_list() {
747 local pkg
748 for pkg in $@ ; do
749 case " $INSTALL_LIST " in
750 *\ $pkg\ *) continue ;;
751 *) if [ -s /home/slitaz/wok/$pkg/receipt ]; then
752 unset DEPENDS
753 . /home/slitaz/wok/$pkg/receipt
754 INSTALL_LIST="$INSTALL_LIST $pkg"
755 [ -n "$DEPENDS" ] && mkinstall_list $DEPENDS
756 fi
757 echo $pkg
758 esac
759 done
760 }
762 tac()
763 {
764 sed '1!G;h;$!d' $1
765 }
767 # Launch the cook command into a chroot jail protected by aufs.
768 # The current filesystems are used read-only and updates are
769 # stored in a separate branch.
770 try_aufs_chroot() {
772 base=/dev/shm/aufsmnt$$
774 # Can we setup the chroot ? Is it already done ?
775 grep -q ^AUFS_NOT_SUPPORTED $receipt && return
776 [ -n "$AUFS_MOUNTS" -a ! -f /aufs-umount.sh ] || return
777 lsmod | grep -q aufs || modprobe aufs 2> /dev/null || return
778 mkdir ${base}root ${base}rw || return
780 echo "Setup aufs chroot..."
782 # Sanity check
783 for i in / /proc /sys /dev/shm /home ; do
784 case " $AUFS_MOUNTS " in
785 *\ $i\ *) ;;
786 *) AUFS_MOUNTS="$AUFS_MOUNTS $i" ;;
787 esac
788 done
789 for mnt in $(echo $AUFS_MOUNTS | sort | uniq); do
790 mount --bind $mnt ${base}root$mnt
791 if [ $mnt == / ] && ! mount -t aufs -o br=${base}rw:/ none ${base}root; then
792 echo "Aufs mountage failure"
793 umount ${base}root
794 rmdir ${base}*
795 return
796 fi
797 echo "umount ${base}root$mnt" >> ${base}rw/aufs-umount.sh
798 done
800 chroot ${base}root $(cd $(dirname $0); pwd)/$(basename $0) "$@"
801 status=$?
803 echo "Leaving aufs chroot..."
804 tac ${base}rw/aufs-umount.sh | sh
805 rm -rf ${base}rw
806 umount ${base}root
807 rmdir $base*
809 # Install package if requested
810 if [ "$inst" ]; then
811 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
812 cd $PKGS && tazpkg install \
813 $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg --forced
814 else
815 gettext -e "Unable to install package, build has failed.\n\n"
816 exit 1
817 fi
818 fi
820 # Install package if part of the chroot to keep env up-to-date.
821 if [ -d "$INSTALLED/$pkg" ]; then
822 . /etc/slitaz/cook.conf
823 . $WOK/$pkg/taz/$pkg-*/receipt
824 echo "Updating chroot environment..."
825 echo "Updating chroot: $pkg (${VERSION}${EXTRAVERSION})" | log
826 cd $PKGS && tazpkg install \
827 $pkg-${VERSION}${EXTRAVERSION}.tazpkg --forced
828 fi
829 exit $status
830 }
832 # Create a XML feed for freshly builded package.
833 gen_rss() {
834 pubdate=$(date "+%a, %d %b %Y %X")
835 cat > $FEEDS/$pkg.xml << EOT
836 <item>
837 <title>$PACKAGE $VERSION${EXTRAVERSION}</title>
838 <link>${COOKER_URL}?pkg=$PACKAGE</link>
839 <guid>$PACKAGE-$VERSION${EXTRAVERSION}</guid>
840 <pubDate>$pubdate</pubDate>
841 <description>$SHORT_DESC</description>
842 </item>
843 EOT
844 }
846 #
847 # Commands
848 #
850 case "$1" in
851 usage|help|-u|-h)
852 usage ;;
853 list-wok)
854 gettext -e "\nList of packages in:"; echo " $WOK"
855 separator
856 cd $WOK && ls -1
857 separator
858 echo -n "Packages: " && ls | wc -l
859 echo "" ;;
860 search)
861 # Just a simple search function, we dont need more actually.
862 query="$2"
863 gettext -e "\nSearch results for:"; echo " $query"
864 separator
865 cd $WOK && ls -1 | grep "$query"
866 separator && echo "" ;;
867 setup)
868 # Setup a build environment
869 check_root
870 echo "Cook: setting up the environment" | log
871 gettext -e "\nSetting up your environment\n"
872 separator && cd $SLITAZ
873 init_db_files
874 gettext -e "Checking for packages to install...\n"
875 case " $@ " in
876 *\ --reinstall\ *)
877 INSTALL_LIST=""
878 for pkg in $(mkinstall_list $SETUP_PKGS); do
879 tazpkg get-install $pkg --forced
880 done ;;
881 *\ --arm\ *)
882 hg clone $WOK_URL wok || exit 1
883 sed -i s'/ARCH=.*/ARCH="arm"/' /etc/slitaz/cook.conf
884 sed -i s'/BUILD_SYSTEM=.*/BUILD_SYSTEM=i486-slitaz-linux/' \
885 /etc/slitaz/cook.conf ;;
886 *)
887 for pkg in $SETUP_PKGS
888 do
889 [ ! -f "$INSTALLED/$pkg/receipt" ] &&
890 tazpkg get-install $pkg
891 done ;;
892 esac
894 # Handle --options
895 case "$2" in
896 --wok|-w)
897 hg clone $WOK_URL wok || exit 1 ;;
898 --stable)
899 hg clone $WOK_URL-stable wok || exit 1 ;;
900 --undigest)
901 hg clone $WOK_URL-undigest wok || exit 1 ;;
902 esac
904 # SliTaz group and permissions
905 if ! grep -q ^slitaz /etc/group; then
906 gettext -e "Adding group: slitaz\n"
907 addgroup slitaz
908 fi
909 gettext -e "Setting permissions for slitaz group...\n"
910 find $SLITAZ -maxdepth 2 -exec chown root.slitaz {} \;
911 find $SLITAZ -maxdepth 2 -exec chmod g+w {} \;
912 separator
913 gettext -e "All done, ready to cook packages :-)\n\n" ;;
914 test)
915 # Test a cook environment.
916 echo "Cook test: testing the cook environment" | log
917 [ ! -d "$WOK" ] && exit 1
918 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK
919 cook cooktest ;;
920 new)
921 # Create the package folder and an empty receipt.
922 pkg="$2"
923 [ "$pkg" ] || usage
924 echo ""
925 if [ -d "$WOK/$pkg" ]; then
926 echo -n "$pkg " && gettext "package already exists."
927 echo -e "\n" && exit 1
928 fi
929 gettext "Creating"; echo -n " $WOK/$pkg"
930 mkdir $WOK/$pkg && cd $WOK/$pkg && status
931 gettext "Preparing the package receipt..."
932 cp $DATA/receipt .
933 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
934 status && echo ""
936 # Interactive mode, asking and seding.
937 case "$3" in
938 --interactive|-x)
939 gettext -e "Entering interactive mode...\n"
940 separator
941 echo "Package : $pkg"
942 # Version.
943 echo -n "Version : " ; read anser
944 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
945 # Category.
946 echo -n "Category : " ; read anser
947 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
948 # Short description.
949 echo -n "Short desc : " ; read anser
950 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
951 # Maintainer.
952 echo -n "Maintainer : " ; read anser
953 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
954 # Web site.
955 echo -n "Web site : " ; read anser
956 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
957 echo ""
958 # Wget URL.
959 echo "Wget URL to download source tarball."
960 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
961 echo -n "Wget url : " ; read anser
962 sed -i s#'WGET_URL=\"$TARBALL\"'#"WGET_URL=\"$anser\""# receipt
963 # Ask for a stuff dir.
964 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
965 if [ "$anser" = "y" ]; then
966 echo -n "Creating the stuff directory..."
967 mkdir $WOK/$pkg/stuff && status
968 fi
969 # Ask for a description file.
970 echo -n "Are you going to write a description ? (y/N) : " ; read anser
971 if [ "$anser" = "y" ]; then
972 echo -n "Creating the description.txt file..."
973 echo "" > $WOK/$pkg/description.txt && status
974 fi
975 separator
976 gettext -e "Receipt is ready to use.\n"
977 echo "" ;;
978 esac ;;
979 list)
980 # Cook a list of packages (better use the Cooker since it will order
981 # packages before executing cook).
982 check_root
983 [ -z "$2" ] && gettext -e "\nNo list in argument.\n\n" && exit 1
984 [ ! -f "$2" ] && gettext -e "\nNo list found:" && \
985 echo -e " $2\n" && exit 1
986 echo "Cook list starting: $2" | log
987 for pkg in $(cat $2)
988 do
989 cook $pkg || broken
990 done ;;
991 clean-wok)
992 check_root
993 gettext -e "\nCleaning all packages files..."
994 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
995 status && echo "" ;;
996 clean-src)
997 check_root
998 gettext -e "\nCleaning all packages sources..."
999 rm -rf $WOK/*/source
1000 status && echo "" ;;
1001 pkgdb)
1002 # Create suitable packages list for TazPKG and only for built packages
1003 # as well as flavors files for TazLiTo. We dont need logs since we do it
1004 # manually to ensure everything is fine before syncing the mirror.
1005 case "$2" in
1006 --flavors)
1007 continue ;;
1008 *)
1009 [ "$2" ] && PKGS="$2"
1010 [ ! -d "$PKGS" ] && \
1011 gettext -e "\nPackages directory doesn't exist\n\n" && exit 1 ;;
1012 esac
1013 time=$(date +%s)
1014 flavors=$SLITAZ/flavors
1015 live=$SLITAZ/live
1016 echo "cook:pkgdb" > $command
1017 echo "Cook pkgdb: Creating all packages lists" | log
1018 echo ""
1019 gettext "Creating lists for: "; echo "$PKGS"
1020 separator
1021 gettext "Cook pkgdb started: "; date "+%Y-%m-%d %H:%M"
1022 cd $PKGS
1023 rm -f packages.*
1024 gettext -e "Creating: packages.list\n"
1025 ls -1 *.tazpkg | sed s'/.tazpkg//' > $PKGS/packages.list
1026 gettext -e "Creating: packages.md5\n"
1027 md5sum *.tazpkg > $PKGS/packages.md5
1028 md5sum packages.md5 | cut -f1 -d' ' > ID
1029 gettext -e "Creating lists from: "; echo "$WOK"
1030 cd $WOK
1031 for pkg in *
1032 do
1033 unset_receipt
1034 . $pkg/receipt
1035 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
1036 # PACKED_SIZE and UNPACKED_SIZE are only in built receipt
1037 if [ -s $pkg/taz/*/receipt ]; then
1038 . $pkg/taz/*/receipt
1039 fi
1040 # packages.desc lets us search easily in DB
1041 cat >> $PKGS/packages.desc << EOT
1042 $PACKAGE | ${VERSION}$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE
1043 EOT
1044 # packages.txt used by tazpkg and tazpkg-web also to provide
1045 # a human readable package list with version and description.
1046 cat >> $PKGS/packages.txt << EOT
1047 $PACKAGE
1048 ${VERSION}$EXTRAVERSION
1049 $SHORT_DESC
1050 $PACKED_SIZE ($UNPACKED_SIZE installed)
1052 EOT
1053 # packages.equiv is used by tazpkg install to check depends.
1054 for i in $PROVIDE; do
1055 DEST=""
1056 echo $i | fgrep -q : && DEST="${i#*:}:"
1057 if grep -qs ^${i%:*}= $PKGS/packages.equiv; then
1058 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" \
1059 $PKGS/packages.equiv
1060 else
1061 echo "${i%:*}=$DEST$PACKAGE" >> $PKGS/packages.equiv
1062 fi
1063 done
1064 # files.list provides a list of all packages files.
1065 cat $pkg/taz/*/files.list | sed s/^/"$pkg: \0"/ >> \
1066 $PKGS/files.list
1067 fi
1068 done
1070 # Display list size.
1071 gettext -e "Done: packages.desc\n"
1072 gettext -e "Done: packages.txt\n"
1073 gettext -e "Done: packages.equiv\n"
1075 # files.list.lzma
1076 gettext -e "Creating: files.list.lzma\n"
1077 cd $PKGS && lzma e files.list files.list.lzma
1078 rm -f files.list
1080 # Display some info.
1081 separator
1082 nb=$(ls $PKGS/*.tazpkg | wc -l)
1083 time=$(($(date +%s) - $time))
1084 echo -e "Packages: $nb - Time: ${time}s\n"
1086 # Create all flavors files at once. Do we really need code to monitor
1087 # flavors changes ? Lets just build them with packages lists before
1088 # syncing the mirror.
1089 [ "$2" == "--flavors" ] || exit 1
1090 [ ! -d "$flavors" ] && echo -e "Missing flavors: $flavors\n" && exit 1
1091 [ -d "$live" ] || mkdir -p $live
1092 gettext "Creating flavors files in:"; echo " $live"
1093 echo "Cook pkgdb: Creating all flavors" | log
1094 separator
1095 gettext -e "Recharging lists to use latest packages...\n"
1096 tazpkg recharge >/dev/null 2>/dev/null
1098 # We need a custom tazlito config to set working dir to /home/slitaz.
1099 if [ ! -f "$live/tazlito.conf" ]; then
1100 echo "Creating configuration file: tazlito.conf"
1101 cp /etc/tazlito/tazlito.conf $live
1102 sed -i s@WORK_DIR=.*@WORK_DIR=\"/home/slitaz\"@ \
1103 $live/tazlito.conf
1104 fi
1106 # Update Hg flavors repo and pack.
1107 [ -d "$flavors/.hg" ] && cd $flavors && hg pull -u
1109 cd $live
1110 echo "Starting to generate flavors..."
1111 rm -f flavors.list *.flavor
1112 for i in $flavors/*
1113 do
1114 fl=$(basename $i)
1115 echo "Packing flavor: $(basename $i)"
1116 tazlito pack-flavor $fl >/dev/null || exit 1
1117 tazlito show-flavor $fl --brief --noheader 2> \
1118 /dev/null >> flavors.list
1119 done
1120 cp -f $live/*.flavor $live/flavors.list $PKGS
1121 separator && gettext "Flavors size: "; du -sh $live | awk '{print $1}'
1122 echo "" && rm -f $command ;;
1123 *)
1124 # Just cook and generate a package.
1125 check_root
1126 time=$(date +%s)
1127 pkg="$1"
1128 [ -z "$pkg" ] && usage
1129 receipt="$WOK/$pkg/receipt"
1130 check_pkg_in_wok && echo ""
1132 # Skip blocked, 3 lines also for the Cooker.
1133 if grep -q "^$pkg$" $blocked && [ "$2" != "--unblock" ]; then
1134 gettext -e "Blocked package:"; echo -e " $pkg\n" && exit 0
1135 fi
1137 try_aufs_chroot "$@"
1139 # Log and source receipt.
1140 echo "Cook started for: <a href='cooker.cgi?pkg=$pkg'>$pkg</a>" | log
1141 echo "cook:$pkg" > $command
1143 # Display and log info if cook process stopped.
1144 trap 'gettext -e "\n\nCook stopped: control-C\n\n" | \
1145 tee -a $LOGS/$pkg.log' INT
1147 unset inst
1148 unset_receipt
1149 . $receipt
1151 # Handle --options
1152 case "$2" in
1153 --clean|-c)
1154 gettext -e "Cleaning:"; echo -n " $pkg"
1155 cd $WOK/$pkg && rm -rf install taz source
1156 status && echo "" && exit 0 ;;
1157 --install|-i)
1158 inst='yes' ;;
1159 --getsrc|-gs)
1160 gettext "Getting source for:"; echo " $pkg"
1161 separator && get_source
1162 echo -e "Tarball: $SRC/$TARBALL\n" && exit 0 ;;
1163 --block|-b)
1164 gettext "Blocking:"; echo -n " $pkg"
1165 [ $(grep "^$pkg$" $blocked) ] || echo "$pkg" >> $blocked
1166 status && echo "" && exit 0 ;;
1167 --unblock|-ub)
1168 gettext "Unblocking:"; echo -n " $pkg"
1169 sed -i "/^${pkg}$/"d $blocked
1170 status && echo "" && exit 0 ;;
1172 esac
1174 # Check if wanted is built now so we have separate log files.
1175 for wanted in $WANTED ; do
1176 if grep -q "^$wanted$" $blocked; then
1177 echo "WANTED package is blocked: $wanted" | tee $LOGS/$pkg.log
1178 echo "" && rm -f $command && exit 1
1179 fi
1180 if grep -q "^$wanted$" $broken; then
1181 echo "WANTED package is broken: $wanted" | tee $LOGS/$pkg.log
1182 echo "" && rm -f $command && exit 1
1183 fi
1184 if [ ! -d "$WOK/$wanted/install" ]; then
1185 cook "$wanted" || exit 1
1186 fi
1187 done
1189 # Cook and pack or exit on error and log everything.
1190 cookit $@ 2>&1 | tee $LOGS/$pkg.log
1191 remove_deps | tee -a $LOGS/$pkg.log
1192 cookit_quality
1193 packit 2>&1 | tee -a $LOGS/$pkg.log
1194 clean_log
1196 # Exit if any error in packing.
1197 if grep -q ^ERROR $LOGS/$pkg.log; then
1198 debug_info | tee -a $LOGS/$pkg.log
1199 rm -f $command && exit 1
1200 fi
1202 # Create an XML feed
1203 gen_rss
1205 # Time and summary
1206 time=$(($(date +%s) - $time))
1207 summary | tee -a $LOGS/$pkg.log
1208 echo ""
1210 # Install package if requested
1211 if [ "$inst" ]; then
1212 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
1213 cd $PKGS && tazpkg install \
1214 $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg --forced
1215 else
1216 gettext -e "Unable to install package, build has failed.\n\n"
1217 exit 1
1218 fi
1219 fi
1221 # Install package if part of the chroot to keep env up-to-date.
1222 if [ -d "$INSTALLED/$PACKAGE" ] && [ -z "$AUFS_MOUNTS" ]; then
1223 echo "Updating chroot environment..."
1224 echo "Updating chroot: $PACKAGE (${VERSION}${EXTRAVERSION})" | log
1225 cd $PKGS && tazpkg install \
1226 $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg --forced
1227 fi
1229 # Finally we DONT WANT to build the *-dev or packages with WANTED="$pkg"
1230 # You want automation: use the Cooker Build Bot.
1231 #[ -d "$WOK/$pkg-dev" ] && cook $pkg-dev
1232 rm -f $command ;;
1233 esac
1235 exit 0