cookutils view cook @ rev 47

cook: Let handle blocked pkgs in 3 lines also used by the Cooker
author Christophe Lincoln <pankso@slitaz.org>
date Sat May 07 04:38:51 2011 +0200 (2011-05-07)
parents 7fc260d77233
children 8df3646e9d8f
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 --wok|-w Setup: $(gettext "create also a wok from Hg repo.")
45 EOT
46 exit 0
47 }
49 # Be sure we root.
50 check_root() {
51 [ $(id -u) != 0 ] && gettext -e "\nYou must be root to cook.\n\n" && exit 0
52 }
54 separator() {
55 echo "================================================================================"
56 }
58 status() {
59 echo -en "\\033[70G[ "
60 if [ $? = 0 ]; then
61 echo -en "\\033[1;32mOK"
62 else
63 echo -en "\\033[1;31mFailed"
64 fi
65 echo -e "\\033[0;39m ]"
66 }
68 # Log activities, we want first letter capitalized.
69 log() {
70 grep ^[A-Z] | \
71 sed s"#^[A-Z]\([^']*\)#$(date '+%Y-%m-%d %H:%M') : \0#" >> $activity
72 }
74 # We dont want those escape in web interface.
75 clean_log() {
76 sed -i -e s'|\[70G\[ \[1;32m| |' \
77 -e s'|\[0;39m \]||' $LOGS/$pkg.log
78 }
80 # Log broken packages.
81 broken() {
82 echo "$pkg" >> $broken
83 }
85 # Be sure package exist in wok.
86 check_pkg_in_wok() {
87 if [ ! -d "$WOK/$pkg" ]; then
88 gettext -e "\nUnable to find package in the wok:"
89 echo -e " $pkg\n" && exit 1
90 fi
91 }
93 if_empty_value() {
94 if [ -z "$value" ]; then
95 gettext "QA: empty variable:"; echo -e " ${var}=\"\"\n"
96 exit 1
97 fi
98 }
100 # QA: check a receip consistency befor building.
101 receipt_quality() {
102 gettext -e "QA: checking package receipt...\n"
103 unset online
104 if ifconfig | grep -q -A 1 "^[a-z]*[0-9]" | fgrep 'addr:'; then
105 online="online"
106 fi
107 for var in PACKAGE VERSION CATEGORY SHORT_DESC MAINTAINER WEB_SITE
108 do
109 unset value
110 value=$(grep ^$var= $receipt | cut -d \" -f 2)
111 case "$var" in
112 PACKAGE|VERSION|SHORT_DESC)
113 if_empty_value ;;
114 CATEGORY)
115 [ -z "$value" ] && value="empty"
116 valid="base-system x-window utilities network graphics \
117 multimedia office development system-tools security games \
118 misc meta non-free"
119 if ! echo "$valid" | grep -q -w "$value"; then
120 gettext "QA: unknow category:"; echo -e " $value\n"
121 exit 1
122 fi ;;
123 WEB_SITE)
124 # We dont check WGET_URL since if dl is needed it will fail.
125 # Break also if we not online. Here error is not fatal.
126 if_empty_value
127 [ -z "$online" ] || break
128 if ! busybox wget -s $value 2>/dev/null; then
129 gettext "QA: Unable to reach:"; echo -e " $value\n"
130 fi ;;
131 esac
132 done
133 }
135 # Executed before sourcing a receipt.
136 unset_receipt() {
137 unset DEPENDS BUILD_DEPENDS WANTED EXTRAVERSION WGET_URL PROVIDE TARBALL
138 }
140 # Path's used in receipt and by cook itself.
141 set_paths() {
142 pkgdir=$WOK/$PACKAGE
143 src=$pkgdir/source/$PACKAGE-$VERSION
144 taz=$pkgdir/taz
145 pack=$taz/$PACKAGE-${VERSION}${EXTRAVERSION}
146 fs=$pack/fs
147 stuff=$pkgdir/stuff
148 install=$pkgdir/install
149 if [ "$WANTED" ]; then
150 src=$WOK/$WANTED/source/$WANTED-$VERSION
151 install=$WOK/$WANTED/install
152 fi
153 # Old way compatibility.
154 _pkg=$install
155 }
157 # Get package source.
158 get_source() {
159 case "$WGET_URL" in
160 http://*|ftp://*)
161 # Busybox Wget is better!
162 busybox wget -c -P $SRC $WGET_URL || \
163 (echo -e "ERROR: wget $WGET_URL" && exit 1) ;;
164 hg*|mercurial*)
165 # We are in cache so clone here and create a tarball
166 pwd=$(pwd)
167 if $(echo "$WGET_URL" | fgrep -q "hg|"); then
168 url=${WGET_URL#hg|}
169 else
170 url=${WGET_URL#mercurial|}
171 fi
172 pkgsrc=${SOURCE:-$PACKAGE}-$VERSION
173 tarball=$pkgsrc.tar.bz2
174 gettext "Getting source from Hg: "; echo $url
175 gettext "Cloning to: "; echo "$pwd/$pkgsrc"
176 hg clone $url $pkgsrc || (echo "ERROR: hg clone $url" && exit 1)
177 gettext "Creating tarball: "; echo "$tarball"
178 tar cjf $tarball $pkgsrc || exit 1
179 mv $tarball $SRC && rm -rf $pkgsrc ;;
180 git*)
181 echo "TODO: git implementation in cook" && exit 1 ;;
182 svn*)
183 echo "TODO: svn implementation in cook" && exit 1 ;;
184 *)
185 gettext -e "\nERROR: Unable to handle:"; echo -e " $WGET_URL \n" | \
186 tee -a $LOGS/$PACKAGE.log
187 exit 1 ;;
188 esac
189 }
191 # Extract source package.
192 extract_source() {
193 gettext "Extracting:"; echo " $TARBALL"
194 case "$TARBALL" in
195 *.tar.gz|*.tgz) tar xzf $SRC/$TARBALL ;;
196 *.tar.bz2|*.tbz) tar xjf $SRC/$TARBALL ;;
197 *.tar.lzma) tar xaf $SRC/$TARBALL ;;
198 *.tar) tar xf $SRC/$TARBALL ;;
199 *.zip|*.xpi) unzip -o $SRC/$TARBALL ;;
200 *.xz) unxz -c $SRC/$TARBALL | tar xf - ;;
201 *.Z) uncompress -c $SRC/$TARBALL | tar xf - ;;
202 *.rpm) rpm2cpio $SRC/$TARBALL | cpio -idm --quiet ;;
203 esac
204 }
206 # Display cooked package summary.
207 summary() {
208 cd $WOK/$pkg
209 [ -d install ] && prod=$(du -sh install | awk '{print $1}' 2>/dev/null)
210 fs=$(du -sh taz/* | awk '{print $1}')
211 size=$(du -sh $PKGS/$pkg-${VERSION}*.tazpkg | awk '{print $1}')
212 files=$(cat taz/$pkg-*/files.list | wc -l)
213 cookdate=$(date "+%Y-%m-%d %H:%M")
214 gettext "Summary for:"; echo " $PACKAGE $VERSION"
215 separator
216 [ "$prod" ] && echo "Produce : $prod"
217 cat << EOT
218 Packed : $fs
219 Compressed : $size
220 Files : $files
221 Cook time : ${time}s
222 Cook date : $cookdate
223 $(separator)
225 EOT
226 }
228 # Display debugging erroe info.
229 debug_info() {
230 echo -e "\nDebug information"
231 separator
232 echo "Cook date: $(date '+%Y-%M-%d %H:%M')"
233 for error in ERROR "No package" "cp: can't stat" "can't open"
234 do
235 fgrep "$error" $LOGS/$pkg.log
236 done
237 separator && echo ""
238 }
240 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
241 # so some packages need to copy these files with the receipt and genpkg_rules.
242 copy_generic_files()
243 {
244 # $LOCALE is set in cook.conf
245 if [ "$LOCALE" ]; then
246 if [ -d "$_pkg/usr/share/locale" ]; then
247 mkdir -p $fs/usr/share/locale
248 for i in $LOCALE
249 do
250 if [ -d "$_pkg/usr/share/locale/$i" ]; then
251 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
252 fi
253 done
254 fi
255 fi
257 # Generic pixmaps copy can be disabled with GENERIC_PIXMAPS="no"
258 if [ "$GENERIC_PIXMAPS" != "no" ]; then
259 if [ -d "$_pkg/usr/share/pixmaps" ]; then
260 mkdir -p $fs/usr/share/pixmaps
261 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
262 $fs/usr/share/pixmaps 2>/dev/null
263 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
264 $fs/usr/share/pixmaps 2>/dev/null
265 fi
267 # Custom or homemade PNG pixmap can be in stuff.
268 if [ -f "$stuff/$PACKAGE.png" ]; then
269 mkdir -p $fs/usr/share/pixmaps
270 cp -a $stuff/$PACKAGE.png $fs/usr/share/pixmaps
271 fi
272 fi
274 # Desktop entry (.desktop).
275 if [ -d "$_pkg/usr/share/applications" ]; then
276 cp -a $_pkg/usr/share/applications $fs/usr/share
277 fi
279 # Homemade desktop file(s) can be in stuff.
280 if [ -d "$stuff/applications" ]; then
281 mkdir -p $fs/usr/share
282 cp -a $stuff/applications $fs/usr/share
283 fi
284 if [ -f "$stuff/$PACKAGE.desktop" ]; then
285 mkdir -p $fs/usr/share/applications
286 cp -a $stuff/$PACKAGE.desktop $fs/usr/share/applications
287 fi
288 }
290 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
291 strip_package()
292 {
293 gettext "Executing strip on all files"
294 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
295 do
296 if [ -d "$dir" ]; then
297 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
298 fi
299 done
300 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
301 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
302 status
303 }
305 # Remove installed deps.
306 remove_deps() {
307 # Now remove installed build deps.
308 diff="$CACHE/installed.diff"
309 deps=$(cat $diff | grep ^+[a-zA-Z0-9] | sed s/^+//)
310 nb=$(cat $diff | grep ^+[a-zA-Z0-9] | wc -l)
311 if [ -s "$CACHE/installed.diff" ]; then
312 gettext "Build dependencies to remove:"; echo " $nb"
313 gettext "Removing:"
314 for dep in $deps
315 do
316 echo -n " $dep"
317 yes | tazpkg remove $dep >/dev/null
318 done
319 echo -e "\n"
320 mv -f $CACHE/installed.diff $CACHE/installed.last.diff
321 fi
322 }
324 # The main cook function.
325 cookit() {
326 echo "Cook: $PACKAGE $VERSION"
327 separator
328 set_paths
329 [ "$QA" ] && receipt_quality
330 cd $pkgdir
331 rm -rf install taz source
333 # Disable -pipe if less than 512Mb free RAM.
334 free=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
335 if [ "$free" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then
336 gettext -e "Disabling -pipe compile flag: $free RAM\n"
337 CFLAGS="${CFLAGS/-pipe}" && CFLAGS=$(echo "$CFLAGS" | tr -s ' ')
338 CXXFLAGS="${CXXFLAGS/-pipe}" && \
339 CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ')
340 fi
341 unset free
343 # Export flags and path to be used by make
344 DESTDIR=$pkgdir/install
345 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS BUILD_HOST CONFIG_SITE
346 local LC_ALL=POSIX LANG=POSIX
348 # Check for build dep.
349 cd $INSTALLED && ls -1 > $CACHE/installed.list
350 [ "$DEPENDS" ] && gettext -e "Checking build dependencies...\n"
351 for dep in $BUILD_DEPENDS
352 do
353 if [ ! -d "$INSTALLED/$dep" ]; then
354 # Try local package first
355 if [ -f "$PKGS/$dep-*.tazpkg" ]; then
356 gettext "Installing dep (local):"; echo " $dep"
357 cd $PKGS && tazpkg install $dep-*.tazpkg >/dev/null
358 else
359 gettext "Installing dep (web/cache):"; echo " $dep"
360 tazpkg get-install $dep >/dev/null
361 fi
362 fi
363 done
364 ls -1 > $CACHE/installed.cook && cd $CACHE
366 # If a cook failed deps are not remove since we exit 1.
367 [ ! -s "installed.diff" ] && \
368 diff installed.list installed.cook > installed.diff
369 deps=$(cat installed.diff | grep ^+[a-zA-Z0-9] | wc -l)
371 # Get source tarball and make sure we have source dir named:
372 # $PACKAGE-$VERSION to be standard in receipts. Her we use tar.lzma
373 # tarball if it exist.
374 if [ "$WGET_URL" ] && [ ! -f "$SRC/$TARBALL" ]; then
375 if [ -f "$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
376 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
377 else
378 get_source || exit 1
379 fi
380 fi
381 if [ ! "$WANTED" ] && [ "$TARBALL" ] && [ ! -d "$src" ]; then
382 mkdir -p $pkgdir/source/tmp && cd $pkgdir/source/tmp
383 extract_source || exit 1
384 mv * ../$PACKAGE-$VERSION
385 cd .. && rm -rf tmp
386 fi
388 # Execute receipt rules.
389 if grep -q ^compile_rules $receipt; then
390 gettext -e "Executing: compile_rules\n"
391 [ -d "$src" ] && cd $src
392 compile_rules || echo "" && exit 1
393 # Stay compatible with _pkg
394 [ -d $src/_pkg ] && mv $src/_pkg $install
395 # QA: compile_rules success so valid.
396 mkdir -p $install
397 else
398 # QA: No compile_rules so no error, valid.
399 mkdir -p $install
400 fi
401 separator && echo ""
402 }
404 # Cook quality assurance.
405 cookit_quality() {
406 if [ ! -d "$WOK/$pkg/install" ] && [ ! "$WANTED" ]; then
407 echo -e "ERROR: cook failed" | tee -a $LOGS/$pkg.log
408 fi
409 # ERROR can be echoed any time in cookit()
410 if fgrep -q ERROR: $LOGS/$pkg.log; then
411 debug_info | tee -a $LOGS/$pkg.log
412 rm -f $command && exit 1
413 fi
414 }
416 # Create the package. Wanted to use Tazpkg to create a tazpkg package at first,
417 # but it dont handle EXTRAVERSION.
418 packit() {
419 set_paths
420 echo "Pack: $PACKAGE $VERSION"
421 separator
422 if grep -q ^genpkg_rules $receipt; then
423 gettext -e "Executing: genpkg_rules\n"
424 cd $pkgdir
425 mkdir -p $fs && genpkg_rules || (echo -e \
426 "\nERROR: genpkg_rules failed\n" >> $LOGS/$pkg.log && exit 1)
427 fi
428 cd $taz
429 for file in receipt description.txt
430 do
431 [ ! -f "../$file" ] && continue
432 gettext "Copying"; echo -n " $file..."
433 cp -f ../$file $pack && chown 0.0 $pack/$file && status
434 done
436 # Create files.list with redirecting find outpout.
437 gettext "Creating the list of files..." && cd $fs
438 find . -type f -print > ../files.list
439 find . -type l -print >> ../files.list
440 cd .. && sed -i s/'^.'/''/ files.list
441 status
443 # QA, strip and stuff files.
445 strip_package
446 copy_generic_files
448 # Md5sum of files.
449 gettext "Creating md5sum of files..."
450 while read file; do
451 [ -L "fs$file" ] && continue
452 [ -f "fs$file" ] || continue
453 case "$file" in
454 /lib/modules/*/modules.*|*.pyc) continue;;
455 esac
456 md5sum "fs$file" | sed 's/ fs/ /'
457 done < files.list > md5sum
458 status
459 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum \
460 description.txt 2> /dev/null | awk \
461 '{ sz=$1 } END { print sz }')
463 # Build cpio archives.
464 gettext "Compressing the fs... "
465 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
466 rm -rf fs
467 status
468 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list \
469 md5sum description.txt 2> /dev/null | awk \
470 '{ sz=$1 } END { print sz }')
471 gettext "Updating receipt sizes..."
472 sed -i s/^PACKED_SIZE.*$// receipt
473 sed -i s/^UNPACKED_SIZE.*$// receipt
474 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
475 status
477 # Set extra version.
478 if [ "$EXTRAVERSION" ]; then
479 gettext "Updating receipt EXTRAVERSION: "; echo -n "$EXTRAVERSION"
480 sed -i s/^EXTRAVERSION.*$// receipt
481 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
482 status
483 fi
485 # Compress.
486 gettext "Creating full cpio archive... "
487 find . -print | cpio -o -H newc --quiet > \
488 ../$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg
489 status
490 gettext "Restoring original package tree... "
491 unlzma -c fs.cpio.lzma | cpio -idm --quiet
492 status
493 rm fs.cpio.lzma && cd ..
495 # QA and give info.
496 tazpkg=$(ls *.tazpkg)
497 packit_quality
498 separator && gettext "Package:"; echo -e " $tazpkg\n"
499 }
501 # Verify package quality and consitensy.
502 packit_quality() {
503 if fgrep -q ERROR: $LOGS/$pkg.log; then
504 rm -f $command && exit 1
505 fi
506 gettext "QA: Checking for empty package..."
507 files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l)
508 if [ "$files" -lt 0 ] && [ "$CATEGORY" != "meta" ]; then
509 echo -e "\nERROR: empty package"
510 rm -f $command && exit 1
511 else
512 status && mv -f $pkgdir/taz/$pkg-*.tazpkg $PKGS
513 sed -i /^${pkg}$/d $broken
514 fi
515 }
517 #
518 # Commands
519 #
521 case "$1" in
522 usage|help|-u|-h)
523 usage ;;
524 list-wok)
525 gettext "List of packages in:"; echo " $WOK"
526 separator
527 cd $WOK && ls -1
528 separator
529 echo -n "Packages: " && ls | wc -l
530 echo "" ;;
531 setup)
532 # Setup a build environment
533 check_root
534 echo "Cook: setting up the environment" | log
535 gettext -e "\nSetting up your environment\n"
536 separator && cd $SLITAZ
537 gettext "Creating directories structure in:"; echo " $SLITAZ"
538 mkdir -p $WOK $PKGS $SRC $CACHE $LOGS
539 gettext -e "Checking for packages to install...\n"
540 for pkg in $SETUP_PKGS
541 do
542 [ ! -d "$INSTALLED/$pkg" ] && tazpkg get-install $pkg
543 done
545 # Handle --options
546 case "$2" in
547 --wok)
548 [ ! -d "$INSTALLED/mercurial" ] && tazpkg get-install mercurial
549 [ -d "$WOK" ] && echo -e "A wok already exist.\n" && exit 1
550 hg clone $HG_URL ;;
551 --chroot)
552 echo "TODO: create a chroot with tazdev" ;;
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; 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 package:"; 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)
681 echo "Getting source for: $pkg"
682 separator && get_source
683 echo -e "Tarball: $SRC/$TARBALL\n" && exit 0 ;;
684 esac
686 # Check if wanted is build now so we have separate log files.
687 if [ "$WANTED" ] && [ ! -d "$WOK/$WANTED/install" ]; then
688 cook "$WANTED"
689 fi
691 # Cook and pack or exit on error and log everything.
692 cookit 2>&1 | tee $LOGS/$pkg.log
693 remove_deps | tee -a $LOGS/$pkg.log
694 cookit_quality
695 packit 2>&1 | tee -a $LOGS/$pkg.log
696 clean_log
698 # Exit if any error in packing.
699 if grep -q ^ERROR $LOGS/$pkg.log; then
700 debug_info | tee -a $LOGS/$pkg.log
701 rm -f $command && exit 1
702 fi
704 # Time and summary
705 time=$(($(date +%s) - $time))
706 summary | tee -a $LOGS/$pkg.log
708 # Install package if requested
709 if [ "$inst" ]; then
710 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
711 cd $PKGS && tazpkg install \
712 $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg --forced
713 else
714 gettext -e "Unable to install package, build have failed.\n\n"
715 exit 1
716 fi
717 fi
718 # Finally we DONT WANT to build the *-dev or packages with WANTED="$pkg"
719 # You want automation: use the Cooker Build Bot.
720 #[ -d "$WOK/$pkg-dev" ] && cook $pkg-dev
721 rm -f $command ;;
722 esac
724 exit 0