cookutils view cook @ rev 912
cook: remake copy_generic_files()/copy_generic_stuff() logic; change build dep installation (AUTO_COOK isn't work now) with tazpkg cookmode; improve mk_pkg_receipt(), copy(); update 'cook package --pack'; add docs about copy(); lighttpd/index.cgi: summary on unpackaged files; tiny edits on lighttpd/cooker.css and modules/compressor.
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Mon Jun 05 15:59:11 2017 +0300 (2017-06-05) |
parents | e68dad1ffbff |
children | 1e4e278b2285 |
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 $PACKAGE $SPLIT; 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" ] &&
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 unset_receipt
839 . "$orig_receipt"
840 PACKAGE="$save_PACKAGE"; DEPENDS="$save_DEPENDS"; PROVIDE="$save_PROVIDE"
841 SUGGESTED="$save_SUGGESTED"; TAZPANEL_DAEMON="$save_TAZPANEL_DAEMON"
843 # Manage split packages
844 SPLIT=" $SPLIT "
845 if [ "$SPLIT" != ' ' -a "${SPLIT/ $PACKAGE /}" != "$SPLIT" ]; then
846 # For packages with empty $DEPENDS
847 if [ -z "$DEPENDS" ]; then
848 case $PACKAGE in
849 *-dev)
850 # main package and all the split packages but this *-dev itself
851 DEPENDS=$(echo "$pkg $SPLIT " | sed "s| $PACKAGE | |; s| *$||") ;;
852 *)
853 # main package
854 DEPENDS="$pkg" ;;
855 esac
856 fi
858 # Default $CAT
859 [ -z "$CAT" ] &&
860 case $PACKAGE in
861 *-dev) CAT="development|development files" ;;
862 esac
864 # Manage two-in-one $CAT="$CATEGORY|$SHORT_DESC_ADDITION"
865 CATEGORY="${CAT%|*}"
866 SHORT_DESC="$SHORT_DESC (${CAT#*|})"
867 fi
869 # Mandatory variables
870 cat <<EOF
871 $signature
873 PACKAGE="$PACKAGE"
874 VERSION="$VERSION"
875 CATEGORY="$CATEGORY"
876 SHORT_DESC="$SHORT_DESC"
877 MAINTAINER="$MAINTAINER"
878 LICENSE="$LICENSE"
879 WEB_SITE="$WEB_SITE"
880 EOF
882 # Optional variables
883 [ -n "$TAGS" ] && echo "TAGS=\"$TAGS\"" | tr -ds '\t' ' '
884 [ -n "${DEPENDS# }" ] && echo "DEPENDS=\"$DEPENDS\"" | tr -ds '\t' ' '
885 [ -n "$PROVIDE" ] && echo "PROVIDE=\"$PROVIDE\"" | tr -ds '\t' ' '
886 [ -n "$CONFIG_FILES" ] && echo "CONFIG_FILES=\"$CONFIG_FILES\"" | tr -ds '\t' ' '
887 [ -n "$DATABASE_FILES" ] && echo "DATABASE_FILES=\"$DATABASE_FILES\""
888 [ -n "$TAZPANEL_DAEMON" ] && echo "TAZPANEL_DAEMON=\"$TAZPANEL_DAEMON\""
890 # Extract {pre,post}_{install,remove} functions;
891 # post_install() will be copied for both main and all the split packages
892 # post_install_gtk_() will be copied as post_install() for gtk+ package only
893 #
894 # restricted name (gtk+ -> gtk_; acl-dev -> acl_dev)
895 rname=$(echo -n $PACKAGE | tr -c 'a-zA-Z0-9' '_')
896 for i in pre post; do
897 for j in install remove; do
898 sed "/^${i}_${j}()/,/^}/!d" "$orig_receipt"
899 sed "/^${i}_${j}_$rname()/,/^}/!d" "$orig_receipt" | \
900 sed "s|^${i}_${j}_$rname()|${i}_${j}()|"
901 done
902 done
903 }
906 # Create the package. Wanted to use TazPkg to create a tazpkg package at first,
907 # but it doesn't handle EXTRAVERSION.
909 packit() {
910 set_paths "$1"
911 PACKAGE="${1:-$PACKAGE}"
913 # Handle cross compilation
914 case "$ARCH" in
915 arm*|x86_64) arch="-$ARCH" ;;
916 esac
918 title 'Pack: %s' "$PACKAGE $VERSION$arch"
920 if grep -q ^genpkg_rules $receipt; then
921 _ 'Executing: %s' 'genpkg_rules'
922 set -e; cd $pkgdir; mkdir -p $fs
923 genpkg_rules || (newline; _ 'ERROR: genpkg_rules failed'; newline) >> \
924 $LOGS/$pkg.log
925 else
926 _ 'No packages rules: meta package'
927 mkdir -p $fs
928 fi
930 # Check CONFIG_FILES
931 if [ -n "$CONFIG_FILES" ]; then
932 unset IFS
933 for i in $CONFIG_FILES; do
934 if [ ! -e $fs$i ]; then
935 case $i in
936 */) mkdir -p $fs$i ;;
937 *) mkdir -p $fs$(dirname $i); touch $fs$i ;;
938 esac
939 fi
940 done
941 fi
943 # First QA check to stop now if genpkg_rules failed.
944 lerror=$(_n 'ERROR')
945 if fgrep -q ^$lerror $LOGS/$pkg.log; then
946 broken; exit 1
947 fi
949 cd $taz
950 action 'Copying "%s"...' 'receipt'
951 mk_pkg_receipt ../receipt > $pack/receipt
952 chown 0.0 $pack/receipt; status
954 unset desc
955 [ "$pkg" == "$PACKAGE" -a -f "../description.txt" ] && desc="../description.txt"
956 [ -f "../description.$PACKAGE.txt" ] && desc="../description.$PACKAGE.txt"
957 if [ -n "$desc" ]; then
958 action 'Copying "%s"...' "$(basename "$desc")"
959 cp -f $desc $pack/description.txt; chown 0.0 $pack/description.txt; status
960 fi
962 copy_generic_files
964 # Strip and stuff files.
965 export COOKOPTS ARCH HOST_SYSTEM LOCALE fs; @@PREFIX@@/libexec/cookutils/compressor fs
967 # Create files.list with redirecting find output.
968 action 'Creating the list of files...'
969 cd $fs
970 find . -type f -print > ../files.list
971 find . -type l -print >> ../files.list
972 cd ..; sed -i s/'^.'/''/ files.list
973 status
975 # Md5sum of files.
976 action 'Creating md5sum of files...'
977 while read file; do
978 [ -L "fs$file" ] && continue
979 [ -f "fs$file" ] || continue
980 case "$file" in
981 /lib/modules/*/modules.*|*.pyc) continue ;;
982 esac
983 md5sum "fs$file" | sed 's/ fs/ /'
984 done < files.list > md5sum
985 status
987 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
988 2>/dev/null | awk 'END{ print $1 }')
990 # Build cpio archive.
991 action 'Compressing the FS...'
992 find fs -newer $receipt -exec touch -hr $receipt '{}' \;
993 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
994 mv fs ../
995 status
997 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list md5sum description.txt \
998 2>/dev/null | awk 'END{ print $1 }')
1000 action 'Updating receipt sizes...'
1001 sed -i s/^PACKED_SIZE.*$// receipt
1002 sed -i s/^UNPACKED_SIZE.*$// receipt
1003 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
1004 status
1006 # Set extra version.
1007 if [ -n "$EXTRAVERSION" ]; then
1008 action 'Updating receipt EXTRAVERSION: %s' "$EXTRAVERSION"
1009 sed -i s/^EXTRAVERSION.*$// receipt
1010 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
1011 status
1012 fi
1014 # Compress.
1015 action 'Creating full cpio archive...'
1016 find . -newer $receipt -exec touch -hr $receipt '{}' \;
1017 find . | cpio -o -H newc --quiet > ../$PACKAGE-$VERSION$EXTRAVERSION$arch.tazpkg
1018 status
1020 action 'Restoring original package tree...'
1021 mv ../fs .
1022 status
1024 rm fs.cpio.lzma; cd ..
1026 # QA and give info.
1027 tazpkg=$(ls *.tazpkg)
1028 packit_quality
1029 footer "$(_ 'Package "%s" created' "$tazpkg")"
1030 update_packages_info
1031 }
1034 # Verify package quality and consistency.
1036 packit_quality() {
1037 #action 'QA: checking for broken link...'
1038 #link=$(find $fs/usr -type l -follow)
1039 #[ "$link" ] && echo -e "\nERROR: broken link in filesystem"
1040 #status
1042 # Exit if any error found in log file.
1043 lerror=$(_n 'ERROR')
1044 if fgrep -q ^$lerror $LOGS/$pkg.log; then
1045 rm -f $command
1046 broken; exit 1
1047 fi
1049 action 'QA: checking for empty package...'
1050 files=$(cat $WOK/$pkg/taz/$PACKAGE-$VERSION/files.list | wc -l)
1051 if [ "$files" -eq 0 -a "$CATEGORY" != 'meta' ]; then
1052 broken
1053 rm -f $command
1054 die 'ERROR: empty package'
1055 fi
1057 :; status
1058 # Find and remove old package(s)
1059 tempd="$(mktemp -d)"; cd "$tempd"
1060 for testpkg in $(ls $PKGS/$PACKAGE-*.tazpkg 2>/dev/null); do
1061 # Extract receipt from each matched package
1062 cpio -F "$testpkg" -i receipt >/dev/null 2>&1
1063 name=$(. receipt; echo $PACKAGE)
1064 rm receipt
1065 if [ "$name" == "$PACKAGE" ]; then
1066 action 'Removing old package "%s"' "$(basename "$testpkg")"
1067 rm -f "$testpkg"
1068 status
1069 fi
1070 done
1071 rm -r "$tempd"
1072 mv -f $pkgdir/taz/$PACKAGE-$VERSION.tazpkg $PKGS
1073 sed -i /^${pkg}$/d $broken
1074 #action 'Removing source tree...'
1075 #rm -f $WOK/$pkg/source; status
1076 }
1079 # v2: pack all packages using compiled files
1081 packall() {
1082 set_paths
1083 if head -n1 "$pkgdir/receipt" | fgrep -q 'v2'; then
1084 for i in $PACKAGE $SPLIT; do
1085 unset TAGS DEPENDS CAT CONFIG_FILES PROVIDE DATABASE_FILES TAZPANEL_DAEMON
1086 packit $i
1087 done
1088 else
1089 packit
1090 fi
1091 }
1094 # Reverse "cat" command: prints input lines in the reverse order
1096 tac() {
1097 sed '1!G;h;$!d' $1
1098 }
1101 # Update chroot with freshly rebuilt package: keep env up-to-date.
1103 update_chroot() {
1104 for i in $pkg $SPLIT; do
1105 if [ -d "$root$INSTALLED/$i" ]; then
1106 . /etc/slitaz/cook.conf
1107 . $WOK/$pkg/taz/$i-$VERSION/receipt
1108 _ 'Updating %s chroot environment...' "$ARCH"
1109 _ 'Updating chroot: %s' "$i ($VERSION$EXTRAVERSION$arch)" | log
1110 cd $PKGS
1111 tazpkg install $i-$VERSION$EXTRAVERSION$arch.tazpkg --forced --root=$root
1112 fi
1113 done
1114 }
1117 # Install package on --inst or update the chroot.
1119 install_package() {
1120 case "$ARCH" in
1121 arm*|x86_64)
1122 arch="-$ARCH"
1123 root="$CROSS_TREE/sysroot" ;;
1124 esac
1125 # Install package if requested but skip install if target host doesn't
1126 # match build system or it will break the build chroot.
1127 build=$(echo $BUILD_SYSTEM | cut -d- -f1)
1128 if [ -n "$inst" -a "$build" == "$ARCH" ]; then
1129 if [ -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ]; then
1130 cd $PKGS
1131 tazpkg install $PACKAGE-$VERSION$EXTRAVERSION.tazpkg --forced
1132 else
1133 broken
1134 die 'Unable to install package, build has failed.'
1135 fi
1136 fi
1138 update_chroot
1139 }
1142 # remove chroot jail
1144 umount_aufs() {
1145 tac ${1}rw/aufs-umount.sh | sh
1146 rm -rf ${1}rw
1147 umount ${1}root
1148 rmdir ${1}r*
1149 }
1152 # Launch the cook command into a chroot jail protected by aufs.
1153 # The current filesystems are used read-only and updates are
1154 # stored in a separate branch.
1156 try_aufs_chroot() {
1158 base="/dev/shm/aufsmnt$$"
1160 # Can we setup the chroot? Is it already done?
1161 grep -q ^AUFS_NOT_SUPPORTED $receipt && return
1162 grep -q ^AUFS_NOT_RAMFS $receipt && base="/mnt/aufsmnt$$"
1163 [ -n "$AUFS_MOUNTS" -a ! -f /aufs-umount.sh ] || return
1164 grep -q ^aufs /proc/modules || modprobe aufs 2> /dev/null || return
1165 mkdir ${base}root ${base}rw || return
1167 _ 'Setup aufs chroot...'
1169 # Sanity check
1170 for i in / /proc /sys /dev/shm /home ; do
1171 case " $AUFS_MOUNTS " in
1172 *\ $i\ *) ;;
1173 *) AUFS_MOUNTS="$AUFS_MOUNTS $i" ;;
1174 esac
1175 done
1176 for mnt in $(ls -d $AUFS_MOUNTS | sort | uniq); do
1177 mount --bind $mnt ${base}root$mnt
1178 if [ $mnt == / ] && ! mount -t aufs -o br=${base}rw:/ none ${base}root; then
1179 _ 'Aufs mount failure'
1180 umount ${base}root
1181 rm -rf ${base}r*
1182 return
1183 fi
1184 echo "umount ${base}root$mnt" >> ${base}rw/aufs-umount.sh
1185 done
1186 trap "umount_aufs ${base}" INT
1188 chroot ${base}root $(cd $(dirname $0); pwd)/$(basename $0) "$@"
1189 status=$?
1191 _ 'Leaving aufs chroot...'
1192 umount_aufs $base
1193 # Install package outside the aufs jail
1194 install_package
1195 exit $status
1196 }
1199 # Encode predefined XML entities
1201 xml_ent() {
1202 sed -e 's|&|\&|g; s|<|\<|g; s|>|\>|g; s|"|\"|g' -e "s|'|\'|g"
1203 }
1206 # Create a XML feed for freshly built packages.
1208 gen_rss() {
1209 pubdate=$(date '+%a, %d %b %Y %X')
1210 cat > $FEEDS/$pkg.xml <<EOT
1211 <item>
1212 <title>$PACKAGE $VERSION$EXTRAVERSION</title>
1213 <link>${COOKER_URL}?pkg=${PACKAGE//+/%2B}</link>
1214 <guid>$PACKAGE-$VERSION$EXTRAVERSION</guid>
1215 <pubDate>$pubdate</pubDate>
1216 <description>$(echo -n "$SHORT_DESC" | xml_ent)</description>
1217 </item>
1218 EOT
1219 }
1222 # Truncate stdout log file to $1 Mb.
1224 loglimit() {
1225 if [ -n "$DEFAULT_LOG_LIMIT" ]; then
1226 tee /dev/stderr | head -qc ${1:-$DEFAULT_LOG_LIMIT}m
1227 else
1228 tee /dev/stderr
1229 fi
1230 }
1233 #
1234 # Receipt functions to ease packaging
1235 #
1237 get_dev_files() {
1238 action 'Getting standard devel files...'
1239 mkdir -p $fs/usr/lib
1240 cp -a $install/usr/lib/pkgconfig $fs/usr/lib
1241 cp -a $install/usr/lib/*a $fs/usr/lib
1242 cp -a $install/usr/include $fs/usr
1243 status
1244 }
1247 # Function to use in compile_rules() to copy man page from $src to $install
1249 cook_pick_manpages() {
1250 local name section
1251 action 'Copying man pages...'
1253 for i in $@; do
1254 name=$(echo $i | sed 's|\.[gbx]z2*$||')
1255 section=${name##*/}; section=${section##*.}
1256 mkdir -p $install/usr/share/man/man$section
1257 scopy $i $install/usr/share/man/man$section
1258 done
1259 status
1260 }
1263 # Function to use in genpkg_rules() to copy specified files from $install to $fs
1265 cook_copy_files() {
1266 action 'Copying files...'
1267 cd $install
1268 local i j
1269 IFS=$'\n'
1270 for i in $@; do
1271 for j in $(find . -name $i ! -type d); do
1272 mkdir -p $fs$(dirname ${j#.})
1273 scopy $j $fs$(dirname ${j#.})
1274 done
1275 done
1276 cd - >/dev/null
1277 status
1278 }
1281 # Function to use in genpkg_rules() to copy specified folders from $install to $fs
1283 cook_copy_folders() {
1284 action 'Copying folders...'
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 cp -a $j $fs$(dirname ${j#.})
1292 done
1293 done
1294 cd - >/dev/null
1295 status
1296 }
1299 # Common function to copy files, folders and patterns
1301 copy() {
1302 action 'Copying folders and files...'
1303 local i j filelist=$(mktemp)
1304 IFS=$'\n'
1305 cd $install; find ! -type d | sed 's|\.||' > $filelist
1306 for i in $@; do
1307 case $i in
1308 @std)
1309 # Copy "standard" files (all but "developer files", man pages, documentation, translations)
1310 sed '/\.h$/d; /\.hxx$/d; /\.a$/d; /\.la$/d; /\.pc$/d; /bin\/.*-config$/d;
1311 /\.m4$/d; /\.gir$/d; /\.typelib$/d; /\.vapi$/d; /\.deps$/d; /\.cmake$/d;
1312 /\/include\//d;
1313 /\/share\/man\//d; /\/share\/doc\//d; /\/share\/gtk-doc\//d; /\/share\/info\//d;
1314 /\/share\/devhelp\//d; /\/share\/locale\//d;
1315 /\/share\/bash-completion\//d; /\/lib\/systemd\//d;
1316 ' $filelist
1317 ;;
1318 @dev)
1319 # Copy "developer files"
1320 sed -n '/\.h$/p; /\.hxx$/p; /\.a$/p; /\.la$/p; /\.pc$/p; /bin\/.*-config$/p;
1321 /\.m4$/p; /\.gir$/p; /\.typelib$/p; /\.vapi$/p; /\.deps$/p; /\.cmake$/p;
1322 /\/include\//p;
1323 ' $filelist
1324 ;;
1325 */)
1326 # Copy specified folders.
1327 i="${i%/}"
1328 find -type d -path "*/${i#/}" | sed 's|^.||'
1329 ;;
1330 *)
1331 # Copy specified files.
1332 find ! -type d -path "*/${i#/}" | sed 's|^.||'
1333 ;;
1334 esac | sort -u | \
1335 while read j; do
1336 mkdir -p $fs$(dirname "$j")
1337 if [ -d "$install$j" ]; then
1338 cp -a "$install$j" $fs$(dirname "$j")
1339 else
1340 scopy "$install$j" $fs$(dirname "$j")
1341 fi
1342 done
1343 done
1344 cd - >/dev/null
1345 unset IFS
1346 rm $filelist
1347 status
1348 }
1351 # Function to use in genpkg_rules() to copy hicolor icons in specified sizes
1352 # (default: 16 and 48) from $install to $fs
1354 cook_copy_icons() {
1355 local sizes=$@
1356 action 'Copying hicolor icons...'
1357 mkdir -p $fs/usr/share/icons/hicolor
1358 for i in ${sizes:-16 48}; do
1359 [ ! -e "$install/usr/share/icons/hicolor/${i}x$i" ] ||
1360 scopy $install/usr/share/icons/hicolor/${i}x$i \
1361 $fs/usr/share/icons/hicolor
1362 done
1363 status
1364 }
1367 # Update packages.info every time after successful build
1369 update_packages_info() {
1370 sed -i "/^$PACKAGE\t/d" $PKGS/packages.info
1371 unset_receipt; . $pack/receipt
1372 SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g')
1373 DEPENDS=$(echo $DEPENDS) # remove newlines, tabs and multiple spaces from variable
1374 MD5="$(md5sum "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" | awk '{print $1}')"
1375 cat >> $PKGS/packages.info <<EOT
1376 $PACKAGE $VERSION$EXTRAVERSION $CATEGORY $SHORT_DESC $WEB_SITE $TAGS $SIZES $DEPENDS $MD5 $PROVIDE
1377 EOT
1379 }
1384 #
1385 # Commands
1386 #
1388 case "$1" in
1389 usage|help|-u|-h)
1390 usage ;;
1392 list-wok)
1393 title 'List of %s packages in "%s"' "$ARCH" "$WOK"
1394 cd $WOK
1395 if [ "$ARCH" != 'i486' ]; then
1396 count=0
1397 for pkg in $(fgrep 'HOST_ARCH=' */receipt | egrep "$ARCH|any" | cut -d: -f1)
1398 do
1399 unset HOST_ARCH
1400 . $pkg
1401 count=$(($count + 1))
1402 colorize 34 "$PACKAGE"
1403 done
1404 else
1405 count=$(ls | wc -l)
1406 ls -1
1407 fi
1408 footer "$(_p '%s package' '%s packages' "$count" "$(colorize 32 "$count")")"
1409 ;;
1411 activity)
1412 cat $activity ;;
1414 search)
1415 # Just a simple search function, we dont need more actually.
1416 query="$2"
1417 title 'Search results for "%s"' "$query"
1418 cd $WOK; ls -1 | grep "$query"
1419 footer ;;
1421 setup)
1422 # Setup a build environment
1423 check_root
1424 _ 'Cook: setup environment' | log
1425 title 'Setting up your environment'
1426 [ -d $SLITAZ ] || mkdir -p $SLITAZ
1427 cd $SLITAZ
1428 init_db_files
1429 _ 'Checking for packages to install...'
1430 # Use setup pkgs from cross.conf or cook.conf. When cross compiling
1431 # ARCH-setup or 'cross check' should be used before: cook setup
1432 case "$ARCH" in
1433 arm*|x86_64)
1434 [ -x '/usr/bin/cross' ] || die 'ERROR: %s is not installed' 'cross'
1435 _ 'Using config file: %s' '/etc/slitaz/cross.conf'
1436 . /etc/slitaz/cross.conf ;;
1437 esac
1438 for pkg in $SETUP_PKGS; do
1439 if [ -n "$forced" ]; then
1440 tazpkg -gi $pkg --forced
1441 else
1442 [ ! -d "$INSTALLED/$pkg" ] && tazpkg get-install $pkg
1443 fi
1444 done
1446 # Handle --options
1447 case "$2" in
1448 --wok) hg clone $WOK_URL wok || exit 1 ;;
1449 --stable) hg clone $WOK_URL-stable wok || exit 1 ;;
1450 --undigest) hg clone $WOK_URL-undigest wok || exit 1 ;;
1451 --tiny) hg clone $WOK_URL-tiny wok || exit 1 ;;
1452 esac
1454 # SliTaz group and permissions
1455 if ! grep -q ^slitaz /etc/group; then
1456 _ 'Adding group "%s"' 'slitaz'
1457 addgroup slitaz
1458 fi
1459 _ 'Setting permissions for group "%s"...' 'slitaz'
1460 find $SLITAZ -maxdepth 2 -exec chown root.slitaz {} \;
1461 find $SLITAZ -maxdepth 2 -exec chmod g+w {} \;
1462 footer "$(_ 'All done, ready to cook packages :-)')" ;;
1464 *-setup)
1465 # Setup for cross compiling.
1466 arch="${1%-setup}"
1467 check_root
1468 . /etc/slitaz/cook.conf
1469 for pkg in $CROSS_SETUP; do
1470 if [ -n "$forced" ]; then
1471 tazpkg -gi $pkg --forced
1472 else
1473 [ ! -d "$INSTALLED/$pkg" ] && tazpkg -gi $pkg
1474 fi
1475 done
1477 _ 'Cook: setup %s cross environment' "$arch" | log
1478 title 'Setting up your %s cross environment' "$arch"
1479 init_db_files
1480 sed -i \
1481 -e s"/ARCH=.*/ARCH=\"$arch\"/" \
1482 -e s"/CROSS_TREE=.*/CROSS_TREE=\"\/cross\/$arch\"/" \
1483 -e s'/BUILD_SYSTEM=.*/BUILD_SYSTEM=i486-slitaz-linux/' \
1484 /etc/slitaz/cook.conf
1485 case "$arch" in
1486 arm)
1487 flags='-O2 -march=armv6'
1488 host="$ARCH-slitaz-linux-gnueabi" ;;
1489 armv6hf)
1490 flags='-O2 -march=armv6j -mfpu=vfp -mfloat-abi=hard'
1491 host="$ARCH-slitaz-linux-gnueabi" ;;
1492 armv7)
1493 flags='-Os -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -pipe'
1494 host="$ARCH-slitaz-linux-gnueabi" ;;
1495 x86_64)
1496 flags='-O2 -mtune=generic -pipe'
1497 host="$ARCH-slitaz-linux" ;;
1498 esac
1499 sed -i \
1500 -e s"/CFLAGS=.*/CFLAGS=\"$flags\"/" \
1501 -e s"/HOST_SYSTEM=.*/HOST_SYSTEM=$host/" /etc/slitaz/cook.conf
1502 . /etc/slitaz/cook.conf
1503 sysroot="$CROSS_TREE/sysroot"
1504 tools="/cross/$arch/tools"
1505 root="$sysroot"
1506 # L10n: keep the same width of translations to get a consistent view
1507 _ 'Target arch : %s' "$ARCH"
1508 _ 'Configure args : %s' "$CONFIGURE_ARGS"
1509 _ 'Build flags : %s' "$flags"
1510 _ 'Arch sysroot : %s' "$sysroot"
1511 _ 'Tools prefix : %s' "$tools/bin"
1512 # Tell the packages manager where to find packages.
1513 _ 'Packages DB : %s' "$root$DB"
1514 mkdir -p $root$INSTALLED
1515 cd $root$DB; rm -f *.bak
1516 for list in packages.list packages.desc packages.equiv packages.md5; do
1517 rm -f $list
1518 ln -s $SLITAZ/packages/$list $list
1519 done
1520 # We must have the cross compiled glibc-base installed or default
1521 # i486 package will be used as dep by tazpkg and then break the
1522 # cross environment
1523 if [ ! -f "$root$INSTALLED/glibc-base/receipt" ]; then
1524 colorize 36 $(_ 'WARNING: %s is not installed in sysroot' '(e)glibc-base')
1525 fi
1526 # Show GCC version or warn if not yet compiled.
1527 if [ -x "$tools/bin/$HOST_SYSTEM-gcc" ]; then
1528 _ 'Cross compiler : %s' "$HOST_SYSTEM-gcc"
1529 else
1530 colorize 36 $(_ 'C compiler "%s" is missing' "$HOST_SYSTEM-gcc")
1531 _ 'Run "%s" to cook a toolchain' 'cross compile'
1532 fi
1533 footer ;;
1535 test)
1536 # Test a cook environment.
1537 _ 'Cook test: testing the cook environment' | log
1538 [ ! -d "$WOK" ] && exit 1
1539 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK
1540 cook cooktest ;;
1542 new)
1543 # Create the package folder and an empty receipt.
1544 pkg="$2"
1545 [ -z "$pkg" ] && usage
1546 newline
1547 [ -d "$WOK/$pkg" ] && die 'Package "%s" already exists.' "$pkg"
1549 action 'Creating folder "%s"' "$WOK/$pkg"
1550 mkdir $WOK/$pkg; cd $WOK/$pkg; status
1552 action 'Preparing the package receipt...'
1553 cp $DATA/receipt .
1554 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
1555 status; newline
1557 # Interactive mode, asking and seding.
1558 case "$3" in
1559 --interactive|-x)
1560 _ 'Entering interactive mode...'
1561 separator
1562 _ 'Package : %s' "$pkg"
1564 _n 'Version : ' ; read answer
1565 sed -i s/'VERSION=\"\"'/"VERSION=\"$answer\""/ receipt
1567 _n 'Category : ' ; read answer
1568 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$answer\""/ receipt
1570 # L10n: Short description
1571 _n 'Short desc : ' ; read answer
1572 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$answer\""/ receipt
1574 _n 'Maintainer : ' ; read answer
1575 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$answer\""/ receipt
1577 _n 'License : ' ; read answer
1578 sed -i s/'LICENSE=\"\"'/"LICENSE=\"$answer\""/ receipt
1580 _n 'Web site : ' ; read answer
1581 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$answer\""# receipt
1582 newline
1584 # Wget URL.
1585 _ 'Wget URL to download source tarball.'
1586 _n 'Example : ' ; echo '$GNU_MIRROR/$PACKAGE/$TARBALL'
1587 _n 'Wget url : ' ; read answer
1588 sed -i "s|WGET_URL=.*|WGET_URL=\"$answer\"|" receipt
1590 # Ask for a stuff dir.
1591 confirm "$(_n 'Do you need a stuff directory? (y/N)')"
1592 if [ "$?" -eq 0 ]; then
1593 action 'Creating the stuff directory...'
1594 mkdir $WOK/$pkg/stuff; status
1595 fi
1597 # Ask for a description file.
1598 confirm "$(_n 'Are you going to write a description? (y/N)')"
1599 if [ "$?" -eq 0 ]; then
1600 action 'Creating the "%s" file...' 'description.txt'
1601 touch $WOK/$pkg/description.txt; status
1602 fi
1604 footer "$(_ 'Receipt is ready to use.')" ;;
1605 esac ;;
1607 list)
1608 # Cook a list of packages (better use the Cooker since it will order
1609 # packages before executing cook).
1610 check_root
1611 [ -z "$2" ] && die 'No list in argument.'
1612 [ -f "$2" ] || die 'List "%s" not found.' "$2"
1614 _ 'Starting cooking the list "%s"' "$2" | log
1616 for pkg in $(cat $2); do
1617 cook $pkg || broken
1618 done ;;
1620 clean-wok)
1621 check_root
1622 newline; action 'Cleaning all packages files...'
1623 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
1624 status; newline ;;
1626 clean-src)
1627 check_root
1628 newline; action 'Cleaning all packages sources...'
1629 rm -rf $WOK/*/source
1630 status; newline ;;
1632 uncook)
1633 cd $WOK
1634 count=0
1635 title 'Checking for uncooked packages'
1637 for pkg in *; do
1638 unset HOST_ARCH EXTRAVERSION
1639 [ ! -e $pkg/receipt ] && continue
1640 . $pkg/receipt
1641 # Source cooked pkg receipt to get EXTRAVERSION
1642 if [ -d "$WOK/$pkg/taz" ]; then
1643 cd $WOK/$pkg/taz/$pkg-*
1644 . receipt; cd $WOK
1645 fi
1646 case "$ARCH" in
1647 i486)
1648 debug "$(_ 'Package "%s"' "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg")"
1649 if [ ! -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ]; then
1650 count=$(($count + 1))
1651 colorize 34 "$pkg"
1652 fi ;;
1653 arm*)
1654 # Check only packages included in arch
1655 if echo "$HOST_ARCH" | egrep -q "$ARCH|any"; then
1656 # *.tazpkg
1657 if [ ! -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg" ]; then
1658 count=$(($count + 1))
1659 colorize 34 "$pkg"
1660 fi
1661 fi ;;
1662 esac
1663 done
1665 if [ "$count" -gt 0 ]; then
1666 footer "$(_p '%s uncooked package' '%s uncooked packages' "$count" "$(colorize 31 "$count")")"
1667 else
1668 _ 'All packages are cooked :-)'
1669 newline
1670 fi
1671 ;;
1673 pkgdb)
1674 # Create suitable packages list for TazPkg and only for built packages
1675 # as well as flavors files for TazLiTo. We don't need logs since we do it
1676 # manually to ensure everything is fine before syncing the mirror.
1677 @@PREFIX@@/libexec/cookutils/pkgdb "$2"
1678 ;;
1680 *)
1681 # Just cook and generate a package.
1682 check_root
1683 time=$(date +%s)
1684 pkg="$1"
1685 [ -z "$pkg" ] && usage
1687 lastcooktime=$(sed '/^Cook time/!d; s|.*: *\([0-9]*\)s.*|\1|' \
1688 $LOGS/$pkg.log 2>/dev/null | sed '$!d')
1689 receipt="$WOK/$pkg/receipt"
1690 check_pkg_in_wok
1691 newline
1693 unset inst
1694 unset_receipt
1695 . $receipt
1697 # Handle cross compilation.
1698 case "$ARCH" in
1699 arm*)
1700 if [ -z "$HOST_ARCH" ]; then
1701 _ 'cook: HOST_ARCH is not set in "%s" receipt' "$pkg"
1702 error="$(_ 'package "%s" is not included in %s' "$pkg" "$ARCH")"
1703 _ 'cook: %s' "$error"
1704 [ -n "$CROSS_BUGS" ] && _ 'bugs: %s' "$CROSS_BUGS"
1705 _ 'Cook skip: %s' "$error" | log
1706 newline
1707 broken; exit 1
1708 fi ;;
1709 esac
1711 # Some packages are not included in some arch or fail to cross compile.
1712 : ${HOST_ARCH=i486}
1713 debug "$(_ 'Host arch %s' "$HOST_ARCH")"
1714 # Handle arm{v6hf,v7,..}
1715 if ! $(echo "$HOST_ARCH" | egrep -q "${ARCH%v[0-9]*}|any"); then
1716 _ 'cook: %s' "HOST_ARCH=$HOST_ARCH"
1717 error="$(_ "package \"%s\" doesn't cook or is not included in %s" "$pkg" "$ARCH")"
1718 _ 'cook: %s' "error"
1719 [ -n "$CROSS_BUGS" ] && _ 'bugs: %s' "$CROSS_BUGS"
1720 _ 'Cook skip: %s' "$error" | log
1721 sed -i /^${pkg}$/d $broken
1722 newline
1723 exit 0
1724 fi
1726 # Skip blocked, 3 lines also for the Cooker.
1727 grep -q "^$pkg$" $blocked && [ "$2" != '--unblock' ] &&
1728 die 'Package "%s" is blocked' "$pkg"
1730 try_aufs_chroot "$@"
1732 # Log and source receipt.
1733 _ 'Cook started for: %s' "<a href='cooker.cgi?pkg=${pkg//+/%2B}'>$pkg</a>" | log
1734 echo "cook:$pkg" > $command
1736 [ -n "$lastcooktime" ] && echo "cook:$pkg $lastcooktime $(date +%s)" >> $cooktime
1738 while read cmd duration start; do
1739 [ $(($start + $duration)) -lt $(date +%s) ] &&
1740 echo "sed -i '/^$cmd $duration/d' $cooktime"
1741 done < $cooktime | sh
1743 # Display and log info if cook process stopped.
1744 # FIXME: gettext not working (in single quotes) here!
1745 trap '_ "\n\nCook stopped: control-C\n\n" | \
1746 tee -a $LOGS/$pkg.log' INT
1748 # Handle --options
1749 case "$2" in
1750 --clean|-c)
1751 action 'Cleaning "%s"' "$pkg"
1752 cd $WOK/$pkg; rm -rf install taz source
1753 status; newline
1754 exit 0 ;;
1756 --install|-i)
1757 inst='yes' ;;
1759 --getsrc|-gs)
1760 title 'Getting source for "%s"' "$pkg"
1761 get_source
1762 _ 'Tarball: %s' "$SRC/$TARBALL"; newline
1763 exit 0 ;;
1765 --block|-b)
1766 action 'Blocking package "%s"' "$pkg"
1767 [ $(grep "^$pkg$" $blocked) ] || echo "$pkg" >> $blocked
1768 status; newline
1769 exit 0 ;;
1771 --unblock|-ub)
1772 action 'Unblocking package "%s"' "$pkg"
1773 sed -i "/^${pkg}$/"d $blocked
1774 status; newline
1775 exit 0 ;;
1777 --pack)
1778 [ -d $WOK/$pkg/taz ] || die 'Need to build "%s"' "$pkg"
1779 rm -rf $WOK/$pkg/taz
1780 [ -f $LOGS/$pkg-pack.log ] && rm -rf $LOGS/$pkg-pack.log
1781 packall 2>&1 | tee -a $LOGS/$pkg-pack.log
1782 clean_log
1783 rm -f $command
1784 exit 0 ;;
1786 --cdeps)
1787 @@PREFIX@@/libexec/cookutils/cdeps $pkg
1788 esac
1790 # Rotate log
1791 for i in $(seq 9 -1 1); do
1792 j=$(($i - 1))
1793 [ -e $LOGS/$pkg.log.$j ] && mv -f $LOGS/$pkg.log.$j $LOGS/$pkg.log.$i
1794 done
1795 [ -e $LOGS/$pkg.log ] && mv $LOGS/$pkg.log $LOGS/$pkg.log.0
1797 # Check if wanted is built now so we have separate log files.
1798 for wanted in $WANTED ; do
1799 if grep -q "^$wanted$" $blocked; then
1800 broken
1801 rm -f $command
1802 die 'WANTED package "%s" is blocked' "$wanted"
1803 fi
1804 if grep -q "^$wanted$" $broken; then
1805 broken
1806 rm -f $command
1807 die 'WANTED package "%s" is broken' "$wanted"
1808 fi
1809 if [ ! -d "$WOK/$wanted/install" ]; then
1810 cook "$wanted" || { broken; exit 1; }
1811 fi
1812 done
1814 # Cook and pack or exit on error and log everything.
1815 cookit $@ 2>&1 | loglimit 50 > $LOGS/$pkg.log
1816 remove_deps | tee -a $LOGS/$pkg.log
1817 cookit_quality
1818 packall 2>&1 | loglimit 5 >> $LOGS/$pkg.log
1819 clean_log
1821 # Exit if any error in packing.
1822 lerror=$(_n 'ERROR')
1823 if grep -Ev "(/root/.cvspass|conftest|df: /|rm: can't remove)" $LOGS/$pkg.log | \
1824 grep -Eq "(^$lerror|: No such file or directory|not remade because of errors|ake: \*\*\* .* Error)"; then
1825 debug_info | tee -a $LOGS/$pkg.log
1826 sed -i '$ s|$| [ Failed ]|' $activity
1827 rm -f $command
1828 broken; exit 1
1829 fi
1831 # Create an XML feed
1832 gen_rss
1834 # Time and summary
1835 time=$(($(date +%s) - $time))
1836 summary | tee -a $LOGS/$pkg.log
1837 newline
1839 # We may want to install/update (outside aufs jail!).
1840 [ -s /aufs-umount.sh ] || install_package
1842 sed -i '$ s|$| [ Done ]|' $activity
1844 # Finally we DON'T WANT to build the *-dev or packages with WANTED="$pkg"
1845 # If you want automation, use the Cooker Build Bot.
1846 rm -f $command
1847 ;;
1848 esac
1850 exit 0