cookutils view cook @ rev 45

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