cookutils view cook @ rev 849

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