cookutils view cook @ rev 846

cook: add normalize_mo(); update doc/cookopts.txt; tiny edits.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Mon Dec 12 05:56:11 2016 +0200 (2016-12-12)
parents 074575c8891b
children 30c6b6064a50
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'
19 _() { local T="$1"; shift; printf "$(gettext "$T")" "$@"; echo; }
20 _n() { local T="$1"; shift; printf "$(gettext "$T")" "$@"; }
21 _p() {
22 local S="$1" P="$2" N="$3"; shift; shift; shift;
23 printf "$(ngettext "$S" "$P" "$N")" "$@"; }
26 #
27 # Functions
28 #
30 usage() {
31 cat <<EOT
33 $(boldify "$(_ 'Usage:')") $(_ 'cook [package|command] [list|--option]')
35 $(boldify "$(_ 'Commands:')")
36 usage|help $(_ 'Display this short usage.')
37 setup $(_ 'Setup your build environment.')
38 *-setup $(_ 'Setup a cross environment.')
39 * = {arm|armv6hf|armv7|x86_64}
40 test $(_ 'Test environment and cook a package.')
41 list-wok $(_ 'List packages in the wok.')
42 search $(_ 'Simple packages search function.')
43 new $(_ 'Create a new package with a receipt.')
44 list $(_ 'Cook a list of packages.')
45 clean-wok $(_ 'Clean-up all packages files.')
46 clean-src $(_ 'Clean-up all packages sources.')
47 uncook $(_ 'Check for uncooked packages')
48 pkgdb $(_ 'Create packages DB lists and flavors.')
50 $(boldify "$(_ 'Options:')")
51 cook <pkg>
52 --clean -c $(_ 'clean the package in the wok.')
53 --install -i $(_ 'cook and install the package.')
54 --getsrc -gs $(_ 'get the package source tarball.')
55 --block -b $(_ 'block a package so cook will skip it.')
56 --unblock -ub $(_ 'unblock a blocked package.')
57 --cdeps $(_ 'check dependencies of cooked package.')
58 --pack $(_ 'repack an already built package.')
59 --debug $(_ 'display debugging messages.')
60 --continue $(_ 'continue running compile_rules.')
61 cook new <pkg>
62 --interactive -x $(_ 'create a receipt interactively.')
63 cook setup
64 --wok $(_ 'clone the cooking wok from Hg repo.')
65 --stable $(_ 'clone the stable wok from Hg repo.')
66 --undigest $(_ 'clone the undigest wok from Hg repo.')
67 --tiny $(_ 'clone the tiny SliTaz wok from Hg repo.')
68 --forced $(_ 'force reinstall of chroot packages.')
69 cook pkgdb
70 --flavors $(_ 'create up-to-date flavors files.')
72 EOT
73 exit 0
74 }
77 # We don't want these escapes in web interface.
79 clean_log() {
80 sed -i -e s'|\[70G\[ \[1;32m| |' \
81 -e s'|\[0;39m \]||' $LOGS/$pkg.log
82 }
85 # Be sure package exists in wok.
87 check_pkg_in_wok() {
88 if [ ! -d "$WOK/$pkg" ]; then
89 newline; _ 'Unable to find package "%s" in the wok' "$pkg"; newline
90 exit 1
91 fi
92 }
95 if_empty_value() {
96 if [ -z "$value" ]; then
97 # L10n: QA is quality assurance
98 _ 'QA: empty variable: %s' "$var=\"\""; newline
99 exit 1
100 fi
101 }
104 # Initialize files used in $CACHE
106 init_db_files() {
107 _ 'Creating directories structure in "%s"' "$SLITAZ"
108 mkdir -p $WOK $PKGS $SRC $CACHE $LOGS $FEEDS
109 _ 'Creating DB files in "%s"' "$CACHE"
110 for f in $activity $command $broken $blocked; do
111 touch $f
112 done
113 }
116 # QA: check a receipt consistency before building.
118 receipt_quality() {
119 _ 'QA: checking package receipt...'
120 unset online
121 if ifconfig | grep -q -A 1 "^[a-z]*[0-9]" | fgrep 'addr:'; then
122 online='online'
123 fi
124 for var in PACKAGE VERSION CATEGORY SHORT_DESC MAINTAINER WEB_SITE; do
125 unset value
126 value="$(. $receipt; eval echo \$$var)"
127 case "$var" in
128 PACKAGE|VERSION|SHORT_DESC)
129 if_empty_value ;;
130 CATEGORY)
131 value="${value:-empty}"
132 valid="$(echo $PKGS_CATEGORIES)" # avoid newlines
133 if ! echo " $valid " | grep -q " $value "; then
134 _ 'QA: unknown category "%s"' "$value"
135 longline "$(_ 'Please, use one of: %s' "$valid")"
136 newline
137 exit 1
138 fi ;;
139 WEB_SITE)
140 # We don't check WGET_URL since if dl is needed it will fail.
141 # Break also if we're not online. Here error is not fatal.
142 if_empty_value
143 [ -z "$online" ] && break
144 if ! busybox wget -T 12 -s $value 2>/dev/null; then
145 _ 'QA: unable to reach "%s"' "$value"
146 fi ;;
147 esac
148 done
149 }
152 # Paths used in receipt and by cook itself.
154 set_paths() {
155 pkgdir="$WOK/$PACKAGE"
156 . "$pkgdir/receipt"
157 basesrc="$pkgdir/source"
158 tmpsrc="$basesrc/tmp"
159 src="$basesrc/$PACKAGE-$VERSION"
160 taz="$pkgdir/taz"
161 pack="$taz/$PACKAGE-$VERSION$EXTRAVERSION"
162 fs="$pack/fs"
163 stuff="$pkgdir/stuff"
164 install="$pkgdir/install"
165 pkgsrc="${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}"
166 lzma_tarball="$pkgsrc.tar.lzma"
167 if [ -n "$PATCH" ]; then
168 [ -z "$PTARBALL" ] && PTARBALL="$(basename $PATCH)"
169 fi
170 if [ -n "$WANTED" ]; then
171 basesrc="$WOK/$WANTED/source"
172 src="$basesrc/$WANTED-$VERSION"
173 install="$WOK/$WANTED/install"
174 wanted_stuff="$WOK/$WANTED/stuff"
175 fi
176 if [ -n "$SOURCE" ]; then
177 source_stuff="$WOK/$SOURCE/stuff"
178 fi
179 # Kernel version is set from wok/linux or installed/linux-api-headers(wok-undigest)
180 if [ -f "$WOK/linux/receipt" ]; then
181 kvers=$(grep ^VERSION= $WOK/linux/receipt | cut -d\" -f2)
182 kbasevers=${kvers:0:3}
183 elif [ -f "$INSTALLED/linux-api-headers/receipt" ]; then
184 kvers=$(grep ^VERSION= $INSTALLED/linux-api-headers/receipt | cut -d\" -f2)
185 kbasevers=${kvers:0:3}
186 fi
187 # Python version
188 if [ -f "$WOK/python/receipt" ]; then
189 pyvers=$(grep ^VERSION= $WOK/python/receipt | cut -d\" -f2)
190 fi
191 # Perl version for some packages needed it
192 if [ -f "$WOK/perl/receipt" ]; then
193 perlvers=$(grep ^VERSION= $WOK/perl/receipt | cut -d\" -f2)
194 fi
195 # Old way compatibility.
196 _pkg="$install"
197 }
200 # Create source tarball when URL is a SCM.
202 create_tarball() {
203 local tarball
204 tarball="$pkgsrc.tar.bz2"
205 [ -n "$LZMA_SRC" ] && tarball="$lzma_tarball"
206 _ 'Creating tarball "%s"' "$tarball"
207 if [ -n "$LZMA_SRC" ]; then
208 tar -c $pkgsrc | lzma e $SRC/$tarball -si $LZMA_SET_DIR || exit 1
209 LZMA_SRC=''
210 else
211 tar -cjf $tarball $pkgsrc || exit 1
212 mv $tarball $SRC; rm -rf $pkgsrc
213 fi
214 TARBALL="$tarball"
215 }
218 # Get package source. For SCM we are in cache so clone here and create a
219 # tarball here.
221 get_source() {
222 local url
223 url="$MIRROR_URL/sources/packages/${TARBALL:0:1}/$TARBALL"
224 set_paths
225 pwd=$(pwd)
226 case "$WGET_URL" in
227 http://*|ftp://*)
228 # Busybox Wget is better!
229 busybox wget -T 60 -c -O $SRC/$TARBALL $WGET_URL || \
230 busybox wget -T 60 -c -O $SRC/$TARBALL $url || \
231 (_ 'ERROR: %s' "wget $WGET_URL" && exit 1) ;;
233 https://*)
234 wget -c --no-check-certificate -O $SRC/$TARBALL $WGET_URL || \
235 busybox wget -T 60 -c -O $SRC/$TARBALL $url || \
236 (_ 'ERROR: %s' "wget $WGET_URL" && exit 1) ;;
238 hg*|mercurial*)
239 if $(echo "$WGET_URL" | fgrep -q 'hg|'); then
240 url=${WGET_URL#hg|}
241 else
242 url=${WGET_URL#mercurial|}
243 fi
244 _ 'Getting source from %s...' 'Hg'
245 _ 'URL: %s' "$url"
246 _ 'Cloning to "%s"' "$pwd/$pkgsrc"
247 if [ -n "$BRANCH" ]; then
248 _ 'Hg branch: %s' "$BRANCH"
249 hg clone $url --rev $BRANCH $pkgsrc || \
250 (_ 'ERROR: %s' "hg clone $url --rev $BRANCH" && exit 1)
251 else
252 hg clone $url $pkgsrc || (_ 'ERROR: %s' "hg clone $url" && exit 1)
253 fi
254 rm -rf $pkgsrc/.hg
255 create_tarball ;;
257 git*)
258 url=${WGET_URL#git|}
259 _ 'Getting source from %s...' 'Git'
260 _ 'URL: %s' "$url"
261 cd $SRC
262 git clone $url $pkgsrc || (_ 'ERROR: %s' "git clone $url" && exit 1)
263 if [ -n "$BRANCH" ]; then
264 _ 'Git branch: %s' "$BRANCH"
265 cd $pkgsrc; git checkout $BRANCH; cd ..
266 fi
267 cd $SRC
268 create_tarball ;;
270 cvs*)
271 url=${WGET_URL#cvs|}
272 mod=$PACKAGE
273 [ -n "$CVS_MODULE" ] && mod=$CVS_MODULE
274 _ 'Getting source from %s...' 'CVS'
275 _ 'URL: %s' "$url"
276 [ -n "$CVS_MODULE" ] && _ 'CVS module: %s' "$mod"
277 _ 'Cloning to "%s"' "$pwd/$mod"
278 cvs -d:$url co $mod && mv $mod $pkgsrc
279 create_tarball ;;
281 svn*|subversion*)
282 if $(echo "$WGET_URL" | fgrep -q "svn|"); then
283 url=${WGET_URL#svn|}
284 else
285 url=${WGET_URL#subversion|}
286 fi
287 _ 'Getting source from %s...' 'SVN'
288 _ 'URL: %s' "$url"
289 if [ -n "$BRANCH" ]; then
290 echo t | svn co $url -r $BRANCH $pkgsrc
291 else
292 echo t | svn co $url $pkgsrc
293 fi
294 create_tarball ;;
296 bzr*)
297 url=${WGET_URL#bzr|}
298 _ 'Getting source from %s...' 'bazaar'
299 cd $SRC
300 pkgsrc=${url#*:}
301 if [ -n "$BRANCH" ]; then
302 echo "bzr -Ossl.cert_reqs=none branch $url -r $BRANCH"
303 bzr -Ossl.cert_reqs=none branch $url -r $BRANCH
304 else
305 echo "bzr -Ossl.cert_reqs=none branch $url"
306 bzr -Ossl.cert_reqs=none branch $url
307 cd $pkgsrc; BRANCH=$(bzr revno); cd ..
308 _ "Don't forget to add to receipt:"
309 echo -e "BRANCH=\"$BRANCH\"\n"
310 fi
311 mv $pkgsrc $pkgsrc-$BRANCH
312 pkgsrc="$pkgsrc-$BRANCH"
313 create_tarball ;;
315 *)
316 (newline; _ 'ERROR: Unable to handle "%s"' "$WGET_URL"; newline) | \
317 tee -a $LOGS/$PACKAGE.log
318 exit 1 ;;
319 esac
320 }
323 # Extract source package.
325 extract_source() {
326 if [ ! -s "$SRC/$TARBALL" ]; then
327 local url
328 url="$MIRROR_URL/sources/packages"
329 url="$url/${TARBALL:0:1}/$TARBALL"
330 _ 'Getting source from %s...' 'mirror'
331 _ 'URL: %s' "$url"
332 busybox wget -c -P $SRC $url || _ 'ERROR: %s' "wget $url"
333 fi
334 _ 'Extracting source archive "%s"' "$TARBALL"
335 case "$TARBALL" in
336 *.tar.gz|*.tgz) tar -xzf $SRC/$TARBALL 2>/dev/null ;;
337 *.tar.bz2|*.tbz|*.tbz2) tar -xjf $SRC/$TARBALL 2>/dev/null ;;
338 *.tar.lzma) tar -xaf $SRC/$TARBALL ;;
339 *.tar.lz|*.tlz) lzip -d < $SRC/$TARBALL | tar -xf - 2>/dev/null ;;
340 *.tar) tar -xf $SRC/$TARBALL ;;
341 *.zip|*.xpi) unzip -o $SRC/$TARBALL ;;
342 *.xz) unxz -c $SRC/$TARBALL | tar -xf - || \
343 tar -xf $SRC/$TARBALL 2>/dev/null;;
344 *.7z) 7zr x $SRC/$TARBALL 2>/dev/null >&2 ;;
345 *.Z|*.z) uncompress -c $SRC/$TARBALL | tar -xf - ;;
346 *.rpm) rpm2cpio $SRC/$TARBALL | cpio -idm --quiet ;;
347 *.run) /bin/sh $SRC/$TARBALL $RUN_OPTS ;;
348 *) cp $SRC/$TARBALL $(pwd) ;;
349 esac
350 }
353 # Display time.
355 disp_time() {
356 local sec div min
357 sec="$1"
358 div=$(( ($1 + 30) / 60))
359 case $div in
360 0) min='';;
361 # L10n: 'm' is for minutes (approximate cooking time)
362 *) min=$(_n ' ~ %dm' "$div");;
363 esac
365 # L10n: 's' is for seconds (cooking time)
366 _ '%ds%s' "$sec" "$min"
367 }
370 # Display cooked package summary.
372 summary() {
373 set_paths
374 cd $WOK/$pkg
375 [ -d $WOK/$pkg/install ] && prod=$(du -sh $WOK/$pkg/install | awk '{print $1}' 2>/dev/null)
376 [ -d $WOK/$pkg/source ] && srcdir=$(du -sh $WOK/$pkg/source | awk '{print $1}' 2>/dev/null)
377 fs=$(du -sh $WOK/$pkg/taz/* | awk '{print $1}')
378 size=$(ls -lh $PKGS/$pkg-${VERSION}*.tazpkg | awk '{print $5}')
379 files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l)
380 [ -n "$TARBALL" ] && srcsize=$(du -sh $SRC/$TARBALL | awk '{print $1}')
382 _ 'Summary for: %s' "$PACKAGE $VERSION"
383 separator
385 # L10n: keep the same width of translations to get a consistent view
386 [ -n "$srcdir" ] && _ 'Source dir : %s' "$srcdir"
387 [ -n "$TARBALL" ] && _ 'Src file : %s' "$TARBALL"
388 [ -n "$srcsize" ] && _ 'Src size : %s' "$srcsize"
389 [ -n "$prod" ] && _ 'Produced : %s' "$prod"
390 _ 'Packed : %s' "$fs"
391 _ 'Compressed : %s' "$size"
392 _ 'Files : %s' "$files"
393 _ 'Cook time : %s' "$(disp_time "$time")"
394 _ 'Cook date : %s' "$(date "$(_ '+%%F %%R')")"
395 _ 'Host arch : %s' "$ARCH"
396 separator
397 }
400 # Display debugging error info.
402 debug_info() {
403 title 'Debug information'
404 # L10n: specify your format of date and time (to help: man date)
405 # L10n: not bad one is '+%x %R'
406 _ 'Cook date: %s' "$(date "$(_ '+%%F %%R')")"
407 [ "$time" ] && _ 'Cook time: %ds' "$(($(date +%s) - $time))"
408 # L10n: Please, translate all messages beginning with ERROR in a same way
409 lerror=$(_n 'ERROR')
410 for error in \
411 ERROR $lerror 'No package' "cp: can't" "can't open" "can't cd" \
412 'error:' 'fatal error:' 'undefined reference to' \
413 'Unable to connect to' 'link: cannot find the library' \
414 'CMake Error' ': No such file or directory' \
415 'Could not read symbols: File in wrong format'
416 do
417 fgrep "$error" $LOGS/$pkg.log
418 done > $LOGS/$pkg.log.debug_info 2>&1
419 cat $LOGS/$pkg.log.debug_info
420 rm -f $LOGS/$pkg.log.debug_info
421 footer
422 }
425 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
426 # so some packages need to copy these files with the receipt and genpkg_rules.
428 copy_generic_files() {
429 # $LOCALE is set in cook.conf
430 if [ -n "$LOCALE" -a -z "$WANTED" ]; then
431 if [ -d "$install/usr/share/locale" ]; then
432 mkdir -p $fs/usr/share/locale
433 for i in $LOCALE; do
434 if [ -d "$install/usr/share/locale/$i" ]; then
435 cp -a $install/usr/share/locale/$i $fs/usr/share/locale
436 fi
437 done
438 fi
439 fi
441 # Generic pixmaps copy can be disabled with COOKOPTS="!pixmaps" (or GENERIC_PIXMAPS="no")
442 if [ "${COOKOPTS/!pixmaps/}" == "$COOKOPTS" -a "$GENERIC_PIXMAPS" != 'no' ]; then
443 if [ -d "$install/usr/share/pixmaps" ]; then
444 mkdir -p $fs/usr/share/pixmaps
445 if [ -f "$install/usr/share/pixmaps/$PACKAGE.png" ]; then
446 cp -a $install/usr/share/pixmaps/$PACKAGE.png \
447 $fs/usr/share/pixmaps
448 elif [ -f "$install/usr/share/pixmaps/$PACKAGE.xpm" ]; then
449 cp -a $install/usr/share/pixmaps/$PACKAGE.xpm \
450 $fs/usr/share/pixmaps
451 fi
452 fi
454 # Custom or homemade PNG pixmap can be in stuff.
455 if [ -f "$stuff/$PACKAGE.png" ]; then
456 mkdir -p $fs/usr/share/pixmaps
457 cp -a $stuff/$PACKAGE.png $fs/usr/share/pixmaps
458 fi
459 fi
461 # Desktop entry (.desktop).
462 # Generic desktop entry copy can be disabled with COOKOPTS="!menus" (or GENERIC_MENUS="no")
463 if [ "${COOKOPTS/!menus/}" == "$COOKOPTS" -a "$GENERIC_MENUS" != 'no' ]; then
464 if [ -d "$install/usr/share/applications" ] && [ -z "$WANTED" ]; then
465 mkdir -p $fs/usr/share
466 cp -a $install/usr/share/applications $fs/usr/share
467 fi
468 fi
470 # Homemade desktop file(s) can be in stuff.
471 if [ -d "$stuff/applications" ]; then
472 mkdir -p $fs/usr/share
473 cp -a $stuff/applications $fs/usr/share
474 fi
475 if [ -f "$stuff/$PACKAGE.desktop" ]; then
476 mkdir -p $fs/usr/share/applications
477 cp -a $stuff/$PACKAGE.desktop $fs/usr/share/applications
478 fi
480 # Add custom licenses
481 if [ -d "$stuff/licenses" ]; then
482 mkdir -p $fs/usr/share/licenses
483 cp -a $stuff/licenses $fs/usr/share/licenses/$PACKAGE
484 fi
485 }
488 # Get list of supported locales...
490 get_supported_locales() {
491 local lpc='/slitaz-i18n/stuff/locale-pack.conf' LOCALE_PACK
492 if [ -e "$WOK$lpc" ]; then
493 # ... from package in the local wok
494 . "$WOK$lpc"
495 else
496 # ... from Hg
497 temp_conf=$(mktemp)
498 wget -q -O $temp_conf -T 10 "http://hg.slitaz.org/wok/raw-file/tip$lpc"
499 if [ -s $temp_conf ]; then
500 . $temp_conf
501 else
502 # Give up and use hardcoded list
503 LOCALE_PACK="ar ca cs da de el en es fi fr hr hu id is it ja nb nl nn pl pt \
504 pt_BR ro ru sl sv tr uk zh_CN zh_TW"
505 fi
506 rm $temp_conf
507 fi
508 echo $LOCALE_PACK
509 }
512 # Fix common errors and warnings in the .desktop files
513 # Fixing can be disabled with COOKOPTS="!fixdesktops"
515 fix_desktop_files() {
516 [ "${COOKOPTS/!fixdesktops/}" != "$COOKOPTS" ] && return
517 [ -z "$(find $install -type f -name '*.desktop')" ] && return
519 local size0=$(find $install -type f -name '*.desktop' -exec ls -l \{\} \; | awk '{s+=$5}END{print s}')
520 local time0=$(date +%s)
522 if [ -n "$QA" -a -z "$(which desktop-file-validate)" ]; then
523 tazpkg -gi desktop-file-utils-extra --quiet
524 fi
526 # The variable $LOCALE is set in cook.conf and may be overridden in the receipt.
527 # Default value is "" (empty). That means for us that we'll use the full
528 # list of supported locales here.
529 [ -z "$LOCALE" ] && LOCALE=$(get_supported_locales)
531 for desktop in $(find $install -type f -name '*.desktop'); do
532 cp "$desktop" "$desktop.orig"
534 # Sort out .desktop file (is prerequisite to correct working of `fix-desktop-file`)
535 sdft "$desktop" -i
537 # Fix common errors in .desktop file
538 fix-desktop-file "$desktop"
540 # Strip unsupported locales from .desktop file
541 [ "${COOKOPTS/!i18nz/}" == "$COOKOPTS" ] &&
542 sdft "$desktop" -i -k "$LOCALE"
544 # Extra-strip
545 [ "${COOKOPTS/!extradesktops/}" == "$COOKOPTS" ] &&
546 sdft "$desktop" -i -g -x -tf -r 'Keywords*' -o
548 if [ -n "$QA" ]; then
549 # Check the rest of errors, warnings and tips
550 _ 'QA: Checking %s...' "$(basename $desktop)"
551 diff "$desktop.orig" "$desktop"
552 desktop-file-validate "$desktop" | busybox fold -s
553 echo
554 fi
556 rm "$desktop.orig"
557 done
559 local size1=$(find $install -type f -name '*.desktop' -exec ls -l \{\} \; | awk '{s+=$5}END{print s}')
560 local time1=$(date +%s)
561 comp_summary "$time0" "$time1" "$size0" "$size1"
562 }
565 # Compressor mini summary
567 comp_summary() {
568 [ "$3" -eq 0 ] && return
569 local time=$(($2 - $1))
570 local saving=$(( ($3 - $4) / 1024 ))
571 _ ' Time: %s. Size: %s B -> %s B. Save: %s KB' "$(disp_time $time)" "$3" "$4" "$saving"
572 }
575 # Find and strip: --strip-all (-s) or --strip-debug on static libs as well
576 # as removing unneeded files like in Python packages. Cross compiled binaries
577 # must be stripped with cross-tools aka $ARCH-slitaz-*-strip
578 # Stripping can be disabled with COOKOPTS="!strip"
580 strip_package() {
581 [ "${COOKOPTS/!strip/}" != "$COOKOPTS" ] && return
583 case "$ARCH" in
584 arm*|x86_64) export STRIP="$HOST_SYSTEM-strip" ;;
585 *) export STRIP='strip' ;;
586 esac
587 action 'Executing strip on all files...'
588 local size0=0 size1=0 oldsize newsize
589 local time0=$(date +%s)
591 # Strip executable files
592 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games; do
593 if [ -d "$dir" ]; then
594 oldsize=$(find $dir -type f -exec ls -l '{}' \; | awk '{s+=$5}END{print s}')
595 find $dir -type f -exec $STRIP -s '{}' 2>/dev/null \;
596 newsize=$(find $dir -type f -exec ls -l '{}' \; | awk '{s+=$5}END{print s}')
597 size0=$((size0 + oldsize)); size1=$((size1 + newsize))
598 fi
599 done
601 # Strip shared and static libraries
602 # Remove Python *.pyc and *.pyo, Perl perllocal.pod and .packlist
603 oldsize=$(find $fs -type f \( \
604 -name '*.so*' -o -name '*.a' -o \
605 -name '*.pyc' -o -name '*.pyo' -o \
606 -name 'perllocal.pod' -o -name '.packlist' \) -exec ls -l '{}' \; | awk '{s+=$5}END{print s}')
608 find $fs -name '*.so*' -exec $STRIP -s '{}' 2>/dev/null \;
609 find $fs -name '*.a' -exec $STRIP --strip-debug '{}' 2>/dev/null \;
610 find $fs -type f \( -name '*.pyc' -o -name '*.pyo' \) -delete 2>/dev/null
611 find $fs -type f \( -name 'perllocal.pod' -o -name '.packlist' \) -delete 2>/dev/null
613 newsize=$(find $fs -type f \( \
614 -name '*.so*' -o -name '*.a' -o \) -exec ls -l '{}' \; | awk '{s+=$5}END{print s}')
616 size0=$((size0 + oldsize)); size1=$((size1 + newsize))
618 local time1=$(date +%s)
619 status
620 comp_summary "$time0" "$time1" "$size0" "$size1"
621 }
624 # Strip unsupported locales (.mo files)
626 strip_mo_i18n() {
627 [ "${COOKOPTS/!i18nz/}" != "$COOKOPTS" ] && return
629 [ ! -d "$fs/usr/share/locale" ] && return
630 [ -z "$(find $fs/usr/share/locale -type f -name '*.mo')" ] && return
632 action 'Thin out translation files...'
633 local size0=$(find $fs/usr/share/locale -type f -name '*.mo' -exec ls -l \{\} \; | awk '{s+=$5}END{print s}')
634 local time0=$(date +%s)
636 # The variable $LOCALE is set in cook.conf and may be overridden in the receipt.
637 # Default value is "" (empty). That means for us that we'll use the full
638 # list of supported locales here.
639 [ -z "$LOCALE" ] && LOCALE=$(get_supported_locales)
641 # Existing locales
642 elocales=" $(ls -1 "$fs/usr/share/locale" | tr '\n' ' ') "
644 # Thin out the list of existing locales. At the end there will be only locales that need
645 # to delete (and the garbage like '_AU', _US', '_BR' leaving from 'en_AU', 'en_US', 'pt_BR'...)
646 for keep_locale in $LOCALE; do
647 elocales=${elocales//$keep_locale}
648 done
650 # Remove the unsupported locales
651 for rem_locale in $elocales; do
652 [ -d "$fs/usr/share/locale/$rem_locale" ] &&
653 rm -r "$fs/usr/share/locale/$rem_locale"
654 done
656 local size1=$(find $fs -type f -name '*.mo' -exec ls -l \{\} \; | awk '{s+=$5}END{print s}')
657 local time1=$(date +%s)
658 status
659 comp_summary "$time0" "$time1" "$size0" "$size1"
660 }
663 # Normalize all *.mo files: unconditionally convert to UTF-8; remove strings that are really not add
664 # translation (msgid = msgstr)
665 # Normalization can be disabled with COOKOPTS="!monorm"
667 normalize_mo() {
668 [ "${COOKOPTS/!monorm/}" != "$COOKOPTS" ] && return
669 [ -z "$(find $install -type f -name '*.mo')" ] && return
671 action 'Normalizing mo files...'
672 local size0=$(find $install -type f -name '*.mo' -exec ls -l \{\} \; | awk '{s+=$5}END{print s}')
673 local time0=$(date +%s)
675 # Gettext functions: msgunfmt, msguniq, msgconv, msgfmt
676 tazpkg -gi gettext --quiet
677 # Gconv modules (convert to UTF-8)
678 tazpkg -gi glibc-locale --quiet
680 # Process all existing *.mo files
681 for mo in $(find "$install" -type f -name '*.mo'); do
682 tmpfile="$(mktemp)"
684 msgunfmt "$mo" | msguniq | msgconv -o "$tmpfile" -t 'UTF-8'
685 # add newline
686 echo >> "$tmpfile"
688 # get Plural-Forms
689 awk '
690 BEGIN { skip = ""; }
691 {
692 if (! skip) {
693 s = $0;
694 gsub(/^[^\"]*\"/, "", s);
695 gsub(/\"$/, "", s);
696 printf("%s", s);
697 }
698 if (! $0) skip = "yes";
699 }
700 ' "$tmpfile" | sed 's|\\n|\n|g' | grep "^Plural-Forms:" > "$tmpfile.pf"
702 if ! grep -q 'msgid_plural' "$tmpfile"; then
703 echo > "$tmpfile.pf"
704 fi
706 # main
707 awk -v pf="$(cat "$tmpfile.pf")" '
708 function clean() {
709 mode = msgctxt = msgid = msgid_plural = msgstr = msgstr0 = msgstr1 = msgstr2 = msgstr3 = msgstr4 = msgstr5 = "";
710 }
712 function getstring() {
713 # Skip unquoted words at the beginning (msgid, msgstr...) and get string from inside quotes
714 s = $0;
715 gsub(/^[^\"]*\"/, "", s);
716 gsub(/\"$/, "", s);
717 return s;
718 }
720 BEGIN {
721 printf("msgid \"\"\nmsgstr \"\"\n\"Content-Type: text/plain; charset=UTF-8\\n\"\n");
722 if (pf)
723 printf("\"%s\\n\"\n", pf);
724 printf("\n");
725 skip = 1;
726 clean();
727 }
729 {
730 # Skip the entire header
731 if (!skip) {
732 if ($1 == "msgctxt" || $1 == "msgid" || $1 == "msgstr" || $1 == "msgid_plural")
733 mode = $1;
734 if ($1 == "msgstr[0]") mode = "msgstr0";
735 if ($1 == "msgstr[1]") mode = "msgstr1";
736 if ($1 == "msgstr[2]") mode = "msgstr2";
737 if ($1 == "msgstr[3]") mode = "msgstr3";
738 if ($1 == "msgstr[4]") mode = "msgstr4";
739 if ($1 == "msgstr[5]") mode = "msgstr5";
741 if (mode == "msgctxt") msgctxt = msgctxt getstring();
742 if (mode == "msgid") msgid = msgid getstring();
743 if (mode == "msgstr") msgstr = msgstr getstring();
744 if (mode == "msgid_plural") msgid_plural = msgid_plural getstring();
745 if (mode == "msgstr0") msgstr0 = msgstr0 getstring();
746 if (mode == "msgstr1") msgstr1 = msgstr1 getstring();
747 if (mode == "msgstr2") msgstr2 = msgstr2 getstring();
748 if (mode == "msgstr3") msgstr3 = msgstr3 getstring();
749 if (mode == "msgstr4") msgstr4 = msgstr4 getstring();
750 if (mode == "msgstr5") msgstr5 = msgstr5 getstring();
752 if (! $0) {
753 if (msgid != msgstr) {
754 if (msgctxt) printf("msgctxt \"%s\"\n", msgctxt);
755 printf("msgid \"%s\"\n", msgid);
756 if (msgid_plural) printf("msgid_plural \"%s\"\n", msgid_plural);
757 if (msgstr) printf("msgstr \"%s\"\n", msgstr);
758 if (msgstr0) printf("msgstr[0] \"%s\"\n", msgstr0);
759 if (msgstr1) printf("msgstr[1] \"%s\"\n", msgstr1);
760 if (msgstr2) printf("msgstr[2] \"%s\"\n", msgstr2);
761 if (msgstr3) printf("msgstr[3] \"%s\"\n", msgstr3);
762 if (msgstr4) printf("msgstr[4] \"%s\"\n", msgstr4);
763 if (msgstr5) printf("msgstr[5] \"%s\"\n", msgstr5);
764 printf("\n");
765 }
766 clean();
767 }
768 }
769 if ($0 == "") skip = "";
770 }
771 ' "$tmpfile" > "$tmpfile.awk"
773 msgfmt "$tmpfile.awk" -o "$tmpfile.mo"
775 if [ -s "$tmpfile.mo" ]; then
776 rm "$mo"; mv "$tmpfile.mo" "$mo"
777 else
778 _ 'Error processing %s' "$mo"
779 [ -e "$tmpfile.mo" ] && rm "$tmpfile.mo"
780 fi
782 # Clean
783 rm "$tmpfile" "$tmpfile.pf" "$tmpfile.awk"
784 done
786 local size1=$(find $install -type f -name '*.mo' -exec ls -l \{\} \; | awk '{s+=$5}END{print s}')
787 local time1=$(date +%s)
788 status
789 comp_summary "$time0" "$time1" "$size0" "$size1"
790 }
793 # Update installed.cook.diff
795 update_installed_cook_diff() {
796 # If a cook failed deps are removed.
797 cd $root$INSTALLED; ls -1 > $CACHE/installed.cook
798 cd $CACHE
799 [ "$1" == 'force' -o ! -s '/tmp/installed.cook.diff' ] && \
800 busybox diff installed.list installed.cook > /tmp/installed.cook.diff
801 deps=$(cat /tmp/installed.cook.diff | grep ^+[a-zA-Z0-9] | wc -l)
802 }
805 # Remove installed deps.
807 remove_deps() {
808 # Now remove installed build deps.
809 diff='/tmp/installed.cook.diff'
810 if [ -s $diff ]; then
811 deps=$(cat $diff | grep ^+[a-zA-Z0-9] | sed s/^+//)
812 nb=$(cat $diff | grep ^+[a-zA-Z0-9] | wc -l)
813 _n 'Build dependencies to remove:'; echo " $nb"
814 [ -n "$root" ] && echo "root=\"$root\""
815 _n 'Removing:'
816 for dep in $deps; do
817 echo -n " $dep"
818 echo 'y' | tazpkg remove $dep --root=$root >/dev/null
819 done
820 newline; newline
821 # Keep the last diff for debug and info.
822 mv -f $diff $CACHE/installed.diff
823 fi
824 }
827 # Function to compress all man pages
828 # Compressing can be disabled with COOKOPTS="!manz"
830 compress_manpages() {
831 [ "${COOKOPTS/!manz/}" != "$COOKOPTS" ] && return
833 case "$ARCH" in
834 arm*) return;; # While SliTaz-arm miss `advancecomp`
835 esac
836 local manpath="$install/usr/share/man" dest link
837 [ -d "$manpath" ] || return
839 action 'Compressing man pages...'
841 local size0=$(find $install/usr/share/man -type f -exec ls -l \{\} \; | awk '{s+=$5}END{print s}')
842 local time0=$(date +%s)
843 # We'll use only Gzip compression, so decompress other formats first
844 find $manpath -type f -name '*.bz2' -exec bunzip2 \{\} \;
845 find $manpath -type f -name '*.xz' -exec unxz \{\} \;
847 # Fast compress with gzip
848 find $manpath -type f -name '*.[1-9]*' -exec gzip \{\} \;
850 # Fix symlinks
851 for i in $(find $install/usr/share/man -type l); do
852 dest=$(readlink $i | sed 's|\.[gbx]z2*$||')
853 link=$(echo $i | sed 's|\.[gbx]z2*$||')
854 rm $i; ln -s $dest.gz $link.gz
855 done
857 # Recompress with advdef (it can't compress, only recompress)
858 tazpkg -gi advancecomp --quiet
859 for i in $(find $install/usr/share/man -type f); do
860 advdef -z4q $i
861 done
863 local size1=$(find $install/usr/share/man -type f -exec ls -l \{\} \; | awk '{s+=$5}END{print s}')
864 local time1=$(date +%s)
865 status
866 comp_summary "$time0" "$time1" "$size0" "$size1"
867 }
870 # Function used after compile_rules() to compress all png images
871 # Compressing can be disabled with COOKOPTS="!pngz"
873 compress_png() {
874 [ "${COOKOPTS/!pngz/}" != "$COOKOPTS" ] && return
875 case "$ARCH" in
876 arm*) return;; # While SliTaz-arm miss `pngquant` and `optipng`
877 esac
878 [ -z "$(find $install -type f -name '*.png')" ] && return
880 action 'Compressing png images...'
881 local size0=$(find $install -type f -name '*.png' -exec ls -l \{\} \; | awk '{s+=$5}END{print s}')
882 local time0=$(date +%s)
884 local use_pq=true use_op=true
885 [ "${COOKOPTS/!pngquant/}" != "$COOKOPTS" ] && use_pq=false
886 [ "${COOKOPTS/!optipng/}" != "$COOKOPTS" ] && use_op=false
888 $use_pq && tazpkg -gi pngquant --quiet
889 $use_op && tazpkg -gi optipng --quiet
891 local oplevel=$(echo $COOKOPTS | grep 'op[0-8]' | sed 's|.*op\([0-8]\).*|\1|')
892 [ -z "$oplevel" ] && oplevel='2'
893 [ "$oplevel" == '8' ] && oplevel='7 -zm1-9'
895 for i in $(find $install -type f -name '*.png'); do
896 $use_pq && pngquant -f --skip-if-larger --ext .png --speed 1 "$i"
897 $use_op && optipng -quiet -strip all -o$oplevel "$i"
898 done
900 local size1=$(find $install -type f -name '*.png' -exec ls -l \{\} \; | awk '{s+=$5}END{print s}')
901 local time1=$(date +%s)
902 status
903 comp_summary "$time0" "$time1" "$size0" "$size1"
904 }
907 # Function used after compile_rules() to compress all svg images
908 # Compressing can be disabled with COOKOPTS="!svgz"
910 compress_svg() {
911 [ "${COOKOPTS/!svgz/}" != "$COOKOPTS" ] && return
912 case "$ARCH" in
913 arm*) return;; # While SliTaz-arm miss `svgcleaner`
914 esac
915 [ -z "$(find $install -type f -name '*.svg')" ] && return
917 action 'Compressing svg images...'
918 local size0=$(find $install -type f -name '*.svg' -exec ls -l \{\} \; | awk '{s+=$5}END{print s}')
919 local time0=$(date +%s)
920 tazpkg -gi svgcleaner --quiet
921 cleaner_log="$(mktemp)"
922 for i in $(find $install -type f -name '*.svg'); do
923 echo -n "$i: " >> "$cleaner_log"
924 svgcleaner "$i" "$i" --remove-unresolved-classes false --quiet true >> "$cleaner_log"
925 done
926 local size1=$(find $install -type f -name '*.svg' -exec ls -l \{\} \; | awk '{s+=$5}END{print s}')
927 local time1=$(date +%s)
928 status
929 comp_summary "$time0" "$time1" "$size0" "$size1"
930 sed -i '/: $/d' "$cleaner_log"
931 if [ -s "$cleaner_log" ]; then
932 echo 'Cleaner warnings and errors:'
933 awk '{printf " %s\n", $0;}' "$cleaner_log"
934 echo
935 fi
936 rm "$cleaner_log"
937 }
940 # Function used after compile_rules() to shrink all *.ui and *.glade files:
941 # remove insignificant spaces and comments
942 # Compressing can be disabled with COOKOPTS="!uiz"
944 compress_ui() {
945 [ "${COOKOPTS/!uiz/}" != "$COOKOPTS" ] && return
946 case "$ARCH" in
947 arm*) return;; # While SliTaz-arm miss `xmlstarlet`
948 esac
949 [ -z "$(find $install -type f \( -name '*.ui' -o -name '*.glade' \) )" ] && return
951 action 'Compressing ui files...'
952 local size0=$(find $install -type f \( -name '*.ui' -o -name '*.glade' \) -exec ls -l \{\} \; | awk '{s+=$5}END{print s}')
953 local time0=$(date +%s)
954 tazpkg -gi xmlstarlet --quiet
955 temp_ui="$(mktemp)"
956 for ui in $(find $install -type f \( -name '*.ui' -o -name '*.glade' \) ); do
957 xmlstarlet c14n --without-comments "$ui" | xmlstarlet sel -B -t -c '*' > "$temp_ui"
958 cat "$temp_ui" > "$ui"
959 done
960 local size1=$(find $install -type f \( -name '*.ui' -o -name '*.glade' \) -exec ls -l \{\} \; | awk '{s+=$5}END{print s}')
961 local time1=$(date +%s)
962 status
963 comp_summary "$time0" "$time1" "$size0" "$size1"
964 rm "$temp_ui"
965 }
968 # The main cook function.
970 cookit() {
971 title 'Cook: %s' "$PACKAGE $VERSION"
972 set_paths
974 # Handle cross-tools.
975 case "$ARCH" in
976 arm*|x86_64)
977 # CROSS_COMPILE is used by at least Busybox and the kernel to set
978 # the cross-tools prefix. Sysroot is the root of our target arch
979 sysroot="$CROSS_TREE/sysroot"
980 tools="$CROSS_TREE/tools"
981 # Set root path when cross compiling. ARM tested but not x86_64
982 # When cross compiling we must install build deps in $sysroot.
983 arch="-$ARCH"
984 root="$sysroot"
985 _ '%s sysroot: %s' "$ARCH" "$sysroot"
986 _ 'Adding "%s" to PATH' "$tools/bin"
987 export PATH="$PATH:$tools/bin"
988 export PKG_CONFIG_PATH="$sysroot/usr/lib/pkgconfig"
989 export CROSS_COMPILE="$HOST_SYSTEM-"
990 _ 'Using cross-tools: %s' "$CROSS_COMPILE"
991 if [ "$ARCH" == 'x86_64' ]; then
992 export CC="$HOST_SYSTEM-gcc -m64"
993 export CXX="$HOST_SYSTEM-g++ -m64"
994 else
995 export CC="$HOST_SYSTEM-gcc"
996 export CXX="$HOST_SYSTEM-g++"
997 fi
998 export AR="$HOST_SYSTEM-ar"
999 export AS="$HOST_SYSTEM-as"
1000 export RANLIB="$HOST_SYSTEM-ranlib"
1001 export LD="$HOST_SYSTEM-ld"
1002 export STRIP="$HOST_SYSTEM-strip"
1003 export LIBTOOL="$HOST_SYSTEM-libtool" ;;
1004 esac
1006 [ -n "$QA" ] && receipt_quality
1007 cd $pkgdir
1008 [ -z "$continue" ] && rm -rf source 2>/dev/null
1009 rm -rf install taz 2>/dev/null
1011 # Disable -pipe if less than 512Mb free RAM.
1012 free=$(free | awk '/buffers:/{print $4}')
1013 if [ "$free" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then
1014 _ 'Disabling -pipe compile flag: %d RAM free' "$free"
1015 CFLAGS="${CFLAGS/-pipe}"; CFLAGS=$(echo "$CFLAGS" | tr -s ' ')
1016 CXXFLAGS="${CXXFLAGS/-pipe}"; CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ')
1017 fi
1018 unset free
1020 # Export flags and path to be used by make and receipt.
1021 DESTDIR="$pkgdir/install"
1022 # FIXME: L10n: Is this the right time for 'LC_ALL=C LANG=C'?
1023 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS CONFIG_SITE LC_ALL=C LANG=C
1024 #LDFLAGS
1026 # Check for build deps and handle implicit depends of *-dev packages
1027 # (ex: libusb-dev :: libusb).
1028 rm -f $CACHE/installed.local $CACHE/installed.web $CACHE/missing.dep
1029 touch $CACHE/installed.local $CACHE/installed.web
1030 [ -n "$BUILD_DEPENDS" ] && _ 'Checking build dependencies...'
1031 [ -n "$root" ] && _ 'Using packages DB: %s' "$root$DB"
1032 for dep in $BUILD_DEPENDS; do
1033 implicit="${dep%-dev}"
1034 # Don't add implicit dependency if it defined in DEPENDS
1035 # echo '' $DEPENDS '' | fgrep -q " $implicit " && implicit=''
1036 for i in $dep $implicit; do
1037 if [ ! -f "$root$INSTALLED/$i/receipt" ]; then
1038 # Try local package first. In some cases implicit doesn't exist, ex:
1039 # libboost-dev exists but not libboost, so check if we got vers.
1040 unset vers
1041 vers=$(. $WOK/$i/receipt 2>/dev/null ; echo $VERSION)
1042 # We may have a local package.
1043 if [ -z "$vers" ]; then
1044 vers=$(awk -F$'\t' -vp="$i" '$1==p{print $2; quit}' $PKGS/packages.info 2> /dev/null)
1045 fi
1046 debug "bdep: $i version: $vers"
1047 if [ -f "$PKGS/$i-$vers$arch.tazpkg" ]; then
1048 echo $i-$vers$arch.tazpkg >> $CACHE/installed.local
1049 else
1050 # Priority to package version in wok (maybe more up-to-date)
1051 # than the mirrored one.
1052 if [ -n "$vers" ]; then
1053 if fgrep -q $i-$vers$arch $root$DB/packages.list; then
1054 echo $i >> $CACHE/installed.web
1055 else
1056 # So package exists in wok but not available.
1057 _ 'Missing dep (wok/pkg): %s' "$i $vers"
1058 echo $i >> $CACHE/missing.dep
1059 fi
1060 else
1061 # Package is not in wok but may be in online repo.
1062 if fgrep -q $i-$vers$arch $root$DB/packages.list; then
1063 echo $i >> $CACHE/installed.web
1064 else
1065 _ 'ERROR: unknown dep "%s"' "$i"
1066 exit 1
1067 fi
1068 fi
1069 fi
1070 fi
1071 done
1072 done
1074 # Get the list of installed packages
1075 cd $root$INSTALLED; ls -1 > $CACHE/installed.list
1077 # Have we a missing build dep to cook?
1078 if [ -s "$CACHE/missing.dep" ] && [ -n "$AUTO_COOK" ]; then
1079 _ 'Auto cook config is set: %s' "$AUTO_COOK"
1080 cp -f $LOGS/$PACKAGE.log $LOGS/$PACKAGE.log.$$
1081 for i in $(uniq $CACHE/missing.dep); do
1082 (_ 'Building dep (wok/pkg) : %s' "$i $vers") | \
1083 tee -a $LOGS/$PACKAGE.log.$$
1084 # programmers: next two messages are exact copy from remove_deps()
1085 togrep1=$(_n 'Build dependencies to remove:')
1086 togrep2=$(_n 'Removing:')
1087 cook $i || (_ "ERROR: can't cook dep \"%s\"" "$i" && newline && \
1088 fgrep $togrep1 $LOGS/$i.log && \
1089 fgrep $togrep2 $LOGS/$i.log && newline) | \
1090 tee -a $LOGS/$PACKAGE.log.$$ && break
1091 done
1092 rm -f $CACHE/missing.dep
1093 mv $LOGS/$PACKAGE.log.$$ $LOGS/$PACKAGE.log
1094 fi
1096 # QA: Exit on missing dep errors. We exit in both cases, if AUTO_COOK
1097 # is enabled and cook fails we have ERROR in log, if no auto cook we have
1098 # missing dep in cached file.
1099 lerror=$(_n 'ERROR')
1100 if fgrep -q ^$lerror $LOGS/$pkg.log || [ -s "$CACHE/missing.dep" ]; then
1101 [ -s "$CACHE/missing.dep" ] && nb=$(cat $CACHE/missing.dep | wc -l)
1102 _p 'ERROR: missing %d dependency' 'ERROR: missing %d dependencies' "$nb" "$nb"
1103 exit 1
1104 fi
1106 # Install local packages: package-version$arch
1107 cd $PKGS
1108 for i in $(uniq $CACHE/installed.local); do
1109 _ 'Installing dep (pkg/local): %s' "$i"
1110 tazpkg install $i --root=$root --local --quiet
1111 done
1113 # Install web or cached packages (if mirror is set to $PKGS we only
1114 # use local packages).
1115 for i in $(uniq $CACHE/installed.web); do
1116 _ 'Installing dep (web/cache): %s' "$i"
1117 tazpkg get-install $i --root=$root --quiet
1118 done
1120 update_installed_cook_diff
1122 # Get source tarball and make sure we have source dir named:
1123 # $PACKAGE-$VERSION to be standard in receipts. Here we use tar.lzma
1124 # tarball if it exists.
1125 if [ -n "$WGET_URL" ] && [ ! -f "$SRC/$TARBALL" ]; then
1126 if [ -f "$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
1127 TARBALL="${SOURCE:-$PACKAGE}-$VERSION.tar.lzma"
1128 LZMA_SRC=''
1129 else
1130 get_source || exit 1
1131 fi
1132 fi
1133 if [ -z "$WANTED" ] && [ -n "$TARBALL" ] && [ ! -d "$src" ]; then
1134 mkdir -p $pkgdir/source/tmp; cd $pkgdir/source/tmp
1135 if ! extract_source ; then
1136 get_source
1137 extract_source || exit 1
1138 fi
1139 if [ -n "$LZMA_SRC" ]; then
1140 cd $pkgdir/source
1141 if [ "$(ls -A tmp | wc -l)" -gl 1 ] || [ -f "$(echo tmp/*)" ]; then
1142 mv tmp tmp-1; mkdir tmp
1143 mv tmp-1 tmp/${SOURCE:-$PACKAGE}-$VERSION
1144 fi
1145 if [ -d "tmp/${SOURCE:-$PACKAGE}-$VERSION" ]; then
1146 cd tmp; tar -c * | lzma e $SRC/$TARBALL -si
1147 fi
1148 fi
1149 cd $pkgdir/source/tmp
1150 # Some archives are not well done and don't extract to one dir (ex lzma).
1151 files=$(ls | wc -l)
1152 [ "$files" == 1 ] && [ -d "$(ls)" ] && mv * ../$PACKAGE-$VERSION
1153 [ "$files" == 1 ] && [ -f "$(ls)" ] && mkdir -p ../$PACKAGE-$VERSION && \
1154 mv * ../$PACKAGE-$VERSION/$TARBALL
1155 [ "$files" -gt 1 ] && mkdir -p ../$PACKAGE-$VERSION && \
1156 mv * ../$PACKAGE-$VERSION
1157 cd ..; rm -rf tmp
1158 fi
1160 # Libtool shared libs path hack.
1161 case "$ARCH" in
1162 arm*) cross libhack ;;
1163 esac
1165 # Execute receipt rules.
1166 if grep -q ^compile_rules $receipt; then
1167 _ 'Executing: %s' 'compile_rules'
1168 echo "CFLAGS : $CFLAGS"
1169 #echo "LDFLAGS : $LDFLAGS"
1170 [ -d "$src" ] && cd $src
1171 compile_rules $@ || exit 1
1172 # Stay compatible with _pkg
1173 [ -d "$src/_pkg" ] && mv $src/_pkg $install
1174 # QA: compile_rules success so valid.
1175 mkdir -p $install
1176 else
1177 # QA: no compile_rules so no error, valid.
1178 mkdir -p $install
1179 fi
1181 # Actions to do after compiling the package
1182 # Skip all for splitted packages (already done in main package)
1183 if [ -z "$WANTED" ]; then
1184 footer
1185 compress_manpages
1186 compress_png
1187 compress_svg
1188 compress_ui
1189 fix_desktop_files
1190 normalize_mo
1191 fi
1192 footer
1194 # Execute testsuite.
1195 if grep -q ^testsuite $receipt; then
1196 title 'Running testsuite'
1197 testsuite $@ || exit 1
1198 footer
1199 fi
1201 update_installed_cook_diff force
1205 # Cook quality assurance.
1207 cookit_quality() {
1208 if [ ! -d "$WOK/$pkg/install" ] && [ -z "$WANTED" ]; then
1209 _ 'ERROR: cook failed' | tee -a $LOGS/$pkg.log
1210 fi
1211 # ERROR can be echoed any time in cookit()
1212 lerror=$(_n 'ERROR')
1213 if grep -Ev "(conftest|configtest)" $LOGS/$pkg.log | \
1214 grep -Eq "(^$lerror|undefined reference to)" ; then
1215 debug_info | tee -a $LOGS/$pkg.log
1216 rm -f $command
1217 exit 1
1218 fi
1222 # Create the package. Wanted to use TazPkg to create a tazpkg package at first,
1223 # but it doesn't handle EXTRAVERSION.
1225 packit() {
1226 set_paths
1228 # Handle cross compilation
1229 case "$ARCH" in
1230 arm*|x86_64) arch="-$ARCH" ;;
1231 esac
1233 title 'Pack: %s' "$PACKAGE $VERSION$arch"
1235 if grep -q ^genpkg_rules $receipt; then
1236 _ 'Executing: %s' 'genpkg_rules'
1237 set -e; cd $pkgdir; mkdir -p $fs
1238 genpkg_rules || (newline; _ 'ERROR: genpkg_rules failed'; newline) >> \
1239 $LOGS/$pkg.log
1240 else
1241 _ 'No packages rules: meta package'
1242 mkdir -p $fs
1243 fi
1245 # First QA check to stop now if genpkg_rules failed.
1246 lerror=$(_n 'ERROR')
1247 if fgrep -q ^$lerror $LOGS/$pkg.log; then
1248 exit 1
1249 fi
1251 cd $taz
1252 for file in receipt description.txt; do
1253 [ ! -f "../$file" ] && continue
1254 action 'Copying "%s"...' "$file"
1255 cp -f ../$file $pack; chown 0.0 $pack/$file; status
1256 done
1257 copy_generic_files
1259 # Strip and stuff files.
1260 strip_package
1261 strip_mo_i18n
1263 # Create files.list with redirecting find output.
1264 action 'Creating the list of files...'
1265 cd $fs
1266 find . -type f -print > ../files.list
1267 find . -type l -print >> ../files.list
1268 cd ..; sed -i s/'^.'/''/ files.list
1269 status
1271 # Md5sum of files.
1272 action 'Creating md5sum of files...'
1273 while read file; do
1274 [ -L "fs$file" ] && continue
1275 [ -f "fs$file" ] || continue
1276 case "$file" in
1277 /lib/modules/*/modules.*|*.pyc) continue ;;
1278 esac
1279 md5sum "fs$file" | sed 's/ fs/ /'
1280 done < files.list > md5sum
1281 status
1283 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
1284 2>/dev/null | awk 'END{ print $1 }')
1286 # Build cpio archives.
1287 action 'Compressing the FS...'
1288 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
1289 rm -rf fs
1290 status
1292 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list md5sum description.txt \
1293 2>/dev/null | awk 'END{ print $1 }')
1295 action 'Updating receipt sizes...'
1296 sed -i s/^PACKED_SIZE.*$// receipt
1297 sed -i s/^UNPACKED_SIZE.*$// receipt
1298 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
1299 status
1301 # Set extra version.
1302 if [ -n "$EXTRAVERSION" ]; then
1303 action 'Updating receipt EXTRAVERSION: %s' "$EXTRAVERSION"
1304 sed -i s/^EXTRAVERSION.*$// receipt
1305 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
1306 status
1307 fi
1309 # Compress.
1310 action 'Creating full cpio archive...'
1311 find . -print | cpio -o -H newc --quiet > \
1312 ../$PACKAGE-$VERSION$EXTRAVERSION$arch.tazpkg
1313 status
1315 action 'Restoring original package tree...'
1316 unlzma -c fs.cpio.lzma | cpio -idm --quiet
1317 status
1319 rm fs.cpio.lzma; cd ..
1321 # QA and give info.
1322 tazpkg=$(ls *.tazpkg)
1323 packit_quality
1324 footer "$(_ 'Package "%s" created' "$tazpkg")"
1328 # Verify package quality and consistency.
1330 packit_quality() {
1331 #action 'QA: checking for broken link...'
1332 #link=$(find $fs/usr -type l -follow)
1333 #[ "$link" ] && echo -e "\nERROR: broken link in filesystem"
1334 #status
1336 # Exit if any error found in log file.
1337 lerror=$(_n 'ERROR')
1338 if fgrep -q ^$lerror $LOGS/$pkg.log; then
1339 rm -f $command
1340 exit 1
1341 fi
1343 action 'QA: checking for empty package...'
1344 files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l)
1345 if [ "$files" -eq 0 -a "$CATEGORY" != 'meta' ]; then
1346 newline; _ 'ERROR: empty package'
1347 rm -f $command
1348 exit 1
1349 else
1350 :; status
1351 # Find and remove old package(s)
1352 tempd="$(mktemp -d)"; cd "$tempd"
1353 for testpkg in $(ls $PKGS/$pkg-*.tazpkg 2> /dev/null); do
1354 # Extract receipt from each matched package
1355 cpio -F "$testpkg" -i receipt >/dev/null 2>&1
1356 name=$(. receipt; echo $PACKAGE)
1357 rm receipt
1358 if [ "$name" == "$pkg" ]; then
1359 action 'Removing old package "%s"' "$(basename "$testpkg")"
1360 rm -f "$testpkg"
1361 status
1362 fi
1363 done
1364 rm -r "$tempd"
1365 mv -f $pkgdir/taz/$pkg-*.tazpkg $PKGS
1366 sed -i /^${pkg}$/d $broken
1367 #action 'Removing source tree...'
1368 #rm -f $WOK/$pkg/source; status
1369 fi
1373 # Reverse "cat" command: prints input lines in the reverse order
1375 tac() {
1376 sed '1!G;h;$!d' $1
1380 # Install package on --install or update the chroot.
1382 install_package() {
1383 case "$ARCH" in
1384 arm*|x86_64)
1385 arch="-$ARCH"
1386 root="$CROSS_TREE/sysroot" ;;
1387 esac
1388 # Install package if requested but skip install if target host doesn't
1389 # match build system or it will break the build chroot.
1390 build=$(echo $BUILD_SYSTEM | cut -d- -f1)
1391 if [ -n "$inst" ] && [ "$build" == "$ARCH" ]; then
1392 if [ -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ]; then
1393 cd $PKGS
1394 tazpkg install $PACKAGE-$VERSION$EXTRAVERSION.tazpkg --forced
1395 else
1396 _ 'Unable to install package, build has failed.'; newline
1397 exit 1
1398 fi
1399 fi
1401 # Install package if part of the chroot to keep env up-to-date.
1402 if [ -d "$root$INSTALLED/$pkg" ]; then
1403 . /etc/slitaz/cook.conf
1404 . $WOK/$pkg/taz/$pkg-*/receipt
1405 _ 'Updating %s chroot environment...' "$ARCH"
1406 _ 'Updating chroot: %s' "$pkg ($VERSION$EXTRAVERSION$arch)" | log
1407 cd $PKGS
1408 tazpkg install $pkg-$VERSION$EXTRAVERSION$arch.tazpkg --forced --root=$root
1409 fi
1413 # remove chroot jail
1415 umount_aufs() {
1416 tac ${1}rw/aufs-umount.sh | sh
1417 rm -rf ${1}rw
1418 umount ${1}root
1419 rmdir ${1}r*
1423 # Launch the cook command into a chroot jail protected by aufs.
1424 # The current filesystems are used read-only and updates are
1425 # stored in a separate branch.
1427 try_aufs_chroot() {
1429 base="/dev/shm/aufsmnt$$"
1431 # Can we setup the chroot? Is it already done?
1432 grep -q ^AUFS_NOT_SUPPORTED $receipt && return
1433 grep -q ^AUFS_NOT_RAMFS $receipt && base="/mnt/aufsmnt$$"
1434 [ -n "$AUFS_MOUNTS" -a ! -f /aufs-umount.sh ] || return
1435 lsmod | grep -q aufs || modprobe aufs 2> /dev/null || return
1436 mkdir ${base}root ${base}rw || return
1438 _ 'Setup aufs chroot...'
1440 # Sanity check
1441 for i in / /proc /sys /dev/shm /home ; do
1442 case " $AUFS_MOUNTS " in
1443 *\ $i\ *) ;;
1444 *) AUFS_MOUNTS="$AUFS_MOUNTS $i" ;;
1445 esac
1446 done
1447 for mnt in $(ls -d $AUFS_MOUNTS | sort | uniq); do
1448 mount --bind $mnt ${base}root$mnt
1449 if [ $mnt == / ] && ! mount -t aufs -o br=${base}rw:/ none ${base}root; then
1450 _ 'Aufs mount failure'
1451 umount ${base}root
1452 rm -rf ${base}r*
1453 return
1454 fi
1455 echo "umount ${base}root$mnt" >> ${base}rw/aufs-umount.sh
1456 done
1457 trap "umount_aufs ${base}" INT
1459 chroot ${base}root $(cd $(dirname $0); pwd)/$(basename $0) "$@"
1460 status=$?
1462 _ 'Leaving aufs chroot...'
1463 umount_aufs $base
1464 # Install package outside the aufs jail
1465 install_package
1466 exit $status
1470 # Encode predefined XML entities
1472 xml_ent() {
1473 sed -e 's|&|\&amp;|g; s|<|\&lt;|g; s|>|\&gt;|g; s|"|\&quot;|g' -e "s|'|\&apos;|g"
1477 # Create a XML feed for freshly built packages.
1479 gen_rss() {
1480 pubdate=$(date '+%a, %d %b %Y %X')
1481 cat > $FEEDS/$pkg.xml <<EOT
1482 <item>
1483 <title>$PACKAGE $VERSION$EXTRAVERSION</title>
1484 <link>${COOKER_URL}?pkg=$PACKAGE</link>
1485 <guid>$PACKAGE-$VERSION$EXTRAVERSION</guid>
1486 <pubDate>$pubdate</pubDate>
1487 <description>$(echo -n "$SHORT_DESC" | xml_ent)</description>
1488 </item>
1489 EOT
1493 # Truncate stdout log file to $1 Mb.
1495 loglimit() {
1496 if [ -n "$DEFAULT_LOG_LIMIT" ]; then
1497 tee /dev/stderr | head -qc ${1:-$DEFAULT_LOG_LIMIT}m
1498 else
1499 tee /dev/stderr
1500 fi
1504 # Search file in mirrored packages
1506 search_file_mirror() {
1507 busybox unlzma -c $DB/files.list.lzma | grep $1\$ | cut -d: -f1 | sort -u
1511 # Search file in local wok packages
1513 search_file_local() {
1514 # existing packages have precedence over the package/taz folder
1515 srch=$1
1516 { for package in $(find $PKGS -name '*.tazpkg'); do
1517 if [ -n "$(busybox cpio --to-stdout --quiet -i files.list < $package | \
1518 grep /$srch\$)" ]; then
1519 busybox cpio -i receipt < $package | fgrep PACKAGE | cut -d\" -f2
1520 fi
1521 done } | sort -u
1525 # Ask in multiple choice
1527 ask_multiple() {
1528 local multiples first my_choice
1529 multiples="$1"
1530 first=$(echo "$multiples" | head -n1)
1531 newline; _ 'Multiple choice:'; echo "$multiples"; newline
1532 _ 'Select one [%s]: ' "$first"; read my_choice
1533 found="${my_choice:-$first}"
1537 # Search file in local cache (fast), local wok packages, mirrored packages
1539 search_file() {
1540 local srch cache missing
1541 srch="$1"
1542 cache='/var/cache/ldsearch.cache'
1543 missing='/var/cache/missing.file'
1544 touch $cache $missing
1545 found=$(grep $srch $cache | cut -d$'\t' -f2)
1546 if [ -z "$found" ]; then
1547 found=$(search_file_local $srch)
1548 if [ -n "$found" ]; then
1549 if [ $(echo "$found" | wc -l) -gt 1 ]; then
1550 ask_multiple "$found"
1551 fi
1552 echo -e "$srch\t$found" >> $cache
1553 else
1554 found=$(search_file_mirror $srch)
1555 if [ -n "$found" ]; then
1556 if [ $(echo "$found" | wc -l) -gt 1 ]; then
1557 ask_multiple "$found"
1558 fi
1559 echo -e "$srch\t$found" >> $cache
1560 else
1561 echo "$srch" >> $missing
1562 fi
1563 fi
1564 fi
1568 # Return size of file in human readible format
1569 # Note, "du" in opposite returns size occupied by file on disk (4KB multiple in most cases)
1570 filesize() {
1571 busybox ls -lh "$1" | awk '{print $5 "B"}'
1576 # Receipt functions to ease packaging
1579 get_dev_files() {
1580 action 'Getting standard devel files...'
1581 mkdir -p $fs/usr/lib
1582 cp -a $install/usr/lib/pkgconfig $fs/usr/lib
1583 cp -a $install/usr/lib/*a $fs/usr/lib
1584 cp -a $install/usr/include $fs/usr
1585 status
1589 # Function to use in compile_rules() to copy man page from $src to $install
1591 cook_pick_manpages() {
1592 local name section
1593 action 'Copying man pages...'
1595 for i in $@; do
1596 name=$(echo $i | sed 's|\.[gbx]z2*$||')
1597 section=${name##*/}; section=${section##*.}
1598 mkdir -p $install/usr/share/man/man$section
1599 cp -a $i $install/usr/share/man/man$section
1600 done
1601 status
1605 # Function to use in genpkg_rules() to copy specified files from $install to $fs
1607 cook_copy_files() {
1608 action 'Copying files...'
1609 cd $install
1610 local i j
1611 for i in $@; do
1612 for j in $(find . -name $i ! -type d); do
1613 mkdir -p $fs$(dirname ${j#.})
1614 cp -a $j $fs/${j#.}
1615 done
1616 done
1617 cd - >/dev/null
1618 status
1622 # Function to use in genpkg_rules() to copy specified folders from $install to $fs
1624 cook_copy_folders() {
1625 action 'Copying folders...'
1626 cd $install
1627 local i j
1628 for i in $@; do
1629 for j in $(find . -name $i -type d); do
1630 mkdir -p $fs$(dirname ${j#.})
1631 cp -a $j $fs/${j#.}
1632 done
1633 done
1634 cd - >/dev/null
1635 status
1639 # Function to use in genpkg_rules() to copy hicolor icons in specified sizes
1640 # (default: 16 and 48) from $install to $fs
1642 cook_copy_icons() {
1643 local sizes=$@
1644 action 'Copying hicolor icons...'
1645 mkdir -p $fs/usr/share/icons/hicolor
1646 for i in ${sizes:-16 48}; do
1647 [ -e "$install/usr/share/icons/hicolor/${i}x$i" ] &&
1648 cp -a $install/usr/share/icons/hicolor/${i}x$i \
1649 $fs/usr/share/icons/hicolor
1650 done
1651 status
1654 dblog() { tee -a $LOGS/pkgdb.log; }
1660 # Commands
1663 case "$1" in
1664 usage|help|-u|-h)
1665 usage ;;
1667 list-wok)
1668 title 'List of %s packages in "%s"' "$ARCH" "$WOK"
1669 cd $WOK
1670 if [ "$ARCH" != 'i486' ]; then
1671 count=0
1672 for pkg in $(fgrep 'HOST_ARCH=' */receipt | egrep "$ARCH|any" | cut -d: -f1)
1673 do
1674 unset HOST_ARCH
1675 . $pkg
1676 count=$(($count + 1))
1677 colorize 34 "$PACKAGE"
1678 done
1679 else
1680 count=$(ls | wc -l)
1681 ls -1
1682 fi
1683 footer "$(_p '%s package' '%s packages' "$count" "$(colorize 32 "$count")")"
1684 ;;
1686 activity)
1687 cat $activity ;;
1689 search)
1690 # Just a simple search function, we dont need more actually.
1691 query="$2"
1692 title 'Search results for "%s"' "$query"
1693 cd $WOK; ls -1 | grep "$query"
1694 footer ;;
1696 setup)
1697 # Setup a build environment
1698 check_root
1699 _ 'Cook: setup environment' | log
1700 title 'Setting up your environment'
1701 [ -d $SLITAZ ] || mkdir -p $SLITAZ
1702 cd $SLITAZ
1703 init_db_files
1704 _ 'Checking for packages to install...'
1705 # Use setup pkgs from cross.conf or cook.conf. When cross compiling
1706 # ARCH-setup or 'cross check' should be used before: cook setup
1707 case "$ARCH" in
1708 arm*|x86_64)
1709 if [ ! -x '/usr/bin/cross' ]; then
1710 _ 'ERROR: %s is not installed' 'cross'
1711 exit 1
1712 fi
1713 _ 'Using config file: %s' '/etc/slitaz/cross.conf'
1714 . /etc/slitaz/cross.conf ;;
1715 esac
1716 for pkg in $SETUP_PKGS; do
1717 if [ -n "$forced" ]; then
1718 tazpkg -gi $pkg --forced
1719 else
1720 [ ! -d "$INSTALLED/$pkg" ] && tazpkg get-install $pkg
1721 fi
1722 done
1724 # Handle --options
1725 case "$2" in
1726 --wok) hg clone $WOK_URL wok || exit 1 ;;
1727 --stable) hg clone $WOK_URL-stable wok || exit 1 ;;
1728 --undigest) hg clone $WOK_URL-undigest wok || exit 1 ;;
1729 --tiny) hg clone $WOK_URL-tiny wok || exit 1 ;;
1730 esac
1732 # SliTaz group and permissions
1733 if ! grep -q ^slitaz /etc/group; then
1734 _ 'Adding group "%s"' 'slitaz'
1735 addgroup slitaz
1736 fi
1737 _ 'Setting permissions for group "%s"...' 'slitaz'
1738 find $SLITAZ -maxdepth 2 -exec chown root.slitaz {} \;
1739 find $SLITAZ -maxdepth 2 -exec chmod g+w {} \;
1740 footer "$(_ 'All done, ready to cook packages :-)')" ;;
1742 *-setup)
1743 # Setup for cross compiling.
1744 arch="${1%-setup}"
1745 check_root
1746 . /etc/slitaz/cook.conf
1747 for pkg in $CROSS_SETUP; do
1748 if [ -n "$forced" ]; then
1749 tazpkg -gi $pkg --forced
1750 else
1751 [ ! -d "$INSTALLED/$pkg" ] && tazpkg -gi $pkg
1752 fi
1753 done
1755 _ 'Cook: setup %s cross environment' "$arch" | log
1756 title 'Setting up your %s cross environment' "$arch"
1757 init_db_files
1758 sed -i \
1759 -e s"/ARCH=.*/ARCH=\"$arch\"/" \
1760 -e s"/CROSS_TREE=.*/CROSS_TREE=\"\/cross\/$arch\"/" \
1761 -e s'/BUILD_SYSTEM=.*/BUILD_SYSTEM=i486-slitaz-linux/' \
1762 /etc/slitaz/cook.conf
1763 case "$arch" in
1764 arm)
1765 flags='-O2 -march=armv6'
1766 host="$ARCH-slitaz-linux-gnueabi" ;;
1767 armv6hf)
1768 flags='-O2 -march=armv6j -mfpu=vfp -mfloat-abi=hard'
1769 host="$ARCH-slitaz-linux-gnueabi" ;;
1770 armv7)
1771 flags='-Os -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -pipe'
1772 host="$ARCH-slitaz-linux-gnueabi" ;;
1773 x86_64)
1774 flags='-O2 -mtune=generic -pipe'
1775 host="$ARCH-slitaz-linux" ;;
1776 esac
1777 sed -i \
1778 -e s"/CFLAGS=.*/CFLAGS=\"$flags\"/" \
1779 -e s"/HOST_SYSTEM=.*/HOST_SYSTEM=$host/" /etc/slitaz/cook.conf
1780 . /etc/slitaz/cook.conf
1781 sysroot="$CROSS_TREE/sysroot"
1782 tools="/cross/$arch/tools"
1783 root="$sysroot"
1784 # L10n: keep the same width of translations to get a consistent view
1785 _ 'Target arch : %s' "$ARCH"
1786 _ 'Configure args : %s' "$CONFIGURE_ARGS"
1787 _ 'Build flags : %s' "$flags"
1788 _ 'Arch sysroot : %s' "$sysroot"
1789 _ 'Tools prefix : %s' "$tools/bin"
1790 # Tell the packages manager where to find packages.
1791 _ 'Packages DB : %s' "$root$DB"
1792 mkdir -p $root$INSTALLED
1793 cd $root$DB; rm -f *.bak
1794 for list in packages.list packages.desc packages.equiv packages.md5; do
1795 rm -f $list
1796 ln -s $SLITAZ/packages/$list $list
1797 done
1798 # We must have the cross compiled glibc-base installed or default
1799 # i486 package will be used as dep by tazpkg and then break the
1800 # cross environment
1801 if [ ! -f "$root$INSTALLED/glibc-base/receipt" ]; then
1802 colorize 36 $(_ 'WARNING: %s is not installed in sysroot' '(e)glibc-base')
1803 fi
1804 # Show GCC version or warn if not yet compiled.
1805 if [ -x "$tools/bin/$HOST_SYSTEM-gcc" ]; then
1806 _ 'Cross compiler : %s' "$HOST_SYSTEM-gcc"
1807 else
1808 colorize 36 $(_ 'C compiler "%s" is missing' "$HOST_SYSTEM-gcc")
1809 _ 'Run "%s" to cook a toolchain' 'cross compile'
1810 fi
1811 footer ;;
1813 test)
1814 # Test a cook environment.
1815 _ 'Cook test: testing the cook environment' | log
1816 [ ! -d "$WOK" ] && exit 1
1817 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK
1818 cook cooktest ;;
1820 new)
1821 # Create the package folder and an empty receipt.
1822 pkg="$2"
1823 [ -z "$pkg" ] && usage
1824 newline
1825 if [ -d "$WOK/$pkg" ]; then
1826 _ 'Package "%s" already exists.' "$pkg"
1827 exit 1
1828 fi
1830 action 'Creating folder "%s"' "$WOK/$pkg"
1831 mkdir $WOK/$pkg; cd $WOK/$pkg; status
1833 action 'Preparing the package receipt...'
1834 cp $DATA/receipt .
1835 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
1836 status; newline
1838 # Interactive mode, asking and seding.
1839 case "$3" in
1840 --interactive|-x)
1841 _ 'Entering interactive mode...'
1842 separator
1843 _ 'Package : %s' "$pkg"
1845 _n 'Version : ' ; read answer
1846 sed -i s/'VERSION=\"\"'/"VERSION=\"$answer\""/ receipt
1848 _n 'Category : ' ; read answer
1849 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$answer\""/ receipt
1851 # L10n: Short description
1852 _n 'Short desc : ' ; read answer
1853 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$answer\""/ receipt
1855 _n 'Maintainer : ' ; read answer
1856 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$answer\""/ receipt
1858 _n 'License : ' ; read answer
1859 sed -i s/'LICENSE=\"\"'/"LICENSE=\"$answer\""/ receipt
1861 _n 'Web site : ' ; read answer
1862 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$answer\""# receipt
1863 newline
1865 # Wget URL.
1866 _ 'Wget URL to download source tarball.'
1867 _n 'Example : ' ; echo '$GNU_MIRROR/$PACKAGE/$TARBALL'
1868 _n 'Wget url : ' ; read answer
1869 sed -i "s|WGET_URL=.*|WGET_URL=\"$answer\"|" receipt
1871 # Ask for a stuff dir.
1872 confirm "$(_n 'Do you need a stuff directory? (y/N)')"
1873 if [ "$?" -eq 0 ]; then
1874 action 'Creating the stuff directory...'
1875 mkdir $WOK/$pkg/stuff; status
1876 fi
1878 # Ask for a description file.
1879 confirm "$(_n 'Are you going to write a description? (y/N)')"
1880 if [ "$?" -eq 0 ]; then
1881 action 'Creating the "%s" file...' 'description.txt'
1882 touch $WOK/$pkg/description.txt; status
1883 fi
1885 footer "$(_ 'Receipt is ready to use.')" ;;
1886 esac ;;
1888 list)
1889 # Cook a list of packages (better use the Cooker since it will order
1890 # packages before executing cook).
1891 check_root
1892 if [ -z "$2" ]; then
1893 newline; _ 'No list in argument.'; newline
1894 exit 1
1895 fi
1896 if [ ! -f "$2" ]; then
1897 newline; _ 'List "%s" not found.' "$2"; newline
1898 exit 1
1899 fi
1901 _ 'Starting cooking the list "%s"' "$2" | log
1903 for pkg in $(cat $2); do
1904 cook $pkg || broken
1905 done ;;
1907 clean-wok)
1908 check_root
1909 newline; action 'Cleaning all packages files...'
1910 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
1911 status; newline ;;
1913 clean-src)
1914 check_root
1915 newline; action 'Cleaning all packages sources...'
1916 rm -rf $WOK/*/source
1917 status; newline ;;
1919 uncook)
1920 cd $WOK
1921 count=0
1922 title 'Checking for uncooked packages'
1924 for pkg in *; do
1925 unset HOST_ARCH EXTRAVERSION
1926 [ ! -e $pkg/receipt ] && continue
1927 . $pkg/receipt
1928 # Source cooked pkg receipt to get EXTRAVERSION
1929 if [ -d "$WOK/$pkg/taz" ]; then
1930 cd $WOK/$pkg/taz/$pkg-*
1931 . receipt; cd $WOK
1932 fi
1933 case "$ARCH" in
1934 i486)
1935 debug "$(_ 'Package "%s"' "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg")"
1936 if [ ! -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ]; then
1937 count=$(($count + 1))
1938 colorize 34 "$pkg"
1939 fi ;;
1940 arm*)
1941 # Check only packages included in arch
1942 if echo "$HOST_ARCH" | egrep -q "$ARCH|any"; then
1943 # *.tazpkg
1944 if [ ! -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg" ]; then
1945 count=$(($count + 1))
1946 colorize 34 "$pkg"
1947 fi
1948 fi ;;
1949 esac
1950 done
1952 if [ "$count" -gt "0" ]; then
1953 footer "$(_p '%s uncooked package' '%s uncooked packages' "$count" "$(colorize 31 "$count")")"
1954 else
1955 _ 'All packages are cooked :-)'
1956 newline
1957 fi
1958 ;;
1960 pkgdb)
1961 # Create suitable packages list for TazPKG and only for built packages
1962 # as well as flavors files for TazLiTo. We dont need logs since we do it
1963 # manually to ensure everything is fine before syncing the mirror.
1965 rm $LOGS/pkgdb.log 2>/dev/null
1967 case "$2" in
1968 --flavors|--rmpkg) ;;
1969 *)
1970 [ -n "$2" ] && PKGS="$2"
1971 if [ ! -d "$PKGS" ]; then
1972 { newline; _ "Packages directory \"%s\" doesn't exist" "$PKGS"; newline; } | dblog
1973 exit 1
1974 fi ;;
1975 esac
1977 time=$(date +%s)
1978 flavors="$SLITAZ/flavors"
1979 live="$SLITAZ/live"
1981 echo 'cook:pkgdb' > $command
1982 _ 'Cook pkgdb: Creating all packages lists' | log
1983 newline; { _ 'Creating lists for "%s"' "$PKGS"; separator; } | dblog
1985 { _ 'Cook pkgdb started: %s' "$(date "$(_ '+%%F %%R')")"; newline; } | dblog
1987 cd $PKGS
1988 rm -f packages.* extra.list
1989 touch packages.equiv
1991 _n 'Creating file "%s"' 'packages.list' | dblog
1992 ls -1 *.tazpkg | sed s'/.tazpkg//' > $PKGS/packages.list
1993 echo " ($(filesize $PKGS/packages.list))" | dblog
1995 _n 'Creating file "%s"' 'packages.md5' | dblog
1996 md5sum *.tazpkg > $PKGS/packages.md5
1997 echo " ($(filesize $PKGS/packages.md5))" | dblog
1998 cp $PKGS/packages.md5 $PKGS/packages.toremove # list of duplicates
2000 md5sum packages.md5 | cut -d' ' -f1 > ID
2001 ( cat ./ID | tr $'\n' ' '; date -ur ./ID +%s ) > IDs # md5 and timestamp
2003 _n 'Creating file "%s"' 'descriptions.txt' | dblog
2004 rm $PKGS/descriptions.txt 2>/dev/null
2005 for i in $(ls $WOK | sort); do
2006 if [ -e "$WOK/$i/description.txt" ]; then
2007 echo "$i" >> descriptions.txt
2008 cat "$WOK/$i/description.txt" | sed 's|^$| |' >> descriptions.txt
2009 echo >> descriptions.txt
2010 fi
2011 done
2012 echo " ($(filesize $PKGS/descriptions.txt))" | dblog
2015 _ 'Creating lists from "%s"' "$WOK" | dblog
2016 cd $WOK
2017 for pkg in *; do
2018 unset_receipt
2019 . $pkg/receipt
2020 # PACKED_SIZE and UNPACKED_SIZE are only in built receipt
2021 [ -s $pkg/taz/*/receipt ] && . $pkg/taz/*/receipt
2023 if [ -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ] || \
2024 [ -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg" ]; then
2026 # packages.desc lets us search easily in DB
2027 cat >> $PKGS/packages.desc <<EOT
2028 $PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE
2029 EOT
2031 # packages.txt used by tazpkg and tazpkg-web also to provide
2032 # a human readable package list with version and description.
2033 cat >> $PKGS/packages.txt <<EOT
2034 $PACKAGE
2035 $VERSION$EXTRAVERSION
2036 $SHORT_DESC
2037 $PACKED_SIZE ($UNPACKED_SIZE installed)
2039 EOT
2041 # packages.info combines TazPkg separate files
2042 # and will substitute them all
2043 SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g')
2044 DEPENDS=$(echo $DEPENDS) # remove newlines from some receipts
2045 MD5="$(fgrep " $PACKAGE-$VERSION$EXTRAVERSION.tazpkg" $PKGS/packages.md5 | awk '{print $1}')"
2046 cat >> $PKGS/packages.info <<EOT
2047 $PACKAGE $VERSION$EXTRAVERSION $CATEGORY $SHORT_DESC $WEB_SITE $TAGS $SIZES $DEPENDS $MD5
2048 EOT
2050 # packages.equiv is used by tazpkg install to check depends.
2051 for i in $PROVIDE; do
2052 DEST=''
2053 echo $i | fgrep -q : && DEST="${i#*:}:"
2054 if grep -qs ^${i%:*}= $PKGS/packages.equiv; then
2055 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" \
2056 $PKGS/packages.equiv
2057 else
2058 echo "${i%:*}=$DEST$PACKAGE" >> $PKGS/packages.equiv
2059 fi
2060 done
2062 # files.list provides a list of all packages files.
2063 cat $pkg/taz/*/files.list | sed s/^/"$pkg: \0"/ >> \
2064 $PKGS/files.list
2066 # list of duplicates
2067 sed -i "/ $PACKAGE-$VERSION$EXTRAVERSION.tazpkg/d" $PKGS/packages.toremove
2068 else
2069 # if receipt variable HOST_ARCH absent/empty or contains ARCH
2070 if [ -z "$HOST_ARCH" -o "${HOST_ARCH/$ARCH/}" != "$HOST_ARCH" ]; then
2071 _ ' - absent: %s (%s)' "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" "$ARCH" | dblog
2072 fi
2073 fi
2074 done
2076 # Display list size.
2077 _ 'Done: %s (%s)' 'packages.desc' "$(filesize $PKGS/packages.desc)" | dblog
2078 _ 'Done: %s (%s)' 'packages.txt' "$(filesize $PKGS/packages.txt)" | dblog
2079 _ 'Done: %s (%s)' 'packages.info' "$(filesize $PKGS/packages.info)" | dblog
2080 _ 'Done: %s (%s)' 'packages.equiv' "$(filesize $PKGS/packages.equiv)" | dblog
2082 cd $PKGS
2085 # Check package duplicates
2086 if [ -s "$PKGS/packages.toremove" ]; then
2087 newline | dblog
2088 _ 'Removing duplicates:' | dblog
2089 while read pkgsum pkgfile; do
2090 echo " - $pkgfile" | dblog
2091 sed -i "/${pkgfile%.tazpkg}/d" $PKGS/packages.list
2092 sed -i "/ $pkgfile/d" $PKGS/packages.md5
2093 [ -n "$rmpkg" ] && rm $PKGS/$pkgfile # remove packages only with --rmpkg
2094 done < $PKGS/packages.toremove
2095 newline | dblog
2096 fi
2097 rm $PKGS/packages.toremove
2100 # files.list.lzma
2101 _n 'Creating file "%s"' 'files.list.lzma' | dblog
2102 touch files.list
2103 # pkgs.slitaz.org strongly depends on list sorted by packages names
2104 lzma e files.list files.list.lzma
2105 echo " ($(filesize $PKGS/files.list.lzma))" | dblog
2107 # Pre-sorting filenames causes 10% smaller resulting lzma file
2108 _n 'Creating file "%s"' 'files-list.lzma' | dblog
2109 cat files.list | sort -k2 -o files.list.sorted
2110 lzma e files.list.sorted files-list.lzma
2111 rm -f files.list files.list.sorted
2112 echo " ($(filesize $PKGS/files-list.lzma))" | dblog
2114 [ -e files.list.md5 ] && rm files.list.md5
2115 md5sum files-list.lzma | cut -d' ' -f1 | tr -d $'\n' > files-list.md5
2117 # packages.info.lzma
2118 PI=packages.info
2119 _n 'Creating file "%s"' 'packages.info.lzma' | dblog
2120 touch $PI
2121 lzma e $PI $PI.lzma
2122 echo " ($(filesize $PKGS/packages.info.lzma))" | dblog
2124 # Make bundle to fast recharge
2125 _n 'Creating file "%s"' 'bundle.tar.lzma' | dblog
2126 [ -f bundle.tar.lzma ] && rm bundle.tar.lzma
2127 # Make sure to get "mirrors" file
2128 until [ -e 'mirrors' ]; do
2129 wget -q http://mirror1.slitaz.org/mirrors
2130 echo -n '.' | dblog; sleep 5
2131 done
2132 # Make sure to get "extra.list" file
2133 until [ -e 'extra.list' ]; do
2134 wget -q -O extra.list http://mirror1.slitaz.org/packages/get.list
2135 echo -n '.' | dblog; sleep 5
2136 done
2137 busybox tar -chaf bundle.tar.lzma \
2138 mirrors extra.list files-list.md5 packages.info descriptions.txt \
2139 packages.desc packages.md5 packages.txt packages.list packages.equiv
2140 rm ./mirrors
2141 echo " ($(filesize $PKGS/bundle.tar.lzma))" | dblog
2143 # Display some info.
2144 separator | dblog
2145 nb=$(ls $PKGS/*.tazpkg | wc -l)
2146 time=$(($(date +%s) - $time))
2147 # L10n: 's' is for seconds (cooking time)
2148 { _ 'Packages: %s - Time: %ss' "$nb" "$time"; newline; } | dblog
2151 # Create all flavors files at once. Do we really need code to monitor
2152 # flavors changes? Lets just build them with packages lists before
2153 # syncing the mirror.
2154 [ "$2" != '--flavors' ] && exit 1
2156 if [ ! -d "$flavors" ]; then
2157 { _ 'Missing flavors folder "%s"' "$flavors"; newline; } | dblog
2158 exit 1
2159 fi
2161 [ ! -d "$live" ] && mkdir -p $live
2162 _ 'Creating flavors files in "%s"' "$live" | dblog
2163 _ 'Cook pkgdb: Creating all flavors' | log
2164 separator | dblog
2166 _ 'Recharging lists to use latest packages...' | dblog
2167 tazpkg recharge >/dev/null 2>/dev/null
2169 # We need a custom tazlito config to set working dir to /home/slitaz.
2170 if [ ! -f "$live/tazlito.conf" ]; then
2171 _ 'Creating configuration file "%s"' 'tazlito.conf' | dblog
2172 cp /etc/tazlito/tazlito.conf $live
2173 sed -i s@WORK_DIR=.*@WORK_DIR=\"/home/slitaz\"@ \
2174 $live/tazlito.conf
2175 fi
2177 # Update Hg flavors repo and pack.
2178 if [ -d "$flavors/.hg" ]; then
2179 cd $flavors; hg pull -u
2180 fi
2182 cd $live
2183 _ 'Starting to generate flavors...' | dblog
2184 rm -f flavors.list *.flavor
2185 for i in $flavors/*; do
2186 fl=$(basename $i)
2187 _ 'Packing flavor "%s"' "$fl" | dblog
2188 tazlito pack-flavor $fl >/dev/null || exit 1
2189 tazlito show-flavor $fl --brief --noheader 2>/dev/null >> flavors.list
2190 done
2191 cp -f $live/*.flavor $live/flavors.list $PKGS
2192 separator | dblog
2193 { _ 'Total flavors size: %s' "$(du -sh $live | awk '{print $1}')"; newline; } | dblog
2194 rm -f $command
2195 separator | dblog
2196 _ 'Cook pkgdb end: %s' "$(date "$(_ '+%%F %%R')")" | dblog
2197 ;;
2199 *)
2200 # Just cook and generate a package.
2201 check_root
2202 time=$(date +%s)
2203 pkg="$1"
2204 [ -z "$pkg" ] && usage
2205 lastcooktime=$(sed '/^Cook time/!d;s|.*: *\([0-9]*\)s.*|\1|' \
2206 $LOGS/$pkg.log 2> /dev/null | sed '$!d')
2207 receipt="$WOK/$pkg/receipt"
2208 check_pkg_in_wok
2209 newline
2211 unset inst
2212 unset_receipt
2213 . $receipt
2215 # Handle cross compilation.
2216 case "$ARCH" in
2217 arm*)
2218 if [ -z "$HOST_ARCH" ]; then
2219 _ 'cook: HOST_ARCH is not set in "%s" receipt' "$pkg"
2220 error="$(_ 'package "%s" is not included in %s' "$pkg" "$ARCH")"
2221 _ 'cook: %s' "$error"
2222 [ -n "$CROSS_BUGS" ] && _ 'bugs: %s' "$CROSS_BUGS"
2223 _ 'Cook skip: %s' "$error" | log
2224 newline
2225 exit 1
2226 fi ;;
2227 esac
2229 # Some packages are not included in some arch or fail to cross compile.
2230 : ${HOST_ARCH=i486}
2231 debug "$(_ 'Host arch %s' "$HOST_ARCH")"
2232 # Handle arm{v6hf,v7,..}
2233 if ! $(echo "$HOST_ARCH" | egrep -q "${ARCH%v[0-9]*}|any"); then
2234 _ 'cook: %s' "HOST_ARCH=$HOST_ARCH"
2235 error="$(_ "package \"%s\" doesn't cook or is not included in %s" "$pkg" "$ARCH")"
2236 _ 'cook: %s' "error"
2237 [ -n "$CROSS_BUGS" ] && _ 'bugs: %s' "$CROSS_BUGS"
2238 _ 'Cook skip: %s' "$error" | log
2239 sed -i /^${pkg}$/d $broken
2240 newline
2241 exit 0
2242 fi
2244 # Skip blocked, 3 lines also for the Cooker.
2245 if grep -q "^$pkg$" $blocked && [ "$2" != '--unblock' ]; then
2246 _ 'Package "%s" is blocked' "$pkg"; newline
2247 exit 0
2248 fi
2250 try_aufs_chroot "$@"
2252 # Log and source receipt.
2253 _ 'Cook started for: %s' "<a href='cooker.cgi?pkg=$pkg'>$pkg</a>" | log
2254 echo "cook:$pkg" > $command
2255 [ "$lastcooktime" ] &&
2256 echo "cook:$pkg $lastcooktime $(date +%s)" >> $cooktime
2257 while read cmd duration start; do
2258 [ $(($start + $duration)) -lt $(date +%s) ] &&
2259 echo "sed -i '/^$cmd $duration/d' $cooktime"
2260 done < $cooktime | sh
2262 # Display and log info if cook process stopped.
2263 # FIXME: gettext not working (in single quotes) here!
2264 trap '_ "\n\nCook stopped: control-C\n\n" | \
2265 tee -a $LOGS/$pkg.log' INT
2267 # Handle --options
2268 case "$2" in
2269 --clean|-c)
2270 action 'Cleaning "%s"' "$pkg"
2271 cd $WOK/$pkg; rm -rf install taz source
2272 status; newline
2273 exit 0 ;;
2275 --install|-i)
2276 inst='yes' ;;
2278 --getsrc|-gs)
2279 title 'Getting source for "%s"' "$pkg"
2280 get_source
2281 _ 'Tarball: %s' "$SRC/$TARBALL"; newline
2282 exit 0 ;;
2284 --block|-b)
2285 action 'Blocking package "%s"' "$pkg"
2286 [ $(grep "^$pkg$" $blocked) ] || echo "$pkg" >> $blocked
2287 status; newline
2288 exit 0 ;;
2290 --unblock|-ub)
2291 action 'Unblocking package "%s"' "$pkg"
2292 sed -i "/^${pkg}$/"d $blocked
2293 status; newline
2294 exit 0 ;;
2296 --pack)
2297 if [ -d $WOK/$pkg/taz ]; then
2298 rm -rf $WOK/$pkg/taz
2299 [ -f $LOGS/$pkg-pack.log ] && rm -rf $LOGS/$pkg-pack.log
2300 packit 2>&1 | tee -a $LOGS/$pkg-pack.log
2301 clean_log
2302 else
2303 _ 'Need to build "%s"' "$pkg"
2304 exit 0
2305 fi
2306 exit 0 ;;
2308 --cdeps)
2309 if [ ! -d $WOK/$pkg/taz ]; then
2310 _ 'Need to build "%s"' "$pkg"
2311 exit 0
2312 fi
2314 title 'Checking depends'
2315 lddlist='/tmp/lddlist'; touch $lddlist
2316 missing='/var/cache/missing.file'
2318 # find all deps using ldd
2319 for exe in $(find $WOK/$pkg/taz -type f -perm +111); do
2320 [ "x$(dd if=$exe bs=4 count=1 2>/dev/null)" == "xELF" ] &&
2321 ldd $exe | sed 's| ||' | cut -d' ' -f1 >> $lddlist
2322 done #"
2324 # remove exe/so duplicates
2325 sort -u $lddlist > $lddlist.sorted
2327 # search packages
2328 for exefile in $(cat $lddlist.sorted); do
2329 search_file $exefile
2330 echo "$found" >> $lddlist.pkgs
2331 echo -n '.'
2332 done
2333 echo
2335 # remove packages duplicates
2336 sort -u $lddlist.pkgs > $lddlist.final
2337 sort -u $missing > $missing.final
2338 rm -f $lddlist $lddlist.sorted $lddlist.pkgs $missing
2339 exit 0 ;;
2340 esac
2342 # Rotate log
2343 for i in $(seq 9 -1 1); do
2344 j=$(($i - 1))
2345 [ -e $LOGS/$pkg.log.$j ] && mv -f $LOGS/$pkg.log.$j $LOGS/$pkg.log.$i
2346 done
2347 [ -e $LOGS/$pkg.log ] && mv $LOGS/$pkg.log $LOGS/$pkg.log.0
2349 # Check if wanted is built now so we have separate log files.
2350 for wanted in $WANTED ; do
2351 if grep -q "^$wanted$" $blocked; then
2352 _ 'WANTED package "%s" is blocked' "$wanted" | tee $LOGS/$pkg.log
2353 newline
2354 rm -f $command
2355 exit 1
2356 fi
2357 if grep -q "^$wanted$" $broken; then
2358 _ 'WANTED package "%s" is broken' "$wanted" | tee $LOGS/$pkg.log
2359 newline
2360 rm -f $command
2361 exit 1
2362 fi
2363 if [ ! -d "$WOK/$wanted/install" ]; then
2364 cook "$wanted" || exit 1
2365 fi
2366 done
2368 # Cook and pack or exit on error and log everything.
2369 cookit $@ 2>&1 | loglimit 50 > $LOGS/$pkg.log
2370 remove_deps | tee -a $LOGS/$pkg.log
2371 cookit_quality
2372 packit 2>&1 | loglimit 5 >> $LOGS/$pkg.log
2373 clean_log
2375 # Exit if any error in packing.
2376 lerror=$(_n 'ERROR')
2377 if grep -Ev "(/root/.cvspass|conftest|df: /|rm: can't remove)" $LOGS/$pkg.log | \
2378 grep -Eq "(^$lerror|: No such file or directory|not remade because of errors|ake: \*\*\* .* Error)"; then
2379 debug_info | tee -a $LOGS/$pkg.log
2380 rm -f $command
2381 exit 1
2382 fi
2384 # Create an XML feed
2385 gen_rss
2387 # Time and summary
2388 time=$(($(date +%s) - $time))
2389 summary | tee -a $LOGS/$pkg.log
2390 newline
2392 # We may want to install/update (outside aufs jail !).
2393 [ -s /aufs-umount.sh ] ||
2394 install_package
2396 # Finally we DON'T WANT to build the *-dev or packages with WANTED="$pkg"
2397 # You want automation: use the Cooker Build Bot.
2398 rm -f $command ;;
2399 esac
2401 exit 0