cookutils view cook @ rev 853

cooker.cgi: sort doc links
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Dec 20 12:55:39 2016 +0100 (2016-12-20)
parents c1f4d81d16e7
children b445a91a8be7
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 not really added
664 # to the 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 # Remove files provided by splitted packages
794 # For example:
795 # 1. Package "pkg-main":
796 # SPLIT="pkg-1 pkg-2 pkg-extra"
797 # 2. Package="pkg-extra":
798 # WANTED="pkg-main"
799 # BUILD_DEPENDS="pkg-1 pkg-2"
800 # cook_copy_folders usr
801 # cook_split_rm $BUILD_DEPENDS
803 cook_split_rm() {
804 for i in $@; do
805 action 'Remove files provided by splitted package %s...' "$i"
806 while read j; do
807 [ -f "$fs$j" -o -h "$fs$j" ] && rm $fs$j
808 rmdir "$(dirname "$fs$j")" 2>/dev/null
809 done < $WOK/$i/taz/$i-$VERSION/files.list
810 :; status
811 done
812 }
815 # Update installed.cook.diff
817 update_installed_cook_diff() {
818 # If a cook failed deps are removed.
819 cd $root$INSTALLED; ls -1 > $CACHE/installed.cook
820 cd $CACHE
821 [ "$1" == 'force' -o ! -s '/tmp/installed.cook.diff' ] && \
822 busybox diff installed.list installed.cook > /tmp/installed.cook.diff
823 deps=$(cat /tmp/installed.cook.diff | grep ^+[a-zA-Z0-9] | wc -l)
824 }
827 # Remove installed deps.
829 remove_deps() {
830 # Now remove installed build deps.
831 diff='/tmp/installed.cook.diff'
832 if [ -s $diff ]; then
833 deps=$(cat $diff | grep ^+[a-zA-Z0-9] | sed s/^+//)
834 nb=$(cat $diff | grep ^+[a-zA-Z0-9] | wc -l)
835 _n 'Build dependencies to remove:'; echo " $nb"
836 [ -n "$root" ] && echo "root=\"$root\""
837 _n 'Removing:'
838 for dep in $deps; do
839 echo -n " $dep"
840 echo 'y' | tazpkg remove $dep --root=$root >/dev/null
841 done
842 newline; newline
843 # Keep the last diff for debug and info.
844 mv -f $diff $CACHE/installed.diff
845 fi
846 }
849 # Function to compress all man pages
850 # Compressing can be disabled with COOKOPTS="!manz"
852 compress_manpages() {
853 [ "${COOKOPTS/!manz/}" != "$COOKOPTS" ] && return
855 case "$ARCH" in
856 arm*) return;; # While SliTaz-arm miss `advancecomp`
857 esac
858 local manpath="$install/usr/share/man" dest link
859 [ -d "$manpath" ] || return
861 action 'Compressing man pages...'
863 local size0=$(find $install/usr/share/man -type f -exec ls -l \{\} \; | awk '{s+=$5}END{print s}')
864 local time0=$(date +%s)
865 # We'll use only Gzip compression, so decompress other formats first
866 find $manpath -type f -name '*.bz2' -exec bunzip2 \{\} \;
867 find $manpath -type f -name '*.xz' -exec unxz \{\} \;
869 # Fast compress with gzip
870 find $manpath -type f -name '*.[1-9]*' -exec gzip \{\} \;
872 # Fix symlinks
873 for i in $(find $install/usr/share/man -type l); do
874 dest=$(readlink $i | sed 's|\.[gbx]z2*$||')
875 link=$(echo $i | sed 's|\.[gbx]z2*$||')
876 rm $i; ln -s $dest.gz $link.gz
877 done
879 # Recompress with advdef (it can't compress, only recompress)
880 tazpkg -gi advancecomp --quiet
881 for i in $(find $install/usr/share/man -type f); do
882 advdef -z4q $i
883 done
885 local size1=$(find $install/usr/share/man -type f -exec ls -l \{\} \; | awk '{s+=$5}END{print s}')
886 local time1=$(date +%s)
887 status
888 comp_summary "$time0" "$time1" "$size0" "$size1"
889 }
892 # Function used after compile_rules() to compress all png images
893 # Compressing can be disabled with COOKOPTS="!pngz"
895 compress_png() {
896 [ "${COOKOPTS/!pngz/}" != "$COOKOPTS" ] && return
897 case "$ARCH" in
898 arm*) return;; # While SliTaz-arm miss `pngquant` and `optipng`
899 esac
900 [ -z "$(find $install -type f -name '*.png')" ] && return
902 action 'Compressing png images...'
903 local size0=$(find $install -type f -name '*.png' -exec ls -l \{\} \; | awk '{s+=$5}END{print s}')
904 local time0=$(date +%s)
906 local use_pq=true use_op=true
907 [ "${COOKOPTS/!pngquant/}" != "$COOKOPTS" ] && use_pq=false
908 [ "${COOKOPTS/!optipng/}" != "$COOKOPTS" ] && use_op=false
910 $use_pq && tazpkg -gi pngquant --quiet
911 $use_op && tazpkg -gi optipng --quiet
913 local oplevel=$(echo $COOKOPTS | grep 'op[0-8]' | sed 's|.*op\([0-8]\).*|\1|')
914 [ -z "$oplevel" ] && oplevel='2'
915 [ "$oplevel" == '8' ] && oplevel='7 -zm1-9'
917 for i in $(find $install -type f -name '*.png'); do
918 $use_pq && pngquant -f --skip-if-larger --ext .png --speed 1 "$i"
919 $use_op && optipng -quiet -strip all -o$oplevel "$i"
920 done
922 local size1=$(find $install -type f -name '*.png' -exec ls -l \{\} \; | awk '{s+=$5}END{print s}')
923 local time1=$(date +%s)
924 status
925 comp_summary "$time0" "$time1" "$size0" "$size1"
926 }
929 # Function used after compile_rules() to compress all svg images
930 # Compressing can be disabled with COOKOPTS="!svgz"
932 compress_svg() {
933 [ "${COOKOPTS/!svgz/}" != "$COOKOPTS" ] && return
934 case "$ARCH" in
935 arm*) return;; # While SliTaz-arm miss `svgcleaner`
936 esac
937 [ -z "$(find $install -type f -name '*.svg')" ] && return
939 action 'Compressing svg images...'
940 local size0=$(find $install -type f -name '*.svg' -exec ls -l \{\} \; | awk '{s+=$5}END{print s}')
941 local time0=$(date +%s)
942 tazpkg -gi svgcleaner --quiet
943 cleaner_log="$(mktemp)"
944 for i in $(find $install -type f -name '*.svg'); do
945 echo -n "$i: " >> "$cleaner_log"
946 svgcleaner "$i" "$i" --remove-unresolved-classes false --quiet true >> "$cleaner_log"
947 done
948 local size1=$(find $install -type f -name '*.svg' -exec ls -l \{\} \; | awk '{s+=$5}END{print s}')
949 local time1=$(date +%s)
950 status
951 comp_summary "$time0" "$time1" "$size0" "$size1"
952 sed -i '/: $/d' "$cleaner_log"
953 if [ -s "$cleaner_log" ]; then
954 echo 'Cleaner warnings and errors:'
955 awk '{printf " %s\n", $0;}' "$cleaner_log"
956 echo
957 fi
958 rm "$cleaner_log"
959 }
962 # Function used after compile_rules() to shrink all *.ui and *.glade files:
963 # remove insignificant spaces and comments
964 # Compressing can be disabled with COOKOPTS="!uiz"
966 compress_ui() {
967 [ "${COOKOPTS/!uiz/}" != "$COOKOPTS" ] && return
968 case "$ARCH" in
969 arm*) return;; # While SliTaz-arm miss `xmlstarlet`
970 esac
971 [ -z "$(find $install -type f \( -name '*.ui' -o -name '*.glade' \) )" ] && return
973 action 'Compressing ui files...'
974 local size0=$(find $install -type f \( -name '*.ui' -o -name '*.glade' \) -exec ls -l \{\} \; | awk '{s+=$5}END{print s}')
975 local time0=$(date +%s)
976 tazpkg -gi xmlstarlet --quiet
977 temp_ui="$(mktemp)"
978 for ui in $(find $install -type f \( -name '*.ui' -o -name '*.glade' \) ); do
979 xmlstarlet c14n --without-comments "$ui" | xmlstarlet sel -B -t -c '*' > "$temp_ui"
980 cat "$temp_ui" > "$ui"
981 done
982 local size1=$(find $install -type f \( -name '*.ui' -o -name '*.glade' \) -exec ls -l \{\} \; | awk '{s+=$5}END{print s}')
983 local time1=$(date +%s)
984 status
985 comp_summary "$time0" "$time1" "$size0" "$size1"
986 rm "$temp_ui"
987 }
990 # The main cook function.
992 cookit() {
993 title 'Cook: %s' "$PACKAGE $VERSION"
994 set_paths
996 # Handle cross-tools.
997 case "$ARCH" in
998 arm*|x86_64)
999 # CROSS_COMPILE is used by at least Busybox and the kernel to set
1000 # the cross-tools prefix. Sysroot is the root of our target arch
1001 sysroot="$CROSS_TREE/sysroot"
1002 tools="$CROSS_TREE/tools"
1003 # Set root path when cross compiling. ARM tested but not x86_64
1004 # When cross compiling we must install build deps in $sysroot.
1005 arch="-$ARCH"
1006 root="$sysroot"
1007 _ '%s sysroot: %s' "$ARCH" "$sysroot"
1008 _ 'Adding "%s" to PATH' "$tools/bin"
1009 export PATH="$PATH:$tools/bin"
1010 export PKG_CONFIG_PATH="$sysroot/usr/lib/pkgconfig"
1011 export CROSS_COMPILE="$HOST_SYSTEM-"
1012 _ 'Using cross-tools: %s' "$CROSS_COMPILE"
1013 if [ "$ARCH" == 'x86_64' ]; then
1014 export CC="$HOST_SYSTEM-gcc -m64"
1015 export CXX="$HOST_SYSTEM-g++ -m64"
1016 else
1017 export CC="$HOST_SYSTEM-gcc"
1018 export CXX="$HOST_SYSTEM-g++"
1019 fi
1020 export AR="$HOST_SYSTEM-ar"
1021 export AS="$HOST_SYSTEM-as"
1022 export RANLIB="$HOST_SYSTEM-ranlib"
1023 export LD="$HOST_SYSTEM-ld"
1024 export STRIP="$HOST_SYSTEM-strip"
1025 export LIBTOOL="$HOST_SYSTEM-libtool" ;;
1026 esac
1028 [ -n "$QA" ] && receipt_quality
1029 cd $pkgdir
1030 [ -z "$continue" ] && rm -rf source 2>/dev/null
1031 rm -rf install taz 2>/dev/null
1033 # Disable -pipe if less than 512Mb free RAM.
1034 free=$(free | awk '/buffers:/{print $4}')
1035 if [ "$free" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then
1036 _ 'Disabling -pipe compile flag: %d RAM free' "$free"
1037 CFLAGS="${CFLAGS/-pipe}"; CFLAGS=$(echo "$CFLAGS" | tr -s ' ')
1038 CXXFLAGS="${CXXFLAGS/-pipe}"; CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ')
1039 fi
1040 unset free
1042 # Export flags and path to be used by make and receipt.
1043 DESTDIR="$pkgdir/install"
1044 # FIXME: L10n: Is this the right time for 'LC_ALL=C LANG=C'?
1045 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS CONFIG_SITE LC_ALL=C LANG=C
1046 #LDFLAGS
1048 # Check for build deps and handle implicit depends of *-dev packages
1049 # (ex: libusb-dev :: libusb).
1050 rm -f $CACHE/installed.local $CACHE/installed.web $CACHE/missing.dep
1051 touch $CACHE/installed.local $CACHE/installed.web
1052 [ -n "$BUILD_DEPENDS" ] && _ 'Checking build dependencies...'
1053 [ -n "$root" ] && _ 'Using packages DB: %s' "$root$DB"
1054 for dep in $BUILD_DEPENDS; do
1055 implicit="${dep%-dev}"
1056 # Don't add implicit dependency if it defined in DEPENDS
1057 # echo '' $DEPENDS '' | fgrep -q " $implicit " && implicit=''
1058 for i in $dep $implicit; do
1059 if [ ! -f "$root$INSTALLED/$i/receipt" ]; then
1060 # Try local package first. In some cases implicit doesn't exist, ex:
1061 # libboost-dev exists but not libboost, so check if we got vers.
1062 unset vers
1063 vers=$(. $WOK/$i/receipt 2>/dev/null ; echo $VERSION)
1064 # We may have a local package.
1065 if [ -z "$vers" ]; then
1066 vers=$(awk -F$'\t' -vp="$i" '$1==p{print $2; quit}' $PKGS/packages.info 2> /dev/null)
1067 fi
1068 debug "bdep: $i version: $vers"
1069 if [ -f "$PKGS/$i-$vers$arch.tazpkg" ]; then
1070 echo $i-$vers$arch.tazpkg >> $CACHE/installed.local
1071 else
1072 # Priority to package version in wok (maybe more up-to-date)
1073 # than the mirrored one.
1074 if [ -n "$vers" ]; then
1075 if fgrep -q $i-$vers$arch $root$DB/packages.list; then
1076 echo $i >> $CACHE/installed.web
1077 else
1078 # So package exists in wok but not available.
1079 _ 'Missing dep (wok/pkg): %s' "$i $vers"
1080 echo $i >> $CACHE/missing.dep
1081 fi
1082 else
1083 # Package is not in wok but may be in online repo.
1084 if fgrep -q $i-$vers$arch $root$DB/packages.list; then
1085 echo $i >> $CACHE/installed.web
1086 else
1087 _ 'ERROR: unknown dep "%s"' "$i"
1088 exit 1
1089 fi
1090 fi
1091 fi
1092 fi
1093 done
1094 done
1096 # Get the list of installed packages
1097 cd $root$INSTALLED; ls -1 > $CACHE/installed.list
1099 # Have we a missing build dep to cook?
1100 if [ -s "$CACHE/missing.dep" ] && [ -n "$AUTO_COOK" ]; then
1101 _ 'Auto cook config is set: %s' "$AUTO_COOK"
1102 cp -f $LOGS/$PACKAGE.log $LOGS/$PACKAGE.log.$$
1103 for i in $(uniq $CACHE/missing.dep); do
1104 (_ 'Building dep (wok/pkg) : %s' "$i $vers") | \
1105 tee -a $LOGS/$PACKAGE.log.$$
1106 # programmers: next two messages are exact copy from remove_deps()
1107 togrep1=$(_n 'Build dependencies to remove:')
1108 togrep2=$(_n 'Removing:')
1109 cook $i || (_ "ERROR: can't cook dep \"%s\"" "$i" && newline && \
1110 fgrep $togrep1 $LOGS/$i.log && \
1111 fgrep $togrep2 $LOGS/$i.log && newline) | \
1112 tee -a $LOGS/$PACKAGE.log.$$ && break
1113 done
1114 rm -f $CACHE/missing.dep
1115 mv $LOGS/$PACKAGE.log.$$ $LOGS/$PACKAGE.log
1116 fi
1118 # QA: Exit on missing dep errors. We exit in both cases, if AUTO_COOK
1119 # is enabled and cook fails we have ERROR in log, if no auto cook we have
1120 # missing dep in cached file.
1121 lerror=$(_n 'ERROR')
1122 if fgrep -q ^$lerror $LOGS/$pkg.log || [ -s "$CACHE/missing.dep" ]; then
1123 [ -s "$CACHE/missing.dep" ] && nb=$(cat $CACHE/missing.dep | wc -l)
1124 _p 'ERROR: missing %d dependency' 'ERROR: missing %d dependencies' "$nb" "$nb"
1125 exit 1
1126 fi
1128 # Install local packages: package-version$arch
1129 cd $PKGS
1130 for i in $(uniq $CACHE/installed.local); do
1131 _ 'Installing dep (pkg/local): %s' "$i"
1132 tazpkg install $i --root=$root --local --quiet
1133 done
1135 # Install web or cached packages (if mirror is set to $PKGS we only
1136 # use local packages).
1137 for i in $(uniq $CACHE/installed.web); do
1138 _ 'Installing dep (web/cache): %s' "$i"
1139 tazpkg get-install $i --root=$root --quiet
1140 done
1142 update_installed_cook_diff
1144 # Get source tarball and make sure we have source dir named:
1145 # $PACKAGE-$VERSION to be standard in receipts. Here we use tar.lzma
1146 # tarball if it exists.
1147 if [ -n "$WGET_URL" ] && [ ! -f "$SRC/$TARBALL" ]; then
1148 if [ -f "$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
1149 TARBALL="${SOURCE:-$PACKAGE}-$VERSION.tar.lzma"
1150 LZMA_SRC=''
1151 else
1152 get_source || exit 1
1153 fi
1154 fi
1155 if [ -z "$WANTED" ] && [ -n "$TARBALL" ] && [ ! -d "$src" ]; then
1156 mkdir -p $pkgdir/source/tmp; cd $pkgdir/source/tmp
1157 if ! extract_source ; then
1158 get_source
1159 extract_source || exit 1
1160 fi
1161 if [ -n "$LZMA_SRC" ]; then
1162 cd $pkgdir/source
1163 if [ "$(ls -A tmp | wc -l)" -gl 1 ] || [ -f "$(echo tmp/*)" ]; then
1164 mv tmp tmp-1; mkdir tmp
1165 mv tmp-1 tmp/${SOURCE:-$PACKAGE}-$VERSION
1166 fi
1167 if [ -d "tmp/${SOURCE:-$PACKAGE}-$VERSION" ]; then
1168 cd tmp; tar -c * | lzma e $SRC/$TARBALL -si
1169 fi
1170 fi
1171 cd $pkgdir/source/tmp
1172 # Some archives are not well done and don't extract to one dir (ex lzma).
1173 files=$(ls | wc -l)
1174 [ "$files" == 1 ] && [ -d "$(ls)" ] && mv * ../$PACKAGE-$VERSION
1175 [ "$files" == 1 ] && [ -f "$(ls)" ] && mkdir -p ../$PACKAGE-$VERSION && \
1176 mv * ../$PACKAGE-$VERSION/$TARBALL
1177 [ "$files" -gt 1 ] && mkdir -p ../$PACKAGE-$VERSION && \
1178 mv * ../$PACKAGE-$VERSION
1179 cd ..; rm -rf tmp
1180 fi
1182 # Libtool shared libs path hack.
1183 case "$ARCH" in
1184 arm*) cross libhack ;;
1185 esac
1187 # Execute receipt rules.
1188 if grep -q ^compile_rules $receipt; then
1189 _ 'Executing: %s' 'compile_rules'
1190 echo "CFLAGS : $CFLAGS"
1191 #echo "LDFLAGS : $LDFLAGS"
1192 [ -d "$src" ] && cd $src
1193 compile_rules $@ || exit 1
1194 # Stay compatible with _pkg
1195 [ -d "$src/_pkg" ] && mv $src/_pkg $install
1196 # QA: compile_rules success so valid.
1197 mkdir -p $install
1198 else
1199 # QA: no compile_rules so no error, valid.
1200 mkdir -p $install
1201 fi
1203 # Actions to do after compiling the package
1204 # Skip all for splitted packages (already done in main package)
1205 if [ -z "$WANTED" ]; then
1206 footer
1207 compress_manpages
1208 compress_png
1209 compress_svg
1210 compress_ui
1211 fix_desktop_files
1212 normalize_mo
1213 fi
1214 footer
1216 # Execute testsuite.
1217 if grep -q ^testsuite $receipt; then
1218 title 'Running testsuite'
1219 testsuite $@ || exit 1
1220 footer
1221 fi
1223 update_installed_cook_diff force
1227 # Cook quality assurance.
1229 cookit_quality() {
1230 if [ ! -d "$WOK/$pkg/install" ] && [ -z "$WANTED" ]; then
1231 _ 'ERROR: cook failed' | tee -a $LOGS/$pkg.log
1232 fi
1233 # ERROR can be echoed any time in cookit()
1234 lerror=$(_n 'ERROR')
1235 if grep -Ev "(conftest|configtest)" $LOGS/$pkg.log | \
1236 grep -Eq "(^$lerror|undefined reference to)" ; then
1237 debug_info | tee -a $LOGS/$pkg.log
1238 rm -f $command
1239 exit 1
1240 fi
1244 # Create the package. Wanted to use TazPkg to create a tazpkg package at first,
1245 # but it doesn't handle EXTRAVERSION.
1247 packit() {
1248 set_paths
1250 # Handle cross compilation
1251 case "$ARCH" in
1252 arm*|x86_64) arch="-$ARCH" ;;
1253 esac
1255 title 'Pack: %s' "$PACKAGE $VERSION$arch"
1257 if grep -q ^genpkg_rules $receipt; then
1258 _ 'Executing: %s' 'genpkg_rules'
1259 set -e; cd $pkgdir; mkdir -p $fs
1260 genpkg_rules || (newline; _ 'ERROR: genpkg_rules failed'; newline) >> \
1261 $LOGS/$pkg.log
1262 else
1263 _ 'No packages rules: meta package'
1264 mkdir -p $fs
1265 fi
1267 # First QA check to stop now if genpkg_rules failed.
1268 lerror=$(_n 'ERROR')
1269 if fgrep -q ^$lerror $LOGS/$pkg.log; then
1270 exit 1
1271 fi
1273 cd $taz
1274 for file in receipt description.txt; do
1275 [ ! -f "../$file" ] && continue
1276 action 'Copying "%s"...' "$file"
1277 cp -f ../$file $pack; chown 0.0 $pack/$file; status
1278 done
1279 copy_generic_files
1281 # Strip and stuff files.
1282 strip_package
1283 strip_mo_i18n
1285 # Create files.list with redirecting find output.
1286 action 'Creating the list of files...'
1287 cd $fs
1288 find . -type f -print > ../files.list
1289 find . -type l -print >> ../files.list
1290 cd ..; sed -i s/'^.'/''/ files.list
1291 status
1293 # Md5sum of files.
1294 action 'Creating md5sum of files...'
1295 while read file; do
1296 [ -L "fs$file" ] && continue
1297 [ -f "fs$file" ] || continue
1298 case "$file" in
1299 /lib/modules/*/modules.*|*.pyc) continue ;;
1300 esac
1301 md5sum "fs$file" | sed 's/ fs/ /'
1302 done < files.list > md5sum
1303 status
1305 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
1306 2>/dev/null | awk 'END{ print $1 }')
1308 # Build cpio archives.
1309 action 'Compressing the FS...'
1310 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
1311 rm -rf fs
1312 status
1314 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list md5sum description.txt \
1315 2>/dev/null | awk 'END{ print $1 }')
1317 action 'Updating receipt sizes...'
1318 sed -i s/^PACKED_SIZE.*$// receipt
1319 sed -i s/^UNPACKED_SIZE.*$// receipt
1320 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
1321 status
1323 # Set extra version.
1324 if [ -n "$EXTRAVERSION" ]; then
1325 action 'Updating receipt EXTRAVERSION: %s' "$EXTRAVERSION"
1326 sed -i s/^EXTRAVERSION.*$// receipt
1327 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
1328 status
1329 fi
1331 # Compress.
1332 action 'Creating full cpio archive...'
1333 find . -print | cpio -o -H newc --quiet > \
1334 ../$PACKAGE-$VERSION$EXTRAVERSION$arch.tazpkg
1335 status
1337 action 'Restoring original package tree...'
1338 unlzma -c fs.cpio.lzma | cpio -idm --quiet
1339 status
1341 rm fs.cpio.lzma; cd ..
1343 # QA and give info.
1344 tazpkg=$(ls *.tazpkg)
1345 packit_quality
1346 footer "$(_ 'Package "%s" created' "$tazpkg")"
1350 # Verify package quality and consistency.
1352 packit_quality() {
1353 #action 'QA: checking for broken link...'
1354 #link=$(find $fs/usr -type l -follow)
1355 #[ "$link" ] && echo -e "\nERROR: broken link in filesystem"
1356 #status
1358 # Exit if any error found in log file.
1359 lerror=$(_n 'ERROR')
1360 if fgrep -q ^$lerror $LOGS/$pkg.log; then
1361 rm -f $command
1362 exit 1
1363 fi
1365 action 'QA: checking for empty package...'
1366 files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l)
1367 if [ "$files" -eq 0 -a "$CATEGORY" != 'meta' ]; then
1368 newline; _ 'ERROR: empty package'
1369 rm -f $command
1370 exit 1
1371 else
1372 :; status
1373 # Find and remove old package(s)
1374 tempd="$(mktemp -d)"; cd "$tempd"
1375 for testpkg in $(ls $PKGS/$pkg-*.tazpkg 2> /dev/null); do
1376 # Extract receipt from each matched package
1377 cpio -F "$testpkg" -i receipt >/dev/null 2>&1
1378 name=$(. receipt; echo $PACKAGE)
1379 rm receipt
1380 if [ "$name" == "$pkg" ]; then
1381 action 'Removing old package "%s"' "$(basename "$testpkg")"
1382 rm -f "$testpkg"
1383 status
1384 fi
1385 done
1386 rm -r "$tempd"
1387 mv -f $pkgdir/taz/$pkg-*.tazpkg $PKGS
1388 sed -i /^${pkg}$/d $broken
1389 #action 'Removing source tree...'
1390 #rm -f $WOK/$pkg/source; status
1391 fi
1395 # Reverse "cat" command: prints input lines in the reverse order
1397 tac() {
1398 sed '1!G;h;$!d' $1
1402 # Install package on --install or update the chroot.
1404 install_package() {
1405 case "$ARCH" in
1406 arm*|x86_64)
1407 arch="-$ARCH"
1408 root="$CROSS_TREE/sysroot" ;;
1409 esac
1410 # Install package if requested but skip install if target host doesn't
1411 # match build system or it will break the build chroot.
1412 build=$(echo $BUILD_SYSTEM | cut -d- -f1)
1413 if [ -n "$inst" ] && [ "$build" == "$ARCH" ]; then
1414 if [ -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ]; then
1415 cd $PKGS
1416 tazpkg install $PACKAGE-$VERSION$EXTRAVERSION.tazpkg --forced
1417 else
1418 _ 'Unable to install package, build has failed.'; newline
1419 exit 1
1420 fi
1421 fi
1423 # Install package if part of the chroot to keep env up-to-date.
1424 if [ -d "$root$INSTALLED/$pkg" ]; then
1425 . /etc/slitaz/cook.conf
1426 . $WOK/$pkg/taz/$pkg-*/receipt
1427 _ 'Updating %s chroot environment...' "$ARCH"
1428 _ 'Updating chroot: %s' "$pkg ($VERSION$EXTRAVERSION$arch)" | log
1429 cd $PKGS
1430 tazpkg install $pkg-$VERSION$EXTRAVERSION$arch.tazpkg --forced --root=$root
1431 fi
1435 # remove chroot jail
1437 umount_aufs() {
1438 tac ${1}rw/aufs-umount.sh | sh
1439 rm -rf ${1}rw
1440 umount ${1}root
1441 rmdir ${1}r*
1445 # Launch the cook command into a chroot jail protected by aufs.
1446 # The current filesystems are used read-only and updates are
1447 # stored in a separate branch.
1449 try_aufs_chroot() {
1451 base="/dev/shm/aufsmnt$$"
1453 # Can we setup the chroot? Is it already done?
1454 grep -q ^AUFS_NOT_SUPPORTED $receipt && return
1455 grep -q ^AUFS_NOT_RAMFS $receipt && base="/mnt/aufsmnt$$"
1456 [ -n "$AUFS_MOUNTS" -a ! -f /aufs-umount.sh ] || return
1457 lsmod | grep -q aufs || modprobe aufs 2> /dev/null || return
1458 mkdir ${base}root ${base}rw || return
1460 _ 'Setup aufs chroot...'
1462 # Sanity check
1463 for i in / /proc /sys /dev/shm /home ; do
1464 case " $AUFS_MOUNTS " in
1465 *\ $i\ *) ;;
1466 *) AUFS_MOUNTS="$AUFS_MOUNTS $i" ;;
1467 esac
1468 done
1469 for mnt in $(ls -d $AUFS_MOUNTS | sort | uniq); do
1470 mount --bind $mnt ${base}root$mnt
1471 if [ $mnt == / ] && ! mount -t aufs -o br=${base}rw:/ none ${base}root; then
1472 _ 'Aufs mount failure'
1473 umount ${base}root
1474 rm -rf ${base}r*
1475 return
1476 fi
1477 echo "umount ${base}root$mnt" >> ${base}rw/aufs-umount.sh
1478 done
1479 trap "umount_aufs ${base}" INT
1481 chroot ${base}root $(cd $(dirname $0); pwd)/$(basename $0) "$@"
1482 status=$?
1484 _ 'Leaving aufs chroot...'
1485 umount_aufs $base
1486 # Install package outside the aufs jail
1487 install_package
1488 exit $status
1492 # Encode predefined XML entities
1494 xml_ent() {
1495 sed -e 's|&|\&amp;|g; s|<|\&lt;|g; s|>|\&gt;|g; s|"|\&quot;|g' -e "s|'|\&apos;|g"
1499 # Create a XML feed for freshly built packages.
1501 gen_rss() {
1502 pubdate=$(date '+%a, %d %b %Y %X')
1503 cat > $FEEDS/$pkg.xml <<EOT
1504 <item>
1505 <title>$PACKAGE $VERSION$EXTRAVERSION</title>
1506 <link>${COOKER_URL}?pkg=$PACKAGE</link>
1507 <guid>$PACKAGE-$VERSION$EXTRAVERSION</guid>
1508 <pubDate>$pubdate</pubDate>
1509 <description>$(echo -n "$SHORT_DESC" | xml_ent)</description>
1510 </item>
1511 EOT
1515 # Truncate stdout log file to $1 Mb.
1517 loglimit() {
1518 if [ -n "$DEFAULT_LOG_LIMIT" ]; then
1519 tee /dev/stderr | head -qc ${1:-$DEFAULT_LOG_LIMIT}m
1520 else
1521 tee /dev/stderr
1522 fi
1526 # Search file in mirrored packages
1528 search_file_mirror() {
1529 busybox unlzma -c $DB/files.list.lzma | grep $1\$ | cut -d: -f1 | sort -u
1533 # Search file in local wok packages
1535 search_file_local() {
1536 # existing packages have precedence over the package/taz folder
1537 srch=$1
1538 { for package in $(find $PKGS -name '*.tazpkg'); do
1539 if [ -n "$(busybox cpio --to-stdout --quiet -i files.list < $package | \
1540 grep /$srch\$)" ]; then
1541 busybox cpio -i receipt < $package | fgrep PACKAGE | cut -d\" -f2
1542 fi
1543 done } | sort -u
1547 # Ask in multiple choice
1549 ask_multiple() {
1550 local multiples first my_choice
1551 multiples="$1"
1552 first=$(echo "$multiples" | head -n1)
1553 newline; _ 'Multiple choice:'; echo "$multiples"; newline
1554 _ 'Select one [%s]: ' "$first"; read my_choice
1555 found="${my_choice:-$first}"
1559 # Search file in local cache (fast), local wok packages, mirrored packages
1561 search_file() {
1562 local srch cache missing
1563 srch="$1"
1564 cache='/var/cache/ldsearch.cache'
1565 missing='/var/cache/missing.file'
1566 touch $cache $missing
1567 found=$(grep $srch $cache | cut -d$'\t' -f2)
1568 if [ -z "$found" ]; then
1569 found=$(search_file_local $srch)
1570 if [ -n "$found" ]; then
1571 if [ $(echo "$found" | wc -l) -gt 1 ]; then
1572 ask_multiple "$found"
1573 fi
1574 echo -e "$srch\t$found" >> $cache
1575 else
1576 found=$(search_file_mirror $srch)
1577 if [ -n "$found" ]; then
1578 if [ $(echo "$found" | wc -l) -gt 1 ]; then
1579 ask_multiple "$found"
1580 fi
1581 echo -e "$srch\t$found" >> $cache
1582 else
1583 echo "$srch" >> $missing
1584 fi
1585 fi
1586 fi
1590 # Return size of file in human readible format
1591 # Note, "du" in opposite returns size occupied by file on disk (4KB multiple in most cases)
1592 filesize() {
1593 busybox ls -lh "$1" | awk '{print $5 "B"}'
1598 # Receipt functions to ease packaging
1601 get_dev_files() {
1602 action 'Getting standard devel files...'
1603 mkdir -p $fs/usr/lib
1604 cp -a $install/usr/lib/pkgconfig $fs/usr/lib
1605 cp -a $install/usr/lib/*a $fs/usr/lib
1606 cp -a $install/usr/include $fs/usr
1607 status
1611 # Function to use in compile_rules() to copy man page from $src to $install
1613 cook_pick_manpages() {
1614 local name section
1615 action 'Copying man pages...'
1617 for i in $@; do
1618 name=$(echo $i | sed 's|\.[gbx]z2*$||')
1619 section=${name##*/}; section=${section##*.}
1620 mkdir -p $install/usr/share/man/man$section
1621 cp -a $i $install/usr/share/man/man$section
1622 done
1623 status
1627 # Function to use in genpkg_rules() to copy specified files from $install to $fs
1629 cook_copy_files() {
1630 action 'Copying files...'
1631 cd $install
1632 local i j
1633 for i in $@; do
1634 for j in $(find . -name $i ! -type d); do
1635 mkdir -p $fs$(dirname ${j#.})
1636 cp -a $j $fs/${j#.}
1637 done
1638 done
1639 cd - >/dev/null
1640 status
1644 # Function to use in genpkg_rules() to copy specified folders from $install to $fs
1646 cook_copy_folders() {
1647 action 'Copying folders...'
1648 cd $install
1649 local i j
1650 for i in $@; do
1651 for j in $(find . -name $i -type d); do
1652 mkdir -p $fs$(dirname ${j#.})
1653 cp -a $j $fs/${j#.}
1654 done
1655 done
1656 cd - >/dev/null
1657 status
1661 # Function to use in genpkg_rules() to copy hicolor icons in specified sizes
1662 # (default: 16 and 48) from $install to $fs
1664 cook_copy_icons() {
1665 local sizes=$@
1666 action 'Copying hicolor icons...'
1667 mkdir -p $fs/usr/share/icons/hicolor
1668 for i in ${sizes:-16 48}; do
1669 [ -e "$install/usr/share/icons/hicolor/${i}x$i" ] &&
1670 cp -a $install/usr/share/icons/hicolor/${i}x$i \
1671 $fs/usr/share/icons/hicolor
1672 done
1673 status
1676 dblog() { tee -a $LOGS/pkgdb.log; }
1682 # Commands
1685 case "$1" in
1686 usage|help|-u|-h)
1687 usage ;;
1689 list-wok)
1690 title 'List of %s packages in "%s"' "$ARCH" "$WOK"
1691 cd $WOK
1692 if [ "$ARCH" != 'i486' ]; then
1693 count=0
1694 for pkg in $(fgrep 'HOST_ARCH=' */receipt | egrep "$ARCH|any" | cut -d: -f1)
1695 do
1696 unset HOST_ARCH
1697 . $pkg
1698 count=$(($count + 1))
1699 colorize 34 "$PACKAGE"
1700 done
1701 else
1702 count=$(ls | wc -l)
1703 ls -1
1704 fi
1705 footer "$(_p '%s package' '%s packages' "$count" "$(colorize 32 "$count")")"
1706 ;;
1708 activity)
1709 cat $activity ;;
1711 search)
1712 # Just a simple search function, we dont need more actually.
1713 query="$2"
1714 title 'Search results for "%s"' "$query"
1715 cd $WOK; ls -1 | grep "$query"
1716 footer ;;
1718 setup)
1719 # Setup a build environment
1720 check_root
1721 _ 'Cook: setup environment' | log
1722 title 'Setting up your environment'
1723 [ -d $SLITAZ ] || mkdir -p $SLITAZ
1724 cd $SLITAZ
1725 init_db_files
1726 _ 'Checking for packages to install...'
1727 # Use setup pkgs from cross.conf or cook.conf. When cross compiling
1728 # ARCH-setup or 'cross check' should be used before: cook setup
1729 case "$ARCH" in
1730 arm*|x86_64)
1731 if [ ! -x '/usr/bin/cross' ]; then
1732 _ 'ERROR: %s is not installed' 'cross'
1733 exit 1
1734 fi
1735 _ 'Using config file: %s' '/etc/slitaz/cross.conf'
1736 . /etc/slitaz/cross.conf ;;
1737 esac
1738 for pkg in $SETUP_PKGS; do
1739 if [ -n "$forced" ]; then
1740 tazpkg -gi $pkg --forced
1741 else
1742 [ ! -d "$INSTALLED/$pkg" ] && tazpkg get-install $pkg
1743 fi
1744 done
1746 # Handle --options
1747 case "$2" in
1748 --wok) hg clone $WOK_URL wok || exit 1 ;;
1749 --stable) hg clone $WOK_URL-stable wok || exit 1 ;;
1750 --undigest) hg clone $WOK_URL-undigest wok || exit 1 ;;
1751 --tiny) hg clone $WOK_URL-tiny wok || exit 1 ;;
1752 esac
1754 # SliTaz group and permissions
1755 if ! grep -q ^slitaz /etc/group; then
1756 _ 'Adding group "%s"' 'slitaz'
1757 addgroup slitaz
1758 fi
1759 _ 'Setting permissions for group "%s"...' 'slitaz'
1760 find $SLITAZ -maxdepth 2 -exec chown root.slitaz {} \;
1761 find $SLITAZ -maxdepth 2 -exec chmod g+w {} \;
1762 footer "$(_ 'All done, ready to cook packages :-)')" ;;
1764 *-setup)
1765 # Setup for cross compiling.
1766 arch="${1%-setup}"
1767 check_root
1768 . /etc/slitaz/cook.conf
1769 for pkg in $CROSS_SETUP; do
1770 if [ -n "$forced" ]; then
1771 tazpkg -gi $pkg --forced
1772 else
1773 [ ! -d "$INSTALLED/$pkg" ] && tazpkg -gi $pkg
1774 fi
1775 done
1777 _ 'Cook: setup %s cross environment' "$arch" | log
1778 title 'Setting up your %s cross environment' "$arch"
1779 init_db_files
1780 sed -i \
1781 -e s"/ARCH=.*/ARCH=\"$arch\"/" \
1782 -e s"/CROSS_TREE=.*/CROSS_TREE=\"\/cross\/$arch\"/" \
1783 -e s'/BUILD_SYSTEM=.*/BUILD_SYSTEM=i486-slitaz-linux/' \
1784 /etc/slitaz/cook.conf
1785 case "$arch" in
1786 arm)
1787 flags='-O2 -march=armv6'
1788 host="$ARCH-slitaz-linux-gnueabi" ;;
1789 armv6hf)
1790 flags='-O2 -march=armv6j -mfpu=vfp -mfloat-abi=hard'
1791 host="$ARCH-slitaz-linux-gnueabi" ;;
1792 armv7)
1793 flags='-Os -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -pipe'
1794 host="$ARCH-slitaz-linux-gnueabi" ;;
1795 x86_64)
1796 flags='-O2 -mtune=generic -pipe'
1797 host="$ARCH-slitaz-linux" ;;
1798 esac
1799 sed -i \
1800 -e s"/CFLAGS=.*/CFLAGS=\"$flags\"/" \
1801 -e s"/HOST_SYSTEM=.*/HOST_SYSTEM=$host/" /etc/slitaz/cook.conf
1802 . /etc/slitaz/cook.conf
1803 sysroot="$CROSS_TREE/sysroot"
1804 tools="/cross/$arch/tools"
1805 root="$sysroot"
1806 # L10n: keep the same width of translations to get a consistent view
1807 _ 'Target arch : %s' "$ARCH"
1808 _ 'Configure args : %s' "$CONFIGURE_ARGS"
1809 _ 'Build flags : %s' "$flags"
1810 _ 'Arch sysroot : %s' "$sysroot"
1811 _ 'Tools prefix : %s' "$tools/bin"
1812 # Tell the packages manager where to find packages.
1813 _ 'Packages DB : %s' "$root$DB"
1814 mkdir -p $root$INSTALLED
1815 cd $root$DB; rm -f *.bak
1816 for list in packages.list packages.desc packages.equiv packages.md5; do
1817 rm -f $list
1818 ln -s $SLITAZ/packages/$list $list
1819 done
1820 # We must have the cross compiled glibc-base installed or default
1821 # i486 package will be used as dep by tazpkg and then break the
1822 # cross environment
1823 if [ ! -f "$root$INSTALLED/glibc-base/receipt" ]; then
1824 colorize 36 $(_ 'WARNING: %s is not installed in sysroot' '(e)glibc-base')
1825 fi
1826 # Show GCC version or warn if not yet compiled.
1827 if [ -x "$tools/bin/$HOST_SYSTEM-gcc" ]; then
1828 _ 'Cross compiler : %s' "$HOST_SYSTEM-gcc"
1829 else
1830 colorize 36 $(_ 'C compiler "%s" is missing' "$HOST_SYSTEM-gcc")
1831 _ 'Run "%s" to cook a toolchain' 'cross compile'
1832 fi
1833 footer ;;
1835 test)
1836 # Test a cook environment.
1837 _ 'Cook test: testing the cook environment' | log
1838 [ ! -d "$WOK" ] && exit 1
1839 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK
1840 cook cooktest ;;
1842 new)
1843 # Create the package folder and an empty receipt.
1844 pkg="$2"
1845 [ -z "$pkg" ] && usage
1846 newline
1847 if [ -d "$WOK/$pkg" ]; then
1848 _ 'Package "%s" already exists.' "$pkg"
1849 exit 1
1850 fi
1852 action 'Creating folder "%s"' "$WOK/$pkg"
1853 mkdir $WOK/$pkg; cd $WOK/$pkg; status
1855 action 'Preparing the package receipt...'
1856 cp $DATA/receipt .
1857 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
1858 status; newline
1860 # Interactive mode, asking and seding.
1861 case "$3" in
1862 --interactive|-x)
1863 _ 'Entering interactive mode...'
1864 separator
1865 _ 'Package : %s' "$pkg"
1867 _n 'Version : ' ; read answer
1868 sed -i s/'VERSION=\"\"'/"VERSION=\"$answer\""/ receipt
1870 _n 'Category : ' ; read answer
1871 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$answer\""/ receipt
1873 # L10n: Short description
1874 _n 'Short desc : ' ; read answer
1875 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$answer\""/ receipt
1877 _n 'Maintainer : ' ; read answer
1878 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$answer\""/ receipt
1880 _n 'License : ' ; read answer
1881 sed -i s/'LICENSE=\"\"'/"LICENSE=\"$answer\""/ receipt
1883 _n 'Web site : ' ; read answer
1884 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$answer\""# receipt
1885 newline
1887 # Wget URL.
1888 _ 'Wget URL to download source tarball.'
1889 _n 'Example : ' ; echo '$GNU_MIRROR/$PACKAGE/$TARBALL'
1890 _n 'Wget url : ' ; read answer
1891 sed -i "s|WGET_URL=.*|WGET_URL=\"$answer\"|" receipt
1893 # Ask for a stuff dir.
1894 confirm "$(_n 'Do you need a stuff directory? (y/N)')"
1895 if [ "$?" -eq 0 ]; then
1896 action 'Creating the stuff directory...'
1897 mkdir $WOK/$pkg/stuff; status
1898 fi
1900 # Ask for a description file.
1901 confirm "$(_n 'Are you going to write a description? (y/N)')"
1902 if [ "$?" -eq 0 ]; then
1903 action 'Creating the "%s" file...' 'description.txt'
1904 touch $WOK/$pkg/description.txt; status
1905 fi
1907 footer "$(_ 'Receipt is ready to use.')" ;;
1908 esac ;;
1910 list)
1911 # Cook a list of packages (better use the Cooker since it will order
1912 # packages before executing cook).
1913 check_root
1914 if [ -z "$2" ]; then
1915 newline; _ 'No list in argument.'; newline
1916 exit 1
1917 fi
1918 if [ ! -f "$2" ]; then
1919 newline; _ 'List "%s" not found.' "$2"; newline
1920 exit 1
1921 fi
1923 _ 'Starting cooking the list "%s"' "$2" | log
1925 for pkg in $(cat $2); do
1926 cook $pkg || broken
1927 done ;;
1929 clean-wok)
1930 check_root
1931 newline; action 'Cleaning all packages files...'
1932 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
1933 status; newline ;;
1935 clean-src)
1936 check_root
1937 newline; action 'Cleaning all packages sources...'
1938 rm -rf $WOK/*/source
1939 status; newline ;;
1941 uncook)
1942 cd $WOK
1943 count=0
1944 title 'Checking for uncooked packages'
1946 for pkg in *; do
1947 unset HOST_ARCH EXTRAVERSION
1948 [ ! -e $pkg/receipt ] && continue
1949 . $pkg/receipt
1950 # Source cooked pkg receipt to get EXTRAVERSION
1951 if [ -d "$WOK/$pkg/taz" ]; then
1952 cd $WOK/$pkg/taz/$pkg-*
1953 . receipt; cd $WOK
1954 fi
1955 case "$ARCH" in
1956 i486)
1957 debug "$(_ 'Package "%s"' "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg")"
1958 if [ ! -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ]; then
1959 count=$(($count + 1))
1960 colorize 34 "$pkg"
1961 fi ;;
1962 arm*)
1963 # Check only packages included in arch
1964 if echo "$HOST_ARCH" | egrep -q "$ARCH|any"; then
1965 # *.tazpkg
1966 if [ ! -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg" ]; then
1967 count=$(($count + 1))
1968 colorize 34 "$pkg"
1969 fi
1970 fi ;;
1971 esac
1972 done
1974 if [ "$count" -gt "0" ]; then
1975 footer "$(_p '%s uncooked package' '%s uncooked packages' "$count" "$(colorize 31 "$count")")"
1976 else
1977 _ 'All packages are cooked :-)'
1978 newline
1979 fi
1980 ;;
1982 pkgdb)
1983 # Create suitable packages list for TazPKG and only for built packages
1984 # as well as flavors files for TazLiTo. We dont need logs since we do it
1985 # manually to ensure everything is fine before syncing the mirror.
1987 rm $LOGS/pkgdb.log 2>/dev/null
1989 case "$2" in
1990 --flavors|--rmpkg) ;;
1991 *)
1992 [ -n "$2" ] && PKGS="$2"
1993 if [ ! -d "$PKGS" ]; then
1994 { newline; _ "Packages directory \"%s\" doesn't exist" "$PKGS"; newline; } | dblog
1995 exit 1
1996 fi ;;
1997 esac
1999 time=$(date +%s)
2000 flavors="$SLITAZ/flavors"
2001 live="$SLITAZ/live"
2003 echo 'cook:pkgdb' > $command
2004 _ 'Cook pkgdb: Creating all packages lists' | log
2005 newline; { _ 'Creating lists for "%s"' "$PKGS"; separator; } | dblog
2007 { _ 'Cook pkgdb started: %s' "$(date "$(_ '+%%F %%R')")"; newline; } | dblog
2009 cd $PKGS
2010 rm -f packages.* extra.list
2011 touch packages.equiv
2013 _n 'Creating file "%s"' 'packages.list' | dblog
2014 ls -1 *.tazpkg | sed s'/.tazpkg//' > $PKGS/packages.list
2015 echo " ($(filesize $PKGS/packages.list))" | dblog
2017 _n 'Creating file "%s"' 'packages.md5' | dblog
2018 md5sum *.tazpkg > $PKGS/packages.md5
2019 echo " ($(filesize $PKGS/packages.md5))" | dblog
2020 cp $PKGS/packages.md5 $PKGS/packages.toremove # list of duplicates
2022 md5sum packages.md5 | cut -d' ' -f1 > ID
2023 ( cat ./ID | tr $'\n' ' '; date -ur ./ID +%s ) > IDs # md5 and timestamp
2025 _n 'Creating file "%s"' 'descriptions.txt' | dblog
2026 rm $PKGS/descriptions.txt 2>/dev/null
2027 for i in $(ls $WOK | sort); do
2028 if [ -e "$WOK/$i/description.txt" ]; then
2029 echo "$i" >> descriptions.txt
2030 cat "$WOK/$i/description.txt" | sed 's|^$| |' >> descriptions.txt
2031 echo >> descriptions.txt
2032 fi
2033 done
2034 echo " ($(filesize $PKGS/descriptions.txt))" | dblog
2037 _ 'Creating lists from "%s"' "$WOK" | dblog
2038 cd $WOK
2039 for pkg in *; do
2040 unset_receipt
2041 . $pkg/receipt
2042 # PACKED_SIZE and UNPACKED_SIZE are only in built receipt
2043 [ -s $pkg/taz/*/receipt ] && . $pkg/taz/*/receipt
2045 if [ -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ] || \
2046 [ -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg" ]; then
2048 # packages.desc lets us search easily in DB
2049 cat >> $PKGS/packages.desc <<EOT
2050 $PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE
2051 EOT
2053 # packages.txt used by tazpkg and tazpkg-web also to provide
2054 # a human readable package list with version and description.
2055 cat >> $PKGS/packages.txt <<EOT
2056 $PACKAGE
2057 $VERSION$EXTRAVERSION
2058 $SHORT_DESC
2059 $PACKED_SIZE ($UNPACKED_SIZE installed)
2061 EOT
2063 # packages.info combines TazPkg separate files
2064 # and will substitute them all
2065 SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g')
2066 DEPENDS=$(echo $DEPENDS) # remove newlines from some receipts
2067 MD5="$(fgrep " $PACKAGE-$VERSION$EXTRAVERSION.tazpkg" $PKGS/packages.md5 | awk '{print $1}')"
2068 cat >> $PKGS/packages.info <<EOT
2069 $PACKAGE $VERSION$EXTRAVERSION $CATEGORY $SHORT_DESC $WEB_SITE $TAGS $SIZES $DEPENDS $MD5
2070 EOT
2072 # packages.equiv is used by tazpkg install to check depends.
2073 for i in $PROVIDE; do
2074 DEST=''
2075 echo $i | fgrep -q : && DEST="${i#*:}:"
2076 if grep -qs ^${i%:*}= $PKGS/packages.equiv; then
2077 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" \
2078 $PKGS/packages.equiv
2079 else
2080 echo "${i%:*}=$DEST$PACKAGE" >> $PKGS/packages.equiv
2081 fi
2082 done
2084 # files.list provides a list of all packages files.
2085 cat $pkg/taz/*/files.list | sed s/^/"$pkg: \0"/ >> \
2086 $PKGS/files.list
2088 # list of duplicates
2089 sed -i "/ $PACKAGE-$VERSION$EXTRAVERSION.tazpkg/d" $PKGS/packages.toremove
2090 else
2091 # if receipt variable HOST_ARCH absent/empty or contains ARCH
2092 if [ -z "$HOST_ARCH" -o "${HOST_ARCH/$ARCH/}" != "$HOST_ARCH" ]; then
2093 _ ' - absent: %s (%s)' "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" "$ARCH" | dblog
2094 fi
2095 fi
2096 done
2098 # Display list size.
2099 _ 'Done: %s (%s)' 'packages.desc' "$(filesize $PKGS/packages.desc)" | dblog
2100 _ 'Done: %s (%s)' 'packages.txt' "$(filesize $PKGS/packages.txt)" | dblog
2101 _ 'Done: %s (%s)' 'packages.info' "$(filesize $PKGS/packages.info)" | dblog
2102 _ 'Done: %s (%s)' 'packages.equiv' "$(filesize $PKGS/packages.equiv)" | dblog
2104 cd $PKGS
2107 # Check package duplicates
2108 if [ -s "$PKGS/packages.toremove" ]; then
2109 newline | dblog
2110 _ 'Removing duplicates:' | dblog
2111 while read pkgsum pkgfile; do
2112 echo " - $pkgfile" | dblog
2113 sed -i "/${pkgfile%.tazpkg}/d" $PKGS/packages.list
2114 sed -i "/ $pkgfile/d" $PKGS/packages.md5
2115 [ -n "$rmpkg" ] && rm $PKGS/$pkgfile # remove packages only with --rmpkg
2116 done < $PKGS/packages.toremove
2117 newline | dblog
2118 fi
2119 rm $PKGS/packages.toremove
2122 # files.list.lzma
2123 _n 'Creating file "%s"' 'files.list.lzma' | dblog
2124 touch files.list
2125 # pkgs.slitaz.org strongly depends on list sorted by packages names
2126 lzma e files.list files.list.lzma
2127 echo " ($(filesize $PKGS/files.list.lzma))" | dblog
2129 # Pre-sorting filenames causes 10% smaller resulting lzma file
2130 _n 'Creating file "%s"' 'files-list.lzma' | dblog
2131 cat files.list | sort -k2 -o files.list.sorted
2132 lzma e files.list.sorted files-list.lzma
2133 rm -f files.list files.list.sorted
2134 echo " ($(filesize $PKGS/files-list.lzma))" | dblog
2136 [ -e files.list.md5 ] && rm files.list.md5
2137 md5sum files-list.lzma | cut -d' ' -f1 | tr -d $'\n' > files-list.md5
2139 # packages.info.lzma
2140 PI=packages.info
2141 _n 'Creating file "%s"' 'packages.info.lzma' | dblog
2142 touch $PI
2143 lzma e $PI $PI.lzma
2144 echo " ($(filesize $PKGS/packages.info.lzma))" | dblog
2146 # Make bundle to fast recharge
2147 _n 'Creating file "%s"' 'bundle.tar.lzma' | dblog
2148 [ -f bundle.tar.lzma ] && rm bundle.tar.lzma
2149 # Make sure to get "mirrors" file
2150 until [ -e 'mirrors' ]; do
2151 wget -q http://mirror1.slitaz.org/mirrors
2152 echo -n '.' | dblog; sleep 5
2153 done
2154 # Make sure to get "extra.list" file
2155 until [ -e 'extra.list' ]; do
2156 wget -q -O extra.list http://mirror1.slitaz.org/packages/get.list
2157 echo -n '.' | dblog; sleep 5
2158 done
2159 busybox tar -chaf bundle.tar.lzma \
2160 mirrors extra.list files-list.md5 packages.info descriptions.txt \
2161 packages.desc packages.md5 packages.txt packages.list packages.equiv
2162 rm ./mirrors
2163 echo " ($(filesize $PKGS/bundle.tar.lzma))" | dblog
2165 # Display some info.
2166 separator | dblog
2167 nb=$(ls $PKGS/*.tazpkg | wc -l)
2168 time=$(($(date +%s) - $time))
2169 # L10n: 's' is for seconds (cooking time)
2170 { _ 'Packages: %s - Time: %ss' "$nb" "$time"; newline; } | dblog
2173 # Create all flavors files at once. Do we really need code to monitor
2174 # flavors changes? Lets just build them with packages lists before
2175 # syncing the mirror.
2176 [ "$2" != '--flavors' ] && exit 1
2178 if [ ! -d "$flavors" ]; then
2179 { _ 'Missing flavors folder "%s"' "$flavors"; newline; } | dblog
2180 exit 1
2181 fi
2183 [ ! -d "$live" ] && mkdir -p $live
2184 _ 'Creating flavors files in "%s"' "$live" | dblog
2185 _ 'Cook pkgdb: Creating all flavors' | log
2186 separator | dblog
2188 _ 'Recharging lists to use latest packages...' | dblog
2189 tazpkg recharge >/dev/null 2>/dev/null
2191 # We need a custom tazlito config to set working dir to /home/slitaz.
2192 if [ ! -f "$live/tazlito.conf" ]; then
2193 _ 'Creating configuration file "%s"' 'tazlito.conf' | dblog
2194 cp /etc/tazlito/tazlito.conf $live
2195 sed -i s@WORK_DIR=.*@WORK_DIR=\"/home/slitaz\"@ \
2196 $live/tazlito.conf
2197 fi
2199 # Update Hg flavors repo and pack.
2200 if [ -d "$flavors/.hg" ]; then
2201 cd $flavors; hg pull -u
2202 fi
2204 cd $live
2205 _ 'Starting to generate flavors...' | dblog
2206 rm -f flavors.list *.flavor
2207 for i in $flavors/*; do
2208 fl=$(basename $i)
2209 _ 'Packing flavor "%s"' "$fl" | dblog
2210 tazlito pack-flavor $fl >/dev/null || exit 1
2211 tazlito show-flavor $fl --brief --noheader 2>/dev/null >> flavors.list
2212 done
2213 cp -f $live/*.flavor $live/flavors.list $PKGS
2214 separator | dblog
2215 { _ 'Total flavors size: %s' "$(du -sh $live | awk '{print $1}')"; newline; } | dblog
2216 rm -f $command
2217 separator | dblog
2218 _ 'Cook pkgdb end: %s' "$(date "$(_ '+%%F %%R')")" | dblog
2219 ;;
2221 *)
2222 # Just cook and generate a package.
2223 check_root
2224 time=$(date +%s)
2225 pkg="$1"
2226 [ -z "$pkg" ] && usage
2227 lastcooktime=$(sed '/^Cook time/!d;s|.*: *\([0-9]*\)s.*|\1|' \
2228 $LOGS/$pkg.log 2> /dev/null | sed '$!d')
2229 receipt="$WOK/$pkg/receipt"
2230 check_pkg_in_wok
2231 newline
2233 unset inst
2234 unset_receipt
2235 . $receipt
2237 # Handle cross compilation.
2238 case "$ARCH" in
2239 arm*)
2240 if [ -z "$HOST_ARCH" ]; then
2241 _ 'cook: HOST_ARCH is not set in "%s" receipt' "$pkg"
2242 error="$(_ 'package "%s" is not included in %s' "$pkg" "$ARCH")"
2243 _ 'cook: %s' "$error"
2244 [ -n "$CROSS_BUGS" ] && _ 'bugs: %s' "$CROSS_BUGS"
2245 _ 'Cook skip: %s' "$error" | log
2246 newline
2247 exit 1
2248 fi ;;
2249 esac
2251 # Some packages are not included in some arch or fail to cross compile.
2252 : ${HOST_ARCH=i486}
2253 debug "$(_ 'Host arch %s' "$HOST_ARCH")"
2254 # Handle arm{v6hf,v7,..}
2255 if ! $(echo "$HOST_ARCH" | egrep -q "${ARCH%v[0-9]*}|any"); then
2256 _ 'cook: %s' "HOST_ARCH=$HOST_ARCH"
2257 error="$(_ "package \"%s\" doesn't cook or is not included in %s" "$pkg" "$ARCH")"
2258 _ 'cook: %s' "error"
2259 [ -n "$CROSS_BUGS" ] && _ 'bugs: %s' "$CROSS_BUGS"
2260 _ 'Cook skip: %s' "$error" | log
2261 sed -i /^${pkg}$/d $broken
2262 newline
2263 exit 0
2264 fi
2266 # Skip blocked, 3 lines also for the Cooker.
2267 if grep -q "^$pkg$" $blocked && [ "$2" != '--unblock' ]; then
2268 _ 'Package "%s" is blocked' "$pkg"; newline
2269 exit 0
2270 fi
2272 try_aufs_chroot "$@"
2274 # Log and source receipt.
2275 _ 'Cook started for: %s' "<a href='cooker.cgi?pkg=$pkg'>$pkg</a>" | log
2276 echo "cook:$pkg" > $command
2277 [ "$lastcooktime" ] &&
2278 echo "cook:$pkg $lastcooktime $(date +%s)" >> $cooktime
2279 while read cmd duration start; do
2280 [ $(($start + $duration)) -lt $(date +%s) ] &&
2281 echo "sed -i '/^$cmd $duration/d' $cooktime"
2282 done < $cooktime | sh
2284 # Display and log info if cook process stopped.
2285 # FIXME: gettext not working (in single quotes) here!
2286 trap '_ "\n\nCook stopped: control-C\n\n" | \
2287 tee -a $LOGS/$pkg.log' INT
2289 # Handle --options
2290 case "$2" in
2291 --clean|-c)
2292 action 'Cleaning "%s"' "$pkg"
2293 cd $WOK/$pkg; rm -rf install taz source
2294 status; newline
2295 exit 0 ;;
2297 --install|-i)
2298 inst='yes' ;;
2300 --getsrc|-gs)
2301 title 'Getting source for "%s"' "$pkg"
2302 get_source
2303 _ 'Tarball: %s' "$SRC/$TARBALL"; newline
2304 exit 0 ;;
2306 --block|-b)
2307 action 'Blocking package "%s"' "$pkg"
2308 [ $(grep "^$pkg$" $blocked) ] || echo "$pkg" >> $blocked
2309 status; newline
2310 exit 0 ;;
2312 --unblock|-ub)
2313 action 'Unblocking package "%s"' "$pkg"
2314 sed -i "/^${pkg}$/"d $blocked
2315 status; newline
2316 exit 0 ;;
2318 --pack)
2319 if [ -d $WOK/$pkg/taz ]; then
2320 rm -rf $WOK/$pkg/taz
2321 [ -f $LOGS/$pkg-pack.log ] && rm -rf $LOGS/$pkg-pack.log
2322 packit 2>&1 | tee -a $LOGS/$pkg-pack.log
2323 clean_log
2324 else
2325 _ 'Need to build "%s"' "$pkg"
2326 exit 0
2327 fi
2328 exit 0 ;;
2330 --cdeps)
2331 if [ ! -d $WOK/$pkg/taz ]; then
2332 _ 'Need to build "%s"' "$pkg"
2333 exit 0
2334 fi
2336 title 'Checking depends'
2337 lddlist='/tmp/lddlist'; touch $lddlist
2338 missing='/var/cache/missing.file'
2340 # find all deps using ldd
2341 for exe in $(find $WOK/$pkg/taz -type f -perm +111); do
2342 [ "x$(dd if=$exe bs=4 count=1 2>/dev/null)" == "xELF" ] &&
2343 ldd $exe | sed 's| ||' | cut -d' ' -f1 >> $lddlist
2344 done #"
2346 # remove exe/so duplicates
2347 sort -u $lddlist > $lddlist.sorted
2349 # search packages
2350 for exefile in $(cat $lddlist.sorted); do
2351 search_file $exefile
2352 echo "$found" >> $lddlist.pkgs
2353 echo -n '.'
2354 done
2355 echo
2357 # remove packages duplicates
2358 sort -u $lddlist.pkgs > $lddlist.final
2359 sort -u $missing > $missing.final
2360 rm -f $lddlist $lddlist.sorted $lddlist.pkgs $missing
2361 exit 0 ;;
2362 esac
2364 # Rotate log
2365 for i in $(seq 9 -1 1); do
2366 j=$(($i - 1))
2367 [ -e $LOGS/$pkg.log.$j ] && mv -f $LOGS/$pkg.log.$j $LOGS/$pkg.log.$i
2368 done
2369 [ -e $LOGS/$pkg.log ] && mv $LOGS/$pkg.log $LOGS/$pkg.log.0
2371 # Check if wanted is built now so we have separate log files.
2372 for wanted in $WANTED ; do
2373 if grep -q "^$wanted$" $blocked; then
2374 _ 'WANTED package "%s" is blocked' "$wanted" | tee $LOGS/$pkg.log
2375 newline
2376 rm -f $command
2377 exit 1
2378 fi
2379 if grep -q "^$wanted$" $broken; then
2380 _ 'WANTED package "%s" is broken' "$wanted" | tee $LOGS/$pkg.log
2381 newline
2382 rm -f $command
2383 exit 1
2384 fi
2385 if [ ! -d "$WOK/$wanted/install" ]; then
2386 cook "$wanted" || exit 1
2387 fi
2388 done
2390 # Cook and pack or exit on error and log everything.
2391 cookit $@ 2>&1 | loglimit 50 > $LOGS/$pkg.log
2392 remove_deps | tee -a $LOGS/$pkg.log
2393 cookit_quality
2394 packit 2>&1 | loglimit 5 >> $LOGS/$pkg.log
2395 clean_log
2397 # Exit if any error in packing.
2398 lerror=$(_n 'ERROR')
2399 if grep -Ev "(/root/.cvspass|conftest|df: /|rm: can't remove)" $LOGS/$pkg.log | \
2400 grep -Eq "(^$lerror|: No such file or directory|not remade because of errors|ake: \*\*\* .* Error)"; then
2401 debug_info | tee -a $LOGS/$pkg.log
2402 rm -f $command
2403 exit 1
2404 fi
2406 # Create an XML feed
2407 gen_rss
2409 # Time and summary
2410 time=$(($(date +%s) - $time))
2411 summary | tee -a $LOGS/$pkg.log
2412 newline
2414 # We may want to install/update (outside aufs jail !).
2415 [ -s /aufs-umount.sh ] ||
2416 install_package
2418 # Finally we DON'T WANT to build the *-dev or packages with WANTED="$pkg"
2419 # You want automation: use the Cooker Build Bot.
2420 rm -f $command ;;
2421 esac
2423 exit 0