cookutils view cook @ rev 26

cooker: add option --list= and log all stderr
author Christophe Lincoln <pankso@slitaz.org>
date Fri May 06 04:07:11 2011 +0200 (2011-05-06)
parents a7f0d97a9ccc
children 107f17f16133
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"
18 #
19 # Functions
20 #
22 usage() {
23 cat << EOT
25 $(echo -e "\033[1m$(gettext "Usage:")\033[0m") cook [package|command|list] [--option]
27 $(echo -e "\033[1m$(gettext "Commands:")\033[0m")
28 usage|help $(gettext "Display this short usage.")
29 list-wok $(gettext "List packages in the wok.")
30 setup $(gettext "Setup your build environment.")
31 test $(gettext "Test environment and cook a package.")
32 new $(gettext "Create a new package with receipt".)
33 list $(gettext "Cook a list of packages.")
34 clean-wok $(gettext "Clean-up all packages files.")
35 clean-src $(gettext "Clean-up all packages source.")
36 pkglist $(gettext "Create all packages.* lists.")
38 $(echo -e "\033[1m$(gettext "Options:")\033[0m")
39 --clean|-c Cook : $(gettext "clean the package in the wok.")
40 --install|-i Cook : $(gettext "and install the package.")
41 --wok|-w Setup: $(gettext "create also a wok from Hg repo.")
43 EOT
44 exit 0
45 }
47 # Be sure we root.
48 check_root() {
49 [ $(id -u) != 0 ] && gettext -e "\nYou must be root to cook.\n\n" && exit 0
50 }
52 separator() {
53 echo "================================================================================"
54 }
56 status() {
57 echo -en "\\033[70G[ "
58 if [ $? = 0 ]; then
59 echo -en "\\033[1;32mOK"
60 else
61 echo -en "\\033[1;31mFailed"
62 fi
63 echo -e "\\033[0;39m ]"
64 }
66 # Log activities, we want first letter capitalized.
67 log() {
68 grep ^[a-zA-Z0-9] | \
69 sed s"#^[A-Z]\([^']*\)#$(date '+%Y-%m-%d %H:%M') : \0#" >> $activity
70 }
72 # We dont want those escape in web interface.
73 clean_log() {
74 sed -i -e s'|\[70G\[ \[1;32m| |' \
75 -e s'|\[0;39m \]||' $LOGS/$pkg.log
76 }
78 # Log broken packages.
79 broken() {
80 echo "$pkg" >> $broken
81 }
83 # Be sure package exist in wok.
84 check_pkg_in_wok() {
85 if [ ! -d "$WOK/$pkg" ]; then
86 gettext -e "\nUnable to find package in the wok:"
87 echo -e " $pkg\n" && exit 1
88 fi
89 }
91 if_empty_value() {
92 if [ -z "$value" ]; then
93 gettext "QA: empty variable:"; echo -e " ${var}=\"\"\n"
94 exit 1
95 fi
96 }
98 # QA: check a receip consistency befor building.
99 receipt_quality() {
100 gettext -e "QA: checking package receipt...\n"
101 unset online
102 if ifconfig | grep -q -A 1 "^[a-z]*[0-9]" | fgrep 'addr:'; then
103 online="online"
104 fi
105 for var in PACKAGE VERSION CATEGORY SHORT_DESC MAINTAINER WEB_SITE
106 do
107 unset value
108 value=$(grep ^$var= receipt | cut -d \" -f 2)
109 case "$var" in
110 PACKAGE|VERSION|SHORT_DESC)
111 if_empty_value ;;
112 CATEGORY)
113 [ -z "$value" ] && value="empty"
114 valid="base-system x-window utilities network graphics \
115 multimedia office development system-tools security games \
116 misc meta non-free"
117 if ! echo "$valid" | grep -q -w "$value"; then
118 gettext "QA: unknow category:"; echo -e " $value\n"
119 exit 1
120 fi ;;
121 WEB_SITE)
122 # We dont check WGET_URL since if dl is needed it will fail.
123 # Break also if we not online. Here error is not fatal.
124 if_empty_value
125 [ -z "$online" ] || break
126 if ! busybox wget -s $value 2>/dev/null; then
127 gettext "QA: Unable to reach:"; echo -e " $value\n"
128 fi ;;
129 esac
130 done
131 }
133 # Executed before sourcing a receipt.
134 unset_receipt() {
135 unset DEPENDS BUILD_DEPENDS WANTED EXTRAVERSION WGET_URL PROVIDE TARBALL
136 }
138 # Path's used in receipt and by cook itself.
139 set_paths() {
140 pkgdir=$WOK/$PACKAGE
141 src=$pkgdir/source/$PACKAGE-$VERSION
142 pack=$pkgdir/taz/$PACKAGE-${VERSION}${EXTRAVERSION}
143 fs=$pack/fs
144 stuff=$pkgdir/stuff
145 install=$pkgdir/install
146 if [ "$WANTED" ]; then
147 src=$WOK/$WANTED/source/$WANTED-$VERSION
148 install=$WOK/$WANTED/install
149 fi
150 # Old way compatibility.
151 _pkg=$install
152 }
154 # Get package source.
155 get_source() {
156 case "$WGET_URL" in
157 http://*|ftp://*)
158 # Busybox Wget is better!
159 busybox wget -c -P $SRC $WGET_URL || \
160 (echo -e "ERROR: wget $WGET_URL" && exit 1) ;;
161 hg*|mercurial*)
162 # We are in cache so clone here and create a tarball
163 pwd=$(pwd)
164 if $(echo "$WGET_URL" | fgrep -q hg); then
165 url=${WGET_URL#hg|}
166 else
167 url=${WGET_URL#mercurial|}
168 fi
169 pkgsrc=${SOURCE:-$PACKAGE}-$VERSION
170 tarball=$pkgsrc.tar.bz2
171 gettext "Getting source from Hg: "; echo $url
172 gettext "Cloning to: "; echo "$pwd/$pkgsrc"
173 hg clone $url $pkgsrc || (echo "ERROR: hg clone $url" && exit 1)
174 gettext "Creating tarball: "; echo "$tarball"
175 tar cjf $tarball $pkgsrc || exit 1
176 mv $tarball $SRC && rm -rf $pkgsrc ;;
177 git*)
178 echo "TODO: git implementation in cook" && exit 1 ;;
179 svn*)
180 echo "TODO: svn implementation in cook" && exit 1 ;;
181 *)
182 gettext -e "\nERROR: Unable to handle:"; echo -e " $WGET_URL \n" | \
183 tee -a $LOGS/$PACKAGE.log
184 exit 1 ;;
185 esac
186 }
188 # Extract source package.
189 extract_source() {
190 gettext "Extracting:"; echo " $TARBALL"
191 case "$TARBALL" in
192 *.tar.gz|*.tgz) tar xzf $SRC/$TARBALL ;;
193 *.tar.bz2) tar xjf $SRC/$TARBALL ;;
194 *.tar.lzma) tar xaf $SRC/$TARBALL ;;
195 *.zip) unzip $SRC/$TARBALL ;;
196 esac
197 }
199 # Display cooked package summary.
200 summary() {
201 cd $WOK/$pkg
202 [ -d install ] && prod=$(du -sh install | awk '{print $1}' 2>/dev/null)
203 fs=$(du -sh taz/* | awk '{print $1}')
204 size=$(du -sh $PKGS/$PACKAGE-${VERSION}*.tazpkg | awk '{print $1}')
205 files=$(cat taz/$PACKAGE-*/files.list | wc -l)
206 cookdate=$(date "+%Y-%m-%d %H:%M")
207 gettext "Summary for:"; echo " $PACKAGE $VERSION"
208 separator
209 [ "$prod" ] && echo "Produce : $prod"
210 cat << EOT
211 Packed : $fs
212 Compressed : $size
213 Files : $files
214 Cook time : ${time}s
215 Cook date : $cookdate
216 $(separator)
218 EOT
219 }
221 # Display debugging erroe info.
222 debug_info() {
223 echo -e "\nDebug information"
224 separator
225 fgrep ERROR $LOGS/$pkg.log
226 separator && echo ""
227 }
229 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
230 # so some packages need to copy these files with the receipt and genpkg_rules.
231 copy_generic_files()
232 {
233 # $LOCALE is set in cook.conf
234 if [ "$LOCALE" ]; then
235 if [ -d "$_pkg/usr/share/locale" ]; then
236 mkdir -p $fs/usr/share/locale
237 for i in $LOCALE
238 do
239 if [ -d "$_pkg/usr/share/locale/$i" ]; then
240 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
241 fi
242 done
243 fi
244 fi
246 # Generic pixmaps copy can be disabled with GENERIC_PIXMAPS="no"
247 if [ "$GENERIC_PIXMAPS" != "no" ]; then
248 if [ -d "$_pkg/usr/share/pixmaps" ]; then
249 mkdir -p $fs/usr/share/pixmaps
250 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
251 $fs/usr/share/pixmaps 2>/dev/null
252 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
253 $fs/usr/share/pixmaps 2>/dev/null
254 fi
256 # Custom or homemade PNG pixmap can be in stuff.
257 if [ -f "$stuff/$PACKAGE.png" ]; then
258 mkdir -p $fs/usr/share/pixmaps
259 cp -a $stuff/$PACKAGE.png $fs/usr/share/pixmaps
260 fi
261 fi
263 # Desktop entry (.desktop).
264 if [ -d "$_pkg/usr/share/applications" ]; then
265 cp -a $_pkg/usr/share/applications $fs/usr/share
266 fi
268 # Homemade desktop file(s) can be in stuff.
269 if [ -d "$stuff/applications" ]; then
270 mkdir -p $fs/usr/share
271 cp -a $stuff/applications $fs/usr/share
272 fi
273 if [ -f "$stuff/$PACKAGE.desktop" ]; then
274 mkdir -p $fs/usr/share/applications
275 cp -a $stuff/$PACKAGE.desktop $fs/usr/share/applications
276 fi
277 }
279 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
280 strip_package()
281 {
282 gettext "Executing strip on all files"
283 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
284 do
285 if [ -d "$dir" ]; then
286 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
287 fi
288 done
289 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
290 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
291 status
292 }
294 # Remove installed deps.
295 remove_deps() {
296 # Now remove installed build deps.
297 diff="$CACHE/installed.diff"
298 deps=$(cat $diff | grep ^+[a-zA-Z0-9] | sed s/^+//)
299 nb=$(cat $diff | grep ^+[a-zA-Z0-9] | wc -l)
300 if [ -s "$CACHE/installed.diff" ]; then
301 gettext "Build dependencies to remove:"; echo " $nb"
302 gettext "Removing:"
303 for dep in $deps
304 do
305 echo -n " $dep"
306 yes | tazpkg remove $dep >/dev/null
307 done
308 echo -e "\n"
309 mv -f $CACHE/installed.diff $CACHE/installed.last.diff
310 fi
311 }
313 # The main cook function.
314 cookit() {
315 echo "Cook: $PACKAGE $VERSION"
316 separator
317 set_paths
318 [ "$QA" ] && receipt_quality
319 rm -rf install taz source $CACHE/error
321 # Disable -pipe if less than 512Mb free RAM.
322 free=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
323 if [ "$free" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then
324 gettext -e "Disabling -pipe compile flag: $free RAM\n"
325 CFLAGS="${CFLAGS/-pipe}" && CFLAGS=$(echo "$CFLAGS" | tr -s ' ')
326 CXXFLAGS="${CXXFLAGS/-pipe}" && CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ')
327 fi
328 unset free
330 # Export flags and path to be used by make
331 DESTDIR=$WOK/$PACKAGE/install
332 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS BUILD_HOST CONFIG_SITE
333 local LC_ALL=POSIX LANG=POSIX
335 # Check for build dep.
336 cd $INSTALLED && ls -1 > $CACHE/installed.list
337 [ "$DEPENDS" ] && gettext -e "Checking build dependencies...\n"
338 for dep in $BUILD_DEPENDS
339 do
340 if [ ! -d "$INSTALLED/$dep" ]; then
341 # Try local package first
342 if [ -f "$PKGS/$dep-*.tazpkg" ]; then
343 gettext "Installing dep (local):"; echo " $dep"
344 cd $PKGS && tazpkg install $dep-*.tazpkg >/dev/null
345 else
346 gettext "Installing dep (web/cache):"; echo " $dep"
347 tazpkg get-install $dep >/dev/null
348 fi
349 fi
350 done
351 ls -1 > $CACHE/installed.cook && cd $CACHE
353 # If a cook failed deps are not remove since we exit 1.
354 [ ! -s "installed.diff" ] && \
355 diff installed.list installed.cook > installed.diff
356 deps=$(cat installed.diff | grep ^+[a-zA-Z0-9] | wc -l)
358 # Get source tarball and make sure we have source dir named:
359 # $PACKAGE-$VERSION to be standard in receipts. Her we use tar.lzma
360 # tarball if it exist.
361 if [ "$WGET_URL" ] && [ ! -f "$SRC/$TARBALL" ]; then
362 if [ -f "$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
363 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
364 else
365 get_source || exit 1
366 fi
367 fi
368 if [ ! "$WANTED" ] && [ "$TARBALL" ] && [ ! -d "$src" ]; then
369 mkdir -p $pkgdir/source/tmp && cd $pkgdir/source/tmp
370 extract_source || exit 1
371 mv * ../$PACKAGE-$VERSION
372 cd .. && rm -rf tmp
373 fi
375 # Execute receipt rules.
376 if grep -q ^compile_rules $pkgdir/receipt; then
377 gettext -e "Executing: compile_rules\n"
378 [ -d "$src" ] && cd $src
379 compile_rules || exit 1
380 # Stay compatible with _pkg
381 [ -d $src/_pkg ] && mv $src/_pkg $install
382 # QA: compile_rules success so valid.
383 mkdir -p $install
384 else
385 # QA: No compile_rules so no error, valid.
386 mkdir -p $install
387 fi
388 separator && echo ""
389 }
391 # Cook quality assurance.
392 cookit_quality() {
393 if [ ! -d "$WOK/$pkg/install" ] && [ ! "$WANTED" ]; then
394 echo -e "ERROR: cook failed" | tee -a $LOGS/$pkg.log
395 fi
396 # ERROR can be echoed any time in cookit()
397 if grep -q ^ERROR $LOGS/$pkg.log; then
398 debug_info | tee -a $LOGS/$pkg.log
399 exit 1
400 fi
401 }
403 # Create the package. Wanted to use Tazpkg to create a tazpkg package at first,
404 # but it dont handle EXTRAVERSION.
405 packit() {
406 set_paths
407 echo "Packing: $PACKAGE $VERSION"
408 separator
409 if grep -q ^genpkg_rules $pkgdir/receipt; then
410 gettext -e "Executing: genpkg_rules\n"
411 cd $pkgdir
412 mkdir -p $fs && genpkg_rules || ( echo -e \
413 "\nERROR: genpkg_rules failed\n" | tee -a $LOGS/$pkg.log && exit 1 )
414 fi
415 cd $pkgdir/taz
416 strip_package
417 for file in receipt description.txt
418 do
419 [ ! -f "../$file" ] && continue
420 gettext "Copying"; echo -n " $file..."
421 cp -f ../$file $pack && chown 0.0 $pack/$file && status
422 done
423 copy_generic_files
425 # Create files.list with redirecting find outpout.
426 gettext "Creating the list of files..." && cd $fs
427 find . -type f -print > ../files.list
428 find . -type l -print >> ../files.list
429 cd .. && sed -i s/'^.'/''/ files.list
430 status
431 gettext "Creating md5sum of files..."
432 while read file; do
433 [ -L "fs$file" ] && continue
434 [ -f "fs$file" ] || continue
435 case "$file" in
436 /lib/modules/*/modules.*|*.pyc) continue;;
437 esac
438 md5sum "fs$file" | sed 's/ fs/ /'
439 done < files.list > md5sum
440 status
441 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum \
442 description.txt 2> /dev/null | awk \
443 '{ sz=$1 } END { print sz }')
445 # Build cpio archives.
446 gettext "Compressing the fs... "
447 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
448 rm -rf fs
449 status
450 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list \
451 md5sum description.txt 2> /dev/null | awk \
452 '{ sz=$1 } END { print sz }')
453 gettext "Updating receipt sizes..."
454 sed -i s/^PACKED_SIZE.*$// receipt
455 sed -i s/^UNPACKED_SIZE.*$// receipt
456 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
457 status
459 # Set extra version.
460 if [ "$EXTRAVERSION" ]; then
461 gettext "Updating receipt EXTRAVERSION: "; echo -n "$EXTRAVERSION"
462 sed -i s/^EXTRAVERSION.*$// receipt
463 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
464 status
465 fi
467 # Compress.
468 gettext "Creating full cpio archive... "
469 find . -print | cpio -o -H newc --quiet > \
470 ../$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg
471 status
472 gettext "Restoring original package tree... "
473 unlzma -c fs.cpio.lzma | cpio -idm --quiet
474 status
475 rm fs.cpio.lzma && cd ..
476 separator && gettext "Package: "
477 du -sh $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg
478 echo ""
479 }
481 # Verify package quality and consitensy.
482 packit_quality() {
483 if grep -q ^ERROR $LOGS/$pkg.log; then
484 exit 1
485 fi
486 if ! grep -q ^/ $WOK/$pkg/taz/$pkg-*/files.list; then
487 echo -e "ERROR: empty package\n" | tee -a $LOGS/$pkg.log && exit 1
488 else
489 mv -f $WOK/$pkg/taz/$pkg-*.tazpkg $PKGS
490 sed -i /^${pkg}$/d $broken
491 fi
492 }
494 #
495 # Commands
496 #
498 case "$1" in
499 usage|help)
500 usage ;;
501 list-wok)
502 gettext "List of packages in:"; echo " $WOK"
503 separator
504 cd $WOK && ls -1
505 separator
506 echo -n "Packages: " && ls | wc -l
507 echo "" ;;
508 setup)
509 # Setup a build environment
510 check_root
511 echo "Cook: setting up the environment" | log
512 gettext -e "\nSetting up your environment\n"
513 separator && cd $SLITAZ
514 gettext "Creating directories structure in:"; echo " $SLITAZ"
515 mkdir -p $WOK $PKGS $SRC $CACHE $LOGS
516 gettext -e "Checking for packages to install...\n"
517 for pkg in slitaz-toolchain tazdev intltool gettext
518 do
519 [ ! -d "$INSTALLED/$pkg" ] && tazpkg get-install $pkg
520 done
522 # Handle --options
523 case "$2" in
524 --wok)
525 [ ! -d "$INSTALLED/mercurial" ] && tazpkg get-install mercurial
526 [ -d "$WOK" ] && echo -e "A wok already exist.\n" && exit 1
527 hg clone $HG_URL ;;
528 --chroot)
529 echo "TODO: create a chroot with tazdev" ;;
530 esac
532 # SliTaz group and permissions
533 if ! grep -q ^slitaz /etc/group; then
534 gettext -e "Adding group: slitaz\n"
535 addgroup slitaz
536 fi
537 gettext -e "Setting permissions for slitaz group...\n"
538 chown -R root.slitaz $SLITAZ
539 chmod -R g+w $SLITAZ
540 separator
541 gettext -e "All done, ready to cook packages :-)\n\n" ;;
542 test)
543 # Test a cook environment.
544 echo "Cook test: testing the cook environment" | log
545 [ ! -d "$WOK" ] && exit 1
546 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK
547 cook cooktest ;;
548 new)
549 # Create the package folder and an empty receipt.
550 pkg="$2"
551 [ "$pkg" ] || usage
552 echo ""
553 if [ -d "$WOK/$pkg" ]; then
554 echo -n "$pkg " && gettext "package already exist."
555 echo -e "\n" && exit 1
556 fi
557 gettext "Creating"; echo -n " $WOK/$pkg"
558 mkdir $WOK/$pkg && cd $WOK/$pkg && status
559 gettext "Preparing the package receipt..."
560 cp $DATA/receipt .
561 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
562 status && echo "" ;;
563 list)
564 # Cook a list of packages (better use the Cooker since it will order
565 # packages before executing cook).
566 check_root
567 [ -z "$2" ] && gettext -e "\nNo list in argument.\n\n" && exit 1
568 [ ! -f "$2" ] && gettext -e "\nNo list found:" && \
569 echo -e " $2\n" && exit 1
570 echo "Cook list starting: $2" | log
571 for pkg in $(cat $2)
572 do
573 cook $pkg || broken
574 done ;;
575 clean-wok)
576 check_root
577 gettext -e "\nCleaning all packages files..."
578 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
579 status && echo "" ;;
580 clean-src)
581 check_root
582 gettext -e "\nCleaning all packages source..."
583 rm -rf $WOK/*/source
584 status && echo "" ;;
585 pkglist)
586 # Create suitable packages list for TazPKG and only for builded packages.
587 [ "$2" ] && PKGS="$2"
588 [ ! -d "$PKGS" ] && \
589 gettext -e "\nPackages directory dont exist\n\n" && exit 1
590 cd $PKGS
591 echo "Cook pkglist: Creating all packages list" | log
592 gettext -e "\nCreating lists for:"; echo " $PKGS"
593 separator
594 rm -f packages.* files.list*
595 gettext -e "Creating: packages.list\n"
596 ls -1 | sed s'/.tazpkg//' > $PKGS/packages.list
597 gettext -e "Creating: packages.md5\n"
598 md5sum *.tazpkg > $PKGS/packages.md5
599 gettext -e "Creating: packages.desc\n"
600 gettext -e "Creating: packages.equiv\n"
601 cd $WOK
602 for pkg in *
603 do
604 unset_receipt
605 . $pkg/receipt
606 # packages.desc let us search easily in DB
607 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
608 cat >> $PKGS/packages.desc << EOT
609 $PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE
610 EOT
611 # Packages.equiv is used by tazpkg install to check depends.
612 for i in $PROVIDE; do
613 DEST=""
614 echo $i | fgrep -q : && DEST="${i#*:}:"
615 if grep -qs ^${i%:*}= $PKGS/packages.equiv; then
616 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" \
617 $PKGS/packages.equiv
618 else
619 echo "${i%:*}=$DEST$PACKAGE" >> $PKGS/packages.equiv
620 fi
621 done
622 fi
623 done
624 # files.list.lzma
625 #lzma e files.list files.list.lzma
626 separator
627 nb=$(ls $PKGS/*.tazpkg | wc -l)
628 echo -e "Packages: $nb\n" ;;
629 *)
630 # Just cook and generate a package.
631 check_root
632 time=$(date +%s)
633 pkg="$1"
634 [ -z "$pkg" ] && usage
635 check_pkg_in_wok && echo ""
636 echo "cook:$pkg" > $command
637 unset inst
638 unset_receipt
639 cd $WOK/$pkg && . ./receipt
641 # Handle --options
642 case "$2" in
643 --clean|-c)
644 gettext -e "Cleaning package:"; echo -n " $pkg"
645 cd $WOK/$pkg && rm -rf install taz source
646 status && echo "" && exit 0 ;;
647 --install|-i)
648 inst='yes' ;;
649 esac
651 # Check if wanted is build now so we have separate log files.
652 if [ "$WANTED" ] && [ ! -d "$WOK/$WANTED/install" ]; then
653 cook "$WANTED"
654 fi
656 # Cook and pack or exit on error and log everything.
657 cookit 2>&1 | tee $LOGS/$pkg.log
658 remove_deps | tee -a $LOGS/$pkg.log
659 cookit_quality
661 packit 2>&1 | tee -a $LOGS/$pkg.log
662 clean_log
663 packit_quality
665 # Time and summary
666 time=$(($(date +%s) - $time))
667 summary | tee -a $LOGS/$pkg.log
669 # Install package if requested
670 if [ "$inst" ]; then
671 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
672 cd $PKGS && tazpkg install \
673 $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg --forced
674 else
675 gettext -e "Unable to install package, build have failed.\n\n"
676 exit 1
677 fi
678 fi
679 # Finally we DONT WANT to build the *-dev or packages with WANTED="$pkg"
680 # You want automation: use the Cooker Build Bot.
681 #[ -d "$WOK/$pkg-dev" ] && cook $pkg-dev
682 rm -f $command ;;
683 esac
685 exit 0