cookutils view cook @ rev 51

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