cookutils view cook @ rev 43

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