cookutils view cook @ rev 16

Cant use tazpkg to pack since it dont handle EXTRAVERSION and improving CGI
author Christophe Lincoln <pankso@slitaz.org>
date Thu May 05 17:05:19 2011 +0200 (2011-05-05)
parents b6bbe55cd15e
children c3c30b1506b8
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 gettext "Summary for:"; echo " $PACKAGE $VERSION"
202 separator
203 [ "$prod" ] && echo "Produce : $prod"
204 cat << EOT
205 Packed : $fs
206 Compressed : $size
207 Cook time : ${time}s
208 Files : $files
209 $(separator)
211 EOT
212 }
214 # Display debugging erroe info.
215 debug_info() {
216 echo "Debug information"
217 separator
218 fgrep ERROR $LOGS/$pkg.log
219 separator && echo ""
220 }
222 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
223 # so some packages need to copy these files with the receipt and genpkg_rules.
224 copy_generic_files()
225 {
226 # $LOCALE is set in cook.conf
227 if [ "$LOCALE" ]; then
228 if [ -d "$_pkg/usr/share/locale" ]; then
229 mkdir -p $fs/usr/share/locale
230 for i in $LOCALE
231 do
232 if [ -d "$_pkg/usr/share/locale/$i" ]; then
233 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
234 fi
235 done
236 fi
237 fi
239 # Generic pixmaps copy can be disabled with GENERIC_PIXMAPS="no"
240 if [ "$GENERIC_PIXMAPS" != "no" ]; then
241 if [ -d "$_pkg/usr/share/pixmaps" ]; then
242 mkdir -p $fs/usr/share/pixmaps
243 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
244 $fs/usr/share/pixmaps 2>/dev/null
245 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
246 $fs/usr/share/pixmaps 2>/dev/null
247 fi
249 # Custom or homemade PNG pixmap can be in stuff.
250 if [ -f "$stuff/$PACKAGE.png" ]; then
251 mkdir -p $fs/usr/share/pixmaps
252 cp -a $stuff/$PACKAGE.png $fs/usr/share/pixmaps
253 fi
254 fi
256 # Desktop entry (.desktop).
257 if [ -d "$_pkg/usr/share/applications" ]; then
258 cp -a $_pkg/usr/share/applications $fs/usr/share
259 fi
261 # Homemade desktop file(s) can be in stuff.
262 if [ -d "$stuff/applications" ]; then
263 mkdir -p $fs/usr/share
264 cp -a $stuff/applications $fs/usr/share
265 fi
266 if [ -f "$stuff/$PACKAGE.desktop" ]; then
267 mkdir -p $fs/usr/share/applications
268 cp -a $stuff/$PACKAGE.desktop $fs/usr/share/applications
269 fi
270 }
272 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
273 strip_package()
274 {
275 gettext "Executing strip on all files"
276 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
277 do
278 if [ -d "$dir" ]; then
279 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
280 fi
281 done
282 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
283 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
284 status
285 }
287 # Remove installed deps.
288 remove_deps() {
289 # Now remove installed build deps.
290 diff="$CACHE/installed.diff"
291 deps=$(cat $diff | grep ^+[a-zA-Z0-9] | sed s/^+//)
292 nb=$(cat $diff | grep ^+[a-zA-Z0-9] | wc -l)
293 if [ -s "$CACHE/installed.diff" ]; then
294 gettext "Build dependencies to remove:"; echo " $nb"
295 gettext "Removing:"
296 for dep in $deps
297 do
298 echo -n " $dep"
299 yes | tazpkg remove $dep >/dev/null
300 done
301 echo -e "\n"
302 mv -f $CACHE/installed.diff $CACHE/installed.last.diff
303 fi
304 }
306 # The main cook function.
307 cookit() {
308 echo "Cook: $PACKAGE $VERSION"
309 separator
310 set_paths
311 [ "$QA" ] && receipt_quality
312 rm -rf install taz source $CACHE/error
314 # Disable -pipe if less than 512Mb free RAM.
315 free=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
316 if [ "$free" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then
317 gettext -e "Disabling -pipe compile flag: $free RAM\n"
318 CFLAGS="${CFLAGS/-pipe}" && CFLAGS=$(echo "$CFLAGS" | tr -s ' ')
319 CXXFLAGS="${CXXFLAGS/-pipe}" && CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ')
320 fi
321 unset free
323 # Export flags and path to be used by make
324 DESTDIR=$WOK/$PACKAGE/install
325 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS BUILD_HOST CONFIG_SITE
326 local LC_ALL=POSIX LANG=POSIX
328 # Check for build dep.
329 cd $INSTALLED && ls -1 > $CACHE/installed.list
330 [ "$DEPENDS" ] && gettext -e "Checking build dependencies...\n"
331 for dep in $BUILD_DEPENDS
332 do
333 if [ ! -d "$INSTALLED/$dep" ]; then
334 # Try local package first
335 if [ -f "$PKGS/$dep-*.tazpkg" ]; then
336 gettext "Installing dep (local):"; echo " $dep"
337 cd $PKGS && tazpkg install $dep-*.tazpkg >/dev/null
338 else
339 gettext "Installing dep (web/cache):"; echo " $dep"
340 tazpkg get-install $dep >/dev/null
341 fi
342 fi
343 done
344 ls -1 > $CACHE/installed.cook && cd $CACHE
346 # If a cook failed deps are not remove since we exit 1.
347 [ ! -s "installed.diff" ] && \
348 diff installed.list installed.cook > installed.diff
349 deps=$(cat installed.diff | grep ^+[a-zA-Z0-9] | wc -l)
351 # Get source tarball and make sure we have source dir named:
352 # $PACKAGE-$VERSION to be standard in receipts. Her we use tar.lzma
353 # tarball if it exist.
354 if [ "$WGET_URL" ] && [ ! -f "$SRC/$TARBALL" ]; then
355 if [ -f "$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
356 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
357 else
358 get_source || exit 1
359 fi
360 fi
361 if [ ! "$WANTED" ] && [ "$TARBALL" ] && [ ! -d "$src" ]; then
362 mkdir -p $pkgdir/source/tmp && cd $pkgdir/source/tmp
363 extract_source || exit 1
364 mv * ../$PACKAGE-$VERSION
365 cd .. && rm -rf tmp
366 fi
368 # Execute receipt rules.
369 if grep -q ^compile_rules $pkgdir/receipt; then
370 gettext -e "Executing: compile_rules\n"
371 [ -d "$src" ] && cd $src
372 compile_rules || exit 1
373 # Stay compatible with _pkg
374 [ -d $src/_pkg ] && mv $src/_pkg $install
375 # QA: compile_rules success so valid.
376 mkdir -p $install
377 else
378 # QA: No compile_rules so no error, valid.
379 mkdir -p $install
380 fi
381 separator && echo ""
382 }
384 # Cook quality assurance.
385 cookit_quality() {
386 if [ ! -d "$WOK/$pkg/install" ] && [ ! "$WANTED" ]; then
387 echo -e "ERROR: cook failed" | tee -a $LOGS/$pkg.log
388 fi
389 # ERROR can be echoed any time in cookit()
390 if grep -q ^ERROR $LOGS/$pkg.log; then
391 echo ""
392 debug_info | tee $CACHE/debug
393 # Debug info on top, easier to check errors.
394 cat $CACHE/debug $LOGS/$pkg.log > $CACHE/$pkg.debug
395 mv -f $CACHE/$pkg.debug $LOGS/$pkg.log
396 exit 1
397 fi
398 }
400 # Create the package. Wanted to use Tazpkg to create a tazpkg package at first,
401 # but it dont handle EXTRAVERSION.
402 packit() {
403 set_paths
404 echo "Packing: $PACKAGE $VERSION"
405 separator
406 if grep -q ^genpkg_rules $pkgdir/receipt; then
407 gettext -e "Executing: genpkg_rules\n"
408 cd $pkgdir
409 mkdir -p $fs && genpkg_rules || ( echo -e \
410 "\nERROR: genpkg_rules failed\n" | tee -a $LOGS/$pkg.log && exit 1 )
411 fi
412 cd $pkgdir/taz
413 strip_package
414 for file in receipt description.txt
415 do
416 [ ! -f "../$file" ] && continue
417 gettext "Copying"; echo -n " $file..."
418 cp -f ../$file $pack && chown 0.0 $pack/$file && status
419 done
420 copy_generic_files
422 # Create files.list with redirecting find outpout.
423 gettext "Creating the list of files..." && cd $fs
424 find . -type f -print > ../files.list
425 find . -type l -print >> ../files.list
426 cd .. && sed -i s/'^.'/''/ files.list
427 status
428 gettext "Creating md5sum of files..."
429 while read file; do
430 [ -L "fs$file" ] && continue
431 [ -f "fs$file" ] || continue
432 case "$file" in
433 /lib/modules/*/modules.*|*.pyc) continue;;
434 esac
435 md5sum "fs$file" | sed 's/ fs/ /'
436 done < files.list > md5sum
437 status
438 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum \
439 description.txt 2> /dev/null | awk \
440 '{ sz=$1 } END { print sz }')
442 # Build cpio archives.
443 gettext "Compressing the fs... "
444 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
445 rm -rf fs
446 status
447 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list \
448 md5sum description.txt 2> /dev/null | awk \
449 '{ sz=$1 } END { print sz }')
450 gettext "Updating receipt sizes..."
451 sed -i s/^PACKED_SIZE.*$// receipt
452 sed -i s/^UNPACKED_SIZE.*$// receipt
453 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
454 status
456 # Set extra version.
457 if [ "$EXTRAVERSION" ]; then
458 gettext "Updating receipt EXTRAVERSION: "; echo -n "$EXTRAVERSION"
459 sed -i s/^EXTRAVERSION.*$// receipt
460 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
461 status
462 fi
464 # Compress.
465 gettext "Creating full cpio archive... "
466 find . -print | cpio -o -H newc --quiet > \
467 ../$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg
468 status
469 gettext "Restoring original package tree... "
470 unlzma -c fs.cpio.lzma | cpio -idm --quiet
471 status
472 rm fs.cpio.lzma && cd ..
473 separator && gettext "Package: "
474 du -sh $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg
475 echo ""
476 }
478 # Verify package quality and consitensy.
479 packit_quality() {
480 if grep -q ^ERROR $LOGS/$pkg.log; then
481 exit 1
482 fi
483 if ! grep -q ^/ $WOK/$pkg/taz/$pkg-*/files.list; then
484 echo -e "ERROR: empty package\n" | tee -a $LOGS/$pkg.log && exit 1
485 else
486 mv -f $WOK/$pkg/taz/$pkg-*.tazpkg $PKGS
487 sed -i /^${pkg}$/d $broken
488 fi
489 }
491 #
492 # Commands
493 #
495 case "$1" in
496 usage|help)
497 usage ;;
498 list-wok)
499 gettext "List of packages in:"; echo " $WOK"
500 separator
501 cd $WOK && ls -1
502 separator
503 echo -n "Packages: " && ls | wc -l
504 echo "" ;;
505 setup)
506 # Setup a build environment
507 check_root
508 echo "Cook: setting up the environment" | log
509 gettext -e "\nSetting up your environment\n"
510 separator && cd $SLITAZ
511 gettext "Creating directories structure in:"; echo " $SLITAZ"
512 mkdir -p $WOK $PKGS $SRC $CACHE $LOGS
513 gettext -e "Checking for packages to install...\n"
514 for pkg in slitaz-toolchain tazdev intltool gettext
515 do
516 [ ! -d "$INSTALLED/$pkg" ] && tazpkg get-install $pkg
517 done
519 # Handle --options
520 case "$2" in
521 --wok)
522 [ ! -d "$INSTALLED/mercurial" ] && tazpkg get-install mercurial
523 [ -d "$WOK" ] && echo -e "A wok already exist.\n" && exit 1
524 hg clone $HG_URL ;;
525 --chroot)
526 echo "TODO: create a chroot with tazdev" ;;
527 esac
529 # SliTaz group and permissions
530 if ! grep -q ^slitaz /etc/group; then
531 gettext -e "Adding group: slitaz\n"
532 addgroup slitaz
533 fi
534 gettext -e "Setting permissions for slitaz group...\n"
535 chown -R root.slitaz $SLITAZ
536 chmod -R g+w $SLITAZ
537 separator
538 gettext -e "All done, ready to cook packages :-)\n\n" ;;
539 test)
540 # Test a cook environment.
541 echo "Cook test: testing the cook environment" | log
542 [ ! -d "$WOK" ] && exit 1
543 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK
544 cook cooktest ;;
545 new)
546 # Create the package folder and an empty receipt.
547 pkg="$2"
548 [ "$pkg" ] || usage
549 echo ""
550 if [ -d "$WOK/$pkg" ]; then
551 echo -n "$pkg " && gettext "package already exist."
552 echo -e "\n" && exit 1
553 fi
554 gettext "Creating"; echo -n " $WOK/$pkg"
555 mkdir $WOK/$pkg && cd $WOK/$pkg && status
556 gettext "Preparing the package receipt..."
557 cp $DATA/receipt .
558 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
559 status && echo "" ;;
560 list)
561 # Cook a list of packages (better use the Cooker since it will order
562 # packages before executing cook).
563 check_root
564 [ -z "$2" ] && gettext -e "\nNo list in argument.\n\n" && exit 1
565 [ ! -f "$2" ] && gettext -e "\nNo list found:" && \
566 echo -e " $2\n" && exit 1
567 echo "Cook list starting: $2" | log
568 for pkg in $(cat $2)
569 do
570 cook $pkg || broken
571 done ;;
572 clean-wok)
573 check_root
574 gettext -e "\nCleaning all packages files..."
575 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
576 status && echo "" ;;
577 clean-src)
578 check_root
579 gettext -e "\nCleaning all packages source..."
580 rm -rf $WOK/*/source
581 status && echo "" ;;
582 pkglist)
583 # Create suitable packages list for TazPKG and only for builded packages.
584 [ "$2" ] && PKGS="$2"
585 [ ! -d "$PKGS" ] && \
586 gettext -e "\nPackages directory dont exist\n\n" && exit 1
587 cd $PKGS
588 echo "Cook pkglist: Creating all packages list" | log
589 gettext -e "\nCreating lists for:"; echo " $PKGS"
590 separator
591 rm -f packages.* files.list*
592 gettext -e "Creating: packages.list\n"
593 ls -1 | sed s'/.tazpkg//' > $PKGS/packages.list
594 gettext -e "Creating: packages.md5\n"
595 md5sum *.tazpkg > $PKGS/packages.md5
596 gettext -e "Creating: packages.desc\n"
597 gettext -e "Creating: packages.equiv\n"
598 cd $WOK
599 for pkg in *
600 do
601 unset_receipt
602 . $pkg/receipt
603 # packages.desc let us search easily in DB
604 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
605 cat >> $PKGS/packages.desc << EOT
606 $PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE
607 EOT
608 # Packages.equiv is used by tazpkg install to check depends.
609 for i in $PROVIDE; do
610 DEST=""
611 echo $i | fgrep -q : && DEST="${i#*:}:"
612 if grep -qs ^${i%:*}= $PKGS/packages.equiv; then
613 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" \
614 $PKGS/packages.equiv
615 else
616 echo "${i%:*}=$DEST$PACKAGE" >> $PKGS/packages.equiv
617 fi
618 done
619 fi
620 done
621 # files.list.lzma
622 #lzma e files.list files.list.lzma
623 separator
624 nb=$(ls $PKGS/*.tazpkg | wc -l)
625 echo -e "Packages: $nb\n" ;;
626 *)
627 # Just cook and generate a package.
628 check_root
629 time=$(date +%s)
630 pkg="$1"
631 [ -z "$pkg" ] && usage
632 check_pkg_in_wok && echo ""
633 echo "cook:$pkg" > $command
634 unset inst
635 unset_receipt
636 cd $WOK/$pkg && . ./receipt
638 # Handle --options
639 case "$2" in
640 --clean|-c)
641 gettext -e "Cleaning package:"; echo -n " $pkg"
642 cd $WOK/$pkg && rm -rf install taz source
643 status && echo "" && exit 0 ;;
644 --install|-i)
645 inst='yes' ;;
646 esac
648 # Check if wanted is build now so we have separate log files.
649 if [ "$WANTED" ] && [ ! -d "$WOK/$WANTED/install" ]; then
650 cook "$WANTED"
651 fi
653 # Cook and pack or exit on error and log everything.
654 cookit | tee $LOGS/$pkg.log
655 remove_deps | tee -a $LOGS/$pkg.log
656 cookit_quality
658 packit | tee -a $LOGS/$pkg.log
659 clean_log
660 packit_quality
662 # Time and summary
663 time=$(($(date +%s) - $time))
664 summary | tee -a $LOGS/$pkg.log
666 # Install package if requested
667 if [ "$inst" ]; then
668 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
669 cd $PKGS && tazpkg install \
670 $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg --forced
671 else
672 gettext -e "Unable to install package, build have failed.\n\n"
673 exit 1
674 fi
675 fi
676 # Finally we DONT WANT to build the *-dev or packages with WANTED="$pkg"
677 # You automation: use the Cooker Build Bot.
678 #[ -d "$WOK/$pkg-dev" ] && cook $pkg-dev
679 ;;
680 esac
682 exit 0