cookutils view cook @ rev 18

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