cookutils view cook @ rev 925

cook: improve $CAT using; lighttpd/index.cgi: improve top buttons.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Tue Jun 13 02:46:13 2017 +0300 (2017-06-13)
parents f4e577c714e2
children a984acecb3fa
line source
1 #!/bin/sh
2 #
3 # Cook - A tool to cook and generate SliTaz packages. Read the README
4 # before adding or modifying any code in cook!
5 #
6 # Copyright (C) SliTaz GNU/Linux - GNU GPL v3
7 # Author: Christophe Lincoln <pankso@slitaz.org>
8 #
10 . /usr/lib/slitaz/libcook.sh
12 VERSION="3.2"
13 export output=raw
16 # Internationalization.
18 export TEXTDOMAIN='cook'
21 #
22 # Functions
23 #
25 usage() {
26 cat <<EOT
28 $(boldify "$(_ 'Usage:')") $(_ 'cook [package|command] [list|--option]')
30 $(boldify "$(_ 'Commands:')")
31 usage|help $(_ 'Display this short usage.')
32 setup $(_ 'Setup your build environment.')
33 *-setup $(_ 'Setup a cross environment.')
34 * = {arm|armv6hf|armv7|x86_64}
35 test $(_ 'Test environment and cook a package.')
36 list-wok $(_ 'List packages in the wok.')
37 search $(_ 'Simple packages search function.')
38 new $(_ 'Create a new package with a receipt.')
39 list $(_ 'Cook a list of packages.')
40 clean-wok $(_ 'Clean-up all packages files.')
41 clean-src $(_ 'Clean-up all packages sources.')
42 uncook $(_ 'Check for uncooked packages')
43 pkgdb $(_ 'Create packages DB lists and flavors.')
45 $(boldify "$(_ 'Options:')")
46 cook <pkg>
47 --clean -c $(_ 'clean the package in the wok.')
48 --install -i $(_ 'cook and install the package.')
49 --getsrc -gs $(_ 'get the package source tarball.')
50 --block -b $(_ 'block a package so cook will skip it.')
51 --unblock -ub $(_ 'unblock a blocked package.')
52 --cdeps $(_ 'check dependencies of cooked package.')
53 --pack $(_ 'repack an already built package.')
54 --debug $(_ 'display debugging messages.')
55 --continue $(_ 'continue running compile_rules.')
56 cook new <pkg>
57 --interactive -x $(_ 'create a receipt interactively.')
58 cook setup
59 --wok $(_ 'clone the cooking wok from Hg repo.')
60 --stable $(_ 'clone the stable wok from Hg repo.')
61 --undigest $(_ 'clone the undigest wok from Hg repo.')
62 --tiny $(_ 'clone the tiny SliTaz wok from Hg repo.')
63 --forced $(_ 'force reinstall of chroot packages.')
64 cook pkgdb
65 --flavors $(_ 'create up-to-date flavors files.')
67 EOT
68 exit 0
69 }
72 # We don't want these escapes in web interface.
74 clean_log() {
75 sed -i -e s'|\[70G\[ \[1;32m| |' \
76 -e s'|\[0;39m \]||' $LOGS/${1:-$pkg}.log
77 }
80 # Be sure package exists in wok.
82 check_pkg_in_wok() {
83 [ -d "$WOK/$pkg" ] || die 'Unable to find package "%s" in the wok' "$pkg"
84 }
87 # Initialize files used in $CACHE
89 init_db_files() {
90 _ 'Creating directories structure in "%s"' "$SLITAZ"
91 mkdir -p $WOK $PKGS $SRC $CACHE $LOGS $FEEDS
92 _ 'Creating DB files in "%s"' "$CACHE"
93 touch $activity $command $broken $blocked
94 }
97 # QA: check a receipt consistency before building.
99 receipt_quality() {
100 _ 'QA: checking package receipt...'
102 for var in PACKAGE VERSION CATEGORY SHORT_DESC MAINTAINER WEB_SITE; do
103 unset value
104 value="$(. $receipt; eval echo \$$var)"
105 # L10n: QA is quality assurance
106 [ -n "$value" ] || die 'QA: empty variable: %s' "$var=\"\""
108 case "$var" in
109 CATEGORY)
110 valid="$(echo $PKGS_CATEGORIES)" # avoid newlines
111 if ! echo " $valid " | grep -q " $value "; then
112 _ 'QA: unknown category "%s"' "$value"
113 die 'Please, use one of: %s' "$valid"
114 fi
115 ;;
116 WEB_SITE)
117 # We don't check WGET_URL since if dl is needed it will fail.
118 # Break also if we're not online. Here error is not fatal.
119 if ifconfig | grep -A1 '^[a-z]*[0-9]' | fgrep -q 'addr:' && \
120 ! busybox wget -T 12 --spider $value 2>/dev/null; then
121 _ 'QA: unable to reach "%s"' "$value"
122 fi
123 ;;
124 esac
125 done
126 }
129 # Paths used in receipt and by cook itself.
131 set_paths() {
132 pkgdir="$WOK/$pkg"
133 . "$pkgdir/receipt"
134 basesrc="$pkgdir/source"
135 tmpsrc="$basesrc/tmp"
136 src="$basesrc/$PACKAGE-$VERSION"
137 taz="$pkgdir/taz"
138 pack="$taz/${1:-$PACKAGE}-$VERSION$EXTRAVERSION" # v2: multiple taz/* folders
139 fs="$pack/fs"
140 stuff="$pkgdir/stuff"
141 install="$pkgdir/install"
143 pkgsrc="${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}"
144 lzma_tarball="$pkgsrc.tar.lzma"
146 [ -n "$PATCH" -a -z "$PTARBALL" ] && PTARBALL="$(basename $PATCH)"
148 if [ -n "$WANTED" ]; then
149 basesrc="$WOK/$WANTED/source"
150 src="$basesrc/$WANTED-$VERSION"
151 install="$WOK/$WANTED/install"
152 wanted_stuff="$WOK/$WANTED/stuff"
153 fi
155 [ -n "$SOURCE" ] && source_stuff="$WOK/$SOURCE/stuff"
157 # Kernel version is set from wok/linux or installed/linux-api-headers(wok-undigest)
158 if [ -f "$WOK/linux/receipt" ]; then
159 kvers=$(. $WOK/linux/receipt; echo $VERSION)
160 kbasevers=$(echo $kvers | cut -d. -f1,2)
161 elif [ -f "$INSTALLED/linux-api-headers/receipt" ]; then
162 kvers=$(. $INSTALLED/linux-api-headers/receipt; echo $VERSION)
163 kbasevers=$(echo $kvers | cut -d. -f1,2)
164 fi
166 # Python version
167 [ -f "$WOK/python/receipt" ] && pyvers=$(. $WOK/python/receipt; echo $VERSION)
168 # Perl version for some packages needed it
169 [ -f "$WOK/perl/receipt" ] && perlvers=$(. $WOK/perl/receipt; echo $VERSION)
171 # Old way compatibility.
172 _pkg="$install"
173 }
176 # Create source tarball when URL is a SCM.
178 create_tarball() {
179 local tarball
180 tarball="$pkgsrc.tar.bz2"
181 [ -n "$LZMA_SRC" ] && tarball="$lzma_tarball"
182 _ 'Creating tarball "%s"' "$tarball"
183 if [ -n "$LZMA_SRC" ]; then
184 tar -c $pkgsrc | lzma e $SRC/$tarball -si $LZMA_SET_DIR || exit 1
185 LZMA_SRC=''
186 else
187 tar -cjf $tarball $pkgsrc || exit 1
188 mv $tarball $SRC; rm -rf $pkgsrc
189 fi
190 TARBALL="$tarball"
191 }
194 # Get package source. For SCM we are in cache so clone here and create a
195 # tarball here.
197 get_source() {
198 local url
199 url=${WGET_URL#*|}
200 set_paths
201 pwd=$(pwd)
202 case "$WGET_URL" in
203 http://*|ftp://*|https://*)
204 url="$MIRROR_URL/sources/packages/${TARBALL:0:1}/$TARBALL"
205 wget -T 60 -c -O $SRC/$TARBALL $WGET_URL ||
206 wget -T 60 -c -O $SRC/$TARBALL $url ||
207 die 'ERROR: %s' "wget $WGET_URL"
208 ;;
210 hg*|mercurial*)
211 _ 'Getting source from %s...' 'Hg'
212 _ 'URL: %s' "$url"
213 _ 'Cloning to "%s"' "$pwd/$pkgsrc"
214 if [ -n "$BRANCH" ]; then
215 _ 'Hg branch: %s' "$BRANCH"
216 hg clone $url --rev $BRANCH $pkgsrc ||
217 die 'ERROR: %s' "hg clone $url --rev $BRANCH"
218 else
219 hg clone $url $pkgsrc || die 'ERROR: %s' "hg clone $url"
220 fi
221 rm -rf $pkgsrc/.hg
222 create_tarball
223 ;;
225 git*)
226 _ 'Getting source from %s...' 'Git'
227 _ 'URL: %s' "$url"
228 cd $SRC
229 git clone $url $pkgsrc || die 'ERROR: %s' "git clone $url"
230 if [ -n "$BRANCH" ]; then
231 _ 'Git branch: %s' "$BRANCH"
232 cd $pkgsrc; git checkout $BRANCH; cd ..
233 fi
234 cd $SRC
235 create_tarball
236 ;;
238 cvs*)
239 mod=$PACKAGE
240 [ -n "$CVS_MODULE" ] && mod=$CVS_MODULE
241 _ 'Getting source from %s...' 'CVS'
242 _ 'URL: %s' "$url"
243 [ -n "$CVS_MODULE" ] && _ 'CVS module: %s' "$mod"
244 _ 'Cloning to "%s"' "$pwd/$mod"
245 cvs -d:$url co $mod && mv $mod $pkgsrc
246 create_tarball
247 ;;
249 svn*|subversion*)
250 _ 'Getting source from %s...' 'SVN'
251 _ 'URL: %s' "$url"
252 if [ -n "$BRANCH" ]; then
253 echo t | svn co $url -r $BRANCH $pkgsrc
254 else
255 echo t | svn co $url $pkgsrc
256 fi
257 create_tarball
258 ;;
260 bzr*)
261 _ 'Getting source from %s...' 'bazaar'
262 cd $SRC
263 pkgsrc=${url#*:}
264 if [ -n "$BRANCH" ]; then
265 echo "bzr -Ossl.cert_reqs=none branch $url -r $BRANCH"
266 bzr -Ossl.cert_reqs=none branch $url -r $BRANCH
267 else
268 echo "bzr -Ossl.cert_reqs=none branch $url"
269 bzr -Ossl.cert_reqs=none branch $url
270 cd $pkgsrc; BRANCH=$(bzr revno); cd ..
271 _ "Don't forget to add to receipt:"
272 echo -e "BRANCH=\"$BRANCH\"\n"
273 fi
274 mv $pkgsrc $pkgsrc-$BRANCH
275 pkgsrc="$pkgsrc-$BRANCH"
276 create_tarball
277 ;;
279 *)
280 broken; die 'ERROR: Unable to handle "%s"' "$WGET_URL"
281 ;;
282 esac
283 }
286 # Extract source package.
288 extract_source() {
289 if [ ! -s "$SRC/$TARBALL" ]; then
290 local url
291 url="$MIRROR_URL/sources/packages"
292 url="$url/${TARBALL:0:1}/$TARBALL"
293 _ 'Getting source from %s...' 'mirror'
294 _ 'URL: %s' "$url"
295 busybox wget -c -P $SRC $url || _ 'ERROR: %s' "wget $url"
296 fi
297 _ 'Extracting source archive "%s"' "$TARBALL"
298 case "$TARBALL" in
299 *.tar.gz|*.tgz) tar -xzf $SRC/$TARBALL 2>/dev/null ;;
300 *.tar.bz2|*.tbz|*.tbz2) tar -xjf $SRC/$TARBALL 2>/dev/null ;;
301 *.tar.lzma) tar -xaf $SRC/$TARBALL ;;
302 *.tar.lz|*.tlz) lzip -d < $SRC/$TARBALL | tar -xf - 2>/dev/null ;;
303 *.tar) tar -xf $SRC/$TARBALL ;;
304 *.zip|*.xpi) unzip -o $SRC/$TARBALL 2>/dev/null >&2;;
305 *.xz) unxz -c $SRC/$TARBALL | tar -xf - || \
306 tar -xf $SRC/$TARBALL 2>/dev/null;;
307 *.7z) 7zr x $SRC/$TARBALL 2>/dev/null >&2 ;;
308 *.Z|*.z) uncompress -c $SRC/$TARBALL | tar -xf - ;;
309 *.rpm) rpm2cpio $SRC/$TARBALL | cpio -idm --quiet ;;
310 *.run) /bin/sh $SRC/$TARBALL $RUN_OPTS ;;
311 *) cp $SRC/$TARBALL $(pwd) ;;
312 esac
313 }
316 # Display time.
318 disp_time() {
319 local sec div min
320 sec="$1"
321 div=$(( ($1 + 30) / 60))
322 case $div in
323 0) min='';;
324 # L10n: 'm' is for minutes (approximate cooking time)
325 *) min=$(_n ' ~ %dm' "$div");;
326 esac
328 # L10n: 's' is for seconds (cooking time)
329 _ '%ds%s' "$sec" "$min"
330 }
333 # Display cooked package summary.
335 summary() {
336 set_paths
337 cd $WOK/$pkg
338 [ -d $WOK/$pkg/install ] && prod=$(du -sh $WOK/$pkg/install | awk '{print $1}' 2>/dev/null)
339 [ -d $WOK/$pkg/source ] && srcdir=$(du -sh $WOK/$pkg/source | awk '{print $1}' 2>/dev/null)
340 [ -n "$TARBALL" ] && srcsize=$(du -sh $SRC/$TARBALL | awk '{print $1}')
342 _ 'Summary for: %s' "$PACKAGE $VERSION"
343 separator
345 # L10n: keep the same width of translations to get a consistent view
346 [ -n "$TARBALL" ] && _ 'Src file : %s' "$TARBALL"
347 [ -n "$srcsize" ] && _ 'Src size : %s' "$srcsize"
348 [ -n "$srcdir" ] && _ 'Source dir : %s' "$srcdir"
349 [ -n "$prod" ] && _ 'Produced : %s' "$prod"
350 _ 'Cook time : %s' "$(disp_time "$time")"
351 _ 'Cook date : %s' "$(date "$(_ '+%%F %%R')")"
352 _ 'Host arch : %s' "$ARCH"
354 separator -
355 _ ' # : Packed : Compressed : Files : Package name'
356 separator -
357 pkgi=1
358 for i in $(all_names); do
359 fs=$(du -sh $WOK/$pkg/taz/$i-$VERSION | awk '{print $1}')
360 pkgname="$i-$VERSION.tazpkg"
361 size=$(ls -lh $PKGS/$pkgname | awk '{print $5}')
362 files=$(wc -l < $WOK/$pkg/taz/$i-$VERSION/files.list)
363 printf "%2d : %7s : %10s : %5s : %s\n" "$pkgi" "$fs" "$size" "$files" "$pkgname"
364 pkgi=$((pkgi + 1))
365 done
366 separator
367 }
370 # Display debugging error info.
372 debug_info() {
373 title 'Debug information'
374 # L10n: specify your format of date and time (to help: man date)
375 # L10n: not bad one is '+%x %R'
376 _ 'Cook date: %s' "$(date "$(_ '+%%F %%R')")"
377 if [ -n "$time" ]; then
378 times="$(($(date +%s) - $time))"
379 _ 'Wasted time : %s' "$(disp_time "$times")"
380 fi
381 for error in \
382 ERROR 'No package' "cp: can't" "can't open" "can't cd" \
383 'error:' 'fatal error:' 'undefined reference to' \
384 'Unable to connect to' 'link: cannot find the library' \
385 'CMake Error' ': No such file or directory' \
386 'Could not read symbols: File in wrong format'
387 do
388 # format "line number:line content"
389 fgrep -n "$error" $LOGS/$pkg.log
390 done > $LOGS/$pkg.log.debug_info 2>&1
391 # sort by line number, remove duplicates
392 sort -gk1,1 -t: -u $LOGS/$pkg.log.debug_info
393 rm -f $LOGS/$pkg.log.debug_info
394 footer
395 }
398 # A bit smarter function than the classic `cp` command
400 scopy() {
401 if [ "$(stat -c %h -- "$1")" -eq 1 ]; then
402 cp -a "$1" "$2" # copy generic files
403 else
404 cp -al "$1" "$2" # copy hardlinks
405 fi
406 }
409 # Copy all generic files (locale, pixmaps, .desktop) from $install to $fs.
410 # We use standard paths, so some packages need to copy these files with the
411 # receipt and genpkg_rules.
412 # This function executes inside the packaging process, before compressor call.
414 copy_generic_files() {
415 # Proceed only for "main" package (for v2), and for any packages (v1)
416 [ "$pkg" == "$PACKAGE" ] || return 0
418 # $LOCALE is set in cook.conf
419 if [ -n "$LOCALE" -a -z "$WANTED" ]; then
420 if [ -d "$install/usr/share/locale" ]; then
421 mkdir -p "$fs/usr/share/locale"
422 for i in $LOCALE; do
423 if [ -d "$install/usr/share/locale/$i" ]; then
424 cp -a $install/usr/share/locale/$i $fs/usr/share/locale
425 fi
426 done
427 fi
428 fi
430 # Generic pixmaps copy can be disabled with COOKOPTS="!pixmaps" (or GENERIC_PIXMAPS="no")
431 if [ "${COOKOPTS/!pixmaps/}" == "$COOKOPTS" -a "$GENERIC_PIXMAPS" != 'no' ]; then
432 if [ -d "$install/usr/share/pixmaps" ]; then
433 mkdir -p "$fs/usr/share/pixmaps"
434 for i in png xpm; do
435 [ -f "$install/usr/share/pixmaps/$PACKAGE.$i" -a ! -f "$fs/usr/share/pixmaps/$PACKAGE.$i" ] &&
436 cp -a $install/usr/share/pixmaps/$PACKAGE.$i $fs/usr/share/pixmaps
437 done
438 fi
439 fi
441 # Desktop entry (.desktop).
442 # Generic desktop entry copy can be disabled with COOKOPTS="!menus" (or GENERIC_MENUS="no")
443 if [ "${COOKOPTS/!menus/}" == "$COOKOPTS" -a "$GENERIC_MENUS" != 'no' ]; then
444 if [ -d "$install/usr/share/applications" -a -z "$WANTED" ]; then
445 mkdir -p "$fs/usr/share"
446 cp -a $install/usr/share/applications $fs/usr/share
447 fi
448 fi
449 }
452 # Copy pixmaps, desktop files and licenses from $stuff to $install.
453 # This function executes after the main compile_rules() is done.
455 copy_generic_stuff() {
456 # Custom or homemade PNG pixmap can be in stuff.
457 if [ -f "$stuff/$PACKAGE.png" ]; then
458 mkdir -p $install/usr/share/pixmaps
459 cp $stuff/$PACKAGE.png $install/usr/share/pixmaps
460 fi
462 # Homemade desktop file(s) can be in stuff.
463 if [ -d "$stuff/applications" ]; then
464 mkdir -p $install/usr/share
465 cp -a $stuff/applications $install/usr/share
466 fi
467 if [ -f "$stuff/$PACKAGE.desktop" ]; then
468 mkdir -p $install/usr/share/applications
469 cp $stuff/$PACKAGE.desktop $install/usr/share/applications
470 fi
472 # Add custom licenses
473 if [ -d "$stuff/licenses" ]; then
474 mkdir -p $install/usr/share/licenses
475 cp -a $stuff/licenses $install/usr/share/licenses/$PACKAGE
476 fi
477 }
480 # Remove files provided by split packages
481 # For example:
482 # 1. Package "pkg-main":
483 # SPLIT="pkg-1 pkg-2 pkg-extra"
484 # 2. Package="pkg-extra":
485 # WANTED="pkg-main"
486 # BUILD_DEPENDS="pkg-1 pkg-2"
487 # cook_copy_folders usr
488 # cook_split_rm $BUILD_DEPENDS
490 cook_split_rm() {
491 for i in $@; do
492 action 'Remove files provided by split package %s...' "$i"
493 while read j; do
494 [ -f "$fs$j" -o -h "$fs$j" ] && rm $fs$j
495 rmdir "$(dirname "$fs$j")" 2>/dev/null
496 done < $WOK/$i/taz/$i-$VERSION/files.list
497 :; status
498 done
499 }
502 # Update installed.cook.diff
504 update_installed_cook_diff() {
505 # If a cook failed deps are removed.
506 cd $root$INSTALLED; ls -1 > $CACHE/installed.cook
507 cd $CACHE
508 [ "$1" == 'force' -o ! -s '/tmp/installed.cook.diff' ] && \
509 busybox diff installed.list installed.cook > /tmp/installed.cook.diff
510 deps=$(cat /tmp/installed.cook.diff | grep ^+[a-zA-Z0-9] | wc -l)
511 }
514 # Remove installed deps.
516 remove_deps() {
517 # Now remove installed build deps.
518 diff='/tmp/installed.cook.diff'
519 [ -s "$diff" ] || return
521 deps=$(cat $diff | grep ^+[a-zA-Z0-9] | sed s/^+//)
522 nb=$(cat $diff | grep ^+[a-zA-Z0-9] | wc -l)
523 newline
524 _n 'Build dependencies to remove:'; echo " $nb"
525 [ -n "$root" ] && echo "root=\"$root\""
526 {
527 _n 'Removing:'
528 for dep in $deps; do
529 echo -n " $dep"
530 echo 'y' | tazpkg remove $dep --root=$root >/dev/null
531 done
532 newline; newline
533 # Keep the last diff for debug and info.
534 mv -f $diff $CACHE/installed.diff
535 } | fold -sw80
536 }
539 # Automatically patch the sources.
541 patchit() {
542 [ -f "$stuff/patches/series" ] || return
544 while read i; do
545 [ -f "$src/done.$i" ] && continue
546 newline
547 _ 'Applying patch %s' "$i"
548 patch -p1 -i $stuff/patches/$i | sed 's|^| |'
549 touch $src/done.$i
550 done < $stuff/patches/series
551 newline
552 }
555 # Check source tarball integrity.
557 check_integrity() {
558 for i in sha1 sha3 sha256 sha512 md5; do
559 I=$(echo $i | tr 'a-z' 'A-Z')
560 eval sum=\$TARBALL_$I
561 if [ -n "$sum" ]; then
562 newline
563 _ 'Checking %ssum of source tarball...' "$i"
564 echo "$sum $SRC/$TARBALL" | ${i}sum -c || exit 1
565 fi
566 done
567 newline
568 }
571 # The main cook function.
573 cookit() {
574 if [ -n "$SETUP_MD5" -a "$SETUP_MD5" != "$(ls $root$INSTALLED | md5sum | cut -c1-32)" ]; then
575 _ 'ERROR: Broken setup. Abort.'
576 return
577 fi
579 title 'Cook: %s' "$PACKAGE $VERSION"
580 set_paths
582 # Handle cross-tools.
583 case "$ARCH" in
584 arm*|x86_64)
585 # CROSS_COMPILE is used by at least Busybox and the kernel to set
586 # the cross-tools prefix. Sysroot is the root of our target arch
587 sysroot="$CROSS_TREE/sysroot"
588 tools="$CROSS_TREE/tools"
589 # Set root path when cross compiling. ARM tested but not x86_64
590 # When cross compiling we must install build deps in $sysroot.
591 arch="-$ARCH"
592 root="$sysroot"
593 _ '%s sysroot: %s' "$ARCH" "$sysroot"
594 _ 'Adding "%s" to PATH' "$tools/bin"
595 export PATH="$PATH:$tools/bin"
596 export PKG_CONFIG_PATH="$sysroot/usr/lib/pkgconfig"
597 export CROSS_COMPILE="$HOST_SYSTEM-"
598 _ 'Using cross-tools: %s' "$CROSS_COMPILE"
599 if [ "$ARCH" == 'x86_64' ]; then
600 export CC="$HOST_SYSTEM-gcc -m64"
601 export CXX="$HOST_SYSTEM-g++ -m64"
602 else
603 export CC="$HOST_SYSTEM-gcc"
604 export CXX="$HOST_SYSTEM-g++"
605 fi
606 export AR="$HOST_SYSTEM-ar"
607 export AS="$HOST_SYSTEM-as"
608 export RANLIB="$HOST_SYSTEM-ranlib"
609 export LD="$HOST_SYSTEM-ld"
610 export STRIP="$HOST_SYSTEM-strip"
611 export LIBTOOL="$HOST_SYSTEM-libtool"
612 ;;
613 esac
615 [ -n "$QA" ] && receipt_quality
617 cd $pkgdir
618 [ -z "$continue" ] && rm -rf source 2>/dev/null
619 rm -rf install taz 2>/dev/null
621 # Disable -pipe if less than 512 MB free RAM.
622 free=$(awk '/^MemFree|^Buffers|^Cached/{s+=$2}END{print int(s/1024)}' /proc/meminfo)
623 if [ "$free" -lt 512 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then
624 _ 'Disabling -pipe compile flag: %d MB RAM free' "$free"
625 CFLAGS="${CFLAGS/-pipe}"; CFLAGS=$(echo "$CFLAGS" | tr -s ' ')
626 CXXFLAGS="${CXXFLAGS/-pipe}"; CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ')
627 fi
628 unset free
630 # Export flags and path to be used by make and receipt.
631 DESTDIR="$pkgdir/install"
632 # FIXME: L10n: Is this the right time for 'LC_ALL=C LANG=C'?
633 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS CONFIG_SITE LC_ALL=C LANG=C
634 #LDFLAGS
636 # BUILD_DEPENDS may vary depending on the ARCH
637 case "$ARCH" in
638 arm*) [ -n "$BUILD_DEPENDS_arm" ] && BUILD_DEPENDS=$BUILD_DEPENDS_arm ;;
639 x86_64) [ -n "$BUILD_DEPENDS_x86_64" ] && BUILD_DEPENDS=$BUILD_DEPENDS_x86_64 ;;
640 esac
642 # Check for build deps and handle implicit depends of *-dev packages
643 # (ex: libusb-dev :: libusb).
644 # rm -f $CACHE/installed.local $CACHE/installed.web $CACHE/missing.dep
645 # touch $CACHE/installed.local $CACHE/installed.web
646 [ -n "$BUILD_DEPENDS" ] && _ 'Checking build dependencies...'
647 [ -n "$root" ] && _ 'Using packages DB: %s' "$root$DB"
649 for action in check install; do
650 for dep in $BUILD_DEPENDS; do
651 implicit="${dep%-dev}"; [ "$implicit" == "$dep" ] && implicit=''
652 for i in $dep $implicit; do
653 # Skip if package already installed
654 [ -f "$root$INSTALLED/$i/receipt" ] && continue
656 case $action in
657 check)
658 # Search for local package or local provided-package
659 name=$(awk -F$'\t' -vpkg="$i" '{
660 if (index(" " $1 " " $10 " ", " " pkg " ")) {print $1; exit}
661 }' "$PKGS/packages.info")
662 if [ -z "$name" ]; then
663 # Search for package in mirror
664 name="$(awk -F$'\t' -vi="$i" '$1==i{print $1; exit}' "$root$DB/packages.info")"
665 [ -z "$name" -a "$i" == "$dep" ] && die 'ERROR: unknown dep "%s"' "$i"
666 fi
667 ;;
668 install)
669 tazpkg get-install $i --root=$root --local --quiet --cookmode || { broken; exit 1; }
670 ;;
671 esac
672 done
673 done
674 done
676 # # Get the list of installed packages
677 # cd $root$INSTALLED; ls -1 > $CACHE/installed.list
678 #
679 # # Have we a missing build dep to cook?
680 # if [ -s "$CACHE/missing.dep" ] && [ -n "$AUTO_COOK" ]; then
681 # _ 'Auto cook config is set: %s' "$AUTO_COOK"
682 # cp -f $LOGS/$PACKAGE.log $LOGS/$PACKAGE.log.$$
683 # for i in $(uniq $CACHE/missing.dep); do
684 # (_ 'Building dep (wok/pkg) : %s' "$i $vers") | \
685 # tee -a $LOGS/$PACKAGE.log.$$
686 # # programmers: next two messages are exact copy from remove_deps()
687 # togrep1=$(_n 'Build dependencies to remove:')
688 # togrep2=$(_n 'Removing:')
689 # cook $i || (_ "ERROR: can't cook dep \"%s\"" "$i" && newline && \
690 # fgrep $togrep1 $LOGS/$i.log && \
691 # fgrep $togrep2 $LOGS/$i.log && newline) | \
692 # tee -a $LOGS/$PACKAGE.log.$$ && break
693 # done
694 # rm -f $CACHE/missing.dep
695 # mv $LOGS/$PACKAGE.log.$$ $LOGS/$PACKAGE.log
696 # fi
697 #
698 # # QA: Exit on missing dep errors. We exit in both cases, if AUTO_COOK
699 # # is enabled and cook fails we have ERROR in log, if no auto cook we have
700 # # missing dep in cached file.
701 # lerror=$(_n 'ERROR')
702 # if fgrep -q ^$lerror $LOGS/$pkg.log || [ -s "$CACHE/missing.dep" ]; then
703 # [ -s "$CACHE/missing.dep" ] && nb=$(wc -l < $CACHE/missing.dep)
704 # _p 'ERROR: missing %d dependency' 'ERROR: missing %d dependencies' "$nb" "$nb"
705 # broken; exit 1
706 # fi
707 #
708 # # Install local packages: package-version$arch
709 # cd $PKGS
710 # for i in $(uniq $CACHE/installed.local); do
711 # # _ 'Installing dep (pkg/local): %s' "$i"
712 # tazpkg install $i --root=$root --local --quiet --cookmode
713 # done
714 #
715 # # Install web or cached packages (if mirror is set to $PKGS we only
716 # # use local packages).
717 # for i in $(uniq $CACHE/installed.web); do
718 # # _ 'Installing dep (web/cache): %s' "$i"
719 # tazpkg get-install $i --root=$root --local --quiet --cookmode
720 # done
722 update_installed_cook_diff
724 # Get source tarball and make sure we have source dir named:
725 # $PACKAGE-$VERSION to be standard in receipts. Here we use tar.lzma
726 # tarball if it exists.
727 if [ -n "$WGET_URL" -a ! -f "$SRC/$TARBALL" ]; then
728 if [ -f "$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
729 TARBALL="${SOURCE:-$PACKAGE}-$VERSION.tar.lzma"
730 LZMA_SRC=''
731 else
732 get_source || { broken; exit 1; }
733 fi
734 fi
735 if [ -z "$WANTED" -a -n "$TARBALL" -a ! -d "$src" ]; then
736 mkdir -p $pkgdir/source/tmp; cd $pkgdir/source/tmp
737 if ! extract_source ; then
738 get_source
739 extract_source || { broken; exit 1; }
740 fi
741 if [ -n "$LZMA_SRC" ]; then
742 cd $pkgdir/source
743 if [ "$(ls -A tmp | wc -l)" -gl 1 -o -f "$(echo tmp/*)" ]; then
744 mv tmp tmp-1; mkdir tmp
745 mv tmp-1 tmp/${SOURCE:-$PACKAGE}-$VERSION
746 fi
747 if [ -d "tmp/${SOURCE:-$PACKAGE}-$VERSION" ]; then
748 cd tmp; tar -c * | lzma e $SRC/$TARBALL -si
749 fi
750 fi
751 cd $pkgdir/source/tmp
752 # Some archives are not well done and don't extract to one dir (ex lzma).
753 files=$(ls | wc -l)
754 [ "$files" -eq 1 -a -d "$(ls)" ] && mv * ../$PACKAGE-$VERSION
755 [ "$files" -eq 1 -a -f "$(ls)" ] && mkdir -p ../$PACKAGE-$VERSION && \
756 mv * ../$PACKAGE-$VERSION/$TARBALL
757 [ "$files" -gt 1 ] && mkdir -p ../$PACKAGE-$VERSION && \
758 mv * ../$PACKAGE-$VERSION
759 cd ..; rm -rf tmp
760 fi
762 check_integrity
764 # Libtool shared libs path hack.
765 case "$ARCH" in
766 arm*) cross libhack ;;
767 esac
769 # Execute receipt rules.
770 if grep -q ^compile_rules $receipt; then
771 _ 'Executing: %s' 'compile_rules'
772 echo "CFLAGS : $CFLAGS"
773 #echo "LDFLAGS : $LDFLAGS"
774 [ -d "$src" ] && cd $src
775 patchit
776 compile_rules $@ || { broken; exit 1; }
777 # Stay compatible with _pkg
778 [ -d "$src/_pkg" ] && mv $src/_pkg $install
779 # QA: compile_rules success so valid.
780 mkdir -p $install
781 else
782 # QA: no compile_rules so no error, valid.
783 mkdir -p $install
784 fi
786 copy_generic_stuff
788 # Actions to do after compiling the package
789 # Skip all for split packages (already done in main package)
790 if [ -z "$WANTED" ]; then
791 footer
792 export COOKOPTS ARCH install; @@PREFIX@@/libexec/cookutils/compressor install
793 fi
794 footer
796 # Execute testsuite.
797 if grep -q ^testsuite $receipt; then
798 title 'Running testsuite'
799 testsuite $@ || { broken; exit 1; }
800 footer
801 fi
803 update_installed_cook_diff force
804 }
807 # Cook quality assurance.
809 cookit_quality() {
810 if [ ! -d "$WOK/$pkg/install" ] && [ -z "$WANTED" ]; then
811 _ 'ERROR: cook failed' | tee -a $LOGS/$pkg.log
812 fi
813 # ERROR can be echoed any time in cookit()
814 lerror=$(_n 'ERROR')
815 if grep -Ev "(conftest|configtest)" $LOGS/$pkg.log | \
816 grep -Eq "(^$lerror|undefined reference to)" ; then
817 debug_info | tee -a $LOGS/$pkg.log
818 sed -i '$ s|$| [ Failed ]|' $activity
819 rm -f $command
820 broken; exit 1
821 fi
822 }
825 # Receipt used for cooking the package is redundant to be included into package.
826 # This script will strip the original receipt to bare minimum: variables,
827 # {pre,post}_{install,remove} functions.
829 mk_pkg_receipt() {
830 orig_receipt="$1"
832 # Receipt's signature is important, although some receipts may miss it
833 signature=$(head -n1 "$orig_receipt")
834 [ "${signature:0:1}" == '#' ] || signature='# SliTaz package receipt.'
836 save_PACKAGE="$PACKAGE"; save_DEPENDS="$DEPENDS"; save_PROVIDE="$PROVIDE"
837 save_SUGGESTED="$SUGGESTED"; save_TAZPANEL_DAEMON="$TAZPANEL_DAEMON"
838 save_TAGS="$TAGS"
839 unset_receipt
840 . "$orig_receipt"
841 PACKAGE="$save_PACKAGE"; DEPENDS="$save_DEPENDS"; PROVIDE="$save_PROVIDE"
842 SUGGESTED="$save_SUGGESTED"; TAZPANEL_DAEMON="$save_TAZPANEL_DAEMON"
843 TAGS="$save_TAGS"
845 # Manage split packages
846 SPLIT=" $SPLIT "
847 if [ "$SPLIT" != ' ' -a "${SPLIT/ $PACKAGE /}" != "$SPLIT" ]; then
848 # For packages with empty $DEPENDS
849 if [ -z "$DEPENDS" ]; then
850 case $PACKAGE in
851 *-dev)
852 # main package and all the split packages but this *-dev itself
853 DEPENDS=$(echo "$pkg $SPLIT " | sed "s| $PACKAGE | |; s| *$||") ;;
854 *)
855 # main package
856 DEPENDS="$pkg" ;;
857 esac
858 fi
860 # Default $CAT
861 [ -z "$CAT" ] &&
862 case $PACKAGE in
863 *-dev) CAT="development|development files" ;;
864 esac
865 fi
867 # Manage two-in-one $CAT="$CATEGORY|$SHORT_DESC_ADDITION"
868 if [ -n "$CAT" ]; then
869 CATEGORY="${CAT%|*}"
870 SHORT_DESC="$SHORT_DESC (${CAT#*|})"
871 fi
873 # Mandatory variables
874 cat <<EOF
875 $signature
877 PACKAGE="$PACKAGE"
878 VERSION="$VERSION"
879 CATEGORY="$CATEGORY"
880 SHORT_DESC="$SHORT_DESC"
881 MAINTAINER="$MAINTAINER"
882 LICENSE="$LICENSE"
883 WEB_SITE="$WEB_SITE"
884 EOF
886 # Optional variables
887 [ -n "$TAGS" ] && echo "TAGS=\"$TAGS\"" | tr -ds '\t' ' '
888 [ -n "${DEPENDS# }" ] && echo "DEPENDS=\"$DEPENDS\"" | tr -ds '\t' ' '
889 [ -n "$PROVIDE" ] && echo "PROVIDE=\"$PROVIDE\"" | tr -ds '\t' ' '
890 [ -n "$CONFIG_FILES" ] && echo "CONFIG_FILES=\"$CONFIG_FILES\"" | tr -ds '\t' ' '
891 [ -n "$SUGGESTED" ] && echo "SUGGESTED=\"$SUGGESTED\"" | tr -ds '\t' ' '
892 [ -n "$DATABASE_FILES" ] && echo "DATABASE_FILES=\"$DATABASE_FILES\""
893 [ -n "$TAZPANEL_DAEMON" ] && echo "TAZPANEL_DAEMON=\"$TAZPANEL_DAEMON\""
895 # Extract {pre,post}_{install,remove} functions;
896 # post_install() will be copied for both main and all the split packages
897 # post_install_gtk_() will be copied as post_install() for gtk+ package only
898 #
899 # restricted name (gtk+ -> gtk_; acl-dev -> acl_dev)
900 rname=$(echo -n $PACKAGE | tr -c 'a-zA-Z0-9' '_')
901 for i in pre post; do
902 for j in install remove; do
903 sed "/^${i}_${j}()/,/^}/!d" "$orig_receipt"
904 sed "/^${i}_${j}_$rname()/,/^}/!d" "$orig_receipt" | \
905 sed "s|^${i}_${j}_$rname()|${i}_${j}()|"
906 done
907 done
908 }
911 # Create the package. Wanted to use TazPkg to create a tazpkg package at first,
912 # but it doesn't handle EXTRAVERSION.
914 packit() {
915 set_paths "$1"
916 PACKAGE="${1:-$PACKAGE}"
918 # Handle cross compilation
919 case "$ARCH" in
920 arm*|x86_64) arch="-$ARCH" ;;
921 esac
923 title 'Pack: %s' "$PACKAGE $VERSION$arch"
925 if grep -q ^genpkg_rules $receipt; then
926 _ 'Executing: %s' 'genpkg_rules'
927 set -e; cd $pkgdir; mkdir -p $fs
928 genpkg_rules || (newline; _ 'ERROR: genpkg_rules failed'; newline) >> \
929 $LOGS/$pkg.log
930 else
931 _ 'No packages rules: meta package'
932 mkdir -p $fs
933 fi
935 # Check CONFIG_FILES
936 if [ -n "$CONFIG_FILES" ]; then
937 unset IFS
938 for i in $CONFIG_FILES; do
939 if [ ! -e $fs$i ]; then
940 case $i in
941 */) mkdir -p $fs$i ;;
942 *) mkdir -p $fs$(dirname $i); touch $fs$i ;;
943 esac
944 fi
945 done
946 fi
948 # First QA check to stop now if genpkg_rules failed.
949 lerror=$(_n 'ERROR')
950 if fgrep -q ^$lerror $LOGS/$pkg.log; then
951 broken; exit 1
952 fi
954 cd $taz
955 action 'Copying "%s"...' 'receipt'
956 mk_pkg_receipt ../receipt > $pack/receipt
957 chown 0.0 $pack/receipt; status
959 unset desc
960 [ "$pkg" == "$PACKAGE" -a -f "../description.txt" ] && desc="../description.txt"
961 [ -f "../description.$PACKAGE.txt" ] && desc="../description.$PACKAGE.txt"
962 if [ -n "$desc" ]; then
963 action 'Copying "%s"...' "$(basename "$desc")"
964 cp -f $desc $pack/description.txt; chown 0.0 $pack/description.txt; status
965 fi
967 copy_generic_files
969 # Strip and stuff files.
970 export COOKOPTS ARCH HOST_SYSTEM LOCALE fs; @@PREFIX@@/libexec/cookutils/compressor fs
972 # Create files.list with redirecting find output.
973 action 'Creating the list of files...'
974 cd $fs
975 find . -type f -print > ../files.list
976 find . -type l -print >> ../files.list
977 cd ..; sed -i s/'^.'/''/ files.list
978 status
980 # Md5sum of files.
981 action 'Creating md5sum of files...'
982 while read file; do
983 [ -L "fs$file" ] && continue
984 [ -f "fs$file" ] || continue
985 case "$file" in
986 /lib/modules/*/modules.*|*.pyc) continue ;;
987 esac
988 md5sum "fs$file" | sed 's/ fs/ /'
989 done < files.list > md5sum
990 status
992 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
993 2>/dev/null | awk 'END{ print $1 }')
995 # Build cpio archive.
996 action 'Compressing the FS...'
997 find fs -newer $receipt -exec touch -hr $receipt '{}' \;
998 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
999 mv fs ../
1000 status
1002 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list md5sum description.txt \
1003 2>/dev/null | awk 'END{ print $1 }')
1005 action 'Updating receipt sizes...'
1006 sed -i s/^PACKED_SIZE.*$// receipt
1007 sed -i s/^UNPACKED_SIZE.*$// receipt
1008 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
1009 status
1011 # Set extra version.
1012 if [ -n "$EXTRAVERSION" ]; then
1013 action 'Updating receipt EXTRAVERSION: %s' "$EXTRAVERSION"
1014 sed -i s/^EXTRAVERSION.*$// receipt
1015 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
1016 status
1017 fi
1019 # Compress.
1020 action 'Creating full cpio archive...'
1021 find . -newer $receipt -exec touch -hr $receipt '{}' \;
1022 find . | cpio -o -H newc --quiet > ../$PACKAGE-$VERSION$EXTRAVERSION$arch.tazpkg
1023 status
1025 action 'Restoring original package tree...'
1026 mv ../fs .
1027 status
1029 rm fs.cpio.lzma; cd ..
1031 # QA and give info.
1032 tazpkg=$(ls *.tazpkg)
1033 packit_quality
1034 footer "$(_ 'Package "%s" created' "$tazpkg")"
1035 update_packages_info
1039 # Verify package quality and consistency.
1041 packit_quality() {
1042 #action 'QA: checking for broken link...'
1043 #link=$(find $fs/usr -type l -follow)
1044 #[ "$link" ] && echo -e "\nERROR: broken link in filesystem"
1045 #status
1047 # Exit if any error found in log file.
1048 lerror=$(_n 'ERROR')
1049 if fgrep -q ^$lerror $LOGS/$pkg.log; then
1050 rm -f $command
1051 broken; exit 1
1052 fi
1054 action 'QA: checking for empty package...'
1055 files=$(cat $WOK/$pkg/taz/$PACKAGE-$VERSION$EXTRAVERSION/files.list | wc -l)
1056 if [ "$files" -eq 0 -a "$CATEGORY" != 'meta' ]; then
1057 broken
1058 rm -f $command
1059 die 'ERROR: empty package'
1060 fi
1062 :; status
1063 # Find and remove old package(s)
1064 tempd="$(mktemp -d)"; cd "$tempd"
1065 for testpkg in $(ls $PKGS/$PACKAGE-*.tazpkg 2>/dev/null); do
1066 # Extract receipt from each matched package
1067 cpio -F "$testpkg" -i receipt >/dev/null 2>&1
1068 name=$(. receipt; echo $PACKAGE)
1069 rm receipt
1070 if [ "$name" == "$PACKAGE" ]; then
1071 action 'Removing old package "%s"' "$(basename "$testpkg")"
1072 rm -f "$testpkg"
1073 status
1074 fi
1075 done
1076 rm -r "$tempd"
1077 mv -f $pkgdir/taz/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg $PKGS
1078 sed -i /^${pkg}$/d $broken
1079 #action 'Removing source tree...'
1080 #rm -f $WOK/$pkg/source; status
1084 # Return all the names of packages bundled in this receipt
1086 all_names() {
1087 local split=" $SPLIT "
1088 if [ "${split/ $PACKAGE /}" != "$split" ]; then
1089 # $PACKAGE included somewhere in $SPLIT (probably in the end).
1090 # We should build packages in the order defined in the $SPLIT.
1091 echo $SPLIT
1092 else
1093 # We'll build the $PACKAGE, then all defined in the $SPLIT.
1094 echo $PACKAGE $SPLIT
1095 fi
1099 # v2: pack all packages using compiled files
1101 packall() {
1102 set_paths
1103 if head -n1 "$pkgdir/receipt" | fgrep -q 'v2'; then
1104 for i in $(all_names); do
1105 unset TAGS DEPENDS CAT CONFIG_FILES PROVIDE SUGGESTED DATABASE_FILES TAZPANEL_DAEMON
1106 packit $i
1107 done
1108 else
1109 packit
1110 fi
1114 # Reverse "cat" command: prints input lines in the reverse order
1116 tac() {
1117 sed '1!G;h;$!d' $1
1121 # Update chroot with freshly rebuilt package: keep env up-to-date.
1123 update_chroot() {
1124 local PACKAGE="$pkg"
1125 for i in $(all_names); do
1126 if [ -d "$root$INSTALLED/$i" ]; then
1127 . /etc/slitaz/cook.conf
1128 . $WOK/$pkg/taz/$i-$VERSION/receipt
1129 _ 'Updating %s chroot environment...' "$ARCH"
1130 _ 'Updating chroot: %s' "$i ($VERSION$EXTRAVERSION$arch)" | log
1131 cd $PKGS
1132 tazpkg install $i-$VERSION$EXTRAVERSION$arch.tazpkg --forced --root=$root
1133 fi
1134 done
1138 # Install package on --inst or update the chroot.
1140 install_package() {
1141 case "$ARCH" in
1142 arm*|x86_64)
1143 arch="-$ARCH"
1144 root="$CROSS_TREE/sysroot" ;;
1145 esac
1146 # Install package if requested but skip install if target host doesn't
1147 # match build system or it will break the build chroot.
1148 build=$(echo $BUILD_SYSTEM | cut -d- -f1)
1149 if [ -n "$inst" -a "$build" == "$ARCH" ]; then
1150 if [ -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ]; then
1151 cd $PKGS
1152 tazpkg install $PACKAGE-$VERSION$EXTRAVERSION.tazpkg --forced
1153 else
1154 broken
1155 die 'Unable to install package, build has failed.'
1156 fi
1157 fi
1159 update_chroot
1163 # remove chroot jail
1165 umount_aufs() {
1166 tac ${1}rw/aufs-umount.sh | sh
1167 rm -rf ${1}rw
1168 umount ${1}root
1169 rmdir ${1}r*
1173 # Launch the cook command into a chroot jail protected by aufs.
1174 # The current filesystems are used read-only and updates are
1175 # stored in a separate branch.
1177 try_aufs_chroot() {
1179 base="/dev/shm/aufsmnt$$"
1181 # Can we setup the chroot? Is it already done?
1182 grep -q ^AUFS_NOT_SUPPORTED $receipt && return
1183 grep -q ^AUFS_NOT_RAMFS $receipt && base="/mnt/aufsmnt$$"
1184 [ -n "$AUFS_MOUNTS" -a ! -f /aufs-umount.sh ] || return
1185 grep -q ^aufs /proc/modules || modprobe aufs 2> /dev/null || return
1186 mkdir ${base}root ${base}rw || return
1188 _ 'Setup aufs chroot...'
1190 # Sanity check
1191 for i in / /proc /sys /dev/shm /home ; do
1192 case " $AUFS_MOUNTS " in
1193 *\ $i\ *) ;;
1194 *) AUFS_MOUNTS="$AUFS_MOUNTS $i" ;;
1195 esac
1196 done
1197 for mnt in $(ls -d $AUFS_MOUNTS | sort | uniq); do
1198 mount --bind $mnt ${base}root$mnt
1199 if [ $mnt == / ] && ! mount -t aufs -o br=${base}rw:/ none ${base}root; then
1200 _ 'Aufs mount failure'
1201 umount ${base}root
1202 rm -rf ${base}r*
1203 return
1204 fi
1205 echo "umount ${base}root$mnt" >> ${base}rw/aufs-umount.sh
1206 done
1207 trap "umount_aufs ${base}" INT
1209 chroot ${base}root $(cd $(dirname $0); pwd)/$(basename $0) "$@"
1210 status=$?
1212 _ 'Leaving aufs chroot...'
1213 umount_aufs $base
1214 # Install package outside the aufs jail
1215 install_package
1216 exit $status
1220 # Encode predefined XML entities
1222 xml_ent() {
1223 sed -e 's|&|\&amp;|g; s|<|\&lt;|g; s|>|\&gt;|g; s|"|\&quot;|g' -e "s|'|\&apos;|g"
1227 # Create a XML feed for freshly built packages.
1229 gen_rss() {
1230 pubdate=$(date '+%a, %d %b %Y %X')
1231 cat > $FEEDS/$pkg.xml <<EOT
1232 <item>
1233 <title>$PACKAGE $VERSION$EXTRAVERSION</title>
1234 <link>${COOKER_URL}?pkg=${PACKAGE//+/%2B}</link>
1235 <guid>$PACKAGE-$VERSION$EXTRAVERSION</guid>
1236 <pubDate>$pubdate</pubDate>
1237 <description>$(echo -n "$SHORT_DESC" | xml_ent)</description>
1238 </item>
1239 EOT
1243 # Truncate stdout log file to $1 Mb.
1245 loglimit() {
1246 if [ -n "$DEFAULT_LOG_LIMIT" ]; then
1247 tee /dev/stderr | head -qc ${1:-$DEFAULT_LOG_LIMIT}m
1248 else
1249 tee /dev/stderr
1250 fi
1255 # Receipt functions to ease packaging
1258 get_dev_files() {
1259 action 'Getting standard devel files...'
1260 mkdir -p $fs/usr/lib
1261 cp -a $install/usr/lib/pkgconfig $fs/usr/lib
1262 cp -a $install/usr/lib/*a $fs/usr/lib
1263 cp -a $install/usr/include $fs/usr
1264 status
1268 # Function to use in compile_rules() to copy man page from $src to $install
1270 cook_pick_manpages() {
1271 local name section
1272 action 'Copying man pages...'
1274 for i in $@; do
1275 name=$(echo $i | sed 's|\.[gbx]z2*$||')
1276 section=${name##*/}; section=${section##*.}
1277 mkdir -p $install/usr/share/man/man$section
1278 scopy $i $install/usr/share/man/man$section
1279 done
1280 status
1284 # Function to use in genpkg_rules() to copy specified files from $install to $fs
1286 cook_copy_files() {
1287 action 'Copying files...'
1288 cd $install
1289 local i j
1290 IFS=$'\n'
1291 for i in $@; do
1292 for j in $(find . -name $i ! -type d); do
1293 mkdir -p $fs$(dirname ${j#.})
1294 scopy $j $fs$(dirname ${j#.})
1295 done
1296 done
1297 cd - >/dev/null
1298 status
1302 # Function to use in genpkg_rules() to copy specified folders from $install to $fs
1304 cook_copy_folders() {
1305 action 'Copying folders...'
1306 cd $install
1307 local i j
1308 IFS=$'\n'
1309 for i in $@; do
1310 for j in $(find . -name $i -type d); do
1311 mkdir -p $fs$(dirname ${j#.})
1312 cp -a $j $fs$(dirname ${j#.})
1313 done
1314 done
1315 cd - >/dev/null
1316 status
1320 # Common function to copy files, folders and patterns
1322 copy() {
1323 action 'Copying folders and files...'
1324 local i j filelist=$(mktemp)
1325 IFS=$'\n'
1326 cd $install; find ! -type d | sed 's|\.||' > $filelist
1327 for i in $@; do
1328 case $i in
1329 @std)
1330 # Copy "standard" files (all but "developer files", man pages, documentation, translations)
1331 sed '/\.h$/d; /\.hxx$/d; /\.a$/d; /\.la$/d; /\.pc$/d; /bin\/.*-config$/d;
1332 /\.m4$/d; /\.gir$/d; /\.typelib$/d; /\.vapi$/d; /\.deps$/d; /\.cmake$/d;
1333 /\/Makefile.*/d; /\.inc$/d; /\/include\//d;
1334 /\/share\/man\//d; /\/share\/doc\//d; /\/share\/gtk-doc\//d; /\/share\/info\//d;
1335 /\/share\/devhelp\//d; /\/share\/locale\//d;
1336 /\/share\/bash-completion\//d; /\/lib\/systemd\//d;
1337 ' $filelist
1338 ;;
1339 @dev)
1340 # Copy "developer files"
1341 sed -n '/\.h$/p; /\.hxx$/p; /\.a$/p; /\.la$/p; /\.pc$/p; /bin\/.*-config$/p;
1342 /\.m4$/p; /\.gir$/p; /\.typelib$/p; /\.vapi$/p; /\.deps$/p; /\.cmake$/p;
1343 /\/Makefile.*/p; /\.inc$/p; /\/include\//p;
1344 ' $filelist
1345 ;;
1346 */)
1347 # Copy specified folders.
1348 i="${i%/}"
1349 find -type d -path "*/${i#/}" | sed 's|^.||'
1350 ;;
1351 *)
1352 # Copy specified files.
1353 find ! -type d -path "*/${i#/}" | sed 's|^.||'
1354 ;;
1355 esac | sort -u | \
1356 while read j; do
1357 mkdir -p $fs$(dirname "$j")
1358 if [ -d "$install$j" ]; then
1359 cp -a "$install$j" $fs$(dirname "$j")
1360 else
1361 scopy "$install$j" $fs$(dirname "$j")
1362 fi
1363 done
1364 done
1365 cd - >/dev/null
1366 unset IFS
1367 rm $filelist
1368 status
1372 # Remove from current $fs files that already packed (for receipts v2).
1373 # Note: the order in $SPLIT is very important.
1375 remove_already_packed() {
1376 local i j
1377 IFS=$'\n'
1378 for i in $taz/*/files.list; do
1379 while read j; do
1380 [ -f $fs$j -o -h $fs$j ] || continue
1381 rm $fs$j
1382 rmdir --parents --ignore-fail-on-non-empty $fs$(dirname $j)
1383 done < $i
1384 done
1385 unset IFS
1389 # Function to use in genpkg_rules() to copy hicolor icons in specified sizes
1390 # (default: 16 and 48) from $install to $fs
1392 cook_copy_icons() {
1393 local sizes=$@
1394 action 'Copying hicolor icons...'
1395 mkdir -p $fs/usr/share/icons/hicolor
1396 for i in ${sizes:-16 48}; do
1397 [ ! -e "$install/usr/share/icons/hicolor/${i}x$i" ] ||
1398 scopy $install/usr/share/icons/hicolor/${i}x$i \
1399 $fs/usr/share/icons/hicolor
1400 done
1401 status
1405 # Update packages.info every time after successful build
1407 update_packages_info() {
1408 sed -i "/^$PACKAGE\t/d" $PKGS/packages.info
1409 unset_receipt; . $pack/receipt
1410 SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g')
1411 DEPENDS=$(echo $DEPENDS) # remove newlines, tabs and multiple spaces from variable
1412 MD5="$(md5sum "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" | awk '{print $1}')"
1413 cat >> $PKGS/packages.info <<EOT
1414 $PACKAGE $VERSION$EXTRAVERSION $CATEGORY $SHORT_DESC $WEB_SITE $TAGS $SIZES $DEPENDS $MD5 $PROVIDE
1415 EOT
1423 # Commands
1426 case "$1" in
1427 usage|help|-u|-h)
1428 usage ;;
1430 list-wok)
1431 title 'List of %s packages in "%s"' "$ARCH" "$WOK"
1432 cd $WOK
1433 if [ "$ARCH" != 'i486' ]; then
1434 count=0
1435 for pkg in $(fgrep 'HOST_ARCH=' */receipt | egrep "$ARCH|any" | cut -d: -f1)
1436 do
1437 unset HOST_ARCH
1438 . $pkg
1439 count=$(($count + 1))
1440 colorize 34 "$PACKAGE"
1441 done
1442 else
1443 count=$(ls | wc -l)
1444 ls -1
1445 fi
1446 footer "$(_p '%s package' '%s packages' "$count" "$(colorize 32 "$count")")"
1447 ;;
1449 activity)
1450 cat $activity ;;
1452 search)
1453 # Just a simple search function, we dont need more actually.
1454 query="$2"
1455 title 'Search results for "%s"' "$query"
1456 cd $WOK; ls -1 | grep "$query"
1457 footer ;;
1459 setup)
1460 # Setup a build environment
1461 check_root
1462 _ 'Cook: setup environment' | log
1463 title 'Setting up your environment'
1464 [ -d $SLITAZ ] || mkdir -p $SLITAZ
1465 cd $SLITAZ
1466 init_db_files
1467 _ 'Checking for packages to install...'
1468 # Use setup pkgs from cross.conf or cook.conf. When cross compiling
1469 # ARCH-setup or 'cross check' should be used before: cook setup
1470 case "$ARCH" in
1471 arm*|x86_64)
1472 [ -x '/usr/bin/cross' ] || die 'ERROR: %s is not installed' 'cross'
1473 _ 'Using config file: %s' '/etc/slitaz/cross.conf'
1474 . /etc/slitaz/cross.conf ;;
1475 esac
1476 for pkg in $SETUP_PKGS; do
1477 if [ -n "$forced" ]; then
1478 tazpkg -gi $pkg --forced
1479 else
1480 [ ! -d "$INSTALLED/$pkg" ] && tazpkg get-install $pkg
1481 fi
1482 done
1484 # Handle --options
1485 case "$2" in
1486 --wok) hg clone $WOK_URL wok || exit 1 ;;
1487 --stable) hg clone $WOK_URL-stable wok || exit 1 ;;
1488 --undigest) hg clone $WOK_URL-undigest wok || exit 1 ;;
1489 --tiny) hg clone $WOK_URL-tiny wok || exit 1 ;;
1490 esac
1492 # SliTaz group and permissions
1493 if ! grep -q ^slitaz /etc/group; then
1494 _ 'Adding group "%s"' 'slitaz'
1495 addgroup slitaz
1496 fi
1497 _ 'Setting permissions for group "%s"...' 'slitaz'
1498 find $SLITAZ -maxdepth 2 -exec chown root.slitaz {} \;
1499 find $SLITAZ -maxdepth 2 -exec chmod g+w {} \;
1500 footer "$(_ 'All done, ready to cook packages :-)')" ;;
1502 *-setup)
1503 # Setup for cross compiling.
1504 arch="${1%-setup}"
1505 check_root
1506 . /etc/slitaz/cook.conf
1507 for pkg in $CROSS_SETUP; do
1508 if [ -n "$forced" ]; then
1509 tazpkg -gi $pkg --forced
1510 else
1511 [ ! -d "$INSTALLED/$pkg" ] && tazpkg -gi $pkg
1512 fi
1513 done
1515 _ 'Cook: setup %s cross environment' "$arch" | log
1516 title 'Setting up your %s cross environment' "$arch"
1517 init_db_files
1518 sed -i \
1519 -e s"/ARCH=.*/ARCH=\"$arch\"/" \
1520 -e s"/CROSS_TREE=.*/CROSS_TREE=\"\/cross\/$arch\"/" \
1521 -e s'/BUILD_SYSTEM=.*/BUILD_SYSTEM=i486-slitaz-linux/' \
1522 /etc/slitaz/cook.conf
1523 case "$arch" in
1524 arm)
1525 flags='-O2 -march=armv6'
1526 host="$ARCH-slitaz-linux-gnueabi" ;;
1527 armv6hf)
1528 flags='-O2 -march=armv6j -mfpu=vfp -mfloat-abi=hard'
1529 host="$ARCH-slitaz-linux-gnueabi" ;;
1530 armv7)
1531 flags='-Os -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -pipe'
1532 host="$ARCH-slitaz-linux-gnueabi" ;;
1533 x86_64)
1534 flags='-O2 -mtune=generic -pipe'
1535 host="$ARCH-slitaz-linux" ;;
1536 esac
1537 sed -i \
1538 -e s"/CFLAGS=.*/CFLAGS=\"$flags\"/" \
1539 -e s"/HOST_SYSTEM=.*/HOST_SYSTEM=$host/" /etc/slitaz/cook.conf
1540 . /etc/slitaz/cook.conf
1541 sysroot="$CROSS_TREE/sysroot"
1542 tools="/cross/$arch/tools"
1543 root="$sysroot"
1544 # L10n: keep the same width of translations to get a consistent view
1545 _ 'Target arch : %s' "$ARCH"
1546 _ 'Configure args : %s' "$CONFIGURE_ARGS"
1547 _ 'Build flags : %s' "$flags"
1548 _ 'Arch sysroot : %s' "$sysroot"
1549 _ 'Tools prefix : %s' "$tools/bin"
1550 # Tell the packages manager where to find packages.
1551 _ 'Packages DB : %s' "$root$DB"
1552 mkdir -p $root$INSTALLED
1553 cd $root$DB; rm -f *.bak
1554 for list in packages.list packages.desc packages.equiv packages.md5; do
1555 rm -f $list
1556 ln -s $SLITAZ/packages/$list $list
1557 done
1558 # We must have the cross compiled glibc-base installed or default
1559 # i486 package will be used as dep by tazpkg and then break the
1560 # cross environment
1561 if [ ! -f "$root$INSTALLED/glibc-base/receipt" ]; then
1562 colorize 36 $(_ 'WARNING: %s is not installed in sysroot' '(e)glibc-base')
1563 fi
1564 # Show GCC version or warn if not yet compiled.
1565 if [ -x "$tools/bin/$HOST_SYSTEM-gcc" ]; then
1566 _ 'Cross compiler : %s' "$HOST_SYSTEM-gcc"
1567 else
1568 colorize 36 $(_ 'C compiler "%s" is missing' "$HOST_SYSTEM-gcc")
1569 _ 'Run "%s" to cook a toolchain' 'cross compile'
1570 fi
1571 footer ;;
1573 test)
1574 # Test a cook environment.
1575 _ 'Cook test: testing the cook environment' | log
1576 [ ! -d "$WOK" ] && exit 1
1577 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK
1578 cook cooktest ;;
1580 new)
1581 # Create the package folder and an empty receipt.
1582 pkg="$2"
1583 [ -z "$pkg" ] && usage
1584 newline
1585 [ -d "$WOK/$pkg" ] && die 'Package "%s" already exists.' "$pkg"
1587 action 'Creating folder "%s"' "$WOK/$pkg"
1588 mkdir $WOK/$pkg; cd $WOK/$pkg; status
1590 action 'Preparing the package receipt...'
1591 cp $DATA/receipt .
1592 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
1593 status; newline
1595 # Interactive mode, asking and seding.
1596 case "$3" in
1597 --interactive|-x)
1598 _ 'Entering interactive mode...'
1599 separator
1600 _ 'Package : %s' "$pkg"
1602 _n 'Version : ' ; read answer
1603 sed -i s/'VERSION=\"\"'/"VERSION=\"$answer\""/ receipt
1605 _n 'Category : ' ; read answer
1606 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$answer\""/ receipt
1608 # L10n: Short description
1609 _n 'Short desc : ' ; read answer
1610 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$answer\""/ receipt
1612 _n 'Maintainer : ' ; read answer
1613 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$answer\""/ receipt
1615 _n 'License : ' ; read answer
1616 sed -i s/'LICENSE=\"\"'/"LICENSE=\"$answer\""/ receipt
1618 _n 'Web site : ' ; read answer
1619 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$answer\""# receipt
1620 newline
1622 # Wget URL.
1623 _ 'Wget URL to download source tarball.'
1624 _n 'Example : ' ; echo '$GNU_MIRROR/$PACKAGE/$TARBALL'
1625 _n 'Wget url : ' ; read answer
1626 sed -i "s|WGET_URL=.*|WGET_URL=\"$answer\"|" receipt
1628 # Ask for a stuff dir.
1629 confirm "$(_n 'Do you need a stuff directory? (y/N)')"
1630 if [ "$?" -eq 0 ]; then
1631 action 'Creating the stuff directory...'
1632 mkdir $WOK/$pkg/stuff; status
1633 fi
1635 # Ask for a description file.
1636 confirm "$(_n 'Are you going to write a description? (y/N)')"
1637 if [ "$?" -eq 0 ]; then
1638 action 'Creating the "%s" file...' 'description.txt'
1639 touch $WOK/$pkg/description.txt; status
1640 fi
1642 footer "$(_ 'Receipt is ready to use.')" ;;
1643 esac ;;
1645 list)
1646 # Cook a list of packages (better use the Cooker since it will order
1647 # packages before executing cook).
1648 check_root
1649 [ -z "$2" ] && die 'No list in argument.'
1650 [ -f "$2" ] || die 'List "%s" not found.' "$2"
1652 _ 'Starting cooking the list "%s"' "$2" | log
1654 for pkg in $(cat $2); do
1655 cook $pkg || broken
1656 done ;;
1658 clean-wok)
1659 check_root
1660 newline; action 'Cleaning all packages files...'
1661 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
1662 status; newline ;;
1664 clean-src)
1665 check_root
1666 newline; action 'Cleaning all packages sources...'
1667 rm -rf $WOK/*/source
1668 status; newline ;;
1670 uncook)
1671 cd $WOK
1672 count=0
1673 title 'Checking for uncooked packages'
1675 for pkg in *; do
1676 unset HOST_ARCH EXTRAVERSION
1677 [ ! -e $pkg/receipt ] && continue
1678 . $pkg/receipt
1679 # Source cooked pkg receipt to get EXTRAVERSION
1680 if [ -d "$WOK/$pkg/taz" ]; then
1681 cd $WOK/$pkg/taz/$pkg-*
1682 . receipt; cd $WOK
1683 fi
1684 case "$ARCH" in
1685 i486)
1686 debug "$(_ 'Package "%s"' "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg")"
1687 if [ ! -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ]; then
1688 count=$(($count + 1))
1689 colorize 34 "$pkg"
1690 fi ;;
1691 arm*)
1692 # Check only packages included in arch
1693 if echo "$HOST_ARCH" | egrep -q "$ARCH|any"; then
1694 # *.tazpkg
1695 if [ ! -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg" ]; then
1696 count=$(($count + 1))
1697 colorize 34 "$pkg"
1698 fi
1699 fi ;;
1700 esac
1701 done
1703 if [ "$count" -gt 0 ]; then
1704 footer "$(_p '%s uncooked package' '%s uncooked packages' "$count" "$(colorize 31 "$count")")"
1705 else
1706 _ 'All packages are cooked :-)'
1707 newline
1708 fi
1709 ;;
1711 pkgdb)
1712 # Create suitable packages list for TazPkg and only for built packages
1713 # as well as flavors files for TazLiTo. We don't need logs since we do it
1714 # manually to ensure everything is fine before syncing the mirror.
1715 @@PREFIX@@/libexec/cookutils/pkgdb "$2"
1716 ;;
1718 *)
1719 # Just cook and generate a package.
1720 check_root
1721 time=$(date +%s)
1722 pkg="$1"
1723 [ -z "$pkg" ] && usage
1725 # Search last successful cook time in all logs from newer to older
1726 for i in '' $(seq 0 9 | sed 's|^|.|'); do
1727 [ -f "$LOGS/$pkg.log$i" ] || break
1728 lastcooktime=$(sed '/^Cook time/!d; s|.*: *\([0-9]*\)s.*|\1|' \
1729 $LOGS/$pkg.log$i 2>/dev/null | sed '$!d')
1730 [ -n "$lastcooktime" ] && break
1731 done
1733 receipt="$WOK/$pkg/receipt"
1734 check_pkg_in_wok
1735 newline
1737 unset inst
1738 unset_receipt
1739 . $receipt
1741 # Handle cross compilation.
1742 case "$ARCH" in
1743 arm*)
1744 if [ -z "$HOST_ARCH" ]; then
1745 _ 'cook: HOST_ARCH is not set in "%s" receipt' "$pkg"
1746 error="$(_ 'package "%s" is not included in %s' "$pkg" "$ARCH")"
1747 _ 'cook: %s' "$error"
1748 [ -n "$CROSS_BUGS" ] && _ 'bugs: %s' "$CROSS_BUGS"
1749 _ 'Cook skip: %s' "$error" | log
1750 newline
1751 broken; exit 1
1752 fi ;;
1753 esac
1755 # Some packages are not included in some arch or fail to cross compile.
1756 : ${HOST_ARCH=i486}
1757 debug "$(_ 'Host arch %s' "$HOST_ARCH")"
1758 # Handle arm{v6hf,v7,..}
1759 if ! $(echo "$HOST_ARCH" | egrep -q "${ARCH%v[0-9]*}|any"); then
1760 _ 'cook: %s' "HOST_ARCH=$HOST_ARCH"
1761 error="$(_ "package \"%s\" doesn't cook or is not included in %s" "$pkg" "$ARCH")"
1762 _ 'cook: %s' "error"
1763 [ -n "$CROSS_BUGS" ] && _ 'bugs: %s' "$CROSS_BUGS"
1764 _ 'Cook skip: %s' "$error" | log
1765 sed -i /^${pkg}$/d $broken
1766 newline
1767 exit 0
1768 fi
1770 # Skip blocked, 3 lines also for the Cooker.
1771 grep -q "^$pkg$" $blocked && [ "$2" != '--unblock' ] &&
1772 die 'Package "%s" is blocked' "$pkg"
1774 try_aufs_chroot "$@"
1776 # Log and source receipt.
1777 _ 'Cook started for: %s' "<a href='cooker.cgi?pkg=${pkg//+/%2B}'>$pkg</a>" | log
1778 echo "cook:$pkg" > $command
1780 [ -n "$lastcooktime" ] && echo "cook:$pkg $lastcooktime $(date +%s)" >> $cooktime
1782 while read cmd duration start; do
1783 [ $(($start + $duration)) -lt $(date +%s) ] &&
1784 echo "sed -i '/^$cmd $duration/d' $cooktime"
1785 done < $cooktime | sh
1787 # Display and log info if cook process stopped.
1788 # FIXME: gettext not working (in single quotes) here!
1789 trap '_ "\n\nCook stopped: control-C\n\n" | \
1790 tee -a $LOGS/$pkg.log' INT
1792 # Handle --options
1793 case "$2" in
1794 --clean|-c)
1795 action 'Cleaning "%s"' "$pkg"
1796 cd $WOK/$pkg; rm -rf install taz source
1797 status; newline
1798 exit 0 ;;
1800 --install|-i)
1801 inst='yes' ;;
1803 --getsrc|-gs)
1804 title 'Getting source for "%s"' "$pkg"
1805 get_source
1806 _ 'Tarball: %s' "$SRC/$TARBALL"; newline
1807 exit 0 ;;
1809 --block|-b)
1810 action 'Blocking package "%s"' "$pkg"
1811 [ $(grep "^$pkg$" $blocked) ] || echo "$pkg" >> $blocked
1812 status; newline
1813 exit 0 ;;
1815 --unblock|-ub)
1816 action 'Unblocking package "%s"' "$pkg"
1817 sed -i "/^${pkg}$/"d $blocked
1818 status; newline
1819 exit 0 ;;
1821 --pack)
1822 [ -d "$WOK/$pkg/install" ] || die 'Need to build "%s"' "$pkg"
1823 [ ! -d "$WOK/$pkg/taz" ] || rm -rf "$WOK/$pkg/taz"
1824 [ ! -f "$LOGS/$pkg-pack.log" ] || rm -rf $LOGS/$pkg-pack.log
1825 packall 2>&1 | tee -a $LOGS/$pkg-pack.log
1826 clean_log "$pkg-pack"
1827 time=$(($(date +%s) - $time))
1828 summary | sed 's|^Cook |Pack |' | tee -a $LOGS/$pkg-pack.log
1829 rm -f $command
1830 exit 0 ;;
1832 --cdeps)
1833 @@PREFIX@@/libexec/cookutils/cdeps $pkg
1834 esac
1836 # Rotate log
1837 for i in $(seq 9 -1 1); do
1838 j=$(($i - 1))
1839 [ -e $LOGS/$pkg.log.$j ] && mv -f $LOGS/$pkg.log.$j $LOGS/$pkg.log.$i
1840 done
1841 [ -e $LOGS/$pkg.log ] && mv $LOGS/$pkg.log $LOGS/$pkg.log.0
1843 # Check if wanted is built now so we have separate log files.
1844 for wanted in $WANTED ; do
1845 if grep -q "^$wanted$" $blocked; then
1846 broken
1847 rm -f $command
1848 die 'WANTED package "%s" is blocked' "$wanted"
1849 fi
1850 if grep -q "^$wanted$" $broken; then
1851 broken
1852 rm -f $command
1853 die 'WANTED package "%s" is broken' "$wanted"
1854 fi
1855 if [ ! -d "$WOK/$wanted/install" ]; then
1856 cook "$wanted" || { broken; exit 1; }
1857 fi
1858 done
1860 # Cook and pack or exit on error and log everything.
1861 cookit $@ 2>&1 | loglimit 50 > $LOGS/$pkg.log
1862 remove_deps | tee -a $LOGS/$pkg.log
1863 cookit_quality
1864 packall 2>&1 | loglimit 5 >> $LOGS/$pkg.log
1865 clean_log
1867 # Exit if any error in packing.
1868 lerror=$(_n 'ERROR')
1869 if grep -Ev "(/root/.cvspass|conftest|df: /|rm: can't remove)" $LOGS/$pkg.log | \
1870 grep -Eq "(^$lerror|: No such file or directory|not remade because of errors|ake: \*\*\* .* Error)"; then
1871 debug_info | tee -a $LOGS/$pkg.log
1872 sed -i '$ s|$| [ Failed ]|' $activity
1873 rm -f $command
1874 broken; exit 1
1875 fi
1877 # Create an XML feed
1878 gen_rss
1880 # Time and summary
1881 time=$(($(date +%s) - $time))
1882 summary | tee -a $LOGS/$pkg.log
1883 newline
1885 # We may want to install/update (outside aufs jail!).
1886 [ -s /aufs-umount.sh ] || install_package
1888 sed -i '$ s|$| [ Done ]|' $activity
1890 # Finally we DON'T WANT to build the *-dev or packages with WANTED="$pkg"
1891 # If you want automation, use the Cooker Build Bot.
1892 rm -f $command
1893 ;;
1894 esac
1896 exit 0