cookutils view cook @ rev 49

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