cookutils view cook @ rev 44

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