cookutils view cook @ rev 60

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