cookutils view cook @ rev 1115

cook: add cook_perl()
author Aleksej Bobylev <al.bobylev@gmail.com>
date Tue Dec 11 23:15:30 2018 +0200 (2018-12-11)
parents 77291d41f21a
children f77e48e58ac0
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
14 prev_ts="/home/slitaz/cache/prev_ts"; touch $prev_ts
17 # Internationalization.
19 export TEXTDOMAIN='cook'
22 #
23 # Functions
24 #
26 usage() {
27 cat <<EOT
29 $(boldify "$(_ 'Usage:')") $(_ 'cook [package|command] [list|--option]')
31 $(boldify "$(_ 'Commands:')")
32 usage|help $(_ 'Display this short usage.')
33 setup $(_ 'Setup your build environment.')
34 *-setup $(_ 'Setup a cross environment.')
35 * = {arm|armv6hf|armv7|x86_64}
36 test $(_ 'Test environment and cook a package.')
37 list-wok $(_ 'List packages in the wok.')
38 search $(_ 'Simple packages search function.')
39 new $(_ 'Create a new package with a receipt.')
40 list $(_ 'Cook a list of packages.')
41 clean-wok $(_ 'Clean-up all packages files.')
42 clean-src $(_ 'Clean-up all packages sources.')
43 uncook $(_ 'Check for uncooked packages')
44 pkgdb $(_ 'Create packages DB lists and flavors.')
46 $(boldify "$(_ 'Options:')")
47 cook <pkg>
48 --clean -c $(_ 'clean the package in the wok.')
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.')
66 cook splitdb $(_ 'create up-to-date split.db file.')
68 EOT
69 exit 0
70 }
73 # We don't want these escapes in web interface.
75 clean_log() {
76 sed -i -e 's|\[70G\[ \[1;32m| |' \
77 -e 's|\[0;39m \]||' $LOGS/${1:-$pkg}.log
78 }
81 # Be sure package exists in wok.
83 check_pkg_in_wok() {
84 [ -d "$WOK/$pkg" ] || die 'Unable to find package "%s" in the wok' "$pkg"
85 }
88 # Find the package, return the receipt name where it was found
89 # for example, libpcreposix -> pcre
91 find_pkg_in_wok() {
92 awk -F$'\t' -vi=" $1 " '{
93 if (index(" " $2 " ", i)) {print $1; exit}
94 }' $cache/split.db
95 }
98 # Initialize files used in $CACHE
100 init_db_files() {
101 _ 'Creating directories structure in "%s"' "$SLITAZ"
102 mkdir -p $WOK $PKGS $SRC $CACHE $LOGS $FEEDS
103 _ 'Creating DB files in "%s"' "$CACHE"
104 touch $activity $command $broken $blocked $CACHE/webstat
105 chown www:www $cache/webstat
106 }
109 # Paths used in receipt and by cook itself.
111 set_paths() {
112 # Kernel version is set from wok/linux or installed/linux-api-headers(wok-undigest)
113 if [ -f "$WOK/linux/receipt" ]; then
114 kvers=$(. $WOK/linux/receipt; echo $VERSION)
115 kbasevers=$(echo $kvers | cut -d. -f1,2)
116 elif [ -f "$INSTALLED/linux-api-headers/receipt" ]; then
117 kvers=$(. $INSTALLED/linux-api-headers/receipt; echo $VERSION)
118 kbasevers=$(echo $kvers | cut -d. -f1,2)
119 fi
121 # Python version
122 [ -f "$WOK/python/receipt" ] && pyvers=$(. $WOK/python/receipt; echo $VERSION)
123 # Perl version for some packages needed it
124 [ -f "$WOK/perl/receipt" ] && perlvers=$(. $WOK/perl/receipt; echo $VERSION)
126 pkgdir="$WOK/$pkg"
127 . "$pkgdir/receipt"
128 basesrc="$pkgdir/source"
129 tmpsrc="$basesrc/tmp"
130 src="$basesrc/$PACKAGE-$VERSION"
131 taz="$pkgdir/taz"
132 pack="$taz/${1:-$PACKAGE}-$VERSION$EXTRAVERSION" # v2: multiple taz/* folders
133 fs="$pack/fs"
134 stuff="$pkgdir/stuff"
135 install="$pkgdir/install"
137 pkgsrc="${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}"
138 lzma_tarball="$pkgsrc.tar.lzma"
140 [ -n "$PATCH" -a -z "$PTARBALL" ] && PTARBALL="$(basename $PATCH)"
142 if [ -n "$WANTED" ]; then
143 basesrc="$WOK/$WANTED/source"
144 src="$basesrc/$WANTED-$VERSION"
145 install="$WOK/$WANTED/install"
146 wanted_stuff="$WOK/$WANTED/stuff"
147 fi
149 [ -n "$SOURCE" ] && source_stuff="$WOK/$SOURCE/stuff"
151 # Old way compatibility.
152 _pkg="$install"
153 }
156 # Create source tarball when URL is a SCM.
158 create_tarball() {
159 local tarball
160 tarball="$pkgsrc.tar.bz2"
161 [ -n "$LZMA_SRC" ] && tarball="$lzma_tarball"
162 _ 'Creating tarball "%s"' "$tarball"
163 if [ -n "$LZMA_SRC" ]; then
164 tar -c $pkgsrc | lzma e $SRC/$tarball -si $LZMA_SET_DIR || exit 1
165 LZMA_SRC=''
166 else
167 tar -cjf $tarball $pkgsrc || exit 1
168 mv $tarball $SRC; rm -rf $pkgsrc
169 fi
170 TARBALL="$tarball"
171 }
174 # Get package source. For SCM we are in cache so clone here and create a
175 # tarball here.
177 get_source() {
178 local url
179 url=${WGET_URL#*|}
180 set_paths
181 pwd=$(pwd)
182 case "$WGET_URL" in
183 http://*|ftp://*|https://*)
184 url="$MIRROR_URL/sources/packages/${TARBALL:0:1}/$TARBALL"
185 wget -T 60 -c -O $SRC/$TARBALL $WGET_URL ||
186 wget -T 60 -c -O $SRC/$TARBALL $url ||
187 die 'ERROR: %s' "wget $WGET_URL"
188 ;;
190 hg*|mercurial*)
191 _ 'Getting source from %s...' 'Hg'
192 _ 'URL: %s' "$url"
193 _ 'Cloning to "%s"' "$pwd/$pkgsrc"
194 if [ -n "$BRANCH" ]; then
195 _ 'Hg branch: %s' "$BRANCH"
196 hg clone $url --rev $BRANCH $pkgsrc ||
197 die 'ERROR: %s' "hg clone $url --rev $BRANCH"
198 else
199 hg clone $url $pkgsrc || die 'ERROR: %s' "hg clone $url"
200 fi
201 rm -rf $pkgsrc/.hg
202 create_tarball
203 ;;
205 git*)
206 _ 'Getting source from %s...' 'Git'
207 _ 'URL: %s' "$url"
208 cd $SRC
209 git clone $url $pkgsrc || die 'ERROR: %s' "git clone $url"
210 if [ -n "$BRANCH" ]; then
211 _ 'Git branch: %s' "$BRANCH"
212 cd $pkgsrc; git checkout $BRANCH; cd ..
213 fi
214 cd $SRC
215 create_tarball
216 ;;
218 cvs*)
219 mod=$PACKAGE
220 [ -n "$CVS_MODULE" ] && mod=$CVS_MODULE
221 _ 'Getting source from %s...' 'CVS'
222 _ 'URL: %s' "$url"
223 [ -n "$CVS_MODULE" ] && _ 'CVS module: %s' "$mod"
224 _ 'Cloning to "%s"' "$pwd/$mod"
225 cvs -d:$url co $mod && mv $mod $pkgsrc
226 create_tarball
227 ;;
229 svn*|subversion*)
230 _ 'Getting source from %s...' 'SVN'
231 _ 'URL: %s' "$url"
232 if [ -n "$BRANCH" ]; then
233 echo t | svn co $url -r $BRANCH $pkgsrc
234 else
235 echo t | svn co $url $pkgsrc
236 fi
237 create_tarball
238 ;;
240 bzr*)
241 _ 'Getting source from %s...' 'bazaar'
242 cd $SRC
243 pkgsrc=${url#*:}
244 if [ -n "$BRANCH" ]; then
245 echo "bzr -Ossl.cert_reqs=none branch $url -r $BRANCH"
246 bzr -Ossl.cert_reqs=none branch $url -r $BRANCH
247 else
248 echo "bzr -Ossl.cert_reqs=none branch $url"
249 bzr -Ossl.cert_reqs=none branch $url
250 cd $pkgsrc; BRANCH=$(bzr revno); cd ..
251 _ "Don't forget to add to receipt:"
252 echo -e "BRANCH=\"$BRANCH\"\n"
253 fi
254 mv $pkgsrc $pkgsrc-$BRANCH
255 pkgsrc="$pkgsrc-$BRANCH"
256 create_tarball
257 ;;
259 *)
260 broken; die 'ERROR: Unable to handle "%s"' "$WGET_URL"
261 ;;
262 esac
263 }
266 # Extract source package.
268 extract_source() {
269 if [ ! -s "$SRC/$TARBALL" ]; then
270 local url
271 url="$MIRROR_URL/sources/packages"
272 url="$url/${TARBALL:0:1}/$TARBALL"
273 _ 'Getting source from %s...' 'mirror'
274 _ 'URL: %s' "$url"
275 busybox wget -c -P $SRC $url || _ 'ERROR: %s' "wget $url"
276 fi
277 _ 'Extracting source archive "%s"' "$TARBALL"
278 case "$TARBALL" in
279 *.tar.gz|*.tgz) tar -xzf $SRC/$TARBALL 2>/dev/null ;;
280 *.tar.bz2|*.tbz|*.tbz2) tar -xjf $SRC/$TARBALL 2>/dev/null ;;
281 *.tar.lzma) tar -xaf $SRC/$TARBALL ;;
282 *.tar.lz|*.tlz) lzip -d < $SRC/$TARBALL | tar -xf - 2>/dev/null ;;
283 *.tar) tar -xf $SRC/$TARBALL ;;
284 *.zip|*.xpi) unzip -o $SRC/$TARBALL 2>/dev/null >&2;;
285 *.xz) unxz -c $SRC/$TARBALL | tar -xf - || \
286 tar -xf $SRC/$TARBALL 2>/dev/null;;
287 *.7z) 7zr x $SRC/$TARBALL 2>/dev/null >&2 ;;
288 *.Z|*.z) uncompress -c $SRC/$TARBALL | tar -xf - ;;
289 *.rpm) rpm2cpio $SRC/$TARBALL | cpio -idm --quiet ;;
290 *.run) /bin/sh $SRC/$TARBALL $RUN_OPTS ;;
291 *) cp $SRC/$TARBALL $(pwd) ;;
292 esac
293 }
296 # Display time.
298 disp_time_old() {
299 local sec div min
300 sec="$1"
301 div=$(( ($1 + 30) / 60))
302 case $div in
303 0) min='';;
304 # L10n: 'm' is for minutes (approximate cooking time)
305 *) min=$(_n ' ~ %dm' "$div");;
306 esac
308 # L10n: 's' is for seconds (cooking time)
309 _ '%ds%s' "$sec" "$min"
310 }
313 # Display time.
315 disp_time() {
316 local sec="$1" day hour min out=''
318 day=$(( sec / 86400 )); sec=$(( sec % 86400 ))
319 hour=$(( sec / 3600 )); sec=$(( sec % 3600 ))
320 min=$(( sec / 60 )); sec=$(( sec % 60 ))
322 [ $day -gt 0 ] && out="${day}d "
323 [ -n "$out" -o $hour -gt 0 ] && out="$out$(printf '%02dh ' $hour)"
324 [ -n "$out" -o $min -gt 0 ] && out="$out$(printf '%02dm ' $min)"
325 [ -n "$out" ] && out=" ~ $out$(printf '%02ds' $sec)"
327 echo "${1}s$out"
328 }
331 # Display cooked package summary.
333 summary() {
334 # local arch=''
335 # case "$ARCH" in
336 # arm*|x86_64) arch="-$ARCH" ;;
337 # esac
339 set_paths
340 cd $WOK/$pkg
341 [ -d $WOK/$pkg/install ] && prod=$(du -sh $WOK/$pkg/install | awk '{print $1}' 2>/dev/null)
342 [ -d $WOK/$pkg/source ] && srcdir=$(du -sh $WOK/$pkg/source | awk '{print $1}' 2>/dev/null)
343 [ -n "$TARBALL" ] && srcsize=$(du -sh $SRC/$TARBALL | awk '{print $1}')
345 title 'Summary for: %s' "$PACKAGE $VERSION$EXTRAVERSION"
347 # L10n: keep the same width of translations to get a consistent view
348 [ -n "$TARBALL" ] && _ 'Src file : %s' "$TARBALL"
349 [ -n "$srcsize" ] && _ 'Src size : %s' "$srcsize"
350 [ -n "$srcdir" ] && _ 'Source dir : %s' "$srcdir"
351 [ -n "$prod" ] && _ 'Produced : %s' "$prod"
352 _ 'Cook time : %s' "$(disp_time "$time")"
353 _ 'Cook date : %s' "$(date "$(_ '+%%F %%R')")"
354 _ 'Target arch : %s' "$(cut -d$'\t' -f2 $pkgdir/.arch | sort -u | tr '\n' ' ' | sed 's| $||; s| |, |g')"
356 separator -
357 _ ' # : Packed : Compressed : Files : Package name'
358 separator -
359 pkgi=1
360 for i in $(all_names); do
361 version=$(awk -F$'\t' -vpkg="$i" '{
362 if ($1 == pkg) {print $2; exit}
363 }' "$PKGS/packages-$ARCH.info")
364 fs=$(du -sh $WOK/$pkg/taz/$i-$VERSION$EXTRAVERSION | awk '{print $1}')
365 arch=$(awk -F$'\t' -vi="$i" '{if ($1 == i) print $2}' $pkgdir/.arch)
366 pkgname="$i-$version-$arch.tazpkg"
367 size=$(ls -lh $PKGS/$pkgname | awk '{print $5}')
368 files=$(wc -l < $WOK/$pkg/taz/$i-$VERSION$EXTRAVERSION/files.list)
369 printf "%2d : %7s : %10s : %5s : %s\n" "$pkgi" "$fs" "$size" "$files" "$pkgname"
370 pkgi=$((pkgi + 1))
371 done
372 separator
373 }
376 # Display debugging error info.
378 debug_info() {
379 title 'Debug information %s.' "$1"
380 # L10n: specify your format of date and time (to help: man date)
381 # L10n: not bad one is '+%x %R'
382 _ 'Cook date: %s' "$(date "$(_ '+%%F %%R')")"
383 if [ -n "$time" ]; then
384 times="$(($(date +%s) - $time))"
385 _ 'Wasted time : %s' "$(disp_time "$times")"
386 fi
387 for error in \
388 ERROR 'No package' "cp: can't" "can't open" "can't cd" \
389 'error:' 'fatal error:' 'undefined reference to' \
390 'Unable to connect to' 'link: cannot find the library' \
391 'CMake Error' ': No such file or directory' \
392 'Could not read symbols: File in wrong format'
393 do
394 # format "line number:line content"
395 fgrep -n "$error" $LOGS/$pkg.log
396 done > $LOGS/$pkg.log.debug_info 2>&1
397 # sort by line number, remove duplicates
398 sort -gk1,1 -t: -u $LOGS/$pkg.log.debug_info
399 rm -f $LOGS/$pkg.log.debug_info
400 footer
401 }
404 # A bit smarter function than the classic `cp` command
406 scopy() {
407 if [ "$(stat -c %h -- "$1")" -eq 1 ]; then
408 cp -a "$1" "$2" # copy generic files
409 else
410 cp -al "$1" "$2" # copy hardlinks
411 fi
412 }
415 # Copy all generic files (locale, pixmaps, .desktop) from $install to $fs.
416 # We use standard paths, so some packages need to copy these files with the
417 # receipt and genpkg_rules.
418 # This function executes inside the packaging process, before compressor call.
420 copy_generic_files() {
421 # Proceed only for "main" package (for v2), and for any packages (v1)
422 [ "$pkg" == "$PACKAGE" ] || return 0
424 # $LOCALE is set in cook.conf
425 if [ -n "$LOCALE" -a -z "$WANTED" ]; then
426 if [ -d "$install/usr/share/locale" ]; then
427 mkdir -p "$fs/usr/share/locale"
428 for i in $LOCALE; do
429 if [ -d "$install/usr/share/locale/$i" ]; then
430 cp -r $install/usr/share/locale/$i $fs/usr/share/locale
431 fi
432 done
433 fi
434 fi
436 # Generic pixmaps copy can be disabled with COOKOPTS="!pixmaps" (or GENERIC_PIXMAPS="no")
437 if [ "${COOKOPTS/!pixmaps/}" == "$COOKOPTS" -a "$GENERIC_PIXMAPS" != 'no' ]; then
438 if [ -d "$install/usr/share/pixmaps" ]; then
439 mkdir -p "$fs/usr/share/pixmaps"
440 for i in png xpm; do
441 [ -f "$install/usr/share/pixmaps/$PACKAGE.$i" -a ! -f "$fs/usr/share/pixmaps/$PACKAGE.$i" ] &&
442 cp -r $install/usr/share/pixmaps/$PACKAGE.$i $fs/usr/share/pixmaps
443 done
444 fi
445 fi
447 # Desktop entry (.desktop).
448 # Generic desktop entry copy can be disabled with COOKOPTS="!menus" (or GENERIC_MENUS="no")
449 if [ "${COOKOPTS/!menus/}" == "$COOKOPTS" -a "$GENERIC_MENUS" != 'no' ]; then
450 if [ -d "$install/usr/share/applications" -a -z "$WANTED" ]; then
451 mkdir -p "$fs/usr/share"
452 cp -r $install/usr/share/applications $fs/usr/share
453 fi
454 fi
455 }
458 # Copy pixmaps, desktop files and licenses from $stuff to $install.
459 # This function executes after the main compile_rules() is done.
461 copy_generic_stuff() {
462 # Custom or homemade PNG pixmap can be in stuff.
463 if [ -f "$stuff/$PACKAGE.png" ]; then
464 mkdir -p $install/usr/share/pixmaps
465 cp $stuff/$PACKAGE.png $install/usr/share/pixmaps
466 fi
468 # Homemade desktop file(s) can be in stuff.
469 if [ -d "$stuff/applications" ]; then
470 mkdir -p $install/usr/share
471 cp -r $stuff/applications $install/usr/share
472 fi
473 if [ -f "$stuff/$PACKAGE.desktop" ]; then
474 mkdir -p $install/usr/share/applications
475 cp $stuff/$PACKAGE.desktop $install/usr/share/applications
476 fi
478 # Add custom licenses
479 if [ -d "$stuff/licenses" ]; then
480 mkdir -p $install/usr/share/licenses
481 cp -r $stuff/licenses $install/usr/share/licenses/$PACKAGE
482 fi
483 }
486 # Update installed.cook.diff
488 update_installed_cook_diff() {
489 # If a cook failed deps are removed.
490 cd $root$INSTALLED; ls -1 > $CACHE/installed.cook
491 cd $CACHE
492 [ "$1" == 'force' -o ! -s '/tmp/installed.cook.diff' ] && \
493 busybox diff installed.list installed.cook > /tmp/installed.cook.diff
494 deps=$(grep ^+[a-zA-Z0-9] /tmp/installed.cook.diff | wc -l)
495 }
498 # Remove installed deps.
500 remove_deps() {
501 # Now remove installed build deps.
502 diff='/tmp/installed.cook.diff'
503 [ -s "$diff" ] || return
505 deps=$(grep ^+[a-zA-Z0-9] $diff | sed 's|^+||')
506 nb=$(grep ^+[a-zA-Z0-9] $diff | wc -l)
507 newline
508 _n 'Build dependencies to remove:'; echo " $nb"
509 [ -n "$root" ] && echo "root=\"$root\""
511 _n 'Removing:'
512 for dep in $deps; do
513 echo -n " $dep"
514 # Do not waste time uninstalling the packages if we are inside
515 # aufs chroot - unmounting chroot will "uninstall" all packages.
516 [ -s /aufs-umount.sh ] ||
517 echo 'y' | tazpkg remove $dep --root=$root >/dev/null
518 done
520 newline; newline
521 # Keep the last diff for debug and info.
522 mv -f $diff $CACHE/installed.diff
523 }
526 # Automatically patch the sources.
528 patchit() {
529 [ -f "$stuff/patches/series" ] || return
531 local done="$pkgdir/.patch.done"
532 IFS=$'\n'
533 while read i; do
534 patchname=$(echo ${i%%#*} | cut -d' ' -f1) # allow comments (anything after the # or space)
535 case $patchname in # allow patch options in form <options_no_spaces>|<file_name>
536 *\|*) patchopts="${patchname%|*}"; patchname="${patchname#*|}";;
537 *) patchopts='-Np1';;
538 esac
539 [ -n "$patchname" ] || continue # allow empty lines
540 touch $done
541 grep -q "^${patchname}$" $done && continue # already applied (useful with `cook --continue`)
542 newline
543 _ 'Applying patch %s' "$patchname"
544 patch $patchopts -i $stuff/patches/$patchname | sed 's|^| |'
545 echo $patchname >> $done
546 done < $stuff/patches/series
547 newline
548 unset IFS
549 }
552 # Check source tarball integrity.
554 check_integrity() {
555 for i in sha1 sha3 sha256 sha512 md5; do
556 I=$(echo $i | tr 'a-z' 'A-Z')
557 eval sum=\$TARBALL_$I
558 if [ -n "$sum" ]; then
559 newline
560 _ 'Checking %ssum of source tarball...' "$i"
561 echo "$sum $SRC/$TARBALL" | ${i}sum -c || exit 1
562 fi
563 done
564 newline
565 }
568 # Misc fix functions
570 fix() {
571 case $1 in
572 # https://bugzilla.gnome.org/show_bug.cgi?id=655517
573 # https://wiki.gentoo.org/wiki/Project:Quality_Assurance/As-needed
574 ld)
575 export LDFLAGS="$LDFLAGS -Wl,-Os,--as-needed"
576 ;;
577 libtool)
578 if [ -e 'libtool' ]; then
579 sed -i 's| -shared | -Wl,-Os,--as-needed\0|g' libtool
580 echo "fix.libtool" >> $pkgdir/.patch.done
581 else
582 echo "fix libtool: warning: libtool absent, nothing to fix."
583 fi
584 ;;
585 math)
586 # fix C++ math issue introduced in Glibc 2.26:
587 # error: '__builtin_isnan' is not a member of 'std'
588 # if (std::isnan(N)) {
589 # ^
590 find $src -type f -exec sed -i '
591 s|std::signbit|__builtin_signbit|g;
592 s|std::isnan|__builtin_isnan|g;
593 s|std::isinf|__builtin_isinf_sign|g;
594 s|std::isfinite|__builtin_isfinite|g;
595 s|std::isnormal|__builtin_isnormal|g
596 ' '{}' \;
597 ;;
598 symlinks)
599 # make absolute symlinks relative
600 echo "fix symlinks"
601 local ifs="$IFS" link target
602 IFS=$'\n'
603 # step 1: fast job, prefix all the absolute symlinks with "$install"
604 for link in $(find $install -type l); do
605 target="$(readlink $link)"
606 case "$target" in
607 /*) ln -sfv "$install$target" "$link";;
608 esac
609 done
610 IFS="$ifs"
611 # step 2: fine tuning, make symlinks relative
612 tazpkg -gi --quiet --local --cookmode symlinks
613 symlinks -cr $install
614 ;;
615 gem)
616 # some useful operations while Ruby gems cooking
617 _gems="$(ruby -e'puts Gem.default_dir')"
619 # remove unwanted empty folders
620 rmdir --ignore-fail-on-non-empty \
621 $install/$_gems/build_info/ \
622 $install/$_gems/cache/ \
623 $install/$_gems/doc/ \
624 $install/$_gems/extensions/
626 # move files to docdir
627 docdir=$install/usr/share/doc/$PACKAGE-$VERSION
628 for i in $(ls -ap $install/$_gems/gems/${PACKAGE#*-}-$VERSION/ | sed '
629 /\/$/d; /^\./d; /gemspec$/d; /Rakefile*/d; /Gemfile*/d; /Makefile/d;
630 /\.c$/d; /\.h$/d; /\.o$/d; /\.rb$/d; /\.so$/d; /\.yml$/d;
631 /Manifest/d; /\.inc$/d; /depend/d;
632 '); do
633 mkdir -p $docdir # docdir will not be created when nothing to move
634 mv $install/$_gems/gems/${PACKAGE#*-}-$VERSION/$i $docdir
635 done
636 if [ -d $install/$_gems/gems/${PACKAGE#*-}-$VERSION/doc/ ]; then
637 mkdir -p $docdir
638 mv $install/$_gems/gems/${PACKAGE#*-}-$VERSION/doc/ $docdir
639 fi
641 if [ -d $docdir ]; then
642 # move man pages
643 unset man_to_copy
644 for i in $(seq 1 8); do
645 for j in $(find $docdir -type f -name "*.$i" | sed '/LGPL-2\.1/d'); do
646 man_to_copy="$man_to_copy $j"
647 done
648 done
649 if [ -n "$man_to_copy" ]; then
650 cook_pick_manpages $man_to_copy
651 rm $man_to_copy
652 fi
654 # convert rdoc to markdown (thanks https://gist.github.com/teeparham/8a99e308884e1c32735a)
655 for i in $(find $docdir -type f -name '*.rdoc'); do
656 fix utf-8
657 LC_ALL=en_US.UTF-8 ruby -r rdoc -e 'puts RDoc::Markup::ToMarkdown.new.convert File.read(ARGV[0] || "'$i'")' >$i.md && rm $i || rm $i.md
658 done
659 fi
661 # move man pages (from the different place)
662 rubyman=$install/$_gems/gems/${PACKAGE#*-}-$VERSION/man
663 if [ -d $rubyman ]; then
664 unset man_to_copy
665 for i in $(seq 1 8); do
666 for j in $(find $rubyman -type f -name "*.$i" | sed '/LGPL-2\.1/d'); do
667 man_to_copy="$man_to_copy $j"
668 done
669 done
670 if [ -n "$man_to_copy" ]; then
671 cook_pick_manpages $man_to_copy
672 fi
673 rm -r $rubyman
674 fi
675 ;;
676 utf-8)
677 # Install UTF-8 locale
678 tazpkg -gi --quiet --local --cookmode locale-en-base
679 mkdir -p /usr/lib/locale
680 localedef -i 'en_US' -c -f 'UTF-8' /usr/lib/locale/en_US.UTF-8
681 ;;
682 esac
683 }
686 # Typical function used in compile_rules() to make perl modules packages
688 cook_perl() {
689 if [ -e "Makefile.PL" ]; then
690 # Up to 3 optional parameters supported
691 PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor $1 &&
692 make $2 &&
693 make $3 PERL_MM_USE_DEFAULT=1 DESTDIR=$install install &&
694 chmod -R u+w $install
695 elif [ -e "Build.PL" ]; then
696 echo "Not implemented yet"
697 return 1
698 else
699 echo "Unable to cook Perl module"
700 return 1
701 fi
702 }
705 # Store timestamps, log jobs length
707 timestamp() {
708 local ts_file="$WOK/$pkg/.ts"
709 local curr_ts=$(date '+%s')
710 case $1 in
711 init)
712 rm $ts_file 2>/dev/null
713 echo $curr_ts > $prev_ts
714 ;;
715 job*)
716 # calculate time from the last timestamp
717 echo "$1='$(( $curr_ts - $(cat $prev_ts) ))'" >> $ts_file
718 echo $curr_ts > $prev_ts
719 ;;
720 sets)
721 echo "sets='$2'" >> $ts_file
722 ;;
723 esac
724 }
727 # Store time statsistics to the cache
729 store_timestats() {
730 # see doc/timestats.txt for file format
731 temp=$(mktemp)
732 {
733 for i in $(seq 1 30); do echo "job$i=0"; done
734 cat $WOK/$pkg/.ts
735 echo -n 'total=$(( 0'
736 for i in $(seq 1 30); do echo -n " + job$i"; done
737 echo ' ))'
738 } > $temp
739 . $temp
740 {
741 echo -n "$pkg $sets "
742 for i in $(seq 1 30); do echo -n "$((job$i)) "; done
743 echo "$total"
744 } >> /home/slitaz/cache/timestats
745 rm $temp $WOK/$pkg/.ts # clean
746 }
749 # Internal function to cook specified SET
751 cook_set() {
752 # Switch to the specified source set
753 set_paths
754 local suffix=''
755 [ -n "$SET" ] && suffix="-$SET"
756 export src="$WOK/$pkg/source/$PACKAGE-$VERSION$suffix"
757 export install="$WOK/$pkg/install$suffix"
758 export DESTDIR="$install"
760 if [ -n "$SETS" ]; then
761 if [ -n "$SET" ]; then
762 title "Switching to the set '$SET'"
763 else
764 title "Switching to the default set"
765 fi
766 echo "src : $src"
767 echo "install: $install"
768 fi
769 [ -d "$src" ] && cd $src # packages without sources exists
770 echo
772 [ -d "$install" ] && rm -r $install
773 #mkdir -p $install
775 compile_rules $@ || { broken; exit 1; }
777 # Stay compatible with _pkg
778 [ -d "$src/_pkg" ] && mv $src/_pkg $install
780 copy_generic_stuff
782 timestamp job$job_counter # compiling (set '$SET')
784 # Actions to do after compiling the package
785 # Skip all for split packages (already done in main package)
786 if [ -z "$WANTED" ]; then
787 footer
788 export COOKOPTS ARCH install
789 @@PREFIX@@/libexec/cookutils/compressor install
790 timestamp job$(($job_counter + 1)) # compressing (set '$SET')
791 fi
793 # Activate "instant-pack" mode
794 if [ "${COOKOPTS/instant-pack/}" != "$COOKOPTS" ]; then
795 echo " $SPLIT " | fgrep -q " $PACKAGE " || SPLIT="$PACKAGE $SPLIT"
796 export PACKAGE
797 # determine the list of the packages belongs to the current SET...
798 echo -n $SPLIT \
799 | awk -vset="$SET" '
800 BEGIN { RS = " "; FS = ":"; }
801 { if ($2 == set) print $1; }' \
802 | xargs -n1 @@PREFIX@@/libexec/cookutils/pack # ... and then pack them
803 fi
805 job_counter=$(($job_counter + 2))
806 }
809 # The main cook function.
811 cookit() {
812 if [ -n "$SETUP_MD5" -a "$SETUP_MD5" != "$(ls $root$INSTALLED | md5sum | cut -c1-32)" ]; then
813 _ 'ERROR: Broken setup. Abort.'
814 return
815 fi
817 title 'Cook: %s' "$PACKAGE $VERSION"
818 set_paths
819 timestamp init # the very start
821 # Handle cross-tools.
822 [ "$BUILD_SYSTEM" != "$HOST_SYSTEM" ] &&
823 case "$ARCH" in
824 arm*|x86_64)
825 # CROSS_COMPILE is used by at least Busybox and the kernel to set
826 # the cross-tools prefix. Sysroot is the root of our target arch
827 sysroot="$CROSS_TREE/sysroot"
828 tools="$CROSS_TREE/tools"
829 # Set root path when cross compiling. ARM tested but not x86_64
830 # When cross compiling we must install build deps in $sysroot.
831 arch="-$ARCH"
832 root="$sysroot"
833 _ '%s sysroot: %s' "$ARCH" "$sysroot"
834 _ 'Adding "%s" to PATH' "$tools/bin"
835 export PATH="$PATH:$tools/bin"
836 export PKG_CONFIG_PATH="$sysroot/usr/lib/pkgconfig"
837 export CROSS_COMPILE="$HOST_SYSTEM-"
838 _ 'Using cross-tools: %s' "$CROSS_COMPILE"
839 if [ "$ARCH" == 'x86_64' ]; then
840 export CC="$HOST_SYSTEM-gcc -m64"
841 export CXX="$HOST_SYSTEM-g++ -m64"
842 else
843 export CC="$HOST_SYSTEM-gcc"
844 export CXX="$HOST_SYSTEM-g++"
845 fi
846 export AR="$HOST_SYSTEM-ar"
847 export AS="$HOST_SYSTEM-as"
848 export RANLIB="$HOST_SYSTEM-ranlib"
849 export LD="$HOST_SYSTEM-ld"
850 export STRIP="$HOST_SYSTEM-strip"
851 export LIBTOOL="$HOST_SYSTEM-libtool"
852 ;;
853 esac
855 @@PREFIX@@/libexec/cookutils/precheck $receipt || exit 1 # former receipt_quality()
857 cd $pkgdir
858 if [ -z "$continue" ]; then
859 rm -rf source 2>/dev/null
860 rm .patch.done 2>/dev/null
861 fi
862 rm -rf install taz 2>/dev/null
864 # Disable -pipe if less than 512 MB free RAM.
865 free=$(awk '/^MemFree|^Buffers|^Cached/{s+=$2}END{print int(s/1024)}' /proc/meminfo)
866 if [ "$free" -lt 512 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then
867 _ 'Disabling -pipe compile flag: %d MB RAM free' "$free"
868 CFLAGS="${CFLAGS/-pipe}"; CFLAGS=$(echo "$CFLAGS" | tr -s ' ')
869 CXXFLAGS="${CXXFLAGS/-pipe}"; CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ')
870 fi
871 unset free
873 # Export flags and path to be used by make and receipt.
874 DESTDIR="$pkgdir/install"
875 # FIXME: L10n: Is this the right time for 'LC_ALL=C LANG=C'?
876 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS CONFIG_SITE LC_ALL=C LANG=C \
877 LDFLAGS
879 timestamp job1 # pre-checks
881 # BUILD_DEPENDS may vary depending on the ARCH
882 case "$ARCH" in
883 arm*) [ -n "$BUILD_DEPENDS_arm" ] && BUILD_DEPENDS=$BUILD_DEPENDS_arm ;;
884 x86_64) [ -n "$BUILD_DEPENDS_x86_64" ] && BUILD_DEPENDS=$BUILD_DEPENDS_x86_64 ;;
885 esac
887 # Check for build deps and handle implicit depends of *-dev packages
888 # (ex: libusb-dev :: libusb).
889 [ -n "$BUILD_DEPENDS" ] && _ 'Checking build dependencies...'
890 [ -n "$root" ] && _ 'Using packages DB: %s' "$root$DB"
892 # Get the list of installed packages
893 cd $root$INSTALLED; ls > $CACHE/installed.list
895 for action in check install; do
896 for dep in $BUILD_DEPENDS; do
897 implicit="${dep%-dev}"; [ "$implicit" == "$dep" ] && implicit=''
898 for i in $dep $implicit; do
899 # Skip if package already installed
900 [ -f "$root$INSTALLED/$i/receipt" ] && continue
902 case $action in
903 check)
904 # Search for local package or local provided-package
905 name=$(awk -F$'\t' -vpkg="$i" '{
906 if (index(" " $1 " " $10 " ", " " pkg " ")) {print $1; exit}
907 }' "$PKGS/packages-$ARCH.info")
908 if [ -z "$name" ]; then
909 # Search for package in mirror
910 name="$(awk -F$'\t' -vi="$i" '$1==i{print $1; exit}' "$root$DB/packages.info")"
911 [ -z "$name" -a "$i" == "$dep" ] && die 'ERROR: unknown dep "%s"' "$i"
912 fi
913 ;;
914 install)
915 tazpkg get-install $i --root=$root --local --quiet --cookmode || { broken; exit 1; }
916 ;;
917 esac
918 done
919 done
920 done
922 update_installed_cook_diff
924 timestamp job2 # installing bdeps
926 # Get source tarball and make sure we have source dir named:
927 # $PACKAGE-$VERSION to be standard in receipts. Here we use tar.lzma
928 # tarball if it exists.
929 if [ -n "$WGET_URL" -a ! -f "$SRC/$TARBALL" ]; then
930 if [ -f "$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
931 TARBALL="${SOURCE:-$PACKAGE}-$VERSION.tar.lzma"
932 LZMA_SRC=''
933 else
934 get_source || { broken; exit 1; }
935 fi
936 fi
937 if [ -z "$WANTED" -a -n "$TARBALL" -a ! -d "$src" ]; then
938 mkdir -p $pkgdir/source/tmp; cd $pkgdir/source/tmp
939 if ! extract_source ; then
940 get_source
941 extract_source || { broken; exit 1; }
942 fi
943 if [ -n "$LZMA_SRC" ]; then
944 cd $pkgdir/source
945 if [ "$(ls -A tmp | wc -l)" -gl 1 -o -f "$(echo tmp/*)" ]; then
946 mv tmp tmp-1; mkdir tmp
947 mv tmp-1 tmp/${SOURCE:-$PACKAGE}-$VERSION
948 fi
949 if [ -d "tmp/${SOURCE:-$PACKAGE}-$VERSION" ]; then
950 cd tmp; tar -c * | lzma e $SRC/$TARBALL -si
951 fi
952 fi
954 cd $pkgdir/source/tmp
955 # Some archives are not well done and don't extract to one dir (ex lzma).
956 files=$(ls | wc -l)
957 [ "$files" -eq 1 -a -d "$(ls)" ] &&
958 mv * ../$PACKAGE-$VERSION
959 [ "$files" -eq 1 -a -f "$(ls)" ] &&
960 mkdir -p ../$PACKAGE-$VERSION &&
961 mv * ../$PACKAGE-$VERSION/$TARBALL
962 [ "$files" -gt 1 ] &&
963 mkdir -p ../$PACKAGE-$VERSION &&
964 mv * ../$PACKAGE-$VERSION
965 cd ..; rm -rf tmp
966 fi
968 # Check md5sum (or similar) for sources tarball
969 check_integrity
971 # Libtool shared libs path hack.
972 case "$ARCH" in
973 arm*) cross libhack ;;
974 esac
976 timestamp job3 # get/unpack src tarball
978 # Compiling all the sets
979 if grep -q ^compile_rules $receipt; then
980 _ 'Executing: %s' 'compile_rules'
981 echo "CFLAGS : $CFLAGS"
982 echo "CXXLAGS : $CXXFLAGS"
983 echo "CPPFLAGS : $CPPFLAGS"
984 echo "LDFLAGS : $LDFLAGS"
985 [ -d "$src" ] && cd $src
986 patchit
988 timestamp job4 # patching
990 # Get set names from $SPLIT variable, format ex. 'pkg1 pkg2:set1 pkg3:set2'
991 # Keep natural order of the sets, don't sort them alphabetically
992 SETS=$(echo -n $SPLIT \
993 | awk '
994 BEGIN { RS = " "; FS = ":"; }
995 {
996 if ($2 && ! set[$2]) { printf("%s ", $2); set[$2] = "1"; }
997 }' \
998 | sed 's| $||')
999 # Prepare specified source sets using patched sources
1000 [ -n "$SETS" -a -d "$src" ] &&
1001 for set in $SETS; do
1002 echo "Preparing set $set" # debug
1003 cp -a $src $src-$set
1004 done
1006 timestamp job5 # preparing sets
1007 timestamp sets "$SETS"
1009 job_counter='6'
1011 SET='' cook_set # first run for empty SET
1013 # Allow to change SETS after the first run, follow the changes
1014 SETS=$(. $receipt; echo -n $SPLIT \
1015 | awk '
1016 BEGIN { RS = " "; FS = ":"; }
1018 if ($2 && ! set[$2]) { printf("%s ", $2); set[$2] = "1"; }
1019 }' \
1020 | sed 's| $||')
1021 for SET in $SETS; do
1022 cook_set
1023 done
1024 else
1025 mkdir -p $install # allow receipts without `compile_rules()`
1026 fi
1027 footer
1029 timestamp job # reset counter
1031 # Execute testsuite.
1032 if grep -q ^testsuite $receipt; then
1033 title 'Running testsuite'
1034 testsuite $@ || { broken; exit 1; }
1035 footer
1036 fi
1038 timestamp job26 # test suite
1040 update_installed_cook_diff force
1044 # Cook quality assurance.
1046 cookit_quality() {
1047 while true; do
1048 [ ! -d "$WOK/$pkg/install" -a -z "$WANTED" ] || break
1049 _ 'ERROR: cook failed' | tee -a $LOGS/$pkg.log
1050 [ "$trials" == 'yes' ] || break
1051 title "Interactive mode"
1052 # TODO: allow commands:
1053 # q - quit; v - edit receipt here using vi;
1054 # s - search for package containing package;
1055 # <package name> - install package; [Enter] - retry
1056 _ 'You may install the packages here and/or edit the receipt there.'
1057 newline
1058 while true; do
1059 _n 'Install the package? [name/N] '; read answer
1060 [ -n "$answer" ] || break
1061 tazpkg -gi $answer --root=$root --local --quiet --cookmode
1062 done
1063 newline
1064 _n 'Try again? [Y/n] '; read answer
1065 [ "$answer" == 'n' ] && break
1066 # here you may append log if you want (">>" instead of last ">")
1067 cookit $@ 2>&1 | loglimit 50 > $LOGS/$pkg.log
1068 done
1070 [ "${COOKOPTS/skip-log-errors/}" != "$COOKOPTS" ] && return 0
1072 # ERROR can be echoed any time in cookit()
1073 if grep -Ev "(conftest|configtest)" $LOGS/$pkg.log | \
1074 grep -Eq "(^ERROR|undefined reference to)" ; then
1075 debug_info "cookit_quality" | tee -a $LOGS/$pkg.log
1076 put_status $pkg Failed
1077 # rm -f $command
1078 # broken; exit 1
1079 fi
1083 # Return all the names of packages bundled in this receipt
1085 all_names() {
1086 # Get package names from $SPLIT variable
1087 local split=$(echo -n $SPLIT \
1088 | awk '
1089 BEGIN { RS = " "; FS = ":"; }
1090 { print $1; }' \
1091 | tr '\n' ' ')
1092 local split_space=" $split "
1093 if ! head -n1 $WOK/$pkg/receipt | fgrep -q 'v2'; then
1094 # For receipts v1: $SPLIT may present in the $WANTED package,
1095 # but split packages have their own receipts
1096 echo $PACKAGE
1097 elif [ "${split_space/ $PACKAGE /}" != "$split_space" ]; then
1098 # $PACKAGE included somewhere in $SPLIT (probably in the end).
1099 # We should build packages in the order defined in the $SPLIT.
1100 echo $split
1101 else
1102 # We'll build the $PACKAGE, then all defined in the $SPLIT.
1103 echo $PACKAGE $split
1104 fi
1108 # v2: pack all packages using compiled files
1110 packall() {
1111 set_paths
1112 [ -e $pkgdir/.arch ] && rm $pkgdir/.arch
1114 if head -n1 "$pkgdir/receipt" | fgrep -q 'v2'; then
1115 for i in $(all_names); do
1116 unset TAGS DEPENDS CAT CONFIG_FILES PROVIDE SUGGESTED DATABASE_FILES TAZPANEL_DAEMON
1117 export PACKAGE; @@PREFIX@@/libexec/cookutils/pack $i
1118 done
1119 else
1120 export PACKAGE; @@PREFIX@@/libexec/cookutils/pack $PACKAGE
1121 fi
1125 # Reverse "cat" command: prints input lines in the reverse order
1127 tac() {
1128 sed '1!G;h;$!d' $1
1132 # Install package: update the chroot with freshly rebuilt package: keep env up-to-date.
1134 install_package() {
1135 set_paths
1136 case "$ARCH" in
1137 arm*) root="$CROSS_TREE/sysroot";;
1138 esac
1140 # Process all the package names built by this receipt (defined in $SPLIT)
1141 for i in $(PACKAGE="$pkg" all_names); do
1142 if [ -d "$root$INSTALLED/$i" ]; then
1143 pkg_file=$(awk -F$'\t' -vpkg="$i" -varch="$ARCH" '{
1144 if ($1 == pkg) {
1145 pkgarch = ($11 == "0") ? "any" : arch;
1146 printf("%s-%s-%s.tazpkg", $1, $2, pkgarch);
1147 exit
1149 }' $PKGS/packages-$ARCH.info)
1150 if [ -e "$PKGS/$pkg_file" ]; then
1151 _ 'Updating %s chroot environment...' "$ARCH"
1152 _ 'Updating chroot: %s' "${pkg_file%.tazpkg}" | log
1153 tazpkg -i "$PKGS/$pkg_file" --forced --root=$root
1154 fi
1155 fi
1156 done
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*
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 /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 mkdir -p ${base}root$mnt # for `mount -o bind`
1196 mount -o bind $mnt ${base}root$mnt # use `-o bind` instead of `--bind`
1197 if [ $mnt == / ] && ! mount -t aufs -o br=${base}rw:/ none ${base}root; then
1198 _ 'Aufs mount failure'
1199 umount ${base}root
1200 rm -rf ${base}r*
1201 return
1202 fi
1203 echo "umount ${base}root$mnt" >> ${base}rw/aufs-umount.sh
1204 done
1205 trap "umount_aufs ${base}" INT
1207 chroot ${base}root $(cd $(dirname $0); pwd)/$(basename $0) "$@"
1208 status=$?
1210 _ 'Leaving aufs chroot...'
1211 umount_aufs $base
1212 # Install package outside the aufs jail
1213 install_package
1214 exit $status
1218 # Encode predefined XML entities
1220 xml_ent() {
1221 sed -e 's|&|\&amp;|g; s|<|\&lt;|g; s|>|\&gt;|g; s|"|\&quot;|g' -e "s|'|\&apos;|g"
1225 # Create a XML feed for freshly built packages.
1227 gen_rss() {
1228 if [ -e "$WOK/$PACKAGE/.icon.png" ]; then
1229 icon="$COOKER_URL$PACKAGE/browse/.icon.png"
1230 else
1231 icon="http://cook.slitaz.org/tazpkg.png"
1232 fi
1234 cat > $FEEDS/$pkg.xml <<EOT
1235 <item>
1236 <title>$PACKAGE $VERSION$EXTRAVERSION</title>
1237 <link>$COOKER_URL${PACKAGE//+/%2B}</link>
1238 <guid isPermaLink="false">$PACKAGE-$VERSION$EXTRAVERSION</guid>
1239 <pubDate>$(date '+%a, %d %b %Y %X GMT')</pubDate>
1240 <description><![CDATA[
1241 <table>
1242 <tr>
1243 <td vertical-align="top"><img src="$icon" alt=""/></td>
1244 <td>$(echo -n "$SHORT_DESC" | xml_ent)</td>
1245 </tr>
1246 </table>
1247 ]]></description>
1248 </item>
1249 EOT
1253 # Truncate stdout log file to $1 Mb.
1255 loglimit() {
1256 if [ -n "$DEFAULT_LOG_LIMIT" ]; then
1257 tee /dev/stderr | head -qc ${1:-$DEFAULT_LOG_LIMIT}m
1258 else
1259 tee /dev/stderr
1260 fi
1265 # Receipt functions to ease packaging
1268 get_dev_files() {
1269 action 'Getting standard devel files...'
1270 mkdir -p $fs/usr/lib
1271 cp -a $install/usr/lib/pkgconfig $fs/usr/lib
1272 cp -a $install/usr/lib/*a $fs/usr/lib
1273 cp -a $install/usr/include $fs/usr
1274 status
1278 # Function to use in compile_rules() to copy man page from $src to $install
1280 cook_pick_manpages() {
1281 local name section
1282 action 'Copying man pages...'
1284 for i in $@; do
1285 name=$(echo $i | sed 's|\.[gbx]z2*$||')
1286 section=${name##*/}; section=${section##*.}
1287 mkdir -p $install/usr/share/man/man$section
1288 scopy $i $install/usr/share/man/man$section
1289 done
1290 status
1294 # Function to use in compile_rules() to copy documentation from $src to $install
1296 cook_pick_docs() {
1297 local docdir="$install/usr/share/doc/$PACKAGE-$VERSION"
1298 action 'Copying documentation...'
1299 mkdir -p $docdir
1300 cp -r $@ $docdir
1301 chmod -R a+r $docdir
1302 status
1306 # Update split.db once for receipt
1308 update_split_db() {
1309 local db="$cache/split.db"
1310 touch $db
1311 sed -i "/^$pkg\t/d" $db
1312 echo -e "$pkg\t$(all_names)" >> $db
1316 # Recreate whole split.db from scratch
1318 recreate_split_db() {
1319 # Clean
1320 local db="$cache/split.db"
1322 cd $WOK
1323 for pkg in *; do
1324 [ -f "$WOK/$pkg/receipt" ] || continue
1325 unset PACKAGE SPLIT
1326 . $WOK/$pkg/receipt
1327 echo -e "$PACKAGE\t$(all_names)"
1328 done > $db
1332 # Recreate whole maint.db from scratch
1334 recreate_maint_db() {
1335 # Clean
1336 local db="$cache/maint.db"
1338 cd $WOK
1339 for pkg in *; do
1340 [ -f "$WOK/$pkg/receipt" ] || continue
1341 unset PACKAGE MAINTAINER
1342 . $WOK/$pkg/receipt
1343 MAINTAINER=$(echo $MAINTAINER | sed 's|.*<||; s|>.*||')
1344 echo -e "$MAINTAINER\t$PACKAGE"
1345 done | sort > $db
1349 # Put the status to the activity log
1351 put_status() {
1352 # $1: package, $2: status, one of 'Done', 'Failed'
1353 sed -i "s|>$1</a>$|& [ $2 ]|" $activity
1354 if [ "$2" == 'Done' ]; then
1355 # overstrike all previous 'Failed' to indicate package is OK now
1356 sed -i "/>$1<\/a>/ s|\[ Failed \]|[ -Failed ]|" $activity
1357 fi
1364 # Commands
1367 # cook <package> --deps
1368 [ -n "$deps" ] && {
1369 @@PREFIX@@/libexec/cookutils/deps $1
1370 exit 0
1373 # cook <package> --clean
1374 # cook <package> -c
1375 [ -n "$clean" -o "$2" == '-c' ] && {
1376 action 'Cleaning "%s"' "$1"
1377 cd $WOK/$1; rm -rf install taz source
1378 status; newline
1379 touch $activity # update $activity -> something changed -> update webstat
1380 exit 0
1383 # cook <package> --getsrc
1384 # cook <package> -gs
1385 [ -n "$getsrc" -o "$2" == '-gs' ] && {
1386 title 'Getting source for "%s"' "$1"
1387 receipt="$WOK/$pkg/receipt"
1388 check_pkg_in_wok
1389 unset_receipt
1390 . $receipt
1391 get_source
1392 _ 'Tarball: %s' "$SRC/$TARBALL"; newline
1393 exit 0
1396 # cook <package> --block
1397 # cook <package> -b
1398 [ -n "$block" -o "$2" == '-b' ] && {
1399 action 'Blocking package "%s"' "$1"
1400 [ $(grep "^$1$" $blocked) ] || echo "$1" >> $blocked
1401 status; newline
1402 touch $activity
1403 exit 0
1406 # cook <package> --unblock
1407 # cook <package> -ub
1408 [ -n "$unblock" -o "$2" == '-ub' ] && {
1409 action 'Unblocking package "%s"' "$1"
1410 sed -i "/^$1$/d" $blocked
1411 status; newline
1412 touch $activity
1413 exit 0
1419 case "$1" in
1420 usage|help|-u|-h)
1421 usage ;;
1423 list-wok)
1424 title 'List of %s packages in "%s"' "$ARCH" "$WOK"
1425 cd $WOK
1426 if [ "$ARCH" != 'i486' ]; then
1427 count=0
1428 for pkg in $(fgrep 'HOST_ARCH=' */receipt | egrep "$ARCH|any" | cut -d: -f1)
1429 do
1430 unset HOST_ARCH
1431 . ./$pkg
1432 count=$(($count + 1))
1433 colorize 34 "$PACKAGE"
1434 done
1435 else
1436 count=$(ls | wc -l)
1437 ls -1
1438 fi
1439 footer "$(_p '%s package' '%s packages' "$count" "$(colorize 32 "$count")")"
1440 ;;
1442 activity)
1443 cat $activity ;;
1445 search)
1446 # Just a simple search function, we don't need more actually.
1447 query="$2"
1448 title 'Search results for "%s"' "$query"
1449 cd $WOK; ls -1 | grep "$query"
1450 footer ;;
1452 setup)
1453 # Setup a build environment
1454 check_root
1455 _ 'Cook: setup environment' | log
1456 title 'Setting up your environment'
1457 [ -d $SLITAZ ] || mkdir -p $SLITAZ
1458 cd $SLITAZ
1459 init_db_files
1460 _ 'Checking for packages to install...'
1461 # Use setup pkgs from cross.conf or cook.conf. When cross compiling
1462 # ARCH-setup or 'cross check' should be used before: cook setup
1463 case "$ARCH" in
1464 arm*|x86_64)
1465 [ -x '/usr/bin/cross' ] || die 'ERROR: %s is not installed' 'cross'
1466 _ 'Using config file: %s' '/etc/slitaz/cross.conf'
1467 . /etc/slitaz/cross.conf ;;
1468 esac
1469 for pkg in $SETUP_PKGS; do
1470 if [ -n "$forced" ]; then
1471 tazpkg -gi $pkg --forced
1472 else
1473 [ ! -d "$INSTALLED/$pkg" ] && tazpkg get-install $pkg
1474 fi
1475 done
1477 # Handle --options
1478 case "$2" in
1479 --wok) hg clone $WOK_URL wok || exit 1 ;;
1480 --stable) hg clone $WOK_URL-stable wok || exit 1 ;;
1481 --undigest) hg clone $WOK_URL-undigest wok || exit 1 ;;
1482 --tiny) hg clone $WOK_URL-tiny wok || exit 1 ;;
1483 esac
1485 # SliTaz group and permissions
1486 if ! grep -q ^slitaz /etc/group; then
1487 _ 'Adding group "%s"' 'slitaz'
1488 addgroup slitaz
1489 fi
1490 _ 'Setting permissions for group "%s"...' 'slitaz'
1491 find $SLITAZ -maxdepth 2 -exec chown root.slitaz {} \;
1492 find $SLITAZ -maxdepth 2 -exec chmod g+w {} \;
1493 footer "$(_ 'All done, ready to cook packages :-)')" ;;
1495 *-setup)
1496 # Setup for cross compiling.
1497 arch="${1%-setup}"
1498 check_root
1499 . /etc/slitaz/cook.conf
1500 for pkg in $CROSS_SETUP; do
1501 if [ -n "$forced" ]; then
1502 tazpkg -gi $pkg --forced
1503 else
1504 [ ! -d "$INSTALLED/$pkg" ] && tazpkg -gi $pkg
1505 fi
1506 done
1508 _ 'Cook: setup %s cross environment' "$arch" | log
1509 title 'Setting up your %s cross environment' "$arch"
1510 init_db_files
1511 sed -i \
1512 -e "s|ARCH=.*|ARCH=\"$arch\"|" \
1513 -e "s|CROSS_TREE=.*|CROSS_TREE=\"/cross/$arch\"|" \
1514 -e 's|BUILD_SYSTEM=.*|BUILD_SYSTEM=i486-slitaz-linux|' \
1515 /etc/slitaz/cook.conf
1516 case "$arch" in
1517 arm)
1518 flags='-O2 -march=armv6'
1519 host="$ARCH-slitaz-linux-gnueabi" ;;
1520 armv6hf)
1521 flags='-O2 -march=armv6j -mfpu=vfp -mfloat-abi=hard'
1522 host="$ARCH-slitaz-linux-gnueabi" ;;
1523 armv7)
1524 flags='-Os -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -pipe'
1525 host="$ARCH-slitaz-linux-gnueabi" ;;
1526 x86_64)
1527 flags='-O2 -mtune=generic -pipe'
1528 host="$ARCH-slitaz-linux" ;;
1529 esac
1530 sed -i \
1531 -e "s|CFLAGS=.*|CFLAGS=\"$flags\"|" \
1532 -e "s|HOST_SYSTEM=.*|HOST_SYSTEM=$host|" /etc/slitaz/cook.conf
1533 . /etc/slitaz/cook.conf
1534 sysroot="$CROSS_TREE/sysroot"
1535 tools="/cross/$arch/tools"
1536 root="$sysroot"
1537 # L10n: keep the same width of translations to get a consistent view
1538 _ 'Target arch : %s' "$ARCH"
1539 _ 'Configure args : %s' "$CONFIGURE_ARGS"
1540 _ 'Build flags : %s' "$flags"
1541 _ 'Arch sysroot : %s' "$sysroot"
1542 _ 'Tools prefix : %s' "$tools/bin"
1543 # Tell the packages manager where to find packages.
1544 _ 'Packages DB : %s' "$root$DB"
1545 mkdir -p $root$INSTALLED
1546 cd $root$DB; rm -f *.bak
1547 for list in packages.list packages.desc packages.equiv packages.md5; do
1548 rm -f $list
1549 ln -s $SLITAZ/packages/$list $list
1550 done
1551 # We must have the cross compiled glibc-base installed or default
1552 # i486 package will be used as dep by tazpkg and then break the
1553 # cross environment
1554 if [ ! -f "$root$INSTALLED/glibc-base/receipt" ]; then
1555 colorize 36 $(_ 'WARNING: %s is not installed in sysroot' '(e)glibc-base')
1556 fi
1557 # Show GCC version or warn if not yet compiled.
1558 if [ -x "$tools/bin/$HOST_SYSTEM-gcc" ]; then
1559 _ 'Cross compiler : %s' "$HOST_SYSTEM-gcc"
1560 else
1561 colorize 36 $(_ 'C compiler "%s" is missing' "$HOST_SYSTEM-gcc")
1562 _ 'Run "%s" to cook a toolchain' 'cross compile'
1563 fi
1564 footer ;;
1566 test)
1567 # Test a cook environment.
1568 _ 'Cook test: testing the cook environment' | log
1569 [ ! -d "$WOK" ] && exit 1
1570 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK
1571 cook cooktest ;;
1573 new)
1574 # Create the package folder and an empty receipt.
1575 pkg="$2"
1576 [ -z "$pkg" ] && usage
1577 newline
1578 [ -d "$WOK/$pkg" ] && die 'Package "%s" already exists.' "$pkg"
1580 action 'Creating folder "%s"' "$WOK/$pkg"
1581 mkdir $WOK/$pkg; cd $WOK/$pkg; status
1583 action 'Preparing the package receipt...'
1584 cp $DATA/receipt .
1585 sed -i "s|^PACKAGE=.*|PACKAGE=\"$pkg\"|" receipt
1586 status; newline
1588 # Interactive mode, asking and seding.
1589 case "$3" in
1590 --interactive|-x)
1591 _ 'Entering interactive mode...'
1592 separator
1593 _ 'Package : %s' "$pkg"
1595 _n 'Version : ' ; read answer
1596 sed -i "s|^VERSION=.*|VERSION=\"$answer\"|" receipt
1598 _n 'Category : ' ; read answer
1599 sed -i "s|^CATEGORY=.*|CATEGORY=\"$answer\"|" receipt
1601 # L10n: Short description
1602 _n 'Short desc : ' ; read answer
1603 sed -i "s|^SHORT_DESC=.*|SHORT_DESC=\"$answer\"|" receipt
1605 _n 'Maintainer : ' ; read answer
1606 sed -i "s|^MAINTAINER=.*|MAINTAINER=\"$answer\"|" receipt
1608 _n 'License : ' ; read answer
1609 sed -i "s|^LICENSE=.*|LICENSE=\"$answer\"|" receipt
1611 _n 'Web site : ' ; read answer
1612 sed -i "s|^WEB_SITE=.*|WEB_SITE=\"$answer\"|" receipt
1613 newline
1615 # Wget URL.
1616 _ 'Wget URL to download source tarball.'
1617 _n 'Example : ' ; echo '$GNU_MIRROR/$PACKAGE/$TARBALL'
1618 _n 'Wget url : ' ; read answer
1619 sed -i "s|^WGET_URL=.*|WGET_URL=\"$answer\"|" receipt
1621 # Ask for a stuff dir.
1622 confirm "$(_n 'Do you need a stuff directory? (y/N)')"
1623 if [ "$?" -eq 0 ]; then
1624 action 'Creating the stuff directory...'
1625 mkdir $WOK/$pkg/stuff; status
1626 fi
1628 # Ask for a description file.
1629 confirm "$(_n 'Are you going to write a description? (y/N)')"
1630 if [ "$?" -eq 0 ]; then
1631 action 'Creating the "%s" file...' 'description.txt'
1632 touch $WOK/$pkg/description.txt; status
1633 fi
1635 footer "$(_ 'Receipt is ready to use.')" ;;
1636 esac ;;
1638 list)
1639 # Cook a list of packages (better use the Cooker since it will order
1640 # packages before executing cook).
1641 check_root
1642 [ -z "$2" ] && die 'No list in argument.'
1643 [ -f "$2" ] || die 'List "%s" not found.' "$2"
1645 _ 'Starting cooking the list "%s"' "$2" | log
1647 while read pkg; do
1648 cook $pkg || broken
1649 done < $2
1650 ;;
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 i in *; do
1670 unset HOST_ARCH EXTRAVERSION
1671 [ ! -e $i/receipt ] && continue
1672 . ./$i/receipt
1673 # Source cooked pkg receipt to get EXTRAVERSION
1674 if [ -d "$WOK/$i/taz" ]; then
1675 cd $WOK/$i/taz/$(ls $WOK/$i/taz/ | head -n1)
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 "$i"
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 "$i"
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 recreate_split_db
1710 recreate_maint_db
1711 @@PREFIX@@/libexec/cookutils/pkgdb "$2"
1712 ;;
1714 splitdb)
1715 # File split.db is useful for searching for split packages.
1716 recreate_split_db
1717 ;;
1719 maintdb)
1720 # File maint.db is useful for searching maintainer's packages.
1721 recreate_maint_db
1722 ;;
1724 *)
1725 # Just cook and generate a package.
1726 check_root
1727 time=$(date +%s)
1728 pkg="$1"
1729 [ -z "$pkg" ] && usage
1731 # Search last successful cook time in all logs from newer to older
1732 for i in '' $(seq 0 9 | sed 's|^|.|'); do
1733 [ -f "$LOGS/$pkg.log$i" ] || break
1734 lastcooktime=$(sed '/^Cook time/!d; s|.*: *\([0-9]*\)s.*|\1|' \
1735 $LOGS/$pkg.log$i 2>/dev/null | sed '$!d')
1736 [ -n "$lastcooktime" ] && break
1737 done
1739 receipt="$WOK/$pkg/receipt"
1740 check_pkg_in_wok
1741 newline
1743 unset inst
1744 unset_receipt
1745 . $receipt
1747 # Handle cross compilation.
1748 case "$ARCH" in
1749 arm*)
1750 if [ -z "$HOST_ARCH" ]; then
1751 _ 'cook: HOST_ARCH is not set in "%s" receipt' "$pkg"
1752 error="$(_ 'package "%s" is not included in %s' "$pkg" "$ARCH")"
1753 _ 'cook: %s' "$error"
1754 [ -n "$CROSS_BUGS" ] && _ 'bugs: %s' "$CROSS_BUGS"
1755 _ 'Cook skip: %s' "$error" | log
1756 newline
1757 broken; exit 1
1758 fi ;;
1759 esac
1761 # Some packages are not included in some arch or fail to cross compile.
1762 : ${HOST_ARCH=$ARCH}
1763 debug "$(_ 'Host arch %s' "$HOST_ARCH")"
1764 # Handle arm{v6hf,v7,..}
1765 if ! $(echo "$HOST_ARCH" | egrep -q "${ARCH%v[0-9]*}|any"); then
1766 _ 'cook: %s' "HOST_ARCH=$HOST_ARCH"
1767 error="$(_ "package \"%s\" doesn't cook or is not included in %s" "$pkg" "$ARCH")"
1768 _ 'cook: %s' "error"
1769 [ -n "$CROSS_BUGS" ] && _ 'bugs: %s' "$CROSS_BUGS"
1770 _ 'Cook skip: %s' "$error" | log
1771 sed -i "/^${pkg}$/d" $broken
1772 newline
1773 exit 0
1774 fi
1776 # Remove package from broken list before cooking
1777 sed -i "/^${pkg}$/d" $broken
1779 # Skip blocked, 3 lines also for the Cooker.
1780 grep -q "^$pkg$" $blocked && [ "$2" != '--unblock' ] &&
1781 die 'Package "%s" is blocked' "$pkg"
1783 try_aufs_chroot "$@"
1785 # Log and source receipt.
1786 echo "cook:$pkg" > $command
1788 [ -n "$lastcooktime" ] && echo "cook:$pkg $lastcooktime $(date +%s)" >> $cooktime
1790 while read cmd duration start; do
1791 [ $(($start + $duration)) -lt $(date +%s) ] &&
1792 echo "sed -i '/^$cmd $duration/d' $cooktime"
1793 done < $cooktime | sh
1795 # Display and log info if cook process stopped.
1796 # FIXME: gettext not working (in single quotes) here!
1797 trap '_ "\n\nCook stopped: control-C\n\n" | \
1798 tee -a $LOGS/$pkg.log' INT
1800 update_split_db
1802 # Handle --options
1803 case "$2" in
1804 --pack)
1805 _ 'Packing %s' "<a href='cooker.cgi?pkg=${pkg//+/%2B}'>$pkg</a>" | log
1806 [ -d "$WOK/$pkg/install" ] || die 'Need to build "%s"' "$pkg"
1807 [ ! -d "$WOK/$pkg/taz" ] || rm -rf "$WOK/$pkg/taz"
1808 [ ! -f "$LOGS/$pkg-pack.log" ] || rm -f $LOGS/$pkg-pack.log
1809 packall 2>&1 | tee -a $LOGS/$pkg-pack.log
1810 @@PREFIX@@/libexec/cookutils/postcheck $pkg | tee -a $LOGS/$pkg.log
1811 clean_log "$pkg-pack"
1812 time=$(($(date +%s) - $time))
1813 summary | sed 's|^Cook |Pack |' | tee -a $LOGS/$pkg-pack.log
1814 gen_rss
1815 put_status $pkg Done
1816 rm -f $command
1817 exit 0 ;;
1819 --trials|-t)
1820 trials='yes' ;;
1821 esac
1823 _ 'Making %s' "<a href='cooker.cgi?pkg=${pkg//+/%2B}'>$pkg</a>" | log
1825 # Rotate log
1826 for i in $(seq 9 -1 1); do
1827 j=$(($i - 1))
1828 [ -e $LOGS/$pkg.log.$j ] && mv -f $LOGS/$pkg.log.$j $LOGS/$pkg.log.$i
1829 done
1830 [ -e $LOGS/$pkg.log ] && mv $LOGS/$pkg.log $LOGS/$pkg.log.0
1832 # Check if wanted is built now so we have separate log files.
1833 for wanted in $WANTED ; do
1834 if grep -q "^$wanted$" $blocked; then
1835 broken
1836 rm -f $command
1837 die 'WANTED package "%s" is blocked' "$wanted"
1838 fi
1839 if grep -q "^$wanted$" $broken; then
1840 broken
1841 rm -f $command
1842 die 'WANTED package "%s" is broken' "$wanted"
1843 fi
1844 if [ ! -d "$WOK/$wanted/install" ]; then
1845 cook "$wanted" || { broken; exit 1; }
1846 fi
1847 done
1849 # Cook and pack or exit on error and log everything.
1850 ( ( ( (cookit $@ 2>&1; echo $? >&3) | loglimit 50 > $LOGS/$pkg.log) 3>&1) | (read rq; exit $rq) )
1851 rq=$? # the return code of `cookit $@` above command
1853 if [ $rq -eq 1 ]; then
1854 broken
1855 fi
1857 # Remove build dependencies both when `cookit` done or fail
1858 remove_deps | tee -a $LOGS/$pkg.log
1859 timestamp job27 # removing bdeps
1860 # cookit_quality
1861 timestamp job28 # checking quality
1863 # Log and stop if `cookit` fails
1864 if [ $rq -eq 1 ]; then
1865 debug_info "ret1" | tee -a $LOGS/$pkg.log
1866 @@PREFIX@@/libexec/cookutils/postcheck $pkg | tee -a $LOGS/$pkg.log
1867 put_status $pkg Failed
1868 rm -f $command
1869 broken
1870 exit 1
1871 fi
1873 # Proceed only if `cookit` return code is zero-OK
1874 # If instant-pack if specified, then packages already packed in the cookit()
1875 [ "${COOKOPTS/instant-pack/}" == "$COOKOPTS" ] &&
1876 packall 2>&1 | loglimit 5 >> $LOGS/$pkg.log
1877 timestamp job29 # packing
1879 @@PREFIX@@/libexec/cookutils/postcheck $pkg | tee -a $LOGS/$pkg.log
1881 clean_log
1883 # Exit if any error in packing.
1884 if [ "${COOKOPTS/skip-log-errors/}" == "$COOKOPTS" ] &&
1885 grep -Ev "(/root/.cvspass|conftest|df: /|rm: can't remove)" $LOGS/$pkg.log | \
1886 grep -Eq "(^ERROR|: No such file or directory|not remade because of errors|ake: \*\*\* .* Error)"; then
1887 debug_info "packerr" | tee -a $LOGS/$pkg.log
1888 put_status $pkg Failed
1889 rm -f $command
1890 broken; exit 1
1891 fi
1893 # Create an XML feed
1894 gen_rss
1896 # Time and summary
1897 time=$(($(date +%s) - $time))
1898 summary | tee -a $LOGS/$pkg.log
1899 newline
1901 # We may want to install/update (outside aufs jail!).
1902 [ -s /aufs-umount.sh ] || install_package
1904 put_status $pkg Done
1906 # Finally we DON'T WANT to build the *-dev or packages with WANTED="$pkg"
1907 # If you want automation, use the Cooker Build Bot.
1908 rm -f $command
1909 timestamp job30 # misc. final operations
1910 store_timestats
1912 sed -n '/^Build dependencies to remove:/,/^$/p' $LOGS/$pkg.log \
1913 | sed '/^Build/d; s|Removing: ||' \
1914 | tr ' ' '\n' \
1915 | sed '/^$/d' \
1916 > $WOK/$pkg/.bdeps
1918 ;;
1919 esac
1921 exit 0