cookutils view cook @ rev 359

cook: Handle cross compilation
author Christophe Lincoln <pankso@slitaz.org>
date Wed May 09 18:25:13 2012 +0200 (2012-05-09)
parents ff8ec325d545
children c75f13234af0
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 Arch type : $ARCH
316 $(separator)
317 EOT
318 }
320 # Display debugging error info.
321 debug_info() {
322 echo -e "\nDebug information"
323 separator
324 echo "Cook date: $(date '+%Y-%m-%d %H:%M')"
325 for error in \
326 ERROR "No package" "cp: can't" "can't open" "can't cd" \
327 "error:" "fatal error:"
328 do
329 fgrep "$error" $LOGS/$pkg.log
330 done
331 separator && echo ""
332 }
334 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
335 # so some packages need to copy these files with the receipt and genpkg_rules.
336 copy_generic_files()
337 {
338 # $LOCALE is set in cook.conf
339 if [ "$LOCALE" ]; then
340 if [ -d "$install/usr/share/locale" ]; then
341 mkdir -p $fs/usr/share/locale
342 for i in $LOCALE
343 do
344 if [ -d "$install/usr/share/locale/$i" ]; then
345 cp -a $install/usr/share/locale/$i $fs/usr/share/locale
346 fi
347 done
348 fi
349 fi
351 # Generic pixmaps copy can be disabled with GENERIC_PIXMAPS="no"
352 if [ "$GENERIC_PIXMAPS" != "no" ]; then
353 if [ -d "$install/usr/share/pixmaps" ]; then
354 mkdir -p $fs/usr/share/pixmaps
355 cp -a $install/usr/share/pixmaps/$PACKAGE.png \
356 $fs/usr/share/pixmaps 2>/dev/null || continue
357 cp -a $install/usr/share/pixmaps/$PACKAGE.xpm \
358 $fs/usr/share/pixmaps 2>/dev/null || continue
359 fi
361 # Custom or homemade PNG pixmap can be in stuff.
362 if [ -f "$stuff/$PACKAGE.png" ]; then
363 mkdir -p $fs/usr/share/pixmaps
364 cp -a $stuff/$PACKAGE.png $fs/usr/share/pixmaps
365 fi
366 fi
368 # Desktop entry (.desktop).
369 # Generic desktop entry copy can be disabled with GENERIC_MENUS="no"
370 if [ "$GENERIC_MENUS" != "no" ]; then
371 if [ -d "$install/usr/share/applications" ] && [ "$WANTED" == "" ]; then
372 cp -a $install/usr/share/applications $fs/usr/share
373 fi
374 fi
376 # Homemade desktop file(s) can be in stuff.
377 if [ -d "$stuff/applications" ]; then
378 mkdir -p $fs/usr/share
379 cp -a $stuff/applications $fs/usr/share
380 fi
381 if [ -f "$stuff/$PACKAGE.desktop" ]; then
382 mkdir -p $fs/usr/share/applications
383 cp -a $stuff/$PACKAGE.desktop $fs/usr/share/applications
384 fi
385 }
387 # Find and strip : --strip-all (-s) or --strip-debug on static libs as well
388 # as removing uneeded files like in Python packages.
389 strip_package()
390 {
391 gettext "Executing strip on all files..."
392 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
393 do
394 if [ -d "$dir" ]; then
395 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
396 fi
397 done
398 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
399 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
400 status
402 # Remove Python .pyc and .pyo from packages.
403 if echo "$PACKAGE $DEPENDS" | fgrep -q "python"; then
404 gettext "Removing Python compiled files..."
405 find $fs -type f -name "*.pyc" -delete 2>/dev/null
406 find $fs -type f -name "*.pyo" -delete 2>/dev/null
407 status
408 fi
410 # Remove Perl perllocal.pod and .packlist from packages.
411 if echo "$DEPENDS" | fgrep -q "perl"; then
412 gettext "Removing Perl compiled files..."
413 find $fs -type f -name "perllocal.pod" -delete 2>/dev/null
414 find $fs -type f -name ".packlist" -delete 2>/dev/null
415 status
416 fi
417 }
419 # Remove installed deps.
420 remove_deps() {
421 # Now remove installed build deps.
422 diff="$CACHE/installed.cook.diff"
423 if [ -s "$CACHE/installed.cook.diff" ]; then
424 deps=$(cat $diff | grep ^+[a-zA-Z0-9] | sed s/^+//)
425 nb=$(cat $diff | grep ^+[a-zA-Z0-9] | wc -l)
426 gettext "Build dependencies to remove:"; echo " $nb"
427 gettext "Removing:"
428 for dep in $deps
429 do
430 echo -n " $dep"
431 echo 'y' | tazpkg remove $dep >/dev/null
432 done
433 echo -e "\n"
434 # Keep the last diff for debug and info.
435 mv -f $CACHE/installed.cook.diff $CACHE/installed.diff
436 fi
437 }
439 # The main cook function.
440 cookit() {
441 echo "Cook: $PACKAGE $VERSION"
442 separator
443 set_paths
445 # Handle cross compilation
446 case "$ARCH" in
447 arm|x86_64)
448 echo "cook: adding /usr/cross/$ARCH/bin to PATH"
449 export PATH=$PATH:/usr/cross/$ARCH/bin
450 echo "cook: using C compiler $HOST_SYSTEM-gcc"
451 export CC=${HOST_SYSTEM}-gcc
452 export CXX=${HOST_SYSTEM}-g++ ;;
453 esac
455 [ "$QA" ] && receipt_quality
456 cd $pkgdir
457 rm -rf install taz source
459 # Disable -pipe if less than 512Mb free RAM.
460 free=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
461 if [ "$free" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then
462 gettext -e "Disabling -pipe compile flag: $free RAM\n"
463 CFLAGS="${CFLAGS/-pipe}" && CFLAGS=$(echo "$CFLAGS" | tr -s ' ')
464 CXXFLAGS="${CXXFLAGS/-pipe}" && \
465 CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ')
466 fi
467 unset free
469 # Export flags and path to be used by make and receipt.
470 DESTDIR=$pkgdir/install
471 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS CONFIG_SITE LC_ALL=C LANG=C
472 #LDFLAGS
474 # Check for build deps and handle implicit depends of *-dev packages
475 # (ex: libusb-dev :: libusb).
476 rm -f $CACHE/installed.local $CACHE/installed.web $CACHE/missing.dep
477 touch $CACHE/installed.local $CACHE/installed.web
478 [ "$BUILD_DEPENDS" ] && gettext -e "Checking build dependencies...\n"
479 for dep in $BUILD_DEPENDS
480 do
481 implicit=${dep%-dev}
482 for i in $dep $implicit
483 do
484 if [ ! -f "$INSTALLED/$i/receipt" ]; then
485 # Try local package first. In some cases implicit doesn't exist, ex:
486 # libboost-dev exists but not libboost, so check if we got vers.
487 unset vers
488 vers=$(. $WOK/$i/receipt 2>/dev/null ; echo $VERSION)
489 if [ -f "$PKGS/$i-$vers.tazpkg" ]; then
490 echo $i-$vers.tazpkg >> $CACHE/installed.local
491 else
492 # Priority to package version in wok (maybe more up-to-date)
493 # than the mirrored one.
494 if [ "$vers" ]; then
495 if fgrep -q $i-$vers $DB/packages.list; then
496 echo $i >> $CACHE/installed.web
497 else
498 # So package exists in wok but not available.
499 gettext "Missing dep (wok/pkg):"; echo " $i $vers"
500 echo $i >> $CACHE/missing.dep
501 fi
502 else
503 # Package is not in wok but may be in repo.
504 if fgrep -q $i-$vers $DB/packages.list; then
505 echo $i >> $CACHE/installed.web
506 else
507 echo "ERROR: unknown dep $i" && exit 1
508 fi
509 fi
510 fi
511 fi
512 done
513 done
515 # Get the list of installed packages
516 cd $INSTALLED && ls -1 > $CACHE/installed.list
518 # Have we a missing build dep to cook ?
519 if [ -s "$CACHE/missing.dep" ] && [ "$AUTO_COOK" ]; then
520 gettext -e "Auto cook config is set : AUTO_COOK\n"
521 cp -f $LOGS/$PACKAGE.log $LOGS/$PACKAGE.log.$$
522 for i in $(uniq $CACHE/missing.dep)
523 do
524 (gettext "Building dep (wok/pkg) :"; echo " $i $vers") | \
525 tee -a $LOGS/$PACKAGE.log.$$
526 cook $i || (echo -e "ERROR: can't cook dep '$i'\n" && \
527 fgrep "remove: " $LOGS/$i.log && \
528 fgrep "Removing: " $LOGS/$i.log && echo "") | \
529 tee -a $LOGS/$PACKAGE.log.$$ && break
530 done
531 rm -f $CACHE/missing.dep
532 mv $LOGS/$PACKAGE.log.$$ $LOGS/$PACKAGE.log
533 fi
535 # QA: Exit on missing dep errors. We exit in both cases, if AUTO_COOK
536 # is enabled and cook fails we have ERROR in log, if no auto cook we have
537 # missing dep in cached file.
538 if fgrep -q "ERROR:" $LOGS/$pkg.log || [ -s "$CACHE/missing.dep" ]; then
539 [ -s "$CACHE/missing.dep" ] && nb=$(cat $CACHE/missing.dep | wc -l)
540 echo "ERROR: missing dep $nb" && exit 1
541 fi
543 # Install local packages.
544 cd $PKGS
545 for i in $(uniq $CACHE/installed.local)
546 do
547 gettext "Installing dep (pkg/local):"; echo " $i"
548 tazpkg install $i >/dev/null
549 done
551 # Install web or cached packages (if mirror is set to $PKGS we only
552 # use local packages).
553 for i in $(uniq $CACHE/installed.web)
554 do
555 gettext "Installing dep (web/cache):"; echo " $i"
556 tazpkg get-install $i >/dev/null
557 done
559 # If a cook failed deps are removed.
560 cd $INSTALLED && ls -1 > $CACHE/installed.cook && cd $CACHE
561 [ ! -s "installed.cook.diff" ] && \
562 busybox diff installed.list installed.cook > installed.cook.diff
563 deps=$(cat installed.cook.diff | grep ^+[a-zA-Z0-9] | wc -l)
565 # Get source tarball and make sure we have source dir named:
566 # $PACKAGE-$VERSION to be standard in receipts. Here we use tar.lzma
567 # tarball if it exists.
568 if [ "$WGET_URL" ] && [ ! -f "$SRC/$TARBALL" ]; then
569 if [ -f "$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
570 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
571 LZMA_SRC=""
572 else
573 get_source || exit 1
574 fi
575 fi
576 if [ ! "$WANTED" ] && [ "$TARBALL" ] && [ ! -d "$src" ]; then
577 mkdir -p $pkgdir/source/tmp && cd $pkgdir/source/tmp
578 if ! extract_source ; then
579 get_source
580 extract_source || exit 1
581 fi
582 if [ "$LZMA_SRC" ]; then
583 cd $pkgdir/source
584 if [ "$(ls -A tmp | wc -l)" -gl 1 ] || [ -f "$(echo tmp/*)" ]; then
585 mv tmp tmp-1 && mkdir tmp
586 mv tmp-1 tmp/${SOURCE:-$PACKAGE}-$VERSION
587 fi
588 if [ -d "tmp/${SOURCE:-$PACKAGE}-$VERSION" ]; then
589 cd tmp && tar -c * | lzma e $SRC/$TARBALL -si
590 fi
591 fi
592 cd $pkgdir/source/tmp
593 # Some archives are not well done and don't extract to one dir (ex lzma).
594 files=$(ls | wc -l)
595 [ "$files" == 1 ] && [ -d "$(ls)" ] && mv * ../$PACKAGE-$VERSION
596 [ "$files" == 1 ] && [ -f "$(ls)" ] && mkdir -p ../$PACKAGE-$VERSION && \
597 mv * ../$PACKAGE-$VERSION/$TARBALL
598 [ "$files" -gt 1 ] && mkdir -p ../$PACKAGE-$VERSION && \
599 mv * ../$PACKAGE-$VERSION
600 cd .. && rm -rf tmp
601 fi
603 # Execute receipt rules.
604 if grep -q ^compile_rules $receipt; then
605 echo "Executing: compile_rules"
606 echo "CFLAGS : $CFLAGS"
607 #echo "LDFLAGS : $LDFLAGS"
608 [ -d "$src" ] && cd $src
609 compile_rules $@ || exit 1
610 # Stay compatible with _pkg
611 [ -d "$src/_pkg" ] && mv $src/_pkg $install
612 # QA: compile_rules success so valid.
613 mkdir -p $install
614 else
615 # QA: No compile_rules so no error, valid.
616 mkdir -p $install
617 fi
618 separator && echo ""
619 }
621 # Cook quality assurance.
622 cookit_quality() {
623 if [ ! -d "$WOK/$pkg/install" ] && [ ! "$WANTED" ]; then
624 echo -e "ERROR: cook failed" | tee -a $LOGS/$pkg.log
625 fi
626 # ERROR can be echoed any time in cookit()
627 if fgrep -q ERROR: $LOGS/$pkg.log; then
628 debug_info | tee -a $LOGS/$pkg.log
629 rm -f $command && exit 1
630 fi
631 }
633 # Create the package. Wanted to use Tazpkg to create a tazpkg package at first,
634 # but it doesn't handle EXTRAVERSION.
635 packit() {
636 set_paths
638 # Handle cross compilation
639 case "$ARCH" in
640 arm|x86_64) VERSION="$VERSION-$ARCH" ;;
641 esac
643 echo "Pack: $PACKAGE $VERSION"
644 separator
646 if grep -q ^genpkg_rules $receipt; then
647 gettext -e "Executing: genpkg_rules\n"
648 set -e && cd $pkgdir && mkdir -p $fs
649 genpkg_rules || echo -e "\nERROR: genpkg_rules failed\n" >> \
650 $LOGS/$pkg.log
651 else
652 gettext "No packages rules: meta package"; echo
653 mkdir -p $fs
654 fi
656 # First QA check to stop now if genpkg_rules failed.
657 if fgrep -q ERROR: $LOGS/$pkg.log; then
658 exit 1
659 fi
661 cd $taz
662 for file in receipt description.txt
663 do
664 [ ! -f "../$file" ] && continue
665 gettext "Copying"; echo -n " $file..."
666 cp -f ../$file $pack && chown 0.0 $pack/$file && status
667 done
668 copy_generic_files
670 # Create files.list with redirecting find output.
671 gettext "Creating the list of files..." && cd $fs
672 find . -type f -print > ../files.list
673 find . -type l -print >> ../files.list
674 cd .. && sed -i s/'^.'/''/ files.list
675 status
677 # Strip and stuff files.
678 strip_package
680 # Md5sum of files.
681 gettext "Creating md5sum of files..."
682 while read file; do
683 [ -L "fs$file" ] && continue
684 [ -f "fs$file" ] || continue
685 case "$file" in
686 /lib/modules/*/modules.*|*.pyc) continue ;;
687 esac
688 md5sum "fs$file" | sed 's/ fs/ /'
689 done < files.list > md5sum
690 status
691 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum \
692 description.txt 2> /dev/null | awk \
693 '{ sz=$1 } END { print sz }')
695 # Build cpio archives.
696 gettext "Compressing the fs... "
697 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
698 rm -rf fs
699 status
700 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list \
701 md5sum description.txt 2> /dev/null | awk \
702 '{ sz=$1 } END { print sz }')
703 gettext "Updating receipt sizes..."
704 sed -i s/^PACKED_SIZE.*$// receipt
705 sed -i s/^UNPACKED_SIZE.*$// receipt
706 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
707 status
709 # Set extra version.
710 if [ "$EXTRAVERSION" ]; then
711 gettext "Updating receipt EXTRAVERSION: "; echo -n "$EXTRAVERSION"
712 sed -i s/^EXTRAVERSION.*$// receipt
713 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
714 status
715 fi
717 # Compress.
718 gettext "Creating full cpio archive... "
719 find . -print | cpio -o -H newc --quiet > \
720 ../$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg
721 status
722 gettext "Restoring original package tree... "
723 unlzma -c fs.cpio.lzma | cpio -idm --quiet
724 status
725 rm fs.cpio.lzma && cd ..
727 # QA and give info.
728 tazpkg=$(ls *.tazpkg)
729 packit_quality
730 separator && gettext "Package:"; echo -e " $tazpkg\n"
731 }
733 # Verify package quality and consistency.
734 packit_quality() {
735 #gettext "QA: Checking for broken link..."
736 #link=$(find $fs/usr -type l -follow)
737 #[ "$link" ] && echo -e "\nERROR: broken link in filesystem"
738 #status
740 # Exit if any error found in log file.
741 if fgrep -q ERROR: $LOGS/$pkg.log; then
742 rm -f $command && exit 1
743 fi
745 gettext "QA: Checking for empty package..."
746 files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l)
747 if [ "$files" == 0 ] && [ "$CATEGORY" != "meta" ]; then
748 echo -e "\nERROR: empty package"
749 rm -f $command && exit 1
750 else
751 # Ls sort by name so the first file is the one we want.
752 old=$(ls $PKGS/$pkg-*.tazpkg 2>/dev/null | head -n 1)
753 status
754 if [ -f "$old" ]; then
755 gettext "Removing old: $(basename $old)"
756 rm -f $old && status
757 fi
758 mv -f $pkgdir/taz/$pkg-*.tazpkg $PKGS
759 sed -i /^${pkg}$/d $broken
760 #gettext "Removing source tree..."
761 #rm -f $WOK/$pkg/source && status
762 fi
763 }
765 mkinstall_list() {
766 local pkg
767 for pkg in $@ ; do
768 case " $INSTALL_LIST " in
769 *\ $pkg\ *) continue ;;
770 *) if [ -s /home/slitaz/wok/$pkg/receipt ]; then
771 unset DEPENDS
772 . /home/slitaz/wok/$pkg/receipt
773 INSTALL_LIST="$INSTALL_LIST $pkg"
774 [ -n "$DEPENDS" ] && mkinstall_list $DEPENDS
775 fi
776 echo $pkg
777 esac
778 done
779 }
781 tac()
782 {
783 sed '1!G;h;$!d' $1
784 }
786 # Launch the cook command into a chroot jail protected by aufs.
787 # The current filesystems are used read-only and updates are
788 # stored in a separate branch.
789 try_aufs_chroot() {
791 base=/dev/shm/aufsmnt$$
793 # Can we setup the chroot ? Is it already done ?
794 grep -q ^AUFS_NOT_SUPPORTED $receipt && return
795 [ -n "$AUFS_MOUNTS" -a ! -f /aufs-umount.sh ] || return
796 lsmod | grep -q aufs || modprobe aufs 2> /dev/null || return
797 mkdir ${base}root ${base}rw || return
799 echo "Setup aufs chroot..."
801 # Sanity check
802 for i in / /proc /sys /dev/shm /home ; do
803 case " $AUFS_MOUNTS " in
804 *\ $i\ *) ;;
805 *) AUFS_MOUNTS="$AUFS_MOUNTS $i" ;;
806 esac
807 done
808 for mnt in $(echo $AUFS_MOUNTS | sort | uniq); do
809 mount --bind $mnt ${base}root$mnt
810 if [ $mnt == / ] && ! mount -t aufs -o br=${base}rw:/ none ${base}root; then
811 echo "Aufs mountage failure"
812 umount ${base}root
813 rmdir ${base}*
814 return
815 fi
816 echo "umount ${base}root$mnt" >> ${base}rw/aufs-umount.sh
817 done
819 chroot ${base}root $(cd $(dirname $0); pwd)/$(basename $0) "$@"
820 status=$?
822 echo "Leaving aufs chroot..."
823 tac ${base}rw/aufs-umount.sh | sh
824 rm -rf ${base}rw
825 umount ${base}root
826 rmdir $base*
828 # Install package if requested
829 if [ "$inst" ]; then
830 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
831 cd $PKGS && tazpkg install \
832 $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg --forced
833 else
834 gettext -e "Unable to install package, build has failed.\n\n"
835 exit 1
836 fi
837 fi
839 # Install package if part of the chroot to keep env up-to-date.
840 if [ -d "$INSTALLED/$pkg" ]; then
841 . /etc/slitaz/cook.conf
842 . $WOK/$pkg/taz/$pkg-*/receipt
843 echo "Updating chroot environment..."
844 echo "Updating chroot: $pkg (${VERSION}${EXTRAVERSION})" | log
845 cd $PKGS && tazpkg install \
846 $pkg-${VERSION}${EXTRAVERSION}.tazpkg --forced
847 fi
848 exit $status
849 }
851 # Create a XML feed for freshly builded package.
852 gen_rss() {
853 pubdate=$(date "+%a, %d %b %Y %X")
854 cat > $FEEDS/$pkg.xml << EOT
855 <item>
856 <title>$PACKAGE $VERSION${EXTRAVERSION}</title>
857 <link>${COOKER_URL}?pkg=$PACKAGE</link>
858 <guid>$PACKAGE-$VERSION${EXTRAVERSION}</guid>
859 <pubDate>$pubdate</pubDate>
860 <description>$SHORT_DESC</description>
861 </item>
862 EOT
863 }
865 #
866 # Commands
867 #
869 case "$1" in
870 usage|help|-u|-h)
871 usage ;;
872 list-wok)
873 gettext -e "\nList of packages in:"; echo " $WOK"
874 separator
875 cd $WOK && ls -1
876 separator
877 echo -n "Packages: " && ls | wc -l
878 echo "" ;;
879 search)
880 # Just a simple search function, we dont need more actually.
881 query="$2"
882 gettext -e "\nSearch results for:"; echo " $query"
883 separator
884 cd $WOK && ls -1 | grep "$query"
885 separator && echo "" ;;
886 setup)
887 # Setup a build environment
888 check_root
889 echo "Cook: setting up the environment" | log
890 gettext -e "\nSetting up your environment\n"
891 separator && cd $SLITAZ
892 init_db_files
893 gettext -e "Checking for packages to install...\n"
894 case " $@ " in
895 *\ --reinstall\ *)
896 INSTALL_LIST=""
897 for pkg in $(mkinstall_list $SETUP_PKGS); do
898 tazpkg get-install $pkg --forced
899 done ;;
900 *)
901 for pkg in $SETUP_PKGS
902 do
903 [ ! -f "$INSTALLED/$pkg/receipt" ] &&
904 tazpkg get-install $pkg
905 done ;;
906 esac
908 # Handle --options
909 case "$2" in
910 --wok|-w)
911 hg clone $WOK_URL wok || exit 1 ;;
912 --stable)
913 hg clone $WOK_URL-stable wok || exit 1 ;;
914 --undigest)
915 hg clone $WOK_URL-undigest wok || exit 1 ;;
916 esac
918 # SliTaz group and permissions
919 if ! grep -q ^slitaz /etc/group; then
920 gettext -e "Adding group: slitaz\n"
921 addgroup slitaz
922 fi
923 gettext -e "Setting permissions for slitaz group...\n"
924 find $SLITAZ -maxdepth 2 -exec chown root.slitaz {} \;
925 find $SLITAZ -maxdepth 2 -exec chmod g+w {} \;
926 separator
927 gettext -e "All done, ready to cook packages :-)\n\n" ;;
928 arm-setup)
929 # Setup fro cross ARM compiling.
930 sed -i \
931 -e s'/ARCH=.*/ARCH="arm"/' \
932 -e s'/CFLAGS=.*/CFLAGS=""/' \
933 -e s'/BUILD_SYSTEM=.*/BUILD_SYSTEM=i486-slitaz-linux/' \
934 -e s'/HOST_SYSTEM=.*/HOST_SYSTEM=$ARCH-slitaz-linux-gnueabi/' \
935 /etc/slitaz/cook.conf
936 . /etc/slitaz/cook.conf
937 echo "Target arch : $ARCH"
938 echo "Configure args: $CONFIGURE_ARGS"
939 if [ -x /usr/cross/$ARCH/bin/${HOST_SYSTEM}-gcc ]; then
940 echo "Cross compiler: ${HOST_SYSTEM}-gcc"
941 else
942 echo "ERROR: C compiler is missing: ${HOST_SYSTEM}-gcc"
943 fi ;;
944 test)
945 # Test a cook environment.
946 echo "Cook test: testing the cook environment" | log
947 [ ! -d "$WOK" ] && exit 1
948 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK
949 cook cooktest ;;
950 new)
951 # Create the package folder and an empty receipt.
952 pkg="$2"
953 [ "$pkg" ] || usage
954 echo ""
955 if [ -d "$WOK/$pkg" ]; then
956 echo -n "$pkg " && gettext "package already exists."
957 echo -e "\n" && exit 1
958 fi
959 gettext "Creating"; echo -n " $WOK/$pkg"
960 mkdir $WOK/$pkg && cd $WOK/$pkg && status
961 gettext "Preparing the package receipt..."
962 cp $DATA/receipt .
963 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
964 status && echo ""
966 # Interactive mode, asking and seding.
967 case "$3" in
968 --interactive|-x)
969 gettext -e "Entering interactive mode...\n"
970 separator
971 echo "Package : $pkg"
972 # Version.
973 echo -n "Version : " ; read anser
974 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
975 # Category.
976 echo -n "Category : " ; read anser
977 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
978 # Short description.
979 echo -n "Short desc : " ; read anser
980 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
981 # Maintainer.
982 echo -n "Maintainer : " ; read anser
983 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
984 # Web site.
985 echo -n "Web site : " ; read anser
986 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
987 echo ""
988 # Wget URL.
989 echo "Wget URL to download source tarball."
990 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
991 echo -n "Wget url : " ; read anser
992 sed -i s#'WGET_URL=\"$TARBALL\"'#"WGET_URL=\"$anser\""# receipt
993 # Ask for a stuff dir.
994 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
995 if [ "$anser" = "y" ]; then
996 echo -n "Creating the stuff directory..."
997 mkdir $WOK/$pkg/stuff && status
998 fi
999 # Ask for a description file.
1000 echo -n "Are you going to write a description ? (y/N) : " ; read anser
1001 if [ "$anser" = "y" ]; then
1002 echo -n "Creating the description.txt file..."
1003 echo "" > $WOK/$pkg/description.txt && status
1004 fi
1005 separator
1006 gettext -e "Receipt is ready to use.\n"
1007 echo "" ;;
1008 esac ;;
1009 list)
1010 # Cook a list of packages (better use the Cooker since it will order
1011 # packages before executing cook).
1012 check_root
1013 [ -z "$2" ] && gettext -e "\nNo list in argument.\n\n" && exit 1
1014 [ ! -f "$2" ] && gettext -e "\nNo list found:" && \
1015 echo -e " $2\n" && exit 1
1016 echo "Cook list starting: $2" | log
1017 for pkg in $(cat $2)
1018 do
1019 cook $pkg || broken
1020 done ;;
1021 clean-wok)
1022 check_root
1023 gettext -e "\nCleaning all packages files..."
1024 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
1025 status && echo "" ;;
1026 clean-src)
1027 check_root
1028 gettext -e "\nCleaning all packages sources..."
1029 rm -rf $WOK/*/source
1030 status && echo "" ;;
1031 pkgdb)
1032 # Create suitable packages list for TazPKG and only for built packages
1033 # as well as flavors files for TazLiTo. We dont need logs since we do it
1034 # manually to ensure everything is fine before syncing the mirror.
1035 case "$2" in
1036 --flavors)
1037 continue ;;
1038 *)
1039 [ "$2" ] && PKGS="$2"
1040 [ ! -d "$PKGS" ] && \
1041 gettext -e "\nPackages directory doesn't exist\n\n" && exit 1 ;;
1042 esac
1043 time=$(date +%s)
1044 flavors=$SLITAZ/flavors
1045 live=$SLITAZ/live
1046 echo "cook:pkgdb" > $command
1047 echo "Cook pkgdb: Creating all packages lists" | log
1048 echo ""
1049 gettext "Creating lists for: "; echo "$PKGS"
1050 separator
1051 gettext "Cook pkgdb started: "; date "+%Y-%m-%d %H:%M"
1052 cd $PKGS
1053 rm -f packages.*
1054 gettext -e "Creating: packages.list\n"
1055 ls -1 *.tazpkg | sed s'/.tazpkg//' > $PKGS/packages.list
1056 gettext -e "Creating: packages.md5\n"
1057 md5sum *.tazpkg > $PKGS/packages.md5
1058 md5sum packages.md5 | cut -f1 -d' ' > ID
1059 gettext -e "Creating lists from: "; echo "$WOK"
1060 cd $WOK
1061 for pkg in *
1062 do
1063 unset_receipt
1064 . $pkg/receipt
1065 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
1066 # PACKED_SIZE and UNPACKED_SIZE are only in built receipt
1067 if [ -s $pkg/taz/*/receipt ]; then
1068 . $pkg/taz/*/receipt
1069 fi
1070 # packages.desc lets us search easily in DB
1071 cat >> $PKGS/packages.desc << EOT
1072 $PACKAGE | ${VERSION}$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE
1073 EOT
1074 # packages.txt used by tazpkg and tazpkg-web also to provide
1075 # a human readable package list with version and description.
1076 cat >> $PKGS/packages.txt << EOT
1077 $PACKAGE
1078 ${VERSION}$EXTRAVERSION
1079 $SHORT_DESC
1080 $PACKED_SIZE ($UNPACKED_SIZE installed)
1082 EOT
1083 # packages.equiv is used by tazpkg install to check depends.
1084 for i in $PROVIDE; do
1085 DEST=""
1086 echo $i | fgrep -q : && DEST="${i#*:}:"
1087 if grep -qs ^${i%:*}= $PKGS/packages.equiv; then
1088 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" \
1089 $PKGS/packages.equiv
1090 else
1091 echo "${i%:*}=$DEST$PACKAGE" >> $PKGS/packages.equiv
1092 fi
1093 done
1094 # files.list provides a list of all packages files.
1095 cat $pkg/taz/*/files.list | sed s/^/"$pkg: \0"/ >> \
1096 $PKGS/files.list
1097 fi
1098 done
1100 # Display list size.
1101 gettext -e "Done: packages.desc\n"
1102 gettext -e "Done: packages.txt\n"
1103 gettext -e "Done: packages.equiv\n"
1105 # files.list.lzma
1106 gettext -e "Creating: files.list.lzma\n"
1107 cd $PKGS && lzma e files.list files.list.lzma
1108 rm -f files.list
1110 # Display some info.
1111 separator
1112 nb=$(ls $PKGS/*.tazpkg | wc -l)
1113 time=$(($(date +%s) - $time))
1114 echo -e "Packages: $nb - Time: ${time}s\n"
1116 # Create all flavors files at once. Do we really need code to monitor
1117 # flavors changes ? Lets just build them with packages lists before
1118 # syncing the mirror.
1119 [ "$2" == "--flavors" ] || exit 1
1120 [ ! -d "$flavors" ] && echo -e "Missing flavors: $flavors\n" && exit 1
1121 [ -d "$live" ] || mkdir -p $live
1122 gettext "Creating flavors files in:"; echo " $live"
1123 echo "Cook pkgdb: Creating all flavors" | log
1124 separator
1125 gettext -e "Recharging lists to use latest packages...\n"
1126 tazpkg recharge >/dev/null 2>/dev/null
1128 # We need a custom tazlito config to set working dir to /home/slitaz.
1129 if [ ! -f "$live/tazlito.conf" ]; then
1130 echo "Creating configuration file: tazlito.conf"
1131 cp /etc/tazlito/tazlito.conf $live
1132 sed -i s@WORK_DIR=.*@WORK_DIR=\"/home/slitaz\"@ \
1133 $live/tazlito.conf
1134 fi
1136 # Update Hg flavors repo and pack.
1137 [ -d "$flavors/.hg" ] && cd $flavors && hg pull -u
1139 cd $live
1140 echo "Starting to generate flavors..."
1141 rm -f flavors.list *.flavor
1142 for i in $flavors/*
1143 do
1144 fl=$(basename $i)
1145 echo "Packing flavor: $(basename $i)"
1146 tazlito pack-flavor $fl >/dev/null || exit 1
1147 tazlito show-flavor $fl --brief --noheader 2> \
1148 /dev/null >> flavors.list
1149 done
1150 cp -f $live/*.flavor $live/flavors.list $PKGS
1151 separator && gettext "Flavors size: "; du -sh $live | awk '{print $1}'
1152 echo "" && rm -f $command ;;
1153 *)
1154 # Just cook and generate a package.
1155 check_root
1156 time=$(date +%s)
1157 pkg="$1"
1158 [ -z "$pkg" ] && usage
1159 receipt="$WOK/$pkg/receipt"
1160 check_pkg_in_wok && echo ""
1162 # Skip blocked, 3 lines also for the Cooker.
1163 if grep -q "^$pkg$" $blocked && [ "$2" != "--unblock" ]; then
1164 gettext -e "Blocked package:"; echo -e " $pkg\n" && exit 0
1165 fi
1167 try_aufs_chroot "$@"
1169 # Log and source receipt.
1170 echo "Cook started for: <a href='cooker.cgi?pkg=$pkg'>$pkg</a>" | log
1171 echo "cook:$pkg" > $command
1173 # Display and log info if cook process stopped.
1174 trap 'gettext -e "\n\nCook stopped: control-C\n\n" | \
1175 tee -a $LOGS/$pkg.log' INT
1177 unset inst
1178 unset_receipt
1179 . $receipt
1181 # Handle --options
1182 case "$2" in
1183 --clean|-c)
1184 gettext -e "Cleaning:"; echo -n " $pkg"
1185 cd $WOK/$pkg && rm -rf install taz source
1186 status && echo "" && exit 0 ;;
1187 --install|-i)
1188 inst='yes' ;;
1189 --getsrc|-gs)
1190 gettext "Getting source for:"; echo " $pkg"
1191 separator && get_source
1192 echo -e "Tarball: $SRC/$TARBALL\n" && exit 0 ;;
1193 --block|-b)
1194 gettext "Blocking:"; echo -n " $pkg"
1195 [ $(grep "^$pkg$" $blocked) ] || echo "$pkg" >> $blocked
1196 status && echo "" && exit 0 ;;
1197 --unblock|-ub)
1198 gettext "Unblocking:"; echo -n " $pkg"
1199 sed -i "/^${pkg}$/"d $blocked
1200 status && echo "" && exit 0 ;;
1202 esac
1204 # Check if wanted is built now so we have separate log files.
1205 for wanted in $WANTED ; do
1206 if grep -q "^$wanted$" $blocked; then
1207 echo "WANTED package is blocked: $wanted" | tee $LOGS/$pkg.log
1208 echo "" && rm -f $command && exit 1
1209 fi
1210 if grep -q "^$wanted$" $broken; then
1211 echo "WANTED package is broken: $wanted" | tee $LOGS/$pkg.log
1212 echo "" && rm -f $command && exit 1
1213 fi
1214 if [ ! -d "$WOK/$wanted/install" ]; then
1215 cook "$wanted" || exit 1
1216 fi
1217 done
1219 # Cook and pack or exit on error and log everything.
1220 cookit $@ 2>&1 | tee $LOGS/$pkg.log
1221 remove_deps | tee -a $LOGS/$pkg.log
1222 cookit_quality
1223 packit 2>&1 | tee -a $LOGS/$pkg.log
1224 clean_log
1226 # Exit if any error in packing.
1227 if grep -q ^ERROR $LOGS/$pkg.log; then
1228 debug_info | tee -a $LOGS/$pkg.log
1229 rm -f $command && exit 1
1230 fi
1232 # Create an XML feed
1233 gen_rss
1235 # Time and summary
1236 time=$(($(date +%s) - $time))
1237 summary | tee -a $LOGS/$pkg.log
1238 echo ""
1240 # Install package if requested
1241 if [ "$inst" ]; then
1242 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
1243 cd $PKGS && tazpkg install \
1244 $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg --forced
1245 else
1246 gettext -e "Unable to install package, build has failed.\n\n"
1247 exit 1
1248 fi
1249 fi
1251 # Install package if part of the chroot to keep env up-to-date.
1252 if [ -d "$INSTALLED/$PACKAGE" ] && [ -z "$AUFS_MOUNTS" ]; then
1253 echo "Updating chroot environment..."
1254 echo "Updating chroot: $PACKAGE (${VERSION}${EXTRAVERSION})" | log
1255 cd $PKGS && tazpkg install \
1256 $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg --forced
1257 fi
1259 # Finally we DONT WANT to build the *-dev or packages with WANTED="$pkg"
1260 # You want automation: use the Cooker Build Bot.
1261 #[ -d "$WOK/$pkg-dev" ] && cook $pkg-dev
1262 rm -f $command ;;
1263 esac
1265 exit 0