cookutils view cook @ rev 916
cook: allow include $PACKAGE into $SPLIT to define desired packaging order.
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Wed Jun 07 23:53:21 2017 +0300 (2017-06-07) |
parents | d30a093674f6 |
children | a6107ae4375e |
line source
1 #!/bin/sh
2 #
3 # Cook - A tool to cook and generate SliTaz packages. Read the README
4 # before adding or modifying any code in cook!
5 #
6 # Copyright (C) SliTaz GNU/Linux - GNU GPL v3
7 # Author: Christophe Lincoln <pankso@slitaz.org>
8 #
10 . /usr/lib/slitaz/libcook.sh
12 VERSION="3.2"
13 export output=raw
16 # Internationalization.
18 export TEXTDOMAIN='cook'
21 #
22 # Functions
23 #
25 usage() {
26 cat <<EOT
28 $(boldify "$(_ 'Usage:')") $(_ 'cook [package|command] [list|--option]')
30 $(boldify "$(_ 'Commands:')")
31 usage|help $(_ 'Display this short usage.')
32 setup $(_ 'Setup your build environment.')
33 *-setup $(_ 'Setup a cross environment.')
34 * = {arm|armv6hf|armv7|x86_64}
35 test $(_ 'Test environment and cook a package.')
36 list-wok $(_ 'List packages in the wok.')
37 search $(_ 'Simple packages search function.')
38 new $(_ 'Create a new package with a receipt.')
39 list $(_ 'Cook a list of packages.')
40 clean-wok $(_ 'Clean-up all packages files.')
41 clean-src $(_ 'Clean-up all packages sources.')
42 uncook $(_ 'Check for uncooked packages')
43 pkgdb $(_ 'Create packages DB lists and flavors.')
45 $(boldify "$(_ 'Options:')")
46 cook <pkg>
47 --clean -c $(_ 'clean the package in the wok.')
48 --install -i $(_ 'cook and install the package.')
49 --getsrc -gs $(_ 'get the package source tarball.')
50 --block -b $(_ 'block a package so cook will skip it.')
51 --unblock -ub $(_ 'unblock a blocked package.')
52 --cdeps $(_ 'check dependencies of cooked package.')
53 --pack $(_ 'repack an already built package.')
54 --debug $(_ 'display debugging messages.')
55 --continue $(_ 'continue running compile_rules.')
56 cook new <pkg>
57 --interactive -x $(_ 'create a receipt interactively.')
58 cook setup
59 --wok $(_ 'clone the cooking wok from Hg repo.')
60 --stable $(_ 'clone the stable wok from Hg repo.')
61 --undigest $(_ 'clone the undigest wok from Hg repo.')
62 --tiny $(_ 'clone the tiny SliTaz wok from Hg repo.')
63 --forced $(_ 'force reinstall of chroot packages.')
64 cook pkgdb
65 --flavors $(_ 'create up-to-date flavors files.')
67 EOT
68 exit 0
69 }
72 # We don't want these escapes in web interface.
74 clean_log() {
75 sed -i -e s'|\[70G\[ \[1;32m| |' \
76 -e s'|\[0;39m \]||' $LOGS/$pkg.log
77 }
80 # Be sure package exists in wok.
82 check_pkg_in_wok() {
83 [ -d "$WOK/$pkg" ] || die 'Unable to find package "%s" in the wok' "$pkg"
84 }
87 # Initialize files used in $CACHE
89 init_db_files() {
90 _ 'Creating directories structure in "%s"' "$SLITAZ"
91 mkdir -p $WOK $PKGS $SRC $CACHE $LOGS $FEEDS
92 _ 'Creating DB files in "%s"' "$CACHE"
93 touch $activity $command $broken $blocked
94 }
97 # QA: check a receipt consistency before building.
99 receipt_quality() {
100 _ 'QA: checking package receipt...'
102 for var in PACKAGE VERSION CATEGORY SHORT_DESC MAINTAINER WEB_SITE; do
103 unset value
104 value="$(. $receipt; eval echo \$$var)"
105 # L10n: QA is quality assurance
106 [ -n "$value" ] || die 'QA: empty variable: %s' "$var=\"\""
108 case "$var" in
109 CATEGORY)
110 valid="$(echo $PKGS_CATEGORIES)" # avoid newlines
111 if ! echo " $valid " | grep -q " $value "; then
112 _ 'QA: unknown category "%s"' "$value"
113 die 'Please, use one of: %s' "$valid"
114 fi
115 ;;
116 WEB_SITE)
117 # We don't check WGET_URL since if dl is needed it will fail.
118 # Break also if we're not online. Here error is not fatal.
119 if ifconfig | grep -A1 '^[a-z]*[0-9]' | fgrep -q 'addr:' && \
120 ! busybox wget -T 12 --spider $value 2>/dev/null; then
121 _ 'QA: unable to reach "%s"' "$value"
122 fi
123 ;;
124 esac
125 done
126 }
129 # Paths used in receipt and by cook itself.
131 set_paths() {
132 pkgdir="$WOK/$pkg"
133 . "$pkgdir/receipt"
134 basesrc="$pkgdir/source"
135 tmpsrc="$basesrc/tmp"
136 src="$basesrc/$PACKAGE-$VERSION"
137 taz="$pkgdir/taz"
138 pack="$taz/${1:-$PACKAGE}-$VERSION$EXTRAVERSION" # v2: multiple taz/* folders
139 fs="$pack/fs"
140 stuff="$pkgdir/stuff"
141 install="$pkgdir/install"
143 pkgsrc="${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}"
144 lzma_tarball="$pkgsrc.tar.lzma"
146 [ -n "$PATCH" -a -z "$PTARBALL" ] && PTARBALL="$(basename $PATCH)"
148 if [ -n "$WANTED" ]; then
149 basesrc="$WOK/$WANTED/source"
150 src="$basesrc/$WANTED-$VERSION"
151 install="$WOK/$WANTED/install"
152 wanted_stuff="$WOK/$WANTED/stuff"
153 fi
155 [ -n "$SOURCE" ] && source_stuff="$WOK/$SOURCE/stuff"
157 # Kernel version is set from wok/linux or installed/linux-api-headers(wok-undigest)
158 if [ -f "$WOK/linux/receipt" ]; then
159 kvers=$(. $WOK/linux/receipt; echo $VERSION)
160 kbasevers=$(echo $kvers | cut -d. -f1,2)
161 elif [ -f "$INSTALLED/linux-api-headers/receipt" ]; then
162 kvers=$(. $INSTALLED/linux-api-headers/receipt; echo $VERSION)
163 kbasevers=$(echo $kvers | cut -d. -f1,2)
164 fi
166 # Python version
167 [ -f "$WOK/python/receipt" ] && pyvers=$(. $WOK/python/receipt; echo $VERSION)
168 # Perl version for some packages needed it
169 [ -f "$WOK/perl/receipt" ] && perlvers=$(. $WOK/perl/receipt; echo $VERSION)
171 # Old way compatibility.
172 _pkg="$install"
173 }
176 # Create source tarball when URL is a SCM.
178 create_tarball() {
179 local tarball
180 tarball="$pkgsrc.tar.bz2"
181 [ -n "$LZMA_SRC" ] && tarball="$lzma_tarball"
182 _ 'Creating tarball "%s"' "$tarball"
183 if [ -n "$LZMA_SRC" ]; then
184 tar -c $pkgsrc | lzma e $SRC/$tarball -si $LZMA_SET_DIR || exit 1
185 LZMA_SRC=''
186 else
187 tar -cjf $tarball $pkgsrc || exit 1
188 mv $tarball $SRC; rm -rf $pkgsrc
189 fi
190 TARBALL="$tarball"
191 }
194 # Get package source. For SCM we are in cache so clone here and create a
195 # tarball here.
197 get_source() {
198 local url
199 url=${WGET_URL#*|}
200 set_paths
201 pwd=$(pwd)
202 case "$WGET_URL" in
203 http://*|ftp://*|https://*)
204 url="$MIRROR_URL/sources/packages/${TARBALL:0:1}/$TARBALL"
205 wget -T 60 -c -O $SRC/$TARBALL $WGET_URL ||
206 wget -T 60 -c -O $SRC/$TARBALL $url ||
207 die 'ERROR: %s' "wget $WGET_URL"
208 ;;
210 hg*|mercurial*)
211 _ 'Getting source from %s...' 'Hg'
212 _ 'URL: %s' "$url"
213 _ 'Cloning to "%s"' "$pwd/$pkgsrc"
214 if [ -n "$BRANCH" ]; then
215 _ 'Hg branch: %s' "$BRANCH"
216 hg clone $url --rev $BRANCH $pkgsrc ||
217 die 'ERROR: %s' "hg clone $url --rev $BRANCH"
218 else
219 hg clone $url $pkgsrc || die 'ERROR: %s' "hg clone $url"
220 fi
221 rm -rf $pkgsrc/.hg
222 create_tarball
223 ;;
225 git*)
226 _ 'Getting source from %s...' 'Git'
227 _ 'URL: %s' "$url"
228 cd $SRC
229 git clone $url $pkgsrc || die 'ERROR: %s' "git clone $url"
230 if [ -n "$BRANCH" ]; then
231 _ 'Git branch: %s' "$BRANCH"
232 cd $pkgsrc; git checkout $BRANCH; cd ..
233 fi
234 cd $SRC
235 create_tarball
236 ;;
238 cvs*)
239 mod=$PACKAGE
240 [ -n "$CVS_MODULE" ] && mod=$CVS_MODULE
241 _ 'Getting source from %s...' 'CVS'
242 _ 'URL: %s' "$url"
243 [ -n "$CVS_MODULE" ] && _ 'CVS module: %s' "$mod"
244 _ 'Cloning to "%s"' "$pwd/$mod"
245 cvs -d:$url co $mod && mv $mod $pkgsrc
246 create_tarball
247 ;;
249 svn*|subversion*)
250 _ 'Getting source from %s...' 'SVN'
251 _ 'URL: %s' "$url"
252 if [ -n "$BRANCH" ]; then
253 echo t | svn co $url -r $BRANCH $pkgsrc
254 else
255 echo t | svn co $url $pkgsrc
256 fi
257 create_tarball
258 ;;
260 bzr*)
261 _ 'Getting source from %s...' 'bazaar'
262 cd $SRC
263 pkgsrc=${url#*:}
264 if [ -n "$BRANCH" ]; then
265 echo "bzr -Ossl.cert_reqs=none branch $url -r $BRANCH"
266 bzr -Ossl.cert_reqs=none branch $url -r $BRANCH
267 else
268 echo "bzr -Ossl.cert_reqs=none branch $url"
269 bzr -Ossl.cert_reqs=none branch $url
270 cd $pkgsrc; BRANCH=$(bzr revno); cd ..
271 _ "Don't forget to add to receipt:"
272 echo -e "BRANCH=\"$BRANCH\"\n"
273 fi
274 mv $pkgsrc $pkgsrc-$BRANCH
275 pkgsrc="$pkgsrc-$BRANCH"
276 create_tarball
277 ;;
279 *)
280 broken; die 'ERROR: Unable to handle "%s"' "$WGET_URL"
281 ;;
282 esac
283 }
286 # Extract source package.
288 extract_source() {
289 if [ ! -s "$SRC/$TARBALL" ]; then
290 local url
291 url="$MIRROR_URL/sources/packages"
292 url="$url/${TARBALL:0:1}/$TARBALL"
293 _ 'Getting source from %s...' 'mirror'
294 _ 'URL: %s' "$url"
295 busybox wget -c -P $SRC $url || _ 'ERROR: %s' "wget $url"
296 fi
297 _ 'Extracting source archive "%s"' "$TARBALL"
298 case "$TARBALL" in
299 *.tar.gz|*.tgz) tar -xzf $SRC/$TARBALL 2>/dev/null ;;
300 *.tar.bz2|*.tbz|*.tbz2) tar -xjf $SRC/$TARBALL 2>/dev/null ;;
301 *.tar.lzma) tar -xaf $SRC/$TARBALL ;;
302 *.tar.lz|*.tlz) lzip -d < $SRC/$TARBALL | tar -xf - 2>/dev/null ;;
303 *.tar) tar -xf $SRC/$TARBALL ;;
304 *.zip|*.xpi) unzip -o $SRC/$TARBALL 2>/dev/null >&2;;
305 *.xz) unxz -c $SRC/$TARBALL | tar -xf - || \
306 tar -xf $SRC/$TARBALL 2>/dev/null;;
307 *.7z) 7zr x $SRC/$TARBALL 2>/dev/null >&2 ;;
308 *.Z|*.z) uncompress -c $SRC/$TARBALL | tar -xf - ;;
309 *.rpm) rpm2cpio $SRC/$TARBALL | cpio -idm --quiet ;;
310 *.run) /bin/sh $SRC/$TARBALL $RUN_OPTS ;;
311 *) cp $SRC/$TARBALL $(pwd) ;;
312 esac
313 }
316 # Display time.
318 disp_time() {
319 local sec div min
320 sec="$1"
321 div=$(( ($1 + 30) / 60))
322 case $div in
323 0) min='';;
324 # L10n: 'm' is for minutes (approximate cooking time)
325 *) min=$(_n ' ~ %dm' "$div");;
326 esac
328 # L10n: 's' is for seconds (cooking time)
329 _ '%ds%s' "$sec" "$min"
330 }
333 # Display cooked package summary.
335 summary() {
336 set_paths
337 cd $WOK/$pkg
338 [ -d $WOK/$pkg/install ] && prod=$(du -sh $WOK/$pkg/install | awk '{print $1}' 2>/dev/null)
339 [ -d $WOK/$pkg/source ] && srcdir=$(du -sh $WOK/$pkg/source | awk '{print $1}' 2>/dev/null)
340 [ -n "$TARBALL" ] && srcsize=$(du -sh $SRC/$TARBALL | awk '{print $1}')
342 _ 'Summary for: %s' "$PACKAGE $VERSION"
343 separator
345 # L10n: keep the same width of translations to get a consistent view
346 [ -n "$TARBALL" ] && _ 'Src file : %s' "$TARBALL"
347 [ -n "$srcsize" ] && _ 'Src size : %s' "$srcsize"
348 [ -n "$srcdir" ] && _ 'Source dir : %s' "$srcdir"
349 [ -n "$prod" ] && _ 'Produced : %s' "$prod"
350 _ 'Cook time : %s' "$(disp_time "$time")"
351 _ 'Cook date : %s' "$(date "$(_ '+%%F %%R')")"
352 _ 'Host arch : %s' "$ARCH"
354 separator -
355 _ ' # : Packed : Compressed : Files : Package name'
356 separator -
357 pkgi=1
358 for i in $(all_names); do
359 fs=$(du -sh $WOK/$pkg/taz/$i-$VERSION | awk '{print $1}')
360 pkgname="$i-$VERSION.tazpkg"
361 size=$(ls -lh $PKGS/$pkgname | awk '{print $5}')
362 files=$(wc -l < $WOK/$pkg/taz/$i-$VERSION/files.list)
363 printf "%2d : %7s : %10s : %5s : %s\n" "$pkgi" "$fs" "$size" "$files" "$pkgname"
364 pkgi=$((pkgi + 1))
365 done
366 separator
367 }
370 # Display debugging error info.
372 debug_info() {
373 title 'Debug information'
374 # L10n: specify your format of date and time (to help: man date)
375 # L10n: not bad one is '+%x %R'
376 _ 'Cook date: %s' "$(date "$(_ '+%%F %%R')")"
377 if [ -n "$time" ]; then
378 times="$(($(date +%s) - $time))"
379 _ 'Wasted time : %s' "$(disp_time "$times")"
380 fi
381 for error in \
382 ERROR 'No package' "cp: can't" "can't open" "can't cd" \
383 'error:' 'fatal error:' 'undefined reference to' \
384 'Unable to connect to' 'link: cannot find the library' \
385 'CMake Error' ': No such file or directory' \
386 'Could not read symbols: File in wrong format'
387 do
388 # format "line number:line content"
389 fgrep -n "$error" $LOGS/$pkg.log
390 done > $LOGS/$pkg.log.debug_info 2>&1
391 # sort by line number, remove duplicates
392 sort -gk1,1 -t: -u $LOGS/$pkg.log.debug_info
393 rm -f $LOGS/$pkg.log.debug_info
394 footer
395 }
398 # A bit smarter function than the classic `cp` command
400 scopy() {
401 if [ "$(stat -c %h -- "$1")" -eq 1 ]; then
402 cp -a "$1" "$2" # copy generic files
403 else
404 cp -al "$1" "$2" # copy hardlinks
405 fi
406 }
409 # Copy all generic files (locale, pixmaps, .desktop) from $install to $fs.
410 # We use standard paths, so some packages need to copy these files with the
411 # receipt and genpkg_rules.
412 # This function executes inside the packaging process, before compressor call.
414 copy_generic_files() {
415 # Proceed only for "main" package (for v2), and for any packages (v1)
416 [ "$pkg" == "$PACKAGE" ] || return 0
418 # $LOCALE is set in cook.conf
419 if [ -n "$LOCALE" -a -z "$WANTED" ]; then
420 if [ -d "$install/usr/share/locale" ]; then
421 mkdir -p "$fs/usr/share/locale"
422 for i in $LOCALE; do
423 if [ -d "$install/usr/share/locale/$i" ]; then
424 cp -a $install/usr/share/locale/$i $fs/usr/share/locale
425 fi
426 done
427 fi
428 fi
430 # Generic pixmaps copy can be disabled with COOKOPTS="!pixmaps" (or GENERIC_PIXMAPS="no")
431 if [ "${COOKOPTS/!pixmaps/}" == "$COOKOPTS" -a "$GENERIC_PIXMAPS" != 'no' ]; then
432 if [ -d "$install/usr/share/pixmaps" ]; then
433 mkdir -p "$fs/usr/share/pixmaps"
434 for i in png xpm; do
435 [ -f "$install/usr/share/pixmaps/$PACKAGE.$i" -a ! -f "$fs/usr/share/pixmaps/$PACKAGE.$i" ] &&
436 cp -a $install/usr/share/pixmaps/$PACKAGE.$i $fs/usr/share/pixmaps
437 done
438 fi
439 fi
441 # Desktop entry (.desktop).
442 # Generic desktop entry copy can be disabled with COOKOPTS="!menus" (or GENERIC_MENUS="no")
443 if [ "${COOKOPTS/!menus/}" == "$COOKOPTS" -a "$GENERIC_MENUS" != 'no' ]; then
444 if [ -d "$install/usr/share/applications" -a -z "$WANTED" ]; then
445 mkdir -p "$fs/usr/share"
446 cp -a $install/usr/share/applications $fs/usr/share
447 fi
448 fi
449 }
452 # Copy pixmaps, desktop files and licenses from $stuff to $install.
453 # This function executes after the main compile_rules() is done.
455 copy_generic_stuff() {
456 # Custom or homemade PNG pixmap can be in stuff.
457 if [ -f "$stuff/$PACKAGE.png" ]; then
458 mkdir -p $install/usr/share/pixmaps
459 cp $stuff/$PACKAGE.png $install/usr/share/pixmaps
460 fi
462 # Homemade desktop file(s) can be in stuff.
463 if [ -d "$stuff/applications" ]; then
464 mkdir -p $install/usr/share
465 cp $stuff/applications $install/usr/share
466 fi
467 if [ -f "$stuff/$PACKAGE.desktop" ]; then
468 mkdir -p $install/usr/share/applications
469 cp $stuff/$PACKAGE.desktop $install/usr/share/applications
470 fi
472 # Add custom licenses
473 if [ -d "$stuff/licenses" ]; then
474 mkdir -p $install/usr/share/licenses
475 cp $stuff/licenses $install/usr/share/licenses/$PACKAGE
476 fi
477 }
480 # Remove files provided by split packages
481 # For example:
482 # 1. Package "pkg-main":
483 # SPLIT="pkg-1 pkg-2 pkg-extra"
484 # 2. Package="pkg-extra":
485 # WANTED="pkg-main"
486 # BUILD_DEPENDS="pkg-1 pkg-2"
487 # cook_copy_folders usr
488 # cook_split_rm $BUILD_DEPENDS
490 cook_split_rm() {
491 for i in $@; do
492 action 'Remove files provided by split package %s...' "$i"
493 while read j; do
494 [ -f "$fs$j" -o -h "$fs$j" ] && rm $fs$j
495 rmdir "$(dirname "$fs$j")" 2>/dev/null
496 done < $WOK/$i/taz/$i-$VERSION/files.list
497 :; status
498 done
499 }
502 # Update installed.cook.diff
504 update_installed_cook_diff() {
505 # If a cook failed deps are removed.
506 cd $root$INSTALLED; ls -1 > $CACHE/installed.cook
507 cd $CACHE
508 [ "$1" == 'force' -o ! -s '/tmp/installed.cook.diff' ] && \
509 busybox diff installed.list installed.cook > /tmp/installed.cook.diff
510 deps=$(cat /tmp/installed.cook.diff | grep ^+[a-zA-Z0-9] | wc -l)
511 }
514 # Remove installed deps.
516 remove_deps() {
517 # Now remove installed build deps.
518 diff='/tmp/installed.cook.diff'
519 [ -s "$diff" ] || return
521 deps=$(cat $diff | grep ^+[a-zA-Z0-9] | sed s/^+//)
522 nb=$(cat $diff | grep ^+[a-zA-Z0-9] | wc -l)
523 newline
524 _n 'Build dependencies to remove:'; echo " $nb"
525 [ -n "$root" ] && echo "root=\"$root\""
526 {
527 _n 'Removing:'
528 for dep in $deps; do
529 echo -n " $dep"
530 echo 'y' | tazpkg remove $dep --root=$root >/dev/null
531 done
532 newline; newline
533 # Keep the last diff for debug and info.
534 mv -f $diff $CACHE/installed.diff
535 } | fold -sw80
536 }
539 # Automatically patch the sources.
541 patchit() {
542 [ -f "$stuff/patches/series" ] || return
544 while read i; do
545 [ -f "$src/done.$i" ] && continue
546 newline
547 _ 'Applying patch %s' "$i"
548 patch -p1 -i $stuff/patches/$i | sed 's|^| |'
549 touch $src/done.$i
550 done < $stuff/patches/series
551 newline
552 }
555 # Check source tarball integrity.
557 check_integrity() {
558 for i in sha1 sha3 sha256 sha512 md5; do
559 I=$(echo $i | tr 'a-z' 'A-Z')
560 eval sum=\$TARBALL_$I
561 if [ -n "$sum" ]; then
562 newline
563 _ 'Checking %ssum of source tarball...' "$i"
564 echo "$sum $SRC/$TARBALL" | ${i}sum -c || exit 1
565 fi
566 done
567 newline
568 }
571 # The main cook function.
573 cookit() {
574 if [ -n "$SETUP_MD5" -a "$SETUP_MD5" != "$(ls $root$INSTALLED | md5sum | cut -c1-32)" ]; then
575 _ 'ERROR: Broken setup. Abort.'
576 return
577 fi
579 title 'Cook: %s' "$PACKAGE $VERSION"
580 set_paths
582 # Handle cross-tools.
583 case "$ARCH" in
584 arm*|x86_64)
585 # CROSS_COMPILE is used by at least Busybox and the kernel to set
586 # the cross-tools prefix. Sysroot is the root of our target arch
587 sysroot="$CROSS_TREE/sysroot"
588 tools="$CROSS_TREE/tools"
589 # Set root path when cross compiling. ARM tested but not x86_64
590 # When cross compiling we must install build deps in $sysroot.
591 arch="-$ARCH"
592 root="$sysroot"
593 _ '%s sysroot: %s' "$ARCH" "$sysroot"
594 _ 'Adding "%s" to PATH' "$tools/bin"
595 export PATH="$PATH:$tools/bin"
596 export PKG_CONFIG_PATH="$sysroot/usr/lib/pkgconfig"
597 export CROSS_COMPILE="$HOST_SYSTEM-"
598 _ 'Using cross-tools: %s' "$CROSS_COMPILE"
599 if [ "$ARCH" == 'x86_64' ]; then
600 export CC="$HOST_SYSTEM-gcc -m64"
601 export CXX="$HOST_SYSTEM-g++ -m64"
602 else
603 export CC="$HOST_SYSTEM-gcc"
604 export CXX="$HOST_SYSTEM-g++"
605 fi
606 export AR="$HOST_SYSTEM-ar"
607 export AS="$HOST_SYSTEM-as"
608 export RANLIB="$HOST_SYSTEM-ranlib"
609 export LD="$HOST_SYSTEM-ld"
610 export STRIP="$HOST_SYSTEM-strip"
611 export LIBTOOL="$HOST_SYSTEM-libtool"
612 ;;
613 esac
615 [ -n "$QA" ] && receipt_quality
617 cd $pkgdir
618 [ -z "$continue" ] && rm -rf source 2>/dev/null
619 rm -rf install taz 2>/dev/null
621 # Disable -pipe if less than 512 MB free RAM.
622 free=$(awk '/^MemFree|^Buffers|^Cached/{s+=$2}END{print int(s/1024)}' /proc/meminfo)
623 if [ "$free" -lt 512 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then
624 _ 'Disabling -pipe compile flag: %d MB RAM free' "$free"
625 CFLAGS="${CFLAGS/-pipe}"; CFLAGS=$(echo "$CFLAGS" | tr -s ' ')
626 CXXFLAGS="${CXXFLAGS/-pipe}"; CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ')
627 fi
628 unset free
630 # Export flags and path to be used by make and receipt.
631 DESTDIR="$pkgdir/install"
632 # FIXME: L10n: Is this the right time for 'LC_ALL=C LANG=C'?
633 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS CONFIG_SITE LC_ALL=C LANG=C
634 #LDFLAGS
636 # BUILD_DEPENDS may vary depending on the ARCH
637 case "$ARCH" in
638 arm*) [ -n "$BUILD_DEPENDS_arm" ] && BUILD_DEPENDS=$BUILD_DEPENDS_arm ;;
639 x86_64) [ -n "$BUILD_DEPENDS_x86_64" ] && BUILD_DEPENDS=$BUILD_DEPENDS_x86_64 ;;
640 esac
642 # Check for build deps and handle implicit depends of *-dev packages
643 # (ex: libusb-dev :: libusb).
644 # rm -f $CACHE/installed.local $CACHE/installed.web $CACHE/missing.dep
645 # touch $CACHE/installed.local $CACHE/installed.web
646 [ -n "$BUILD_DEPENDS" ] && _ 'Checking build dependencies...'
647 [ -n "$root" ] && _ 'Using packages DB: %s' "$root$DB"
649 for action in check install; do
650 for dep in $BUILD_DEPENDS; do
651 implicit="${dep%-dev}"; [ "$implicit" == "$dep" ] && implicit=''
652 for i in $dep $implicit; do
653 # Skip if package already installed
654 [ -f "$root$INSTALLED/$i/receipt" ] && continue
656 case $action in
657 check)
658 # Search for local package or local provided-package
659 name=$(awk -F$'\t' -vpkg="$i" '{
660 if (index(" " $1 " " $10 " ", " " pkg " ")) {print $1; exit}
661 }' "$PKGS/packages.info")
662 if [ -z "$name" ]; then
663 # Search for package in mirror
664 name="$(awk -F$'\t' -vi="$i" '$1==i{print $1; exit}' "$root$DB/packages.info")"
665 [ -z "$name" -a "$i" == "$dep" ] && die 'ERROR: unknown dep "%s"' "$i"
666 fi
667 ;;
668 install)
669 tazpkg get-install $i --root=$root --local --quiet --cookmode || { broken; exit 1; }
670 ;;
671 esac
672 done
673 done
674 done
676 # # Get the list of installed packages
677 # cd $root$INSTALLED; ls -1 > $CACHE/installed.list
678 #
679 # # Have we a missing build dep to cook?
680 # if [ -s "$CACHE/missing.dep" ] && [ -n "$AUTO_COOK" ]; then
681 # _ 'Auto cook config is set: %s' "$AUTO_COOK"
682 # cp -f $LOGS/$PACKAGE.log $LOGS/$PACKAGE.log.$$
683 # for i in $(uniq $CACHE/missing.dep); do
684 # (_ 'Building dep (wok/pkg) : %s' "$i $vers") | \
685 # tee -a $LOGS/$PACKAGE.log.$$
686 # # programmers: next two messages are exact copy from remove_deps()
687 # togrep1=$(_n 'Build dependencies to remove:')
688 # togrep2=$(_n 'Removing:')
689 # cook $i || (_ "ERROR: can't cook dep \"%s\"" "$i" && newline && \
690 # fgrep $togrep1 $LOGS/$i.log && \
691 # fgrep $togrep2 $LOGS/$i.log && newline) | \
692 # tee -a $LOGS/$PACKAGE.log.$$ && break
693 # done
694 # rm -f $CACHE/missing.dep
695 # mv $LOGS/$PACKAGE.log.$$ $LOGS/$PACKAGE.log
696 # fi
697 #
698 # # QA: Exit on missing dep errors. We exit in both cases, if AUTO_COOK
699 # # is enabled and cook fails we have ERROR in log, if no auto cook we have
700 # # missing dep in cached file.
701 # lerror=$(_n 'ERROR')
702 # if fgrep -q ^$lerror $LOGS/$pkg.log || [ -s "$CACHE/missing.dep" ]; then
703 # [ -s "$CACHE/missing.dep" ] && nb=$(wc -l < $CACHE/missing.dep)
704 # _p 'ERROR: missing %d dependency' 'ERROR: missing %d dependencies' "$nb" "$nb"
705 # broken; exit 1
706 # fi
707 #
708 # # Install local packages: package-version$arch
709 # cd $PKGS
710 # for i in $(uniq $CACHE/installed.local); do
711 # # _ 'Installing dep (pkg/local): %s' "$i"
712 # tazpkg install $i --root=$root --local --quiet --cookmode
713 # done
714 #
715 # # Install web or cached packages (if mirror is set to $PKGS we only
716 # # use local packages).
717 # for i in $(uniq $CACHE/installed.web); do
718 # # _ 'Installing dep (web/cache): %s' "$i"
719 # tazpkg get-install $i --root=$root --local --quiet --cookmode
720 # done
722 update_installed_cook_diff
724 # Get source tarball and make sure we have source dir named:
725 # $PACKAGE-$VERSION to be standard in receipts. Here we use tar.lzma
726 # tarball if it exists.
727 if [ -n "$WGET_URL" -a ! -f "$SRC/$TARBALL" ]; then
728 if [ -f "$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
729 TARBALL="${SOURCE:-$PACKAGE}-$VERSION.tar.lzma"
730 LZMA_SRC=''
731 else
732 get_source || { broken; exit 1; }
733 fi
734 fi
735 if [ -z "$WANTED" -a -n "$TARBALL" -a ! -d "$src" ]; then
736 mkdir -p $pkgdir/source/tmp; cd $pkgdir/source/tmp
737 if ! extract_source ; then
738 get_source
739 extract_source || { broken; exit 1; }
740 fi
741 if [ -n "$LZMA_SRC" ]; then
742 cd $pkgdir/source
743 if [ "$(ls -A tmp | wc -l)" -gl 1 -o -f "$(echo tmp/*)" ]; then
744 mv tmp tmp-1; mkdir tmp
745 mv tmp-1 tmp/${SOURCE:-$PACKAGE}-$VERSION
746 fi
747 if [ -d "tmp/${SOURCE:-$PACKAGE}-$VERSION" ]; then
748 cd tmp; tar -c * | lzma e $SRC/$TARBALL -si
749 fi
750 fi
751 cd $pkgdir/source/tmp
752 # Some archives are not well done and don't extract to one dir (ex lzma).
753 files=$(ls | wc -l)
754 [ "$files" -eq 1 -a -d "$(ls)" ] && mv * ../$PACKAGE-$VERSION
755 [ "$files" -eq 1 -a -f "$(ls)" ] && mkdir -p ../$PACKAGE-$VERSION && \
756 mv * ../$PACKAGE-$VERSION/$TARBALL
757 [ "$files" -gt 1 ] && mkdir -p ../$PACKAGE-$VERSION && \
758 mv * ../$PACKAGE-$VERSION
759 cd ..; rm -rf tmp
760 fi
762 check_integrity
764 # Libtool shared libs path hack.
765 case "$ARCH" in
766 arm*) cross libhack ;;
767 esac
769 # Execute receipt rules.
770 if grep -q ^compile_rules $receipt; then
771 _ 'Executing: %s' 'compile_rules'
772 echo "CFLAGS : $CFLAGS"
773 #echo "LDFLAGS : $LDFLAGS"
774 [ -d "$src" ] && cd $src
775 patchit
776 compile_rules $@ || { broken; exit 1; }
777 # Stay compatible with _pkg
778 [ -d "$src/_pkg" ] && mv $src/_pkg $install
779 # QA: compile_rules success so valid.
780 mkdir -p $install
781 else
782 # QA: no compile_rules so no error, valid.
783 mkdir -p $install
784 fi
786 copy_generic_stuff
788 # Actions to do after compiling the package
789 # Skip all for split packages (already done in main package)
790 if [ -z "$WANTED" ]; then
791 footer
792 export COOKOPTS ARCH install; @@PREFIX@@/libexec/cookutils/compressor install
793 fi
794 footer
796 # Execute testsuite.
797 if grep -q ^testsuite $receipt; then
798 title 'Running testsuite'
799 testsuite $@ || { broken; exit 1; }
800 footer
801 fi
803 update_installed_cook_diff force
804 }
807 # Cook quality assurance.
809 cookit_quality() {
810 if [ ! -d "$WOK/$pkg/install" ] && [ -z "$WANTED" ]; then
811 _ 'ERROR: cook failed' | tee -a $LOGS/$pkg.log
812 fi
813 # ERROR can be echoed any time in cookit()
814 lerror=$(_n 'ERROR')
815 if grep -Ev "(conftest|configtest)" $LOGS/$pkg.log | \
816 grep -Eq "(^$lerror|undefined reference to)" ; then
817 debug_info | tee -a $LOGS/$pkg.log
818 sed -i '$ s|$| [ Failed ]|' $activity
819 rm -f $command
820 broken; exit 1
821 fi
822 }
825 # Receipt used for cooking the package is redundant to be included into package.
826 # This script will strip the original receipt to bare minimum: variables,
827 # {pre,post}_{install,remove} functions.
829 mk_pkg_receipt() {
830 orig_receipt="$1"
832 # Receipt's signature is important, although some receipts may miss it
833 signature=$(head -n1 "$orig_receipt")
834 [ "${signature:0:1}" == '#' ] || signature='# SliTaz package receipt.'
836 save_PACKAGE="$PACKAGE"; save_DEPENDS="$DEPENDS"; save_PROVIDE="$PROVIDE"
837 save_SUGGESTED="$SUGGESTED"; save_TAZPANEL_DAEMON="$TAZPANEL_DAEMON"
838 save_TAGS="$TAGS"
839 unset_receipt
840 . "$orig_receipt"
841 PACKAGE="$save_PACKAGE"; DEPENDS="$save_DEPENDS"; PROVIDE="$save_PROVIDE"
842 SUGGESTED="$save_SUGGESTED"; TAZPANEL_DAEMON="$save_TAZPANEL_DAEMON"
843 TAGS="$save_TAGS"
845 # Manage split packages
846 SPLIT=" $SPLIT "
847 if [ "$SPLIT" != ' ' -a "${SPLIT/ $PACKAGE /}" != "$SPLIT" ]; then
848 # For packages with empty $DEPENDS
849 if [ -z "$DEPENDS" ]; then
850 case $PACKAGE in
851 *-dev)
852 # main package and all the split packages but this *-dev itself
853 DEPENDS=$(echo "$pkg $SPLIT " | sed "s| $PACKAGE | |; s| *$||") ;;
854 *)
855 # main package
856 DEPENDS="$pkg" ;;
857 esac
858 fi
860 # Default $CAT
861 [ -z "$CAT" ] &&
862 case $PACKAGE in
863 *-dev) CAT="development|development files" ;;
864 esac
866 # Manage two-in-one $CAT="$CATEGORY|$SHORT_DESC_ADDITION"
867 CATEGORY="${CAT%|*}"
868 SHORT_DESC="$SHORT_DESC (${CAT#*|})"
869 fi
871 # Mandatory variables
872 cat <<EOF
873 $signature
875 PACKAGE="$PACKAGE"
876 VERSION="$VERSION"
877 CATEGORY="$CATEGORY"
878 SHORT_DESC="$SHORT_DESC"
879 MAINTAINER="$MAINTAINER"
880 LICENSE="$LICENSE"
881 WEB_SITE="$WEB_SITE"
882 EOF
884 # Optional variables
885 [ -n "$TAGS" ] && echo "TAGS=\"$TAGS\"" | tr -ds '\t' ' '
886 [ -n "${DEPENDS# }" ] && echo "DEPENDS=\"$DEPENDS\"" | tr -ds '\t' ' '
887 [ -n "$PROVIDE" ] && echo "PROVIDE=\"$PROVIDE\"" | tr -ds '\t' ' '
888 [ -n "$CONFIG_FILES" ] && echo "CONFIG_FILES=\"$CONFIG_FILES\"" | tr -ds '\t' ' '
889 [ -n "$SUGGESTED" ] && echo "SUGGESTED=\"$SUGGESTED\"" | tr -ds '\t' ' '
890 [ -n "$DATABASE_FILES" ] && echo "DATABASE_FILES=\"$DATABASE_FILES\""
891 [ -n "$TAZPANEL_DAEMON" ] && echo "TAZPANEL_DAEMON=\"$TAZPANEL_DAEMON\""
893 # Extract {pre,post}_{install,remove} functions;
894 # post_install() will be copied for both main and all the split packages
895 # post_install_gtk_() will be copied as post_install() for gtk+ package only
896 #
897 # restricted name (gtk+ -> gtk_; acl-dev -> acl_dev)
898 rname=$(echo -n $PACKAGE | tr -c 'a-zA-Z0-9' '_')
899 for i in pre post; do
900 for j in install remove; do
901 sed "/^${i}_${j}()/,/^}/!d" "$orig_receipt"
902 sed "/^${i}_${j}_$rname()/,/^}/!d" "$orig_receipt" | \
903 sed "s|^${i}_${j}_$rname()|${i}_${j}()|"
904 done
905 done
906 }
909 # Create the package. Wanted to use TazPkg to create a tazpkg package at first,
910 # but it doesn't handle EXTRAVERSION.
912 packit() {
913 set_paths "$1"
914 PACKAGE="${1:-$PACKAGE}"
916 # Handle cross compilation
917 case "$ARCH" in
918 arm*|x86_64) arch="-$ARCH" ;;
919 esac
921 title 'Pack: %s' "$PACKAGE $VERSION$arch"
923 if grep -q ^genpkg_rules $receipt; then
924 _ 'Executing: %s' 'genpkg_rules'
925 set -e; cd $pkgdir; mkdir -p $fs
926 genpkg_rules || (newline; _ 'ERROR: genpkg_rules failed'; newline) >> \
927 $LOGS/$pkg.log
928 else
929 _ 'No packages rules: meta package'
930 mkdir -p $fs
931 fi
933 # Check CONFIG_FILES
934 if [ -n "$CONFIG_FILES" ]; then
935 unset IFS
936 for i in $CONFIG_FILES; do
937 if [ ! -e $fs$i ]; then
938 case $i in
939 */) mkdir -p $fs$i ;;
940 *) mkdir -p $fs$(dirname $i); touch $fs$i ;;
941 esac
942 fi
943 done
944 fi
946 # First QA check to stop now if genpkg_rules failed.
947 lerror=$(_n 'ERROR')
948 if fgrep -q ^$lerror $LOGS/$pkg.log; then
949 broken; exit 1
950 fi
952 cd $taz
953 action 'Copying "%s"...' 'receipt'
954 mk_pkg_receipt ../receipt > $pack/receipt
955 chown 0.0 $pack/receipt; status
957 unset desc
958 [ "$pkg" == "$PACKAGE" -a -f "../description.txt" ] && desc="../description.txt"
959 [ -f "../description.$PACKAGE.txt" ] && desc="../description.$PACKAGE.txt"
960 if [ -n "$desc" ]; then
961 action 'Copying "%s"...' "$(basename "$desc")"
962 cp -f $desc $pack/description.txt; chown 0.0 $pack/description.txt; status
963 fi
965 copy_generic_files
967 # Strip and stuff files.
968 export COOKOPTS ARCH HOST_SYSTEM LOCALE fs; @@PREFIX@@/libexec/cookutils/compressor fs
970 # Create files.list with redirecting find output.
971 action 'Creating the list of files...'
972 cd $fs
973 find . -type f -print > ../files.list
974 find . -type l -print >> ../files.list
975 cd ..; sed -i s/'^.'/''/ files.list
976 status
978 # Md5sum of files.
979 action 'Creating md5sum of files...'
980 while read file; do
981 [ -L "fs$file" ] && continue
982 [ -f "fs$file" ] || continue
983 case "$file" in
984 /lib/modules/*/modules.*|*.pyc) continue ;;
985 esac
986 md5sum "fs$file" | sed 's/ fs/ /'
987 done < files.list > md5sum
988 status
990 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
991 2>/dev/null | awk 'END{ print $1 }')
993 # Build cpio archive.
994 action 'Compressing the FS...'
995 find fs -newer $receipt -exec touch -hr $receipt '{}' \;
996 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
997 mv fs ../
998 status
1000 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list md5sum description.txt \
1001 2>/dev/null | awk 'END{ print $1 }')
1003 action 'Updating receipt sizes...'
1004 sed -i s/^PACKED_SIZE.*$// receipt
1005 sed -i s/^UNPACKED_SIZE.*$// receipt
1006 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
1007 status
1009 # Set extra version.
1010 if [ -n "$EXTRAVERSION" ]; then
1011 action 'Updating receipt EXTRAVERSION: %s' "$EXTRAVERSION"
1012 sed -i s/^EXTRAVERSION.*$// receipt
1013 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
1014 status
1015 fi
1017 # Compress.
1018 action 'Creating full cpio archive...'
1019 find . -newer $receipt -exec touch -hr $receipt '{}' \;
1020 find . | cpio -o -H newc --quiet > ../$PACKAGE-$VERSION$EXTRAVERSION$arch.tazpkg
1021 status
1023 action 'Restoring original package tree...'
1024 mv ../fs .
1025 status
1027 rm fs.cpio.lzma; cd ..
1029 # QA and give info.
1030 tazpkg=$(ls *.tazpkg)
1031 packit_quality
1032 footer "$(_ 'Package "%s" created' "$tazpkg")"
1033 update_packages_info
1034 }
1037 # Verify package quality and consistency.
1039 packit_quality() {
1040 #action 'QA: checking for broken link...'
1041 #link=$(find $fs/usr -type l -follow)
1042 #[ "$link" ] && echo -e "\nERROR: broken link in filesystem"
1043 #status
1045 # Exit if any error found in log file.
1046 lerror=$(_n 'ERROR')
1047 if fgrep -q ^$lerror $LOGS/$pkg.log; then
1048 rm -f $command
1049 broken; exit 1
1050 fi
1052 action 'QA: checking for empty package...'
1053 files=$(cat $WOK/$pkg/taz/$PACKAGE-$VERSION$EXTRAVERSION/files.list | wc -l)
1054 if [ "$files" -eq 0 -a "$CATEGORY" != 'meta' ]; then
1055 broken
1056 rm -f $command
1057 die 'ERROR: empty package'
1058 fi
1060 :; status
1061 # Find and remove old package(s)
1062 tempd="$(mktemp -d)"; cd "$tempd"
1063 for testpkg in $(ls $PKGS/$PACKAGE-*.tazpkg 2>/dev/null); do
1064 # Extract receipt from each matched package
1065 cpio -F "$testpkg" -i receipt >/dev/null 2>&1
1066 name=$(. receipt; echo $PACKAGE)
1067 rm receipt
1068 if [ "$name" == "$PACKAGE" ]; then
1069 action 'Removing old package "%s"' "$(basename "$testpkg")"
1070 rm -f "$testpkg"
1071 status
1072 fi
1073 done
1074 rm -r "$tempd"
1075 mv -f $pkgdir/taz/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg $PKGS
1076 sed -i /^${pkg}$/d $broken
1077 #action 'Removing source tree...'
1078 #rm -f $WOK/$pkg/source; status
1079 }
1082 # Return all the names of packages bundled in this receipt
1084 all_names() {
1085 local split=" $SPLIT "
1086 if [ "${split/ $PACKAGE /}" != "$split" ]; then
1087 # $PACKAGE included somewhere in $SPLIT (probably in the end).
1088 # We should build packages in the order defined in the $SPLIT.
1089 echo $SPLIT
1090 else
1091 # We'll build the $PACKAGE, then all defined in the $SPLIT.
1092 echo $PACKAGE $SPLIT
1093 fi
1094 }
1097 # v2: pack all packages using compiled files
1099 packall() {
1100 set_paths
1101 if head -n1 "$pkgdir/receipt" | fgrep -q 'v2'; then
1102 for i in $(all_names); do
1103 unset TAGS DEPENDS CAT CONFIG_FILES PROVIDE SUGGESTED DATABASE_FILES TAZPANEL_DAEMON
1104 packit $i
1105 done
1106 else
1107 packit
1108 fi
1109 }
1112 # Reverse "cat" command: prints input lines in the reverse order
1114 tac() {
1115 sed '1!G;h;$!d' $1
1116 }
1119 # Update chroot with freshly rebuilt package: keep env up-to-date.
1121 update_chroot() {
1122 for i in $pkg $SPLIT; do
1123 if [ -d "$root$INSTALLED/$i" ]; then
1124 . /etc/slitaz/cook.conf
1125 . $WOK/$pkg/taz/$i-$VERSION/receipt
1126 _ 'Updating %s chroot environment...' "$ARCH"
1127 _ 'Updating chroot: %s' "$i ($VERSION$EXTRAVERSION$arch)" | log
1128 cd $PKGS
1129 tazpkg install $i-$VERSION$EXTRAVERSION$arch.tazpkg --forced --root=$root
1130 fi
1131 done
1132 }
1135 # Install package on --inst or update the chroot.
1137 install_package() {
1138 case "$ARCH" in
1139 arm*|x86_64)
1140 arch="-$ARCH"
1141 root="$CROSS_TREE/sysroot" ;;
1142 esac
1143 # Install package if requested but skip install if target host doesn't
1144 # match build system or it will break the build chroot.
1145 build=$(echo $BUILD_SYSTEM | cut -d- -f1)
1146 if [ -n "$inst" -a "$build" == "$ARCH" ]; then
1147 if [ -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ]; then
1148 cd $PKGS
1149 tazpkg install $PACKAGE-$VERSION$EXTRAVERSION.tazpkg --forced
1150 else
1151 broken
1152 die 'Unable to install package, build has failed.'
1153 fi
1154 fi
1156 update_chroot
1157 }
1160 # remove chroot jail
1162 umount_aufs() {
1163 tac ${1}rw/aufs-umount.sh | sh
1164 rm -rf ${1}rw
1165 umount ${1}root
1166 rmdir ${1}r*
1167 }
1170 # Launch the cook command into a chroot jail protected by aufs.
1171 # The current filesystems are used read-only and updates are
1172 # stored in a separate branch.
1174 try_aufs_chroot() {
1176 base="/dev/shm/aufsmnt$$"
1178 # Can we setup the chroot? Is it already done?
1179 grep -q ^AUFS_NOT_SUPPORTED $receipt && return
1180 grep -q ^AUFS_NOT_RAMFS $receipt && base="/mnt/aufsmnt$$"
1181 [ -n "$AUFS_MOUNTS" -a ! -f /aufs-umount.sh ] || return
1182 grep -q ^aufs /proc/modules || modprobe aufs 2> /dev/null || return
1183 mkdir ${base}root ${base}rw || return
1185 _ 'Setup aufs chroot...'
1187 # Sanity check
1188 for i in / /proc /sys /dev/shm /home ; do
1189 case " $AUFS_MOUNTS " in
1190 *\ $i\ *) ;;
1191 *) AUFS_MOUNTS="$AUFS_MOUNTS $i" ;;
1192 esac
1193 done
1194 for mnt in $(ls -d $AUFS_MOUNTS | sort | uniq); do
1195 mount --bind $mnt ${base}root$mnt
1196 if [ $mnt == / ] && ! mount -t aufs -o br=${base}rw:/ none ${base}root; then
1197 _ 'Aufs mount failure'
1198 umount ${base}root
1199 rm -rf ${base}r*
1200 return
1201 fi
1202 echo "umount ${base}root$mnt" >> ${base}rw/aufs-umount.sh
1203 done
1204 trap "umount_aufs ${base}" INT
1206 chroot ${base}root $(cd $(dirname $0); pwd)/$(basename $0) "$@"
1207 status=$?
1209 _ 'Leaving aufs chroot...'
1210 umount_aufs $base
1211 # Install package outside the aufs jail
1212 install_package
1213 exit $status
1214 }
1217 # Encode predefined XML entities
1219 xml_ent() {
1220 sed -e 's|&|\&|g; s|<|\<|g; s|>|\>|g; s|"|\"|g' -e "s|'|\'|g"
1221 }
1224 # Create a XML feed for freshly built packages.
1226 gen_rss() {
1227 pubdate=$(date '+%a, %d %b %Y %X')
1228 cat > $FEEDS/$pkg.xml <<EOT
1229 <item>
1230 <title>$PACKAGE $VERSION$EXTRAVERSION</title>
1231 <link>${COOKER_URL}?pkg=${PACKAGE//+/%2B}</link>
1232 <guid>$PACKAGE-$VERSION$EXTRAVERSION</guid>
1233 <pubDate>$pubdate</pubDate>
1234 <description>$(echo -n "$SHORT_DESC" | xml_ent)</description>
1235 </item>
1236 EOT
1237 }
1240 # Truncate stdout log file to $1 Mb.
1242 loglimit() {
1243 if [ -n "$DEFAULT_LOG_LIMIT" ]; then
1244 tee /dev/stderr | head -qc ${1:-$DEFAULT_LOG_LIMIT}m
1245 else
1246 tee /dev/stderr
1247 fi
1248 }
1251 #
1252 # Receipt functions to ease packaging
1253 #
1255 get_dev_files() {
1256 action 'Getting standard devel files...'
1257 mkdir -p $fs/usr/lib
1258 cp -a $install/usr/lib/pkgconfig $fs/usr/lib
1259 cp -a $install/usr/lib/*a $fs/usr/lib
1260 cp -a $install/usr/include $fs/usr
1261 status
1262 }
1265 # Function to use in compile_rules() to copy man page from $src to $install
1267 cook_pick_manpages() {
1268 local name section
1269 action 'Copying man pages...'
1271 for i in $@; do
1272 name=$(echo $i | sed 's|\.[gbx]z2*$||')
1273 section=${name##*/}; section=${section##*.}
1274 mkdir -p $install/usr/share/man/man$section
1275 scopy $i $install/usr/share/man/man$section
1276 done
1277 status
1278 }
1281 # Function to use in genpkg_rules() to copy specified files from $install to $fs
1283 cook_copy_files() {
1284 action 'Copying files...'
1285 cd $install
1286 local i j
1287 IFS=$'\n'
1288 for i in $@; do
1289 for j in $(find . -name $i ! -type d); do
1290 mkdir -p $fs$(dirname ${j#.})
1291 scopy $j $fs$(dirname ${j#.})
1292 done
1293 done
1294 cd - >/dev/null
1295 status
1296 }
1299 # Function to use in genpkg_rules() to copy specified folders from $install to $fs
1301 cook_copy_folders() {
1302 action 'Copying folders...'
1303 cd $install
1304 local i j
1305 IFS=$'\n'
1306 for i in $@; do
1307 for j in $(find . -name $i -type d); do
1308 mkdir -p $fs$(dirname ${j#.})
1309 cp -a $j $fs$(dirname ${j#.})
1310 done
1311 done
1312 cd - >/dev/null
1313 status
1314 }
1317 # Common function to copy files, folders and patterns
1319 copy() {
1320 action 'Copying folders and files...'
1321 local i j filelist=$(mktemp)
1322 IFS=$'\n'
1323 cd $install; find ! -type d | sed 's|\.||' > $filelist
1324 for i in $@; do
1325 case $i in
1326 @std)
1327 # Copy "standard" files (all but "developer files", man pages, documentation, translations)
1328 sed '/\.h$/d; /\.hxx$/d; /\.a$/d; /\.la$/d; /\.pc$/d; /bin\/.*-config$/d;
1329 /\.m4$/d; /\.gir$/d; /\.typelib$/d; /\.vapi$/d; /\.deps$/d; /\.cmake$/d;
1330 /\/Makefile.*/d; /\/include\//d;
1331 /\/share\/man\//d; /\/share\/doc\//d; /\/share\/gtk-doc\//d; /\/share\/info\//d;
1332 /\/share\/devhelp\//d; /\/share\/locale\//d;
1333 /\/share\/bash-completion\//d; /\/lib\/systemd\//d;
1334 ' $filelist
1335 ;;
1336 @dev)
1337 # Copy "developer files"
1338 sed -n '/\.h$/p; /\.hxx$/p; /\.a$/p; /\.la$/p; /\.pc$/p; /bin\/.*-config$/p;
1339 /\.m4$/p; /\.gir$/p; /\.typelib$/p; /\.vapi$/p; /\.deps$/p; /\.cmake$/p;
1340 /\/Makefile.*/p; /\/include\//p;
1341 ' $filelist
1342 ;;
1343 */)
1344 # Copy specified folders.
1345 i="${i%/}"
1346 find -type d -path "*/${i#/}" | sed 's|^.||'
1347 ;;
1348 *)
1349 # Copy specified files.
1350 find ! -type d -path "*/${i#/}" | sed 's|^.||'
1351 ;;
1352 esac | sort -u | \
1353 while read j; do
1354 mkdir -p $fs$(dirname "$j")
1355 if [ -d "$install$j" ]; then
1356 cp -a "$install$j" $fs$(dirname "$j")
1357 else
1358 scopy "$install$j" $fs$(dirname "$j")
1359 fi
1360 done
1361 done
1362 cd - >/dev/null
1363 unset IFS
1364 rm $filelist
1365 status
1366 }
1369 # Remove from current $fs files that already packed (for receipts v2).
1370 # Note: the order in $SPLIT is very important.
1372 remove_already_packed() {
1373 local i j
1374 for i in $taz/*/files.list; do
1375 while read j; do
1376 rm $fs$j
1377 rmdir --parents --ignore-fail-on-non-empty $fs$(dirname $j)
1378 done < $i
1379 done
1380 }
1383 # Function to use in genpkg_rules() to copy hicolor icons in specified sizes
1384 # (default: 16 and 48) from $install to $fs
1386 cook_copy_icons() {
1387 local sizes=$@
1388 action 'Copying hicolor icons...'
1389 mkdir -p $fs/usr/share/icons/hicolor
1390 for i in ${sizes:-16 48}; do
1391 [ ! -e "$install/usr/share/icons/hicolor/${i}x$i" ] ||
1392 scopy $install/usr/share/icons/hicolor/${i}x$i \
1393 $fs/usr/share/icons/hicolor
1394 done
1395 status
1396 }
1399 # Update packages.info every time after successful build
1401 update_packages_info() {
1402 sed -i "/^$PACKAGE\t/d" $PKGS/packages.info
1403 unset_receipt; . $pack/receipt
1404 SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g')
1405 DEPENDS=$(echo $DEPENDS) # remove newlines, tabs and multiple spaces from variable
1406 MD5="$(md5sum "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" | awk '{print $1}')"
1407 cat >> $PKGS/packages.info <<EOT
1408 $PACKAGE $VERSION$EXTRAVERSION $CATEGORY $SHORT_DESC $WEB_SITE $TAGS $SIZES $DEPENDS $MD5 $PROVIDE
1409 EOT
1411 }
1416 #
1417 # Commands
1418 #
1420 case "$1" in
1421 usage|help|-u|-h)
1422 usage ;;
1424 list-wok)
1425 title 'List of %s packages in "%s"' "$ARCH" "$WOK"
1426 cd $WOK
1427 if [ "$ARCH" != 'i486' ]; then
1428 count=0
1429 for pkg in $(fgrep 'HOST_ARCH=' */receipt | egrep "$ARCH|any" | cut -d: -f1)
1430 do
1431 unset HOST_ARCH
1432 . $pkg
1433 count=$(($count + 1))
1434 colorize 34 "$PACKAGE"
1435 done
1436 else
1437 count=$(ls | wc -l)
1438 ls -1
1439 fi
1440 footer "$(_p '%s package' '%s packages' "$count" "$(colorize 32 "$count")")"
1441 ;;
1443 activity)
1444 cat $activity ;;
1446 search)
1447 # Just a simple search function, we dont need more actually.
1448 query="$2"
1449 title 'Search results for "%s"' "$query"
1450 cd $WOK; ls -1 | grep "$query"
1451 footer ;;
1453 setup)
1454 # Setup a build environment
1455 check_root
1456 _ 'Cook: setup environment' | log
1457 title 'Setting up your environment'
1458 [ -d $SLITAZ ] || mkdir -p $SLITAZ
1459 cd $SLITAZ
1460 init_db_files
1461 _ 'Checking for packages to install...'
1462 # Use setup pkgs from cross.conf or cook.conf. When cross compiling
1463 # ARCH-setup or 'cross check' should be used before: cook setup
1464 case "$ARCH" in
1465 arm*|x86_64)
1466 [ -x '/usr/bin/cross' ] || die 'ERROR: %s is not installed' 'cross'
1467 _ 'Using config file: %s' '/etc/slitaz/cross.conf'
1468 . /etc/slitaz/cross.conf ;;
1469 esac
1470 for pkg in $SETUP_PKGS; do
1471 if [ -n "$forced" ]; then
1472 tazpkg -gi $pkg --forced
1473 else
1474 [ ! -d "$INSTALLED/$pkg" ] && tazpkg get-install $pkg
1475 fi
1476 done
1478 # Handle --options
1479 case "$2" in
1480 --wok) hg clone $WOK_URL wok || exit 1 ;;
1481 --stable) hg clone $WOK_URL-stable wok || exit 1 ;;
1482 --undigest) hg clone $WOK_URL-undigest wok || exit 1 ;;
1483 --tiny) hg clone $WOK_URL-tiny wok || exit 1 ;;
1484 esac
1486 # SliTaz group and permissions
1487 if ! grep -q ^slitaz /etc/group; then
1488 _ 'Adding group "%s"' 'slitaz'
1489 addgroup slitaz
1490 fi
1491 _ 'Setting permissions for group "%s"...' 'slitaz'
1492 find $SLITAZ -maxdepth 2 -exec chown root.slitaz {} \;
1493 find $SLITAZ -maxdepth 2 -exec chmod g+w {} \;
1494 footer "$(_ 'All done, ready to cook packages :-)')" ;;
1496 *-setup)
1497 # Setup for cross compiling.
1498 arch="${1%-setup}"
1499 check_root
1500 . /etc/slitaz/cook.conf
1501 for pkg in $CROSS_SETUP; do
1502 if [ -n "$forced" ]; then
1503 tazpkg -gi $pkg --forced
1504 else
1505 [ ! -d "$INSTALLED/$pkg" ] && tazpkg -gi $pkg
1506 fi
1507 done
1509 _ 'Cook: setup %s cross environment' "$arch" | log
1510 title 'Setting up your %s cross environment' "$arch"
1511 init_db_files
1512 sed -i \
1513 -e s"/ARCH=.*/ARCH=\"$arch\"/" \
1514 -e s"/CROSS_TREE=.*/CROSS_TREE=\"\/cross\/$arch\"/" \
1515 -e s'/BUILD_SYSTEM=.*/BUILD_SYSTEM=i486-slitaz-linux/' \
1516 /etc/slitaz/cook.conf
1517 case "$arch" in
1518 arm)
1519 flags='-O2 -march=armv6'
1520 host="$ARCH-slitaz-linux-gnueabi" ;;
1521 armv6hf)
1522 flags='-O2 -march=armv6j -mfpu=vfp -mfloat-abi=hard'
1523 host="$ARCH-slitaz-linux-gnueabi" ;;
1524 armv7)
1525 flags='-Os -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -pipe'
1526 host="$ARCH-slitaz-linux-gnueabi" ;;
1527 x86_64)
1528 flags='-O2 -mtune=generic -pipe'
1529 host="$ARCH-slitaz-linux" ;;
1530 esac
1531 sed -i \
1532 -e s"/CFLAGS=.*/CFLAGS=\"$flags\"/" \
1533 -e s"/HOST_SYSTEM=.*/HOST_SYSTEM=$host/" /etc/slitaz/cook.conf
1534 . /etc/slitaz/cook.conf
1535 sysroot="$CROSS_TREE/sysroot"
1536 tools="/cross/$arch/tools"
1537 root="$sysroot"
1538 # L10n: keep the same width of translations to get a consistent view
1539 _ 'Target arch : %s' "$ARCH"
1540 _ 'Configure args : %s' "$CONFIGURE_ARGS"
1541 _ 'Build flags : %s' "$flags"
1542 _ 'Arch sysroot : %s' "$sysroot"
1543 _ 'Tools prefix : %s' "$tools/bin"
1544 # Tell the packages manager where to find packages.
1545 _ 'Packages DB : %s' "$root$DB"
1546 mkdir -p $root$INSTALLED
1547 cd $root$DB; rm -f *.bak
1548 for list in packages.list packages.desc packages.equiv packages.md5; do
1549 rm -f $list
1550 ln -s $SLITAZ/packages/$list $list
1551 done
1552 # We must have the cross compiled glibc-base installed or default
1553 # i486 package will be used as dep by tazpkg and then break the
1554 # cross environment
1555 if [ ! -f "$root$INSTALLED/glibc-base/receipt" ]; then
1556 colorize 36 $(_ 'WARNING: %s is not installed in sysroot' '(e)glibc-base')
1557 fi
1558 # Show GCC version or warn if not yet compiled.
1559 if [ -x "$tools/bin/$HOST_SYSTEM-gcc" ]; then
1560 _ 'Cross compiler : %s' "$HOST_SYSTEM-gcc"
1561 else
1562 colorize 36 $(_ 'C compiler "%s" is missing' "$HOST_SYSTEM-gcc")
1563 _ 'Run "%s" to cook a toolchain' 'cross compile'
1564 fi
1565 footer ;;
1567 test)
1568 # Test a cook environment.
1569 _ 'Cook test: testing the cook environment' | log
1570 [ ! -d "$WOK" ] && exit 1
1571 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK
1572 cook cooktest ;;
1574 new)
1575 # Create the package folder and an empty receipt.
1576 pkg="$2"
1577 [ -z "$pkg" ] && usage
1578 newline
1579 [ -d "$WOK/$pkg" ] && die 'Package "%s" already exists.' "$pkg"
1581 action 'Creating folder "%s"' "$WOK/$pkg"
1582 mkdir $WOK/$pkg; cd $WOK/$pkg; status
1584 action 'Preparing the package receipt...'
1585 cp $DATA/receipt .
1586 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
1587 status; newline
1589 # Interactive mode, asking and seding.
1590 case "$3" in
1591 --interactive|-x)
1592 _ 'Entering interactive mode...'
1593 separator
1594 _ 'Package : %s' "$pkg"
1596 _n 'Version : ' ; read answer
1597 sed -i s/'VERSION=\"\"'/"VERSION=\"$answer\""/ receipt
1599 _n 'Category : ' ; read answer
1600 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$answer\""/ receipt
1602 # L10n: Short description
1603 _n 'Short desc : ' ; read answer
1604 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$answer\""/ receipt
1606 _n 'Maintainer : ' ; read answer
1607 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$answer\""/ receipt
1609 _n 'License : ' ; read answer
1610 sed -i s/'LICENSE=\"\"'/"LICENSE=\"$answer\""/ receipt
1612 _n 'Web site : ' ; read answer
1613 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$answer\""# receipt
1614 newline
1616 # Wget URL.
1617 _ 'Wget URL to download source tarball.'
1618 _n 'Example : ' ; echo '$GNU_MIRROR/$PACKAGE/$TARBALL'
1619 _n 'Wget url : ' ; read answer
1620 sed -i "s|WGET_URL=.*|WGET_URL=\"$answer\"|" receipt
1622 # Ask for a stuff dir.
1623 confirm "$(_n 'Do you need a stuff directory? (y/N)')"
1624 if [ "$?" -eq 0 ]; then
1625 action 'Creating the stuff directory...'
1626 mkdir $WOK/$pkg/stuff; status
1627 fi
1629 # Ask for a description file.
1630 confirm "$(_n 'Are you going to write a description? (y/N)')"
1631 if [ "$?" -eq 0 ]; then
1632 action 'Creating the "%s" file...' 'description.txt'
1633 touch $WOK/$pkg/description.txt; status
1634 fi
1636 footer "$(_ 'Receipt is ready to use.')" ;;
1637 esac ;;
1639 list)
1640 # Cook a list of packages (better use the Cooker since it will order
1641 # packages before executing cook).
1642 check_root
1643 [ -z "$2" ] && die 'No list in argument.'
1644 [ -f "$2" ] || die 'List "%s" not found.' "$2"
1646 _ 'Starting cooking the list "%s"' "$2" | log
1648 for pkg in $(cat $2); do
1649 cook $pkg || broken
1650 done ;;
1652 clean-wok)
1653 check_root
1654 newline; action 'Cleaning all packages files...'
1655 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
1656 status; newline ;;
1658 clean-src)
1659 check_root
1660 newline; action 'Cleaning all packages sources...'
1661 rm -rf $WOK/*/source
1662 status; newline ;;
1664 uncook)
1665 cd $WOK
1666 count=0
1667 title 'Checking for uncooked packages'
1669 for pkg in *; do
1670 unset HOST_ARCH EXTRAVERSION
1671 [ ! -e $pkg/receipt ] && continue
1672 . $pkg/receipt
1673 # Source cooked pkg receipt to get EXTRAVERSION
1674 if [ -d "$WOK/$pkg/taz" ]; then
1675 cd $WOK/$pkg/taz/$pkg-*
1676 . receipt; cd $WOK
1677 fi
1678 case "$ARCH" in
1679 i486)
1680 debug "$(_ 'Package "%s"' "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg")"
1681 if [ ! -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ]; then
1682 count=$(($count + 1))
1683 colorize 34 "$pkg"
1684 fi ;;
1685 arm*)
1686 # Check only packages included in arch
1687 if echo "$HOST_ARCH" | egrep -q "$ARCH|any"; then
1688 # *.tazpkg
1689 if [ ! -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg" ]; then
1690 count=$(($count + 1))
1691 colorize 34 "$pkg"
1692 fi
1693 fi ;;
1694 esac
1695 done
1697 if [ "$count" -gt 0 ]; then
1698 footer "$(_p '%s uncooked package' '%s uncooked packages' "$count" "$(colorize 31 "$count")")"
1699 else
1700 _ 'All packages are cooked :-)'
1701 newline
1702 fi
1703 ;;
1705 pkgdb)
1706 # Create suitable packages list for TazPkg and only for built packages
1707 # as well as flavors files for TazLiTo. We don't need logs since we do it
1708 # manually to ensure everything is fine before syncing the mirror.
1709 @@PREFIX@@/libexec/cookutils/pkgdb "$2"
1710 ;;
1712 *)
1713 # Just cook and generate a package.
1714 check_root
1715 time=$(date +%s)
1716 pkg="$1"
1717 [ -z "$pkg" ] && usage
1719 lastcooktime=$(sed '/^Cook time/!d; s|.*: *\([0-9]*\)s.*|\1|' \
1720 $LOGS/$pkg.log 2>/dev/null | sed '$!d')
1721 receipt="$WOK/$pkg/receipt"
1722 check_pkg_in_wok
1723 newline
1725 unset inst
1726 unset_receipt
1727 . $receipt
1729 # Handle cross compilation.
1730 case "$ARCH" in
1731 arm*)
1732 if [ -z "$HOST_ARCH" ]; then
1733 _ 'cook: HOST_ARCH is not set in "%s" receipt' "$pkg"
1734 error="$(_ 'package "%s" is not included in %s' "$pkg" "$ARCH")"
1735 _ 'cook: %s' "$error"
1736 [ -n "$CROSS_BUGS" ] && _ 'bugs: %s' "$CROSS_BUGS"
1737 _ 'Cook skip: %s' "$error" | log
1738 newline
1739 broken; exit 1
1740 fi ;;
1741 esac
1743 # Some packages are not included in some arch or fail to cross compile.
1744 : ${HOST_ARCH=i486}
1745 debug "$(_ 'Host arch %s' "$HOST_ARCH")"
1746 # Handle arm{v6hf,v7,..}
1747 if ! $(echo "$HOST_ARCH" | egrep -q "${ARCH%v[0-9]*}|any"); then
1748 _ 'cook: %s' "HOST_ARCH=$HOST_ARCH"
1749 error="$(_ "package \"%s\" doesn't cook or is not included in %s" "$pkg" "$ARCH")"
1750 _ 'cook: %s' "error"
1751 [ -n "$CROSS_BUGS" ] && _ 'bugs: %s' "$CROSS_BUGS"
1752 _ 'Cook skip: %s' "$error" | log
1753 sed -i /^${pkg}$/d $broken
1754 newline
1755 exit 0
1756 fi
1758 # Skip blocked, 3 lines also for the Cooker.
1759 grep -q "^$pkg$" $blocked && [ "$2" != '--unblock' ] &&
1760 die 'Package "%s" is blocked' "$pkg"
1762 try_aufs_chroot "$@"
1764 # Log and source receipt.
1765 _ 'Cook started for: %s' "<a href='cooker.cgi?pkg=${pkg//+/%2B}'>$pkg</a>" | log
1766 echo "cook:$pkg" > $command
1768 [ -n "$lastcooktime" ] && echo "cook:$pkg $lastcooktime $(date +%s)" >> $cooktime
1770 while read cmd duration start; do
1771 [ $(($start + $duration)) -lt $(date +%s) ] &&
1772 echo "sed -i '/^$cmd $duration/d' $cooktime"
1773 done < $cooktime | sh
1775 # Display and log info if cook process stopped.
1776 # FIXME: gettext not working (in single quotes) here!
1777 trap '_ "\n\nCook stopped: control-C\n\n" | \
1778 tee -a $LOGS/$pkg.log' INT
1780 # Handle --options
1781 case "$2" in
1782 --clean|-c)
1783 action 'Cleaning "%s"' "$pkg"
1784 cd $WOK/$pkg; rm -rf install taz source
1785 status; newline
1786 exit 0 ;;
1788 --install|-i)
1789 inst='yes' ;;
1791 --getsrc|-gs)
1792 title 'Getting source for "%s"' "$pkg"
1793 get_source
1794 _ 'Tarball: %s' "$SRC/$TARBALL"; newline
1795 exit 0 ;;
1797 --block|-b)
1798 action 'Blocking package "%s"' "$pkg"
1799 [ $(grep "^$pkg$" $blocked) ] || echo "$pkg" >> $blocked
1800 status; newline
1801 exit 0 ;;
1803 --unblock|-ub)
1804 action 'Unblocking package "%s"' "$pkg"
1805 sed -i "/^${pkg}$/"d $blocked
1806 status; newline
1807 exit 0 ;;
1809 --pack)
1810 [ -d $WOK/$pkg/taz ] || die 'Need to build "%s"' "$pkg"
1811 rm -rf $WOK/$pkg/taz
1812 [ -f $LOGS/$pkg-pack.log ] && rm -rf $LOGS/$pkg-pack.log
1813 packall 2>&1 | tee -a $LOGS/$pkg-pack.log
1814 clean_log
1815 rm -f $command
1816 exit 0 ;;
1818 --cdeps)
1819 @@PREFIX@@/libexec/cookutils/cdeps $pkg
1820 esac
1822 # Rotate log
1823 for i in $(seq 9 -1 1); do
1824 j=$(($i - 1))
1825 [ -e $LOGS/$pkg.log.$j ] && mv -f $LOGS/$pkg.log.$j $LOGS/$pkg.log.$i
1826 done
1827 [ -e $LOGS/$pkg.log ] && mv $LOGS/$pkg.log $LOGS/$pkg.log.0
1829 # Check if wanted is built now so we have separate log files.
1830 for wanted in $WANTED ; do
1831 if grep -q "^$wanted$" $blocked; then
1832 broken
1833 rm -f $command
1834 die 'WANTED package "%s" is blocked' "$wanted"
1835 fi
1836 if grep -q "^$wanted$" $broken; then
1837 broken
1838 rm -f $command
1839 die 'WANTED package "%s" is broken' "$wanted"
1840 fi
1841 if [ ! -d "$WOK/$wanted/install" ]; then
1842 cook "$wanted" || { broken; exit 1; }
1843 fi
1844 done
1846 # Cook and pack or exit on error and log everything.
1847 cookit $@ 2>&1 | loglimit 50 > $LOGS/$pkg.log
1848 remove_deps | tee -a $LOGS/$pkg.log
1849 cookit_quality
1850 packall 2>&1 | loglimit 5 >> $LOGS/$pkg.log
1851 clean_log
1853 # Exit if any error in packing.
1854 lerror=$(_n 'ERROR')
1855 if grep -Ev "(/root/.cvspass|conftest|df: /|rm: can't remove)" $LOGS/$pkg.log | \
1856 grep -Eq "(^$lerror|: No such file or directory|not remade because of errors|ake: \*\*\* .* Error)"; then
1857 debug_info | tee -a $LOGS/$pkg.log
1858 sed -i '$ s|$| [ Failed ]|' $activity
1859 rm -f $command
1860 broken; exit 1
1861 fi
1863 # Create an XML feed
1864 gen_rss
1866 # Time and summary
1867 time=$(($(date +%s) - $time))
1868 summary | tee -a $LOGS/$pkg.log
1869 newline
1871 # We may want to install/update (outside aufs jail!).
1872 [ -s /aufs-umount.sh ] || install_package
1874 sed -i '$ s|$| [ Done ]|' $activity
1876 # Finally we DON'T WANT to build the *-dev or packages with WANTED="$pkg"
1877 # If you want automation, use the Cooker Build Bot.
1878 rm -f $command
1879 ;;
1880 esac
1882 exit 0