cookutils view cook @ rev 328
cookiso use: yes '' not echo -e
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Fri Mar 16 03:10:54 2012 +0100 (2012-03-16) |
parents | 2f199cb51bce |
children | 461c9664ef91 |
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 # Old style compatibility
20 SOURCES_REPOSITORY=$SRC
22 #
23 # Functions
24 #
26 usage() {
27 cat << EOT
29 $(echo -e "\033[1m$(gettext "Usage:")\033[0m") cook [package|command] [list|--option]
31 $(echo -e "\033[1m$(gettext "Commands:")\033[0m")
32 usage|help $(gettext "Display this short usage.")
33 setup $(gettext "Setup your build environment.")
34 test $(gettext "Test environment and cook a package.")
35 list-wok $(gettext "List packages in the wok.")
36 search $(gettext "Simple packages search function.")
37 new $(gettext "Create a new package with a receipt".)
38 list $(gettext "Cook a list of packages.")
39 clean-wok $(gettext "Clean-up all packages files.")
40 clean-src $(gettext "Clean-up all packages sources.")
41 pkgdb $(gettext "Create packages DB lists and flavors.")
43 $(echo -e "\033[1m$(gettext "Options:")\033[0m")
44 --clean|-c Cook : $(gettext "clean the package in the wok.")
45 --install|-i Cook : $(gettext "cook and install the package.")
46 --getsrc|-gs Cook : $(gettext "get the package source tarball.")
47 --block|-b Cook : $(gettext "Block a package so cook will skip it.")
48 --unblock|-ub Cook : $(gettext "Unblock a blocked package.")
49 --interactive|-x New : $(gettext "create a receipt interactively.")
50 --wok|-w Setup: $(gettext "clone the cooking wok from Hg repo.")
51 --stable Setup: $(gettext "clone the stable wok from Hg repo.")
52 --undigest Setup: $(gettext "clone the undigest wok from Hg repo.")
53 --flavors Pkgdb: $(gettext "create up-to-date flavors files.")
55 EOT
56 exit 0
57 }
59 # Be sure we're root.
60 check_root() {
61 [ $(id -u) != 0 ] && gettext -e "\nYou must be root to cook.\n\n" && exit 0
62 }
64 separator() {
65 echo "================================================================================"
66 }
68 status() {
69 echo -en "\\033[70G[ "
70 if [ $? = 0 ]; then
71 echo -en "\\033[1;32mOK"
72 else
73 echo -en "\\033[1;31mFailed"
74 fi
75 echo -e "\\033[0;39m ]"
76 }
78 # Log activities, we want first letter capitalized.
79 log() {
80 grep ^[A-Z] | \
81 sed s"#^[A-Z]\([^']*\)#$(date '+%Y-%m-%d %H:%M') : \0#" >> $activity
82 }
84 # We don't want these escapes in web interface.
85 clean_log() {
86 sed -i -e s'|\[70G\[ \[1;32m| |' \
87 -e s'|\[0;39m \]||' $LOGS/$pkg.log
88 }
90 # Log broken packages.
91 broken() {
92 if ! grep -q "^$pkg$" $broken; then
93 echo "$pkg" >> $broken
94 fi
95 }
97 # Be sure package exists in wok.
98 check_pkg_in_wok() {
99 if [ ! -d "$WOK/$pkg" ]; then
100 gettext -e "\nUnable to find package in the wok:"
101 echo -e " $pkg\n" && exit 1
102 fi
103 }
105 if_empty_value() {
106 if [ -z "$value" ]; then
107 gettext "QA: empty variable:"; echo -e " ${var}=\"\"\n"
108 exit 1
109 fi
110 }
112 # Initialize files used in $CACHE
113 init_db_files() {
114 gettext "Creating directories structure in:"; echo " $SLITAZ"
115 mkdir -p $WOK $PKGS $SRC $CACHE $LOGS
116 gettext "Creating DB files in:"; echo " $CACHE"
117 for f in $activity $command $broken $blocked
118 do
119 touch $f
120 done
121 }
123 # QA: check a receipt consistency before building.
124 receipt_quality() {
125 gettext -e "QA: checking package receipt...\n"
126 unset online
127 if ifconfig | grep -q -A 1 "^[a-z]*[0-9]" | fgrep 'addr:'; then
128 online="online"
129 fi
130 for var in PACKAGE VERSION CATEGORY SHORT_DESC MAINTAINER WEB_SITE
131 do
132 unset value
133 value="$(. $receipt ; eval echo \$$var)"
134 case "$var" in
135 PACKAGE|VERSION|SHORT_DESC)
136 if_empty_value ;;
137 CATEGORY)
138 [ -z "$value" ] && value="empty"
139 valid="base-system x-window utilities network graphics \
140 multimedia office development system-tools security games \
141 misc meta non-free"
142 if ! echo "$valid" | grep -q -w "$value"; then
143 gettext "QA: unknown category:"; echo -e " $value\n"
144 exit 1
145 fi ;;
146 WEB_SITE)
147 # We don't check WGET_URL since if dl is needed it will fail.
148 # Break also if we're not online. Here error is not fatal.
149 if_empty_value
150 [ -z "$online" ] || break
151 if ! busybox wget -T 12 -s $value 2>/dev/null; then
152 gettext "QA: Unable to reach:"; echo -e " $value"
153 fi ;;
154 esac
155 done
156 }
158 # Executed before sourcing a receipt.
159 unset_receipt() {
160 unset DEPENDS BUILD_DEPENDS WANTED EXTRAVERSION WGET_URL PROVIDE TARBALL
161 }
163 # Paths used in receipt and by cook itself.
164 set_paths() {
165 pkgdir=$WOK/$PACKAGE
166 src=$pkgdir/source/$PACKAGE-$VERSION
167 taz=$pkgdir/taz
168 pack=$taz/$PACKAGE-${VERSION}${EXTRAVERSION}
169 fs=$pack/fs
170 stuff=$pkgdir/stuff
171 install=$pkgdir/install
172 if [ "$WANTED" ]; then
173 wanted=${WANTED%% *}
174 src=$WOK/$wanted/source/$wanted-$VERSION
175 install=$WOK/$wanted/install
176 wanted_stuff=$WOK/$wanted/stuff
177 fi
178 # Kernel version is set from linux-api-headers since it is part of toolchain.
179 if [ -f "$INSTALLED/linux-api-headers/receipt" ]; then
180 kvers=$(grep ^VERSION= $INSTALLED/linux-api-headers/receipt | cut -d '"' -f 2)
181 fi
182 # Old way compatibility.
183 _pkg=$install
184 }
186 # Create source tarball when URL is a SCM.
187 create_tarball() {
188 gettext "Creating tarball: "; echo "$tarball"
189 if [ "$LZMA_SRC" ]; then
190 tar -c $pkgsrc | lzma e $SRC/$tarball -si || exit 1
191 else
192 tar cjf $tarball $pkgsrc || exit 1
193 mv $tarball $SRC && rm -rf $pkgsrc
194 fi
195 }
197 # Get package source. For SCM we are in cache so clone here and create a
198 # tarball here.
199 get_source() {
200 pwd=$(pwd)
201 pkgsrc=${SOURCE:-$PACKAGE}-$VERSION
202 tarball=$pkgsrc.tar.bz2
203 [ "$LZMA_SRC" ] && tarball=$pkgsrc.tar.lzma
204 case "$WGET_URL" in
205 http://*|ftp://*)
206 # Busybox Wget is better!
207 busybox wget -T 60 -c -O $SRC/$TARBALL $WGET_URL || \
208 (echo -e "ERROR: wget $WGET_URL" && exit 1) ;;
209 https://*)
210 wget -c --no-check-certificate -O $SRC/$TARBALL $WGET_URL || \
211 (echo -e "ERROR: wget $WGET_URL" && exit 1) ;;
212 hg*|mercurial*)
213 if $(echo "$WGET_URL" | fgrep -q "hg|"); then
214 url=${WGET_URL#hg|}
215 else
216 url=${WGET_URL#mercurial|}
217 fi
218 gettext -e "Getting source from Hg...\n"
219 echo "URL: $url"
220 gettext "Cloning to: "; echo "$pwd/$pkgsrc"
221 if [ "$BRANCH" ]; then
222 echo "Hg branch: $BRANCH"
223 hg clone $url --rev $BRANCH $pkgsrc || \
224 (echo "ERROR: hg clone $url --rev $BRANCH" && exit 1)
225 else
226 hg clone $url $pkgsrc || (echo "ERROR: hg clone $url" && exit 1)
227 fi
228 rm -rf $pkgsrc/.hg
229 create_tarball ;;
230 git*)
231 url=${WGET_URL#git|}
232 gettext -e "Getting source from Git...\n"
233 echo "URL: $url"
234 git clone $url $pkgsrc || (echo "ERROR: git clone $url" && exit 1)
235 if [ "$BRANCH" ]; then
236 echo "Git branch: $BRANCH"
237 cd $pkgsrc && git checkout $BRANCH && cd ..
238 fi
239 create_tarball ;;
240 cvs*)
241 url=${WGET_URL#cvs|}
242 mod=$PACKAGE
243 [ "$CVS_MODULE" ] && mod=$CVS_MODULE
244 gettext -e "Getting source from CVS...\n"
245 echo "URL: $url"
246 [ "$CVS_MODULE" ] && echo "CVS module: $mod"
247 gettext "Cloning to: "; echo "$pwd/$mod"
248 cvs -d:$url co $mod && mv $mod $pkgsrc
249 create_tarball ;;
250 svn*|subversion*)
251 if $(echo "$WGET_URL" | fgrep -q "svn|"); then
252 url=${WGET_URL#svn|}
253 else
254 url=${WGET_URL#subversion|}
255 fi
256 gettext -e "Getting source from SVN...\n"
257 echo "URL: $url"
258 if [ "$BRANCH" ]; then
259 echo t | svn co $url -r $BRANCH $pkgsrc
260 else
261 echo t | svn co $url $pkgsrc
262 fi
263 create_tarball ;;
264 *)
265 gettext -e "\nERROR: Unable to handle:"; echo -e " $WGET_URL \n" | \
266 tee -a $LOGS/$PACKAGE.log
267 exit 1 ;;
268 esac
269 }
271 # Extract source package.
272 extract_source() {
273 if [ ! -s "$SRC/$TARBALL" ]; then
274 local url
275 url="http://mirror.slitaz.org/sources/packages"
276 url=$url/${TARBALL:0:1}/$TARBALL
277 gettext "Getting source from mirror:"; echo " $url"
278 busybox wget -c -P $SRC $url || echo -e "ERROR: wget $url"
279 fi
280 gettext "Extracting:"; echo " $TARBALL"
281 case "$TARBALL" in
282 *.tar.gz|*.tgz) tar xzf $SRC/$TARBALL 2>/dev/null ;;
283 *.tar.bz2|*.tbz|*.tbz2) tar xjf $SRC/$TARBALL 2>/dev/null ;;
284 *.tar.lzma) tar xaf $SRC/$TARBALL ;;
285 *.tar) tar xf $SRC/$TARBALL ;;
286 *.zip|*.xpi) unzip -o $SRC/$TARBALL ;;
287 *.xz) unxz -c $SRC/$TARBALL | tar xf - ;;
288 *.Z) uncompress -c $SRC/$TARBALL | tar xf - ;;
289 *.rpm) rpm2cpio $SRC/$TARBALL | cpio -idm --quiet ;;
290 *.run) /bin/sh $SRC/$TARBALL $RUN_OPTS ;;
291 *) cp $SRC/$TARBALL $(pwd) ;;
292 esac
293 }
295 # Display cooked package summary.
296 summary() {
297 cd $WOK/$pkg
298 [ -d install ] && prod=$(du -sh install | awk '{print $1}' 2>/dev/null)
299 fs=$(du -sh taz/* | awk '{print $1}')
300 size=$(du -sh $PKGS/$pkg-${VERSION}*.tazpkg | awk '{print $1}')
301 files=$(cat taz/$pkg-*/files.list | wc -l)
302 cookdate=$(date "+%Y-%m-%d %H:%M")
303 sec=$time
304 div=$(( ($time + 30) / 60))
305 [ "$div" != 0 ] && min="~ ${div}m"
306 gettext "Summary for:"; echo " $PACKAGE $VERSION"
307 separator
308 [ "$prod" ] && echo "Produced : $prod"
309 cat << EOT
310 Packed : $fs
311 Compressed : $size
312 Files : $files
313 Cook time : ${sec}s $min
314 Cook date : $cookdate
315 $(separator)
316 EOT
317 }
319 # Display debugging error info.
320 debug_info() {
321 echo -e "\nDebug information"
322 separator
323 echo "Cook date: $(date '+%Y-%m-%d %H:%M')"
324 for error in \
325 ERROR "No package" "cp: can't" "can't open" "can't cd" \
326 "error:" "fatal error:"
327 do
328 fgrep "$error" $LOGS/$pkg.log
329 done
330 separator && echo ""
331 }
333 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
334 # so some packages need to copy these files with the receipt and genpkg_rules.
335 copy_generic_files()
336 {
337 # $LOCALE is set in cook.conf
338 if [ "$LOCALE" ]; then
339 if [ -d "$install/usr/share/locale" ]; then
340 mkdir -p $fs/usr/share/locale
341 for i in $LOCALE
342 do
343 if [ -d "$install/usr/share/locale/$i" ]; then
344 cp -a $install/usr/share/locale/$i $fs/usr/share/locale
345 fi
346 done
347 fi
348 fi
350 # Generic pixmaps copy can be disabled with GENERIC_PIXMAPS="no"
351 if [ "$GENERIC_PIXMAPS" != "no" ]; then
352 if [ -d "$install/usr/share/pixmaps" ]; then
353 mkdir -p $fs/usr/share/pixmaps
354 cp -a $install/usr/share/pixmaps/$PACKAGE.png \
355 $fs/usr/share/pixmaps 2>/dev/null || continue
356 cp -a $install/usr/share/pixmaps/$PACKAGE.xpm \
357 $fs/usr/share/pixmaps 2>/dev/null || continue
358 fi
360 # Custom or homemade PNG pixmap can be in stuff.
361 if [ -f "$stuff/$PACKAGE.png" ]; then
362 mkdir -p $fs/usr/share/pixmaps
363 cp -a $stuff/$PACKAGE.png $fs/usr/share/pixmaps
364 fi
365 fi
367 # Desktop entry (.desktop).
368 # Generic desktop entry copy can be disabled with GENERIC_MENUS="no"
369 if [ "$GENERIC_MENUS" != "no" ]; then
370 if [ -d "$install/usr/share/applications" ] && [ "$WANTED" == "" ]; then
371 cp -a $install/usr/share/applications $fs/usr/share
372 fi
373 fi
375 # Homemade desktop file(s) can be in stuff.
376 if [ -d "$stuff/applications" ]; then
377 mkdir -p $fs/usr/share
378 cp -a $stuff/applications $fs/usr/share
379 fi
380 if [ -f "$stuff/$PACKAGE.desktop" ]; then
381 mkdir -p $fs/usr/share/applications
382 cp -a $stuff/$PACKAGE.desktop $fs/usr/share/applications
383 fi
384 }
386 # Find and strip : --strip-all (-s) or --strip-debug on static libs as well
387 # as removing uneeded files like in Python packages.
388 strip_package()
389 {
390 gettext "Executing strip on all files..."
391 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
392 do
393 if [ -d "$dir" ]; then
394 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
395 fi
396 done
397 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
398 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
399 status
401 # Remove Python .pyc and .pyo from packages.
402 if echo "$PACKAGE $DEPENDS" | fgrep -q "python"; then
403 gettext "Removing Python compiled files..."
404 find $fs -type f -name "*.pyc" -delete 2>/dev/null
405 find $fs -type f -name "*.pyo" -delete 2>/dev/null
406 status
407 fi
409 # Remove Perl perllocal.pod and .packlist from packages.
410 if echo "$DEPENDS" | fgrep -q "perl"; then
411 gettext "Removing Perl compiled files..."
412 find $fs -type f -name "perllocal.pod" -delete 2>/dev/null
413 find $fs -type f -name ".packlist" -delete 2>/dev/null
414 status
415 fi
416 }
418 # Remove installed deps.
419 remove_deps() {
420 # Now remove installed build deps.
421 diff="$CACHE/installed.cook.diff"
422 if [ -s "$CACHE/installed.cook.diff" ]; then
423 deps=$(cat $diff | grep ^+[a-zA-Z0-9] | sed s/^+//)
424 nb=$(cat $diff | grep ^+[a-zA-Z0-9] | wc -l)
425 gettext "Build dependencies to remove:"; echo " $nb"
426 gettext "Removing:"
427 for dep in $deps
428 do
429 echo -n " $dep"
430 echo 'y' | tazpkg remove $dep >/dev/null
431 done
432 echo -e "\n"
433 # Keep the last diff for debug and info.
434 mv -f $CACHE/installed.cook.diff $CACHE/installed.diff
435 fi
436 }
438 # The main cook function.
439 cookit() {
440 echo "Cook: $PACKAGE $VERSION"
441 separator
442 set_paths
443 [ "$QA" ] && receipt_quality
444 cd $pkgdir
445 rm -rf install taz source
447 # Disable -pipe if less than 512Mb free RAM.
448 free=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
449 if [ "$free" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then
450 gettext -e "Disabling -pipe compile flag: $free RAM\n"
451 CFLAGS="${CFLAGS/-pipe}" && CFLAGS=$(echo "$CFLAGS" | tr -s ' ')
452 CXXFLAGS="${CXXFLAGS/-pipe}" && \
453 CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ')
454 fi
455 unset free
457 # Export flags and path to be used by make and receipt.
458 DESTDIR=$pkgdir/install
459 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS CONFIG_SITE LC_ALL=C LANG=C
461 # Check for build deps and handle implicit depends of *-dev packages
462 # (ex: libusb-dev :: libusb).
463 rm -f $CACHE/installed.local $CACHE/installed.web $CACHE/missing.dep
464 touch $CACHE/installed.local $CACHE/installed.web
465 [ "$BUILD_DEPENDS" ] && gettext -e "Checking build dependencies...\n"
466 for dep in $BUILD_DEPENDS
467 do
468 implicit=${dep%-dev}
469 for i in $dep $implicit
470 do
471 if [ ! -f "$INSTALLED/$i/receipt" ]; then
472 # Try local package first. In some cases implicit doesn't exist, ex:
473 # libboost-dev exists but not libboost, so check if we got vers.
474 unset vers
475 vers=$(grep ^VERSION= $WOK/$i/receipt 2>/dev/null | cut -d '"' -f 2)
476 if [ -f "$PKGS/$i-$vers.tazpkg" ]; then
477 echo $i-$vers.tazpkg >> $CACHE/installed.local
478 else
479 # Priority to package version in wok (maybe more up-to-date)
480 # than the mirrored one.
481 if [ "$vers" ]; then
482 if fgrep -q $i-$vers $DB/packages.list; then
483 echo $i >> $CACHE/installed.web
484 else
485 # So package exists in wok but not available.
486 gettext "Missing dep (wok/pkg):"; echo " $i $vers"
487 echo $i >> $CACHE/missing.dep
488 fi
489 else
490 # Package is not in wok but may be in repo.
491 if fgrep -q $i-$vers $DB/packages.list; then
492 echo $i >> $CACHE/installed.web
493 else
494 echo "ERROR: unknown dep $i" && exit 1
495 fi
496 fi
497 fi
498 fi
499 done
500 done
502 # Get the list of installed packages
503 cd $INSTALLED && ls -1 > $CACHE/installed.list
505 # Have we a missing build dep to cook ?
506 if [ -s "$CACHE/missing.dep" ] && [ "$AUTO_COOK" ]; then
507 gettext -e "Auto cook config is set : AUTO_COOK\n"
508 cp -f $LOGS/$PACKAGE.log $LOGS/$PACKAGE.log.$$
509 for i in $(uniq $CACHE/missing.dep)
510 do
511 (gettext "Building dep (wok/pkg) :"; echo " $i $vers") | \
512 tee -a $LOGS/$PACKAGE.log.$$
513 cook $i || (echo -e "ERROR: can't cook dep '$i'\n" && \
514 fgrep "remove: " $LOGS/$i.log && \
515 fgrep "Removing: " $LOGS/$i.log && echo "") | \
516 tee -a $LOGS/$PACKAGE.log.$$ && break
517 done
518 rm -f $CACHE/missing.dep
519 mv $LOGS/$PACKAGE.log.$$ $LOGS/$PACKAGE.log
520 fi
522 # QA: Exit on missing dep errors. We exit in both cases, if AUTO_COOK
523 # is enabled and cook fails we have ERROR in log, if no auto cook we have
524 # missing dep in cached file.
525 if fgrep -q "ERROR:" $LOGS/$pkg.log || [ -s "$CACHE/missing.dep" ]; then
526 [ -s "$CACHE/missing.dep" ] && nb=$(cat $CACHE/missing.dep | wc -l)
527 echo "ERROR: missing dep $nb" && exit 1
528 fi
530 # Install local packages.
531 cd $PKGS
532 for i in $(uniq $CACHE/installed.local)
533 do
534 gettext "Installing dep (pkg/local):"; echo " $i"
535 tazpkg install $i >/dev/null
536 done
538 # Install web or cached packages (if mirror is set to $PKGS we only
539 # use local packages).
540 for i in $(uniq $CACHE/installed.web)
541 do
542 gettext "Installing dep (web/cache):"; echo " $i"
543 tazpkg get-install $i >/dev/null
544 done
546 # If a cook failed deps are removed.
547 cd $INSTALLED && ls -1 > $CACHE/installed.cook && cd $CACHE
548 [ ! -s "installed.cook.diff" ] && \
549 busybox diff installed.list installed.cook > installed.cook.diff
550 deps=$(cat installed.cook.diff | grep ^+[a-zA-Z0-9] | wc -l)
552 # Get source tarball and make sure we have source dir named:
553 # $PACKAGE-$VERSION to be standard in receipts. Here we use tar.lzma
554 # tarball if it exists.
555 if [ "$WGET_URL" ] && [ ! -f "$SRC/$TARBALL" ]; then
556 if [ -f "$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
557 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
558 LZMA_SRC=""
559 else
560 get_source || exit 1
561 fi
562 fi
563 if [ ! "$WANTED" ] && [ "$TARBALL" ] && [ ! -d "$src" ]; then
564 mkdir -p $pkgdir/source/tmp && cd $pkgdir/source/tmp
565 if ! extract_source ; then
566 get_source
567 extract_source || exit 1
568 fi
569 if [ "$LZMA_SRC" ]; then
570 cd $pkgdir/source
571 if [ "$(ls -A tmp | wc -l)" -gl 1 ] || [ -f "$(echo tmp/*)" ]; then
572 mv tmp tmp-1 && mkdir tmp
573 mv tmp-1 tmp/${SOURCE:-$PACKAGE}-$VERSION
574 fi
575 if [ -d "tmp/${SOURCE:-$PACKAGE}-$VERSION" ]; then
576 cd tmp && tar -c * | lzma e $SRC/$TARBALL -si
577 fi
578 fi
579 cd $pkgdir/source/tmp
580 # Some archives are not well done and don't extract to one dir (ex lzma).
581 files=$(ls | wc -l)
582 [ "$files" == 1 ] && [ -d "$(ls)" ] && mv * ../$PACKAGE-$VERSION
583 [ "$files" == 1 ] && [ -f "$(ls)" ] && mkdir -p ../$PACKAGE-$VERSION && \
584 mv * ../$PACKAGE-$VERSION/$TARBALL
585 [ "$files" -gt 1 ] && mkdir -p ../$PACKAGE-$VERSION && \
586 mv * ../$PACKAGE-$VERSION
587 cd .. && rm -rf tmp
588 fi
590 # Execute receipt rules.
591 if grep -q ^compile_rules $receipt; then
592 gettext -e "Executing: compile_rules\n"
593 [ -d "$src" ] && cd $src
594 compile_rules $@ || exit 1
595 # Stay compatible with _pkg
596 [ -d "$src/_pkg" ] && mv $src/_pkg $install
597 # QA: compile_rules success so valid.
598 mkdir -p $install
599 else
600 # QA: No compile_rules so no error, valid.
601 mkdir -p $install
602 fi
603 separator && echo ""
604 }
606 # Cook quality assurance.
607 cookit_quality() {
608 if [ ! -d "$WOK/$pkg/install" ] && [ ! "$WANTED" ]; then
609 echo -e "ERROR: cook failed" | tee -a $LOGS/$pkg.log
610 fi
611 # ERROR can be echoed any time in cookit()
612 if fgrep -q ERROR: $LOGS/$pkg.log; then
613 debug_info | tee -a $LOGS/$pkg.log
614 rm -f $command && exit 1
615 fi
616 }
618 # Create the package. Wanted to use Tazpkg to create a tazpkg package at first,
619 # but it doesn't handle EXTRAVERSION.
620 packit() {
621 set_paths
622 echo "Pack: $PACKAGE $VERSION"
623 separator
624 if grep -q ^genpkg_rules $receipt; then
625 gettext -e "Executing: genpkg_rules\n"
626 set -e && cd $pkgdir && mkdir -p $fs
627 genpkg_rules || echo -e "\nERROR: genpkg_rules failed\n" >> \
628 $LOGS/$pkg.log
629 else
630 gettext "No packages rules: meta package"; echo
631 mkdir -p $fs
632 fi
634 # First QA check to stop now if genpkg_rules failed.
635 if fgrep -q ERROR: $LOGS/$pkg.log; then
636 exit 1
637 fi
639 cd $taz
640 for file in receipt description.txt
641 do
642 [ ! -f "../$file" ] && continue
643 gettext "Copying"; echo -n " $file..."
644 cp -f ../$file $pack && chown 0.0 $pack/$file && status
645 done
646 copy_generic_files
648 # Create files.list with redirecting find output.
649 gettext "Creating the list of files..." && cd $fs
650 find . -type f -print > ../files.list
651 find . -type l -print >> ../files.list
652 cd .. && sed -i s/'^.'/''/ files.list
653 status
655 # Strip and stuff files.
656 strip_package
658 # Md5sum of files.
659 gettext "Creating md5sum of files..."
660 while read file; do
661 [ -L "fs$file" ] && continue
662 [ -f "fs$file" ] || continue
663 case "$file" in
664 /lib/modules/*/modules.*|*.pyc) continue ;;
665 esac
666 md5sum "fs$file" | sed 's/ fs/ /'
667 done < files.list > md5sum
668 status
669 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum \
670 description.txt 2> /dev/null | awk \
671 '{ sz=$1 } END { print sz }')
673 # Build cpio archives.
674 gettext "Compressing the fs... "
675 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
676 rm -rf fs
677 status
678 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list \
679 md5sum description.txt 2> /dev/null | awk \
680 '{ sz=$1 } END { print sz }')
681 gettext "Updating receipt sizes..."
682 sed -i s/^PACKED_SIZE.*$// receipt
683 sed -i s/^UNPACKED_SIZE.*$// receipt
684 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
685 status
687 # Set extra version.
688 if [ "$EXTRAVERSION" ]; then
689 gettext "Updating receipt EXTRAVERSION: "; echo -n "$EXTRAVERSION"
690 sed -i s/^EXTRAVERSION.*$// receipt
691 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
692 status
693 fi
695 # Compress.
696 gettext "Creating full cpio archive... "
697 find . -print | cpio -o -H newc --quiet > \
698 ../$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg
699 status
700 gettext "Restoring original package tree... "
701 unlzma -c fs.cpio.lzma | cpio -idm --quiet
702 status
703 rm fs.cpio.lzma && cd ..
705 # QA and give info.
706 tazpkg=$(ls *.tazpkg)
707 packit_quality
708 separator && gettext "Package:"; echo -e " $tazpkg\n"
709 }
711 # Verify package quality and consistency.
712 packit_quality() {
713 #gettext "QA: Checking for broken link..."
714 #link=$(find $fs/usr -type l -follow)
715 #[ "$link" ] && echo -e "\nERROR: broken link in filesystem"
716 #status
718 # Exit if any error found in log file.
719 if fgrep -q ERROR: $LOGS/$pkg.log; then
720 rm -f $command && exit 1
721 fi
723 gettext "QA: Checking for empty package..."
724 files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l)
725 if [ "$files" == 0 ] && [ "$CATEGORY" != "meta" ]; then
726 echo -e "\nERROR: empty package"
727 rm -f $command && exit 1
728 else
729 # Ls sort by name so the first file is the one we want.
730 old=$(ls $PKGS/$pkg-*.tazpkg 2>/dev/null | head -n 1)
731 status
732 if [ -f "$old" ]; then
733 gettext "Removing old: $(basename $old)"
734 rm -f $old && status
735 fi
736 mv -f $pkgdir/taz/$pkg-*.tazpkg $PKGS
737 sed -i /^${pkg}$/d $broken
738 #gettext "Removing source tree..."
739 #rm -f $WOK/$pkg/source && status
740 fi
741 }
743 mkinstall_list() {
744 local pkg
745 for pkg in $@ ; do
746 case " $INSTALL_LIST " in
747 *\ $pkg\ *) continue ;;
748 *) if [ -s /home/slitaz/wok/$pkg/receipt ]; then
749 unset DEPENDS
750 . /home/slitaz/wok/$pkg/receipt
751 INSTALL_LIST="$INSTALL_LIST $pkg"
752 [ -n "$DEPENDS" ] && mkinstall_list $DEPENDS
753 fi
754 echo $pkg
755 esac
756 done
757 }
759 tac()
760 {
761 sed '1!G;h;$!d' $1
762 }
764 # Launch the cook command into a chroot jail protected by aufs.
765 # The current filesystems are used read-only and updates are
766 # stored in a separate branch.
767 try_aufs_chroot() {
769 base=/dev/shm/aufsmnt$$
771 # Can we setup the chroot ? Is it already done ?
772 grep -q ^AUFS_NOT_SUPPORTED $receipt && return
773 [ -n "$AUFS_MOUNTS" -a ! -f /aufs-umount.sh ] || return
774 lsmod | grep -q aufs || modprobe aufs 2> /dev/null || return
775 mkdir ${base}root ${base}rw || return
777 echo "Setup aufs chroot..."
779 # Sanity check
780 for i in / /proc /sys /dev/shm /home ; do
781 case " $AUFS_MOUNTS " in
782 *\ $i\ *) ;;
783 *) AUFS_MOUNTS="$AUFS_MOUNTS $i" ;;
784 esac
785 done
786 for mnt in $(echo $AUFS_MOUNTS | sort | uniq); do
787 mount --bind $mnt ${base}root$mnt
788 if [ $mnt == / ] && ! mount -t aufs -o br=${base}rw:/ none ${base}root; then
789 echo "Aufs mountage failure"
790 umount ${base}root
791 rmdir ${base}*
792 return
793 fi
794 echo "umount ${base}root$mnt" >> ${base}rw/aufs-umount.sh
795 done
797 chroot ${base}root $(cd $(dirname $0); pwd)/$(basename $0) "$@"
798 status=$?
800 echo "Leave aufs chroot..."
801 tac ${base}rw/aufs-umount.sh | sh
802 rm -rf ${base}rw
803 umount ${base}root
804 rmdir $base*
806 # Install package if requested
807 if [ "$inst" ]; then
808 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
809 cd $PKGS && tazpkg install \
810 $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg --forced
811 else
812 gettext -e "Unable to install package, build has failed.\n\n"
813 exit 1
814 fi
815 fi
817 # Install package if part of the chroot to keep env up-to-date.
818 if [ -d "$INSTALLED/$pkg" ]; then
819 . /etc/slitaz/cook.conf
820 . $WOK/$pkg/taz/$pkg-*/receipt
821 echo "Updating chroot environment..."
822 echo "Updating chroot: $pkg (${VERSION}${EXTRAVERSION})" | log
823 cd $PKGS && tazpkg install \
824 $pkg-${VERSION}${EXTRAVERSION}.tazpkg --forced
825 fi
826 exit $status
827 }
829 # Create a XML feed for freshly builded package.
830 gen_rss() {
831 pubdate=$(date "+%a, %d %b %Y %X")
832 cat > $FEEDS/$pkg.xml << EOT
833 <item>
834 <title>$PACKAGE $VERSION${EXTRAVERSION}</title>
835 <link>${COOKER_URL}?pkg=$PACKAGE</link>
836 <guid>$PACKAGE-$VERSION${EXTRAVERSION}</guid>
837 <pubDate>$pubdate</pubDate>
838 <description>$SHORT_DESC</description>
839 </item>
840 EOT
841 }
843 #
844 # Commands
845 #
847 case "$1" in
848 usage|help|-u|-h)
849 usage ;;
850 list-wok)
851 gettext -e "\nList of packages in:"; echo " $WOK"
852 separator
853 cd $WOK && ls -1
854 separator
855 echo -n "Packages: " && ls | wc -l
856 echo "" ;;
857 search)
858 # Just a simple search function, we dont need more actually.
859 query="$2"
860 gettext -e "\nSearch results for:"; echo " $query"
861 separator
862 cd $WOK && ls -1 | grep "$query"
863 separator && echo "" ;;
864 setup)
865 # Setup a build environment
866 check_root
867 echo "Cook: setting up the environment" | log
868 gettext -e "\nSetting up your environment\n"
869 separator && cd $SLITAZ
870 init_db_files
871 gettext -e "Checking for packages to install...\n"
872 case " $@ " in
873 *\ --reinstall\ *)
874 INSTALL_LIST=""
875 for pkg in $(mkinstall_list $SETUP_PKGS); do
876 tazpkg get-install $pkg --forced
877 done ;;
878 *)
879 for pkg in $SETUP_PKGS
880 do
881 [ ! -f "$INSTALLED/$pkg/receipt" ] &&
882 tazpkg get-install $pkg
883 done ;;
884 esac
886 # Handle --options
887 case "$2" in
888 --wok|-w)
889 hg clone $WOK_URL wok || exit 1 ;;
890 --stable)
891 hg clone $WOK_URL-stable wok || exit 1 ;;
892 --undigest)
893 hg clone $WOK_URL-undigest wok || exit 1 ;;
894 esac
896 # SliTaz group and permissions
897 if ! grep -q ^slitaz /etc/group; then
898 gettext -e "Adding group: slitaz\n"
899 addgroup slitaz
900 fi
901 gettext -e "Setting permissions for slitaz group...\n"
902 find $SLITAZ -maxdepth 2 -exec chown root.slitaz {} \;
903 find $SLITAZ -maxdepth 2 -exec chmod g+w {} \;
904 separator
905 gettext -e "All done, ready to cook packages :-)\n\n" ;;
906 test)
907 # Test a cook environment.
908 echo "Cook test: testing the cook environment" | log
909 [ ! -d "$WOK" ] && exit 1
910 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK
911 cook cooktest ;;
912 new)
913 # Create the package folder and an empty receipt.
914 pkg="$2"
915 [ "$pkg" ] || usage
916 echo ""
917 if [ -d "$WOK/$pkg" ]; then
918 echo -n "$pkg " && gettext "package already exists."
919 echo -e "\n" && exit 1
920 fi
921 gettext "Creating"; echo -n " $WOK/$pkg"
922 mkdir $WOK/$pkg && cd $WOK/$pkg && status
923 gettext "Preparing the package receipt..."
924 cp $DATA/receipt .
925 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
926 status && echo ""
928 # Interactive mode, asking and seding.
929 case "$3" in
930 --interactive|-x)
931 gettext -e "Entering interactive mode...\n"
932 separator
933 echo "Package : $pkg"
934 # Version.
935 echo -n "Version : " ; read anser
936 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
937 # Category.
938 echo -n "Category : " ; read anser
939 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
940 # Short description.
941 echo -n "Short desc : " ; read anser
942 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
943 # Maintainer.
944 echo -n "Maintainer : " ; read anser
945 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
946 # Web site.
947 echo -n "Web site : " ; read anser
948 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
949 echo ""
950 # Wget URL.
951 echo "Wget URL to download source tarball."
952 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
953 echo -n "Wget url : " ; read anser
954 sed -i s#'WGET_URL=\"$TARBALL\"'#"WGET_URL=\"$anser\""# receipt
955 # Ask for a stuff dir.
956 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
957 if [ "$anser" = "y" ]; then
958 echo -n "Creating the stuff directory..."
959 mkdir $WOK/$pkg/stuff && status
960 fi
961 # Ask for a description file.
962 echo -n "Are you going to write a description ? (y/N) : " ; read anser
963 if [ "$anser" = "y" ]; then
964 echo -n "Creating the description.txt file..."
965 echo "" > $WOK/$pkg/description.txt && status
966 fi
967 separator
968 gettext -e "Receipt is ready to use.\n"
969 echo "" ;;
970 esac ;;
971 list)
972 # Cook a list of packages (better use the Cooker since it will order
973 # packages before executing cook).
974 check_root
975 [ -z "$2" ] && gettext -e "\nNo list in argument.\n\n" && exit 1
976 [ ! -f "$2" ] && gettext -e "\nNo list found:" && \
977 echo -e " $2\n" && exit 1
978 echo "Cook list starting: $2" | log
979 for pkg in $(cat $2)
980 do
981 cook $pkg || broken
982 done ;;
983 clean-wok)
984 check_root
985 gettext -e "\nCleaning all packages files..."
986 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
987 status && echo "" ;;
988 clean-src)
989 check_root
990 gettext -e "\nCleaning all packages sources..."
991 rm -rf $WOK/*/source
992 status && echo "" ;;
993 pkgdb)
994 # Create suitable packages list for TazPKG and only for built packages
995 # as well as flavors files for TazLiTo. We dont need logs since we do it
996 # manually to ensure everything is fine before syncing the mirror.
997 case "$2" in
998 --flavors)
999 continue ;;
1000 *)
1001 [ "$2" ] && PKGS="$2"
1002 [ ! -d "$PKGS" ] && \
1003 gettext -e "\nPackages directory doesn't exist\n\n" && exit 1 ;;
1004 esac
1005 time=$(date +%s)
1006 flavors=$SLITAZ/flavors
1007 live=$SLITAZ/live
1008 echo "cook:pkgdb" > $command
1009 echo "Cook pkgdb: Creating all packages lists" | log
1010 echo ""
1011 gettext "Creating lists for: "; echo "$PKGS"
1012 separator
1013 gettext "Cook pkgdb started: "; date "+%Y-%m-%d %H:%M"
1014 cd $PKGS
1015 rm -f packages.*
1016 gettext -e "Creating: packages.list\n"
1017 ls -1 *.tazpkg | sed s'/.tazpkg//' > $PKGS/packages.list
1018 gettext -e "Creating: packages.md5\n"
1019 md5sum *.tazpkg > $PKGS/packages.md5
1020 md5sum packages.md5 | cut -f1 -d' ' > ID
1021 gettext -e "Creating lists from: "; echo "$WOK"
1022 cd $WOK
1023 for pkg in *
1024 do
1025 unset_receipt
1026 . $pkg/receipt
1027 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
1028 # PACKED_SIZE and UNPACKED_SIZE are only in built receipt
1029 if [ -s $pkg/taz/*/receipt ]; then
1030 . $pkg/taz/*/receipt
1031 fi
1032 # packages.desc lets us search easily in DB
1033 cat >> $PKGS/packages.desc << EOT
1034 $PACKAGE | ${VERSION}$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE
1035 EOT
1036 # packages.txt used by tazpkg and tazpkg-web also to provide
1037 # a human readable package list with version and description.
1038 cat >> $PKGS/packages.txt << EOT
1039 $PACKAGE
1040 ${VERSION}$EXTRAVERSION
1041 $SHORT_DESC
1042 $PACKED_SIZE ($UNPACKED_SIZE installed)
1044 EOT
1045 # packages.equiv is used by tazpkg install to check depends.
1046 for i in $PROVIDE; do
1047 DEST=""
1048 echo $i | fgrep -q : && DEST="${i#*:}:"
1049 if grep -qs ^${i%:*}= $PKGS/packages.equiv; then
1050 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" \
1051 $PKGS/packages.equiv
1052 else
1053 echo "${i%:*}=$DEST$PACKAGE" >> $PKGS/packages.equiv
1054 fi
1055 done
1056 # files.list provides a list of all packages files.
1057 cat $pkg/taz/*/files.list | sed s/^/"$pkg: \0"/ >> \
1058 $PKGS/files.list
1059 fi
1060 done
1062 # Display list size.
1063 gettext -e "Done: packages.desc\n"
1064 gettext -e "Done: packages.txt\n"
1065 gettext -e "Done: packages.equiv\n"
1067 # files.list.lzma
1068 gettext -e "Creating: files.list.lzma\n"
1069 cd $PKGS && lzma e files.list files.list.lzma
1070 rm -f files.list
1072 # Display some info.
1073 separator
1074 nb=$(ls $PKGS/*.tazpkg | wc -l)
1075 time=$(($(date +%s) - $time))
1076 echo -e "Packages: $nb - Time: ${time}s\n"
1078 # Create all flavors files at once. Do we really need code to monitor
1079 # flavors changes ? Lets just build them with packages lists before
1080 # syncing the mirror.
1081 [ "$2" == "--flavors" ] || exit 1
1082 [ ! -d "$flavors" ] && echo -e "Missing flavors: $flavors\n" && exit 1
1083 [ -d "$live" ] || mkdir -p $live
1084 gettext "Creating flavors files in:"; echo " $live"
1085 echo "Cook pkgdb: Creating all flavors" | log
1086 separator
1087 gettext -e "Recharging lists to use latest packages...\n"
1088 tazpkg recharge 2>1 >/dev/null
1090 # We need a custom tazlito config to set working dir to /home/slitaz.
1091 if [ ! -f "$live/tazlito.conf" ]; then
1092 echo "Creating configuration file: tazlito.conf"
1093 cp /etc/tazlito/tazlito.conf $live
1094 sed -i s@WORK_DIR=.*@WORK_DIR=\"/home/slitaz\"@ \
1095 $live/tazlito.conf
1096 fi
1098 # Update Hg flavors repo and pack.
1099 [ -d "$flavors/.hg" ] && cd $flavors && hg pull -u
1101 cd $live
1102 echo "Starting to generate flavors..."
1103 rm -f flavors.list *.flavor
1104 for i in $flavors/*
1105 do
1106 fl=$(basename $i)
1107 echo "Packing flavor: $(basename $i)"
1108 tazlito pack-flavor $fl >/dev/null || exit 1
1109 tazlito show-flavor $fl --brief --noheader 2> \
1110 /dev/null >> flavors.list
1111 done
1112 cp -f $live/*.flavor $live/flavors.list $PKGS
1113 separator && gettext "Flavors size: "; du -sh $live | awk '{print $1}'
1114 echo "" && rm -f $command ;;
1115 *)
1116 # Just cook and generate a package.
1117 check_root
1118 time=$(date +%s)
1119 pkg="$1"
1120 [ -z "$pkg" ] && usage
1121 receipt="$WOK/$pkg/receipt"
1122 check_pkg_in_wok && echo ""
1124 # Skip blocked, 3 lines also for the Cooker.
1125 if grep -q "^$pkg$" $blocked && [ "$2" != "--unblock" ]; then
1126 gettext -e "Blocked package:"; echo -e " $pkg\n" && exit 0
1127 fi
1129 try_aufs_chroot "$@"
1131 # Log and source receipt.
1132 echo "Cook started for: <a href='cooker.cgi?pkg=$pkg'>$pkg</a>" | log
1133 echo "cook:$pkg" > $command
1135 # Display and log info if cook process stopped.
1136 trap 'gettext -e "\n\nCook stopped: control-C\n\n" | \
1137 tee -a $LOGS/$pkg.log' INT
1139 unset inst
1140 unset_receipt
1141 . $receipt
1143 # Handle --options
1144 case "$2" in
1145 --clean|-c)
1146 gettext -e "Cleaning:"; echo -n " $pkg"
1147 cd $WOK/$pkg && rm -rf install taz source
1148 status && echo "" && exit 0 ;;
1149 --install|-i)
1150 inst='yes' ;;
1151 --getsrc|-gs)
1152 gettext "Getting source for:"; echo " $pkg"
1153 separator && get_source
1154 echo -e "Tarball: $SRC/$TARBALL\n" && exit 0 ;;
1155 --block|-b)
1156 gettext "Blocking:"; echo -n " $pkg"
1157 [ $(grep "^$pkg$" $blocked) ] || echo "$pkg" >> $blocked
1158 status && echo "" && exit 0 ;;
1159 --unblock|-ub)
1160 gettext "Unblocking:"; echo -n " $pkg"
1161 sed -i "/^${pkg}$/"d $blocked
1162 status && echo "" && exit 0 ;;
1164 esac
1166 # Check if wanted is built now so we have separate log files.
1167 for wanted in $WANTED ; do
1168 if grep -q "^$wanted$" $blocked; then
1169 echo "WANTED package is blocked: $wanted" | tee $LOGS/$pkg.log
1170 echo "" && rm -f $command && exit 1
1171 fi
1172 if grep -q "^$wanted$" $broken; then
1173 echo "WANTED package is broken: $wanted" | tee $LOGS/$pkg.log
1174 echo "" && rm -f $command && exit 1
1175 fi
1176 if [ ! -d "$WOK/$wanted/install" ]; then
1177 cook "$wanted" || exit 1
1178 fi
1179 done
1181 # Cook and pack or exit on error and log everything.
1182 cookit $@ 2>&1 | tee $LOGS/$pkg.log
1183 remove_deps | tee -a $LOGS/$pkg.log
1184 cookit_quality
1185 packit 2>&1 | tee -a $LOGS/$pkg.log
1186 clean_log
1188 # Exit if any error in packing.
1189 if grep -q ^ERROR $LOGS/$pkg.log; then
1190 debug_info | tee -a $LOGS/$pkg.log
1191 rm -f $command && exit 1
1192 fi
1194 # Create an XML feed
1195 gen_rss
1197 # Time and summary
1198 time=$(($(date +%s) - $time))
1199 summary | tee -a $LOGS/$pkg.log
1200 echo ""
1202 # Install package if requested
1203 if [ "$inst" ]; then
1204 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
1205 cd $PKGS && tazpkg install \
1206 $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg --forced
1207 else
1208 gettext -e "Unable to install package, build has failed.\n\n"
1209 exit 1
1210 fi
1211 fi
1213 # Install package if part of the chroot to keep env up-to-date.
1214 if [ -d "$INSTALLED/$PACKAGE" ] && [ -z "$AUFS_MOUNTS" ]; then
1215 echo "Updating chroot environment..."
1216 echo "Updating chroot: $PACKAGE (${VERSION}${EXTRAVERSION})" | log
1217 cd $PKGS && tazpkg install \
1218 $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg --forced
1219 fi
1221 # Finally we DONT WANT to build the *-dev or packages with WANTED="$pkg"
1222 # You want automation: use the Cooker Build Bot.
1223 #[ -d "$WOK/$pkg-dev" ] && cook $pkg-dev
1224 rm -f $command ;;
1225 esac
1227 exit 0