cookutils view cook @ rev 366

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