cookutils view cook @ rev 41

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