cookutils view cook @ rev 928

lighttpd/index.cgi: files: improve quick jump links.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Thu Jun 15 03:28:08 2017 +0300 (2017-06-15)
parents a984acecb3fa
children 253b4ffeef27
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 # escape quotes for receipt
874 SHORT_DESC="${SHORT_DESC//\"/\\\"}"
876 # Mandatory variables
877 cat <<EOF
878 $signature
880 PACKAGE="$PACKAGE"
881 VERSION="$VERSION"
882 CATEGORY="$CATEGORY"
883 SHORT_DESC="$SHORT_DESC"
884 MAINTAINER="$MAINTAINER"
885 LICENSE="$LICENSE"
886 WEB_SITE="$WEB_SITE"
887 EOF
889 # Optional variables
890 [ -n "$TAGS" ] && echo "TAGS=\"$TAGS\"" | tr -ds '\t' ' '
891 [ -n "${DEPENDS# }" ] && echo "DEPENDS=\"$DEPENDS\"" | tr -ds '\t' ' '
892 [ -n "$PROVIDE" ] && echo "PROVIDE=\"$PROVIDE\"" | tr -ds '\t' ' '
893 [ -n "$CONFIG_FILES" ] && echo "CONFIG_FILES=\"$CONFIG_FILES\"" | tr -ds '\t' ' '
894 [ -n "$SUGGESTED" ] && echo "SUGGESTED=\"$SUGGESTED\"" | tr -ds '\t' ' '
895 [ -n "$DATABASE_FILES" ] && echo "DATABASE_FILES=\"$DATABASE_FILES\""
896 [ -n "$TAZPANEL_DAEMON" ] && echo "TAZPANEL_DAEMON=\"$TAZPANEL_DAEMON\""
898 # Extract {pre,post}_{install,remove} functions;
899 # post_install() will be copied for both main and all the split packages
900 # post_install_gtk_() will be copied as post_install() for gtk+ package only
901 #
902 # restricted name (gtk+ -> gtk_; acl-dev -> acl_dev)
903 rname=$(echo -n $PACKAGE | tr -c 'a-zA-Z0-9' '_')
904 for i in pre post; do
905 for j in install remove; do
906 sed "/^${i}_${j}()/,/^}/!d" "$orig_receipt"
907 sed "/^${i}_${j}_$rname()/,/^}/!d" "$orig_receipt" | \
908 sed "s|^${i}_${j}_$rname()|${i}_${j}()|"
909 done
910 done
911 }
914 # Create the package. Wanted to use TazPkg to create a tazpkg package at first,
915 # but it doesn't handle EXTRAVERSION.
917 packit() {
918 set_paths "$1"
919 PACKAGE="${1:-$PACKAGE}"
921 # Handle cross compilation
922 case "$ARCH" in
923 arm*|x86_64) arch="-$ARCH" ;;
924 esac
926 title 'Pack: %s' "$PACKAGE $VERSION$arch"
928 if grep -q ^genpkg_rules $receipt; then
929 _ 'Executing: %s' 'genpkg_rules'
930 set -e; cd $pkgdir; mkdir -p $fs
931 genpkg_rules || (newline; _ 'ERROR: genpkg_rules failed'; newline) >> \
932 $LOGS/$pkg.log
933 else
934 _ 'No packages rules: meta package'
935 mkdir -p $fs
936 fi
938 # Check CONFIG_FILES
939 if [ -n "$CONFIG_FILES" ]; then
940 unset IFS
941 for i in $CONFIG_FILES; do
942 if [ ! -e $fs$i ]; then
943 case $i in
944 */) mkdir -p $fs$i ;;
945 *) mkdir -p $fs$(dirname $i); touch $fs$i ;;
946 esac
947 fi
948 done
949 fi
951 # First QA check to stop now if genpkg_rules failed.
952 lerror=$(_n 'ERROR')
953 if fgrep -q ^$lerror $LOGS/$pkg.log; then
954 broken; exit 1
955 fi
957 cd $taz
958 action 'Copying "%s"...' 'receipt'
959 mk_pkg_receipt ../receipt > $pack/receipt
960 chown 0.0 $pack/receipt; status
962 unset desc
963 [ "$pkg" == "$PACKAGE" -a -f "../description.txt" ] && desc="../description.txt"
964 [ -f "../description.$PACKAGE.txt" ] && desc="../description.$PACKAGE.txt"
965 if [ -n "$desc" ]; then
966 action 'Copying "%s"...' "$(basename "$desc")"
967 cp -f $desc $pack/description.txt; chown 0.0 $pack/description.txt; status
968 fi
970 copy_generic_files
972 # Strip and stuff files.
973 export COOKOPTS ARCH HOST_SYSTEM LOCALE fs; @@PREFIX@@/libexec/cookutils/compressor fs
975 # Create files.list with redirecting find output.
976 action 'Creating the list of files...'
977 cd $fs
978 find . -type f -print > ../files.list
979 find . -type l -print >> ../files.list
980 cd ..; sed -i s/'^.'/''/ files.list
981 status
983 # Md5sum of files.
984 action 'Creating md5sum of files...'
985 while read file; do
986 [ -L "fs$file" ] && continue
987 [ -f "fs$file" ] || continue
988 case "$file" in
989 /lib/modules/*/modules.*|*.pyc) continue ;;
990 esac
991 md5sum "fs$file" | sed 's/ fs/ /'
992 done < files.list > md5sum
993 status
995 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
996 2>/dev/null | awk 'END{ print $1 }')
998 # Build cpio archive.
999 action 'Compressing the FS...'
1000 find fs -newer $receipt -exec touch -hr $receipt '{}' \;
1001 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
1002 mv fs ../
1003 status
1005 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list md5sum description.txt \
1006 2>/dev/null | awk 'END{ print $1 }')
1008 action 'Updating receipt sizes...'
1009 sed -i s/^PACKED_SIZE.*$// receipt
1010 sed -i s/^UNPACKED_SIZE.*$// receipt
1011 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
1012 status
1014 # Set extra version.
1015 if [ -n "$EXTRAVERSION" ]; then
1016 action 'Updating receipt EXTRAVERSION: %s' "$EXTRAVERSION"
1017 sed -i s/^EXTRAVERSION.*$// receipt
1018 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
1019 status
1020 fi
1022 # Compress.
1023 action 'Creating full cpio archive...'
1024 find . -newer $receipt -exec touch -hr $receipt '{}' \;
1025 find . | cpio -o -H newc --quiet > ../$PACKAGE-$VERSION$EXTRAVERSION$arch.tazpkg
1026 status
1028 action 'Restoring original package tree...'
1029 mv ../fs .
1030 status
1032 rm fs.cpio.lzma; cd ..
1034 # QA and give info.
1035 tazpkg=$(ls *.tazpkg)
1036 packit_quality
1037 footer "$(_ 'Package "%s" created' "$tazpkg")"
1038 update_packages_info
1042 # Verify package quality and consistency.
1044 packit_quality() {
1045 #action 'QA: checking for broken link...'
1046 #link=$(find $fs/usr -type l -follow)
1047 #[ "$link" ] && echo -e "\nERROR: broken link in filesystem"
1048 #status
1050 # Exit if any error found in log file.
1051 lerror=$(_n 'ERROR')
1052 if fgrep -q ^$lerror $LOGS/$pkg.log; then
1053 rm -f $command
1054 broken; exit 1
1055 fi
1057 action 'QA: checking for empty package...'
1058 files=$(wc -l < $WOK/$pkg/taz/$PACKAGE-$VERSION$EXTRAVERSION/files.list)
1059 if [ "$files" -eq 0 -a "$CATEGORY" != 'meta' ]; then
1060 broken
1061 rm -f $command
1062 die 'ERROR: empty package'
1063 fi
1065 :; status
1066 # Find and remove old package(s)
1067 tempd="$(mktemp -d)"; cd "$tempd"
1068 for testpkg in $(ls $PKGS/$PACKAGE-*.tazpkg 2>/dev/null); do
1069 # Extract receipt from each matched package
1070 cpio -F "$testpkg" -i receipt >/dev/null 2>&1
1071 name=$(. receipt; echo $PACKAGE)
1072 rm receipt
1073 if [ "$name" == "$PACKAGE" ]; then
1074 action 'Removing old package "%s"' "$(basename "$testpkg")"
1075 rm -f "$testpkg"
1076 status
1077 fi
1078 done
1079 rm -r "$tempd"
1080 mv -f $pkgdir/taz/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg $PKGS
1081 sed -i /^${pkg}$/d $broken
1082 #action 'Removing source tree...'
1083 #rm -f $WOK/$pkg/source; status
1087 # Return all the names of packages bundled in this receipt
1089 all_names() {
1090 local split=" $SPLIT "
1091 if [ "${split/ $PACKAGE /}" != "$split" ]; then
1092 # $PACKAGE included somewhere in $SPLIT (probably in the end).
1093 # We should build packages in the order defined in the $SPLIT.
1094 echo $SPLIT
1095 else
1096 # We'll build the $PACKAGE, then all defined in the $SPLIT.
1097 echo $PACKAGE $SPLIT
1098 fi
1102 # v2: pack all packages using compiled files
1104 packall() {
1105 set_paths
1106 if head -n1 "$pkgdir/receipt" | fgrep -q 'v2'; then
1107 for i in $(all_names); do
1108 unset TAGS DEPENDS CAT CONFIG_FILES PROVIDE SUGGESTED DATABASE_FILES TAZPANEL_DAEMON
1109 packit $i
1110 done
1111 else
1112 packit
1113 fi
1117 # Reverse "cat" command: prints input lines in the reverse order
1119 tac() {
1120 sed '1!G;h;$!d' $1
1124 # Update chroot with freshly rebuilt package: keep env up-to-date.
1126 update_chroot() {
1127 local PACKAGE="$pkg"
1128 for i in $(all_names); do
1129 if [ -d "$root$INSTALLED/$i" ]; then
1130 . /etc/slitaz/cook.conf
1131 . $WOK/$pkg/taz/$i-$VERSION/receipt
1132 _ 'Updating %s chroot environment...' "$ARCH"
1133 _ 'Updating chroot: %s' "$i ($VERSION$EXTRAVERSION$arch)" | log
1134 cd $PKGS
1135 tazpkg install $i-$VERSION$EXTRAVERSION$arch.tazpkg --forced --root=$root
1136 fi
1137 done
1141 # Install package on --inst or update the chroot.
1143 install_package() {
1144 case "$ARCH" in
1145 arm*|x86_64)
1146 arch="-$ARCH"
1147 root="$CROSS_TREE/sysroot" ;;
1148 esac
1149 # Install package if requested but skip install if target host doesn't
1150 # match build system or it will break the build chroot.
1151 build=$(echo $BUILD_SYSTEM | cut -d- -f1)
1152 if [ -n "$inst" -a "$build" == "$ARCH" ]; then
1153 if [ -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ]; then
1154 cd $PKGS
1155 tazpkg install $PACKAGE-$VERSION$EXTRAVERSION.tazpkg --forced
1156 else
1157 broken
1158 die 'Unable to install package, build has failed.'
1159 fi
1160 fi
1162 update_chroot
1166 # remove chroot jail
1168 umount_aufs() {
1169 tac ${1}rw/aufs-umount.sh | sh
1170 rm -rf ${1}rw
1171 umount ${1}root
1172 rmdir ${1}r*
1176 # Launch the cook command into a chroot jail protected by aufs.
1177 # The current filesystems are used read-only and updates are
1178 # stored in a separate branch.
1180 try_aufs_chroot() {
1182 base="/dev/shm/aufsmnt$$"
1184 # Can we setup the chroot? Is it already done?
1185 grep -q ^AUFS_NOT_SUPPORTED $receipt && return
1186 grep -q ^AUFS_NOT_RAMFS $receipt && base="/mnt/aufsmnt$$"
1187 [ -n "$AUFS_MOUNTS" -a ! -f /aufs-umount.sh ] || return
1188 grep -q ^aufs /proc/modules || modprobe aufs 2> /dev/null || return
1189 mkdir ${base}root ${base}rw || return
1191 _ 'Setup aufs chroot...'
1193 # Sanity check
1194 for i in / /proc /sys /dev/shm /home ; do
1195 case " $AUFS_MOUNTS " in
1196 *\ $i\ *) ;;
1197 *) AUFS_MOUNTS="$AUFS_MOUNTS $i" ;;
1198 esac
1199 done
1200 for mnt in $(ls -d $AUFS_MOUNTS | sort | uniq); do
1201 mount --bind $mnt ${base}root$mnt
1202 if [ $mnt == / ] && ! mount -t aufs -o br=${base}rw:/ none ${base}root; then
1203 _ 'Aufs mount failure'
1204 umount ${base}root
1205 rm -rf ${base}r*
1206 return
1207 fi
1208 echo "umount ${base}root$mnt" >> ${base}rw/aufs-umount.sh
1209 done
1210 trap "umount_aufs ${base}" INT
1212 chroot ${base}root $(cd $(dirname $0); pwd)/$(basename $0) "$@"
1213 status=$?
1215 _ 'Leaving aufs chroot...'
1216 umount_aufs $base
1217 # Install package outside the aufs jail
1218 install_package
1219 exit $status
1223 # Encode predefined XML entities
1225 xml_ent() {
1226 sed -e 's|&|\&amp;|g; s|<|\&lt;|g; s|>|\&gt;|g; s|"|\&quot;|g' -e "s|'|\&apos;|g"
1230 # Create a XML feed for freshly built packages.
1232 gen_rss() {
1233 pubdate=$(date '+%a, %d %b %Y %X')
1234 cat > $FEEDS/$pkg.xml <<EOT
1235 <item>
1236 <title>$PACKAGE $VERSION$EXTRAVERSION</title>
1237 <link>${COOKER_URL}?pkg=${PACKAGE//+/%2B}</link>
1238 <guid>$PACKAGE-$VERSION$EXTRAVERSION</guid>
1239 <pubDate>$pubdate</pubDate>
1240 <description>$(echo -n "$SHORT_DESC" | xml_ent)</description>
1241 </item>
1242 EOT
1246 # Truncate stdout log file to $1 Mb.
1248 loglimit() {
1249 if [ -n "$DEFAULT_LOG_LIMIT" ]; then
1250 tee /dev/stderr | head -qc ${1:-$DEFAULT_LOG_LIMIT}m
1251 else
1252 tee /dev/stderr
1253 fi
1258 # Receipt functions to ease packaging
1261 get_dev_files() {
1262 action 'Getting standard devel files...'
1263 mkdir -p $fs/usr/lib
1264 cp -a $install/usr/lib/pkgconfig $fs/usr/lib
1265 cp -a $install/usr/lib/*a $fs/usr/lib
1266 cp -a $install/usr/include $fs/usr
1267 status
1271 # Function to use in compile_rules() to copy man page from $src to $install
1273 cook_pick_manpages() {
1274 local name section
1275 action 'Copying man pages...'
1277 for i in $@; do
1278 name=$(echo $i | sed 's|\.[gbx]z2*$||')
1279 section=${name##*/}; section=${section##*.}
1280 mkdir -p $install/usr/share/man/man$section
1281 scopy $i $install/usr/share/man/man$section
1282 done
1283 status
1287 # Function to use in genpkg_rules() to copy specified files from $install to $fs
1289 cook_copy_files() {
1290 action 'Copying files...'
1291 cd $install
1292 local i j
1293 IFS=$'\n'
1294 for i in $@; do
1295 for j in $(find . -name $i ! -type d); do
1296 mkdir -p $fs$(dirname ${j#.})
1297 scopy $j $fs$(dirname ${j#.})
1298 done
1299 done
1300 cd - >/dev/null
1301 status
1305 # Function to use in genpkg_rules() to copy specified folders from $install to $fs
1307 cook_copy_folders() {
1308 action 'Copying folders...'
1309 cd $install
1310 local i j
1311 IFS=$'\n'
1312 for i in $@; do
1313 for j in $(find . -name $i -type d); do
1314 mkdir -p $fs$(dirname ${j#.})
1315 cp -a $j $fs$(dirname ${j#.})
1316 done
1317 done
1318 cd - >/dev/null
1319 status
1323 # Common function to copy files, folders and patterns
1325 copy() {
1326 action 'Copying folders and files...'
1327 local i j filelist=$(mktemp)
1328 IFS=$'\n'
1329 cd $install; find ! -type d | sed 's|\.||' > $filelist
1330 for i in $@; do
1331 case $i in
1332 @std)
1333 # Copy "standard" files (all but "developer files", man pages, documentation, translations)
1334 sed '/\.h$/d; /\.hxx$/d; /\.a$/d; /\.la$/d; /\.pc$/d; /bin\/.*-config$/d;
1335 /\.m4$/d; /\.gir$/d; /\.typelib$/d; /\.vapi$/d; /\.deps$/d; /\.cmake$/d;
1336 /\/Makefile.*/d; /\.inc$/d; /\/include\//d;
1337 /\/share\/man\//d; /\/share\/doc\//d; /\/share\/gtk-doc\//d; /\/share\/info\//d;
1338 /\/share\/devhelp\//d; /\/share\/locale\//d;
1339 /\/share\/bash-completion\//d; /\/lib\/systemd\//d;
1340 ' $filelist
1341 ;;
1342 @dev)
1343 # Copy "developer files"
1344 sed -n '/\.h$/p; /\.hxx$/p; /\.a$/p; /\.la$/p; /\.pc$/p; /bin\/.*-config$/p;
1345 /\.m4$/p; /\.gir$/p; /\.typelib$/p; /\.vapi$/p; /\.deps$/p; /\.cmake$/p;
1346 /\/Makefile.*/p; /\.inc$/p; /\/include\//p;
1347 ' $filelist
1348 ;;
1349 */)
1350 # Copy specified folders.
1351 i="${i%/}"
1352 find -type d -path "*/${i#/}" | sed 's|^.||'
1353 ;;
1354 *)
1355 # Copy specified files.
1356 find ! -type d -path "*/${i#/}" | sed 's|^.||'
1357 ;;
1358 esac | sort -u | \
1359 while read j; do
1360 mkdir -p $fs$(dirname "$j")
1361 if [ -d "$install$j" ]; then
1362 cp -a "$install$j" $fs$(dirname "$j")
1363 else
1364 scopy "$install$j" $fs$(dirname "$j")
1365 fi
1366 done
1367 done
1368 cd - >/dev/null
1369 unset IFS
1370 rm $filelist
1371 status
1375 # Remove from current $fs files that already packed (for receipts v2).
1376 # Note: the order in $SPLIT is very important.
1378 remove_already_packed() {
1379 local i j
1380 IFS=$'\n'
1381 for i in $taz/*/files.list; do
1382 while read j; do
1383 [ -f $fs$j -o -h $fs$j ] || continue
1384 rm $fs$j
1385 rmdir --parents --ignore-fail-on-non-empty $fs$(dirname $j)
1386 done < $i
1387 done
1388 unset IFS
1392 # Function to use in genpkg_rules() to copy hicolor icons in specified sizes
1393 # (default: 16 and 48) from $install to $fs
1395 cook_copy_icons() {
1396 local sizes=$@
1397 action 'Copying hicolor icons...'
1398 mkdir -p $fs/usr/share/icons/hicolor
1399 for i in ${sizes:-16 48}; do
1400 [ ! -e "$install/usr/share/icons/hicolor/${i}x$i" ] ||
1401 scopy $install/usr/share/icons/hicolor/${i}x$i \
1402 $fs/usr/share/icons/hicolor
1403 done
1404 status
1408 # Update packages.info every time after successful build
1410 update_packages_info() {
1411 sed -i "/^$PACKAGE\t/d" $PKGS/packages.info
1412 unset_receipt; . $pack/receipt
1413 SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g')
1414 DEPENDS=$(echo $DEPENDS) # remove newlines, tabs and multiple spaces from variable
1415 MD5="$(md5sum "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" | awk '{print $1}')"
1416 cat >> $PKGS/packages.info <<EOT
1417 $PACKAGE $VERSION$EXTRAVERSION $CATEGORY $SHORT_DESC $WEB_SITE $TAGS $SIZES $DEPENDS $MD5 $PROVIDE
1418 EOT
1426 # Commands
1429 case "$1" in
1430 usage|help|-u|-h)
1431 usage ;;
1433 list-wok)
1434 title 'List of %s packages in "%s"' "$ARCH" "$WOK"
1435 cd $WOK
1436 if [ "$ARCH" != 'i486' ]; then
1437 count=0
1438 for pkg in $(fgrep 'HOST_ARCH=' */receipt | egrep "$ARCH|any" | cut -d: -f1)
1439 do
1440 unset HOST_ARCH
1441 . $pkg
1442 count=$(($count + 1))
1443 colorize 34 "$PACKAGE"
1444 done
1445 else
1446 count=$(ls | wc -l)
1447 ls -1
1448 fi
1449 footer "$(_p '%s package' '%s packages' "$count" "$(colorize 32 "$count")")"
1450 ;;
1452 activity)
1453 cat $activity ;;
1455 search)
1456 # Just a simple search function, we dont need more actually.
1457 query="$2"
1458 title 'Search results for "%s"' "$query"
1459 cd $WOK; ls -1 | grep "$query"
1460 footer ;;
1462 setup)
1463 # Setup a build environment
1464 check_root
1465 _ 'Cook: setup environment' | log
1466 title 'Setting up your environment'
1467 [ -d $SLITAZ ] || mkdir -p $SLITAZ
1468 cd $SLITAZ
1469 init_db_files
1470 _ 'Checking for packages to install...'
1471 # Use setup pkgs from cross.conf or cook.conf. When cross compiling
1472 # ARCH-setup or 'cross check' should be used before: cook setup
1473 case "$ARCH" in
1474 arm*|x86_64)
1475 [ -x '/usr/bin/cross' ] || die 'ERROR: %s is not installed' 'cross'
1476 _ 'Using config file: %s' '/etc/slitaz/cross.conf'
1477 . /etc/slitaz/cross.conf ;;
1478 esac
1479 for pkg in $SETUP_PKGS; do
1480 if [ -n "$forced" ]; then
1481 tazpkg -gi $pkg --forced
1482 else
1483 [ ! -d "$INSTALLED/$pkg" ] && tazpkg get-install $pkg
1484 fi
1485 done
1487 # Handle --options
1488 case "$2" in
1489 --wok) hg clone $WOK_URL wok || exit 1 ;;
1490 --stable) hg clone $WOK_URL-stable wok || exit 1 ;;
1491 --undigest) hg clone $WOK_URL-undigest wok || exit 1 ;;
1492 --tiny) hg clone $WOK_URL-tiny wok || exit 1 ;;
1493 esac
1495 # SliTaz group and permissions
1496 if ! grep -q ^slitaz /etc/group; then
1497 _ 'Adding group "%s"' 'slitaz'
1498 addgroup slitaz
1499 fi
1500 _ 'Setting permissions for group "%s"...' 'slitaz'
1501 find $SLITAZ -maxdepth 2 -exec chown root.slitaz {} \;
1502 find $SLITAZ -maxdepth 2 -exec chmod g+w {} \;
1503 footer "$(_ 'All done, ready to cook packages :-)')" ;;
1505 *-setup)
1506 # Setup for cross compiling.
1507 arch="${1%-setup}"
1508 check_root
1509 . /etc/slitaz/cook.conf
1510 for pkg in $CROSS_SETUP; do
1511 if [ -n "$forced" ]; then
1512 tazpkg -gi $pkg --forced
1513 else
1514 [ ! -d "$INSTALLED/$pkg" ] && tazpkg -gi $pkg
1515 fi
1516 done
1518 _ 'Cook: setup %s cross environment' "$arch" | log
1519 title 'Setting up your %s cross environment' "$arch"
1520 init_db_files
1521 sed -i \
1522 -e s"/ARCH=.*/ARCH=\"$arch\"/" \
1523 -e s"/CROSS_TREE=.*/CROSS_TREE=\"\/cross\/$arch\"/" \
1524 -e s'/BUILD_SYSTEM=.*/BUILD_SYSTEM=i486-slitaz-linux/' \
1525 /etc/slitaz/cook.conf
1526 case "$arch" in
1527 arm)
1528 flags='-O2 -march=armv6'
1529 host="$ARCH-slitaz-linux-gnueabi" ;;
1530 armv6hf)
1531 flags='-O2 -march=armv6j -mfpu=vfp -mfloat-abi=hard'
1532 host="$ARCH-slitaz-linux-gnueabi" ;;
1533 armv7)
1534 flags='-Os -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -pipe'
1535 host="$ARCH-slitaz-linux-gnueabi" ;;
1536 x86_64)
1537 flags='-O2 -mtune=generic -pipe'
1538 host="$ARCH-slitaz-linux" ;;
1539 esac
1540 sed -i \
1541 -e s"/CFLAGS=.*/CFLAGS=\"$flags\"/" \
1542 -e s"/HOST_SYSTEM=.*/HOST_SYSTEM=$host/" /etc/slitaz/cook.conf
1543 . /etc/slitaz/cook.conf
1544 sysroot="$CROSS_TREE/sysroot"
1545 tools="/cross/$arch/tools"
1546 root="$sysroot"
1547 # L10n: keep the same width of translations to get a consistent view
1548 _ 'Target arch : %s' "$ARCH"
1549 _ 'Configure args : %s' "$CONFIGURE_ARGS"
1550 _ 'Build flags : %s' "$flags"
1551 _ 'Arch sysroot : %s' "$sysroot"
1552 _ 'Tools prefix : %s' "$tools/bin"
1553 # Tell the packages manager where to find packages.
1554 _ 'Packages DB : %s' "$root$DB"
1555 mkdir -p $root$INSTALLED
1556 cd $root$DB; rm -f *.bak
1557 for list in packages.list packages.desc packages.equiv packages.md5; do
1558 rm -f $list
1559 ln -s $SLITAZ/packages/$list $list
1560 done
1561 # We must have the cross compiled glibc-base installed or default
1562 # i486 package will be used as dep by tazpkg and then break the
1563 # cross environment
1564 if [ ! -f "$root$INSTALLED/glibc-base/receipt" ]; then
1565 colorize 36 $(_ 'WARNING: %s is not installed in sysroot' '(e)glibc-base')
1566 fi
1567 # Show GCC version or warn if not yet compiled.
1568 if [ -x "$tools/bin/$HOST_SYSTEM-gcc" ]; then
1569 _ 'Cross compiler : %s' "$HOST_SYSTEM-gcc"
1570 else
1571 colorize 36 $(_ 'C compiler "%s" is missing' "$HOST_SYSTEM-gcc")
1572 _ 'Run "%s" to cook a toolchain' 'cross compile'
1573 fi
1574 footer ;;
1576 test)
1577 # Test a cook environment.
1578 _ 'Cook test: testing the cook environment' | log
1579 [ ! -d "$WOK" ] && exit 1
1580 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK
1581 cook cooktest ;;
1583 new)
1584 # Create the package folder and an empty receipt.
1585 pkg="$2"
1586 [ -z "$pkg" ] && usage
1587 newline
1588 [ -d "$WOK/$pkg" ] && die 'Package "%s" already exists.' "$pkg"
1590 action 'Creating folder "%s"' "$WOK/$pkg"
1591 mkdir $WOK/$pkg; cd $WOK/$pkg; status
1593 action 'Preparing the package receipt...'
1594 cp $DATA/receipt .
1595 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
1596 status; newline
1598 # Interactive mode, asking and seding.
1599 case "$3" in
1600 --interactive|-x)
1601 _ 'Entering interactive mode...'
1602 separator
1603 _ 'Package : %s' "$pkg"
1605 _n 'Version : ' ; read answer
1606 sed -i s/'VERSION=\"\"'/"VERSION=\"$answer\""/ receipt
1608 _n 'Category : ' ; read answer
1609 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$answer\""/ receipt
1611 # L10n: Short description
1612 _n 'Short desc : ' ; read answer
1613 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$answer\""/ receipt
1615 _n 'Maintainer : ' ; read answer
1616 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$answer\""/ receipt
1618 _n 'License : ' ; read answer
1619 sed -i s/'LICENSE=\"\"'/"LICENSE=\"$answer\""/ receipt
1621 _n 'Web site : ' ; read answer
1622 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$answer\""# receipt
1623 newline
1625 # Wget URL.
1626 _ 'Wget URL to download source tarball.'
1627 _n 'Example : ' ; echo '$GNU_MIRROR/$PACKAGE/$TARBALL'
1628 _n 'Wget url : ' ; read answer
1629 sed -i "s|WGET_URL=.*|WGET_URL=\"$answer\"|" receipt
1631 # Ask for a stuff dir.
1632 confirm "$(_n 'Do you need a stuff directory? (y/N)')"
1633 if [ "$?" -eq 0 ]; then
1634 action 'Creating the stuff directory...'
1635 mkdir $WOK/$pkg/stuff; status
1636 fi
1638 # Ask for a description file.
1639 confirm "$(_n 'Are you going to write a description? (y/N)')"
1640 if [ "$?" -eq 0 ]; then
1641 action 'Creating the "%s" file...' 'description.txt'
1642 touch $WOK/$pkg/description.txt; status
1643 fi
1645 footer "$(_ 'Receipt is ready to use.')" ;;
1646 esac ;;
1648 list)
1649 # Cook a list of packages (better use the Cooker since it will order
1650 # packages before executing cook).
1651 check_root
1652 [ -z "$2" ] && die 'No list in argument.'
1653 [ -f "$2" ] || die 'List "%s" not found.' "$2"
1655 _ 'Starting cooking the list "%s"' "$2" | log
1657 for pkg in $(cat $2); do
1658 cook $pkg || broken
1659 done ;;
1661 clean-wok)
1662 check_root
1663 newline; action 'Cleaning all packages files...'
1664 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
1665 status; newline ;;
1667 clean-src)
1668 check_root
1669 newline; action 'Cleaning all packages sources...'
1670 rm -rf $WOK/*/source
1671 status; newline ;;
1673 uncook)
1674 cd $WOK
1675 count=0
1676 title 'Checking for uncooked packages'
1678 for pkg in *; do
1679 unset HOST_ARCH EXTRAVERSION
1680 [ ! -e $pkg/receipt ] && continue
1681 . $pkg/receipt
1682 # Source cooked pkg receipt to get EXTRAVERSION
1683 if [ -d "$WOK/$pkg/taz" ]; then
1684 cd $WOK/$pkg/taz/$pkg-*
1685 . receipt; cd $WOK
1686 fi
1687 case "$ARCH" in
1688 i486)
1689 debug "$(_ 'Package "%s"' "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg")"
1690 if [ ! -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ]; then
1691 count=$(($count + 1))
1692 colorize 34 "$pkg"
1693 fi ;;
1694 arm*)
1695 # Check only packages included in arch
1696 if echo "$HOST_ARCH" | egrep -q "$ARCH|any"; then
1697 # *.tazpkg
1698 if [ ! -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg" ]; then
1699 count=$(($count + 1))
1700 colorize 34 "$pkg"
1701 fi
1702 fi ;;
1703 esac
1704 done
1706 if [ "$count" -gt 0 ]; then
1707 footer "$(_p '%s uncooked package' '%s uncooked packages' "$count" "$(colorize 31 "$count")")"
1708 else
1709 _ 'All packages are cooked :-)'
1710 newline
1711 fi
1712 ;;
1714 pkgdb)
1715 # Create suitable packages list for TazPkg and only for built packages
1716 # as well as flavors files for TazLiTo. We don't need logs since we do it
1717 # manually to ensure everything is fine before syncing the mirror.
1718 @@PREFIX@@/libexec/cookutils/pkgdb "$2"
1719 ;;
1721 *)
1722 # Just cook and generate a package.
1723 check_root
1724 time=$(date +%s)
1725 pkg="$1"
1726 [ -z "$pkg" ] && usage
1728 # Search last successful cook time in all logs from newer to older
1729 for i in '' $(seq 0 9 | sed 's|^|.|'); do
1730 [ -f "$LOGS/$pkg.log$i" ] || break
1731 lastcooktime=$(sed '/^Cook time/!d; s|.*: *\([0-9]*\)s.*|\1|' \
1732 $LOGS/$pkg.log$i 2>/dev/null | sed '$!d')
1733 [ -n "$lastcooktime" ] && break
1734 done
1736 receipt="$WOK/$pkg/receipt"
1737 check_pkg_in_wok
1738 newline
1740 unset inst
1741 unset_receipt
1742 . $receipt
1744 # Handle cross compilation.
1745 case "$ARCH" in
1746 arm*)
1747 if [ -z "$HOST_ARCH" ]; then
1748 _ 'cook: HOST_ARCH is not set in "%s" receipt' "$pkg"
1749 error="$(_ 'package "%s" is not included in %s' "$pkg" "$ARCH")"
1750 _ 'cook: %s' "$error"
1751 [ -n "$CROSS_BUGS" ] && _ 'bugs: %s' "$CROSS_BUGS"
1752 _ 'Cook skip: %s' "$error" | log
1753 newline
1754 broken; exit 1
1755 fi ;;
1756 esac
1758 # Some packages are not included in some arch or fail to cross compile.
1759 : ${HOST_ARCH=i486}
1760 debug "$(_ 'Host arch %s' "$HOST_ARCH")"
1761 # Handle arm{v6hf,v7,..}
1762 if ! $(echo "$HOST_ARCH" | egrep -q "${ARCH%v[0-9]*}|any"); then
1763 _ 'cook: %s' "HOST_ARCH=$HOST_ARCH"
1764 error="$(_ "package \"%s\" doesn't cook or is not included in %s" "$pkg" "$ARCH")"
1765 _ 'cook: %s' "error"
1766 [ -n "$CROSS_BUGS" ] && _ 'bugs: %s' "$CROSS_BUGS"
1767 _ 'Cook skip: %s' "$error" | log
1768 sed -i /^${pkg}$/d $broken
1769 newline
1770 exit 0
1771 fi
1773 # Skip blocked, 3 lines also for the Cooker.
1774 grep -q "^$pkg$" $blocked && [ "$2" != '--unblock' ] &&
1775 die 'Package "%s" is blocked' "$pkg"
1777 try_aufs_chroot "$@"
1779 # Log and source receipt.
1780 _ 'Cook started for: %s' "<a href='cooker.cgi?pkg=${pkg//+/%2B}'>$pkg</a>" | log
1781 echo "cook:$pkg" > $command
1783 [ -n "$lastcooktime" ] && echo "cook:$pkg $lastcooktime $(date +%s)" >> $cooktime
1785 while read cmd duration start; do
1786 [ $(($start + $duration)) -lt $(date +%s) ] &&
1787 echo "sed -i '/^$cmd $duration/d' $cooktime"
1788 done < $cooktime | sh
1790 # Display and log info if cook process stopped.
1791 # FIXME: gettext not working (in single quotes) here!
1792 trap '_ "\n\nCook stopped: control-C\n\n" | \
1793 tee -a $LOGS/$pkg.log' INT
1795 # Handle --options
1796 case "$2" in
1797 --clean|-c)
1798 action 'Cleaning "%s"' "$pkg"
1799 cd $WOK/$pkg; rm -rf install taz source
1800 status; newline
1801 exit 0 ;;
1803 --install|-i)
1804 inst='yes' ;;
1806 --getsrc|-gs)
1807 title 'Getting source for "%s"' "$pkg"
1808 get_source
1809 _ 'Tarball: %s' "$SRC/$TARBALL"; newline
1810 exit 0 ;;
1812 --block|-b)
1813 action 'Blocking package "%s"' "$pkg"
1814 [ $(grep "^$pkg$" $blocked) ] || echo "$pkg" >> $blocked
1815 status; newline
1816 exit 0 ;;
1818 --unblock|-ub)
1819 action 'Unblocking package "%s"' "$pkg"
1820 sed -i "/^${pkg}$/"d $blocked
1821 status; newline
1822 exit 0 ;;
1824 --pack)
1825 [ -d "$WOK/$pkg/install" ] || die 'Need to build "%s"' "$pkg"
1826 [ ! -d "$WOK/$pkg/taz" ] || rm -rf "$WOK/$pkg/taz"
1827 [ ! -f "$LOGS/$pkg-pack.log" ] || rm -rf $LOGS/$pkg-pack.log
1828 sed -i '$ s|$| (packing)|' $activity
1829 packall 2>&1 | tee -a $LOGS/$pkg-pack.log
1830 clean_log "$pkg-pack"
1831 time=$(($(date +%s) - $time))
1832 summary | sed 's|^Cook |Pack |' | tee -a $LOGS/$pkg-pack.log
1833 sed -i '$ s|$| [ Done ]|' $activity
1834 rm -f $command
1835 exit 0 ;;
1837 --cdeps)
1838 @@PREFIX@@/libexec/cookutils/cdeps $pkg
1839 esac
1841 # Rotate log
1842 for i in $(seq 9 -1 1); do
1843 j=$(($i - 1))
1844 [ -e $LOGS/$pkg.log.$j ] && mv -f $LOGS/$pkg.log.$j $LOGS/$pkg.log.$i
1845 done
1846 [ -e $LOGS/$pkg.log ] && mv $LOGS/$pkg.log $LOGS/$pkg.log.0
1848 # Check if wanted is built now so we have separate log files.
1849 for wanted in $WANTED ; do
1850 if grep -q "^$wanted$" $blocked; then
1851 broken
1852 rm -f $command
1853 die 'WANTED package "%s" is blocked' "$wanted"
1854 fi
1855 if grep -q "^$wanted$" $broken; then
1856 broken
1857 rm -f $command
1858 die 'WANTED package "%s" is broken' "$wanted"
1859 fi
1860 if [ ! -d "$WOK/$wanted/install" ]; then
1861 cook "$wanted" || { broken; exit 1; }
1862 fi
1863 done
1865 # Cook and pack or exit on error and log everything.
1866 cookit $@ 2>&1 | loglimit 50 > $LOGS/$pkg.log
1867 remove_deps | tee -a $LOGS/$pkg.log
1868 cookit_quality
1869 packall 2>&1 | loglimit 5 >> $LOGS/$pkg.log
1870 clean_log
1872 # Exit if any error in packing.
1873 lerror=$(_n 'ERROR')
1874 if grep -Ev "(/root/.cvspass|conftest|df: /|rm: can't remove)" $LOGS/$pkg.log | \
1875 grep -Eq "(^$lerror|: No such file or directory|not remade because of errors|ake: \*\*\* .* Error)"; then
1876 debug_info | tee -a $LOGS/$pkg.log
1877 sed -i '$ s|$| [ Failed ]|' $activity
1878 rm -f $command
1879 broken; exit 1
1880 fi
1882 # Create an XML feed
1883 gen_rss
1885 # Time and summary
1886 time=$(($(date +%s) - $time))
1887 summary | tee -a $LOGS/$pkg.log
1888 newline
1890 # We may want to install/update (outside aufs jail!).
1891 [ -s /aufs-umount.sh ] || install_package
1893 sed -i '$ s|$| [ Done ]|' $activity
1895 # Finally we DON'T WANT to build the *-dev or packages with WANTED="$pkg"
1896 # If you want automation, use the Cooker Build Bot.
1897 rm -f $command
1898 ;;
1899 esac
1901 exit 0