cookutils view cook @ rev 723

cook: Fixed loglimit function.
author Christopher Rogers <slaxemulator@gmail.com>
date Fri Apr 17 21:02:34 2015 +0000 (2015-04-17)
parents 5cb10078fbc0
children 7618375fefaa
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 #
9 . /usr/lib/slitaz/libcook.sh
10 . /usr/lib/slitaz/libcookorder.sh
11 . /usr/lib/slitaz/libcookiso.sh
13 VERSION="3.2"
15 # Internationalization.
16 . /usr/bin/gettext.sh
17 TEXTDOMAIN='cook'
18 export TEXTDOMAIN
20 _() echo -e "$(eval_gettext "$1")"
21 _n() echo -en "$(eval_gettext "$1")"
22 # to disable i18n:
23 # _() echo -e "$1"
24 # _n() echo -en "$1"
26 COMMAND="$1"
28 #
29 # Functions
30 #
32 usage() {
33 cat << EOT
35 $(_ "\033[1mUsage:\033[0m cook [package|command] [list|--option]")
37 $(_ "\033[1mCommands:\033[0m")
38 usage|help $(_ "Display this short usage.")
39 setup $(_ "Setup your build environment.")
40 *-setup $(_ "Setup a cross environment.")
41 test $(_ "Test environment and cook a package.")
42 list-wok $(_ "List packages in the wok.")
43 search $(_ "Simple packages search function.")
44 new $(_ "Create a new package with a receipt.")
45 list $(_ "Cook a list of packages.")
46 clean-wok $(_ "Clean-up all packages files.")
47 clean-src $(_ "Clean-up all packages sources.")
48 uncook $(_ "Check for uncooked packages")
49 pkgdb $(_ "Create packages DB lists and flavors.")
50 upwok $(_ "Update wok.")
51 gen-wok-db $(_ "Build cook order files.")
52 gen-src $(_ "Build source list.")
53 check-incoming $(_ "Move incoming packages to packages folder.")
54 gen-cooklist $(_ "Make cook order list.")
55 check-src $(_ "Check upstream tarball for package in the wok.")
56 maintainers $(_ "List all maintainers in the wok.")
57 maintained-by $(_ "List packages maintained by a contributor.")
58 tags $(_ "List all tags used in wok receipts.")
59 unbuild $(_ "List all unbuild packages.")
61 $(_ "\033[1mOptions:\033[0m")
62 --clean|-c Cook : $(_ "clean the package in the wok.")
63 --install|-i Cook : $(_ "cook and install the package.")
64 --getsrc|-gs Cook : $(_ "get the package source tarball.")
65 --block|-b Cook : $(_ "block a package so cook will skip it.")
66 --unblock|-ub Cook : $(_ "unblock a blocked package.")
68 --interactive|-x New : $(_ "create a receipt interactively.")
69 --local Upwok: $(_ "update wok local changes in wok-hg.")
70 --wok Setup: $(_ "clone the cooking wok from Hg repo.")
71 --stable Setup: $(_ "clone the stable wok from Hg repo.")
72 --undigest Setup: $(_ "clone the undigest wok from Hg repo.")
73 --tiny Setup: $(_ "clone the tiny SliTaz wok from Hg repo.")
74 --forced Setup: $(_ "force reinstall of chroot packages.")
75 --flavors Pkgdb: $(_ "create up-to-date flavors files.")
76 --full Unbuild: $(_ "create a full unbuild list.")
77 --list Unbuild: $(_ "Copy unbuild list into your cooklist.")
79 EOT
80 exit 0
81 }
83 # We don't want these escapes in web interface.
84 clean_log() {
85 sed -i -e s'|\[70G\[ \[1;32m| |' \
86 -e s'|\[0;39m \]||' $LOGS/$pkg.log
87 }
89 # check if $value is empty
90 if_empty_value() {
91 if [ -z "$value" ]; then
92 # L10n: QA is quality assurance
93 _ "QA: empty variable: \${var}=\"\""; newline
94 exit 1
95 fi
96 }
99 # QA: check a receipt consistency before building.
100 receipt_quality() {
101 _ "QA: checking package receipt..."
102 unset online
103 if ifconfig | grep -q -A 1 "^[a-z]*[0-9]" | fgrep 'addr:'; then
104 online="online"
105 fi
106 for var in PACKAGE VERSION CATEGORY SHORT_DESC MAINTAINER WEB_SITE
107 do
108 unset value
109 value="$(. $receipt ; eval echo \$$var)"
110 case "$var" in
111 PACKAGE|VERSION|SHORT_DESC)
112 if_empty_value ;;
113 CATEGORY)
114 [ -z "$value" ] && value="empty"
115 valid="$PKGS_CATEGORIES"
116 if ! echo "$valid" | grep -q -w "$value"; then
117 _ "QA: unknown category: \$value"
118 _ "Please, use one of: \$valid" | busybox fold -s
119 newline; exit 1
120 fi ;;
121 WEB_SITE)
122 # We don't check WGET_URL since if dl is needed it will fail.
123 # Break also if we're not online. Here error is not fatal.
124 if_empty_value
125 [ -z "$online" ] || break
126 case $value in
127 https://*)
128 if ! wget -T $TIMEOUT --spider --no-check-certificate $value 2>/dev/null; then
129 _ "QA: Unable to reach: \$value"
130 fi ;;
131 http://*|ftp://*)
132 if ! busybox wget -T $TIMEOUT -s $value 2>/dev/null; then
133 _ "QA: Unable to reach: \$value"
134 fi ;;
135 esac
136 esac
137 done
138 }
140 # Paths used in receipt and by cook itself.
141 set_paths() {
142 pkgdir=$WOK/$PACKAGE
143 basesrc=$pkgdir/source
144 tmpsrc=$basesrc/tmp
145 src=$basesrc/$PACKAGE-$VERSION
146 taz=$pkgdir/taz
147 pack=$taz/$PACKAGE-${VERSION}${EXTRAVERSION}
148 fs=$pack/fs
149 stuff=$pkgdir/stuff
150 install=$pkgdir/install
151 pkgsrc="${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}"
152 lzma_tarball="$pkgsrc.tar.lzma"
153 orig_tarball="$TARBALL"
154 if [ "$PATCH" ]; then
155 [ "${PTARBALL}" ] || PTARBALL="$(basename $PATCH)"
156 fi
157 if [ "$WANTED" ]; then
158 basesrc=$WOK/$WANTED/source
159 src=$basesrc/$WANTED-$VERSION
160 install=$WOK/$WANTED/install
161 wanted_stuff=$WOK/$WANTED/stuff
162 fi
163 if [ "$SOURCE" ]; then
164 source_stuff=$WOK/$SOURCE/stuff
165 fi
166 # Kernel version is set from linux
167 if [ -f "$WOK/linux/receipt" ]; then
168 kvers=$(grep ^VERSION= $WOK/linux/receipt | cut -d '"' -f 2)
169 kbasevers=${kvers:0:3}
170 fi
171 # Python version
172 if [ -f "$WOK/python/receipt" ]; then
173 pyvers=$(grep ^VERSION= $WOK/python/receipt | cut -d '"' -f 2)
174 fi
175 # perl version for some packages needed it
176 if [ -f "$WOK/perl/receipt" ]; then
177 perlvers=$(grep ^VERSION= $WOK/perl/receipt | cut -d '"' -f 2)
178 fi
179 # Old way compatibility.
180 _pkg=$install
181 }
183 # Create source tarball when URL is a SCM.
184 create_tarball() {
185 local tarball
186 tarball=$pkgsrc.tar.bz2
187 [ "$LZMA_SRC" ] && tarball=$lzma_tarball
188 _ "Creating tarball: \$tarball"
189 if [ "$LZMA_SRC" ]; then
190 tar -c $pkgsrc | lzma e $SRC/$tarball -si $LZMA_SET_DIR || exit 1
191 LZMA_SRC=""
192 else
193 tar cjf $tarball $pkgsrc || exit 1
194 mv $tarball $SRC && rm -rf $pkgsrc
195 fi
196 TARBALL=$tarball
197 }
199 # Get package source. For SCM we are in cache so clone here and create a
200 # tarball here.
201 get_source() {
202 pwd=$(pwd)
203 for file in $@; do
204 _ "Getting source from url: \${file#*|}"
205 if [ "$file" = "$PATCH" -o "$file" = "$orig_url_patch" ]; then
206 SAVE_FILE="$SRC/$PTARBALL"
207 else
208 SAVE_FILE="$SRC/$TARBALL"
209 fi
210 case "$file" in
211 http://*|ftp://*)
212 # Busybox Wget is better!
213 busybox wget $WGET_OPTIONS -T $TIMEOUT -c -O $SAVE_FILE $file || \
214 (_ "ERROR: wget \$file" && exit 1) ;;
215 https://*)
216 wget $WGET_OPTIONS -T $TIMEOUT -c --no-check-certificate -O $SAVE_FILE $file || \
217 (_ "ERROR: wget \$file" && exit 1) ;;
218 hg*|mercurial*)
219 if $(echo "$file" | fgrep -q "hg|"); then
220 url=${file#hg|}
221 else
222 url=${file#mercurial|}
223 fi
224 _ "Getting source from Hg..."
225 _ "URL: \$url"
226 _ "Cloning to: \$pwd/\$pkgsrc"
227 if [ "$BRANCH" ]; then
228 _ "Hg branch: \$BRANCH"
229 hg clone $url --rev $BRANCH $pkgsrc || \
230 (_ "ERROR: hg clone \$url --rev \$BRANCH" && exit 1)
231 else
232 hg clone $url $pkgsrc || (_ "ERROR: hg clone \$url" && exit 1)
233 fi
234 create_tarball ;;
235 git*)
236 [ -f $INSTALLED/git/receipt ] || tazpkg get-install git
237 url=${file#git|}
238 _ "Getting source from Git..."
239 _ "URL: \$url"
240 git clone $url $pkgsrc || (_ "ERROR: git clone \$url" && exit 1)
241 if [ "$BRANCH" ]; then
242 _ "Git branch: \$BRANCH"
243 cd $pkgsrc && git checkout $BRANCH && cd ..
244 fi
245 create_tarball ;;
246 bzr*|bazaar*)
247 [ -f $INSTALLED/bazaar/receipt ] || tazpkg get-install bazaar
248 if $(echo "$file" | fgrep -q "bzr|"); then
249 url=${file#bzr|}
250 else
251 url=${file#bazaar|}
252 fi
253 _ "Getting source from BZR..."
254 _ "URL: \$url"
255 bzr branch $url $pkgsrc
256 create_tarball ;;
257 cvs*)
258 [ -f $INSTALLED/cvs/receipt ] || tazpkg get-install cvs
259 url=${file#cvs|}
260 mod=$PACKAGE
261 [ "$CVS_MODULE" ] && mod=$CVS_MODULE
262 _ "Getting source from CVS..."
263 _ "URL: \$url"
264 [ "$CVS_MODULE" ] && _ "CVS module: \$mod"
265 _ "Cloning to: \$pwd/\$mod"
266 cvs -d:$url co $mod && mv $mod $pkgsrc
267 create_tarball ;;
268 svn*|subversion*)
269 [ -f $INSTALLED/subversion/receipt ] || tazpkg get-install subversion
270 if $(echo "$file" | fgrep -q "svn|"); then
271 url=${file#svn|}
272 else
273 url=${file#subversion|}
274 fi
275 _ "Getting source from SVN..."
276 _ "URL: \$url"
277 if [ "$BRANCH" ]; then
278 echo t | svn co $url -r $BRANCH $pkgsrc
279 else
280 echo t | svn co $url $pkgsrc
281 fi
282 create_tarball ;;
283 *)
284 (newline; _ "ERROR: Unable to handle: \$file"; newline)| \
285 tee -a $LOGS/$PACKAGE.log
286 exit 1 ;;
287 esac
288 done
289 }
291 # get source tarball
292 # $1 = --extract
293 getsrc() {
294 _ "Getting source for: \$pkg"
295 set_paths
296 [ -f "$SRC/$lzma_tarball" ] && \
297 TARBALL="$lzma_tarball"
299 # Get source tarball and make sure we have source dir named:
300 # $PACKAGE-$VERSION to be standard in receipts. Here we use tar.lzma
301 # tarball if it exists.
302 look_for_cookopt !unpack && unpack="no"
303 look_for_cookopt !repack_src && LZMA_SRC=""
304 if [ ! "$WANTED" ] && [ "$TARBALL" ] && [ ! "$unpack" ] && [ ! "$cook_code" ]; then
305 [ -d $tmpsrc ] && rm -rf $tmpsrc
306 mkdir -p $tmpsrc && cd $tmpsrc
307 fi
309 if [ "$WGET_URL" ] && [ ! -f "$SRC/$TARBALL" ]; then
310 separator && download
311 fi
313 if [ "$WGET_URL" ] && [ -f "$SRC/$TARBALL" ] && [ ! "$unpack" ] && [ ! "$cook_code" ]; then
314 [ "$TARBALL" = "$lzma_tarball" ] && LZMA_SRC=""
315 if [ "$1" = "--extract" ]; then
316 extract_source || exit 1
317 if [ ! -f "$SRC/$lzma_tarball" ] && [ "$LZMA_SRC" ]; then
318 echo -e "Repacking source."
319 repack_source || exit 1
320 fi
321 extract_path || exit 1
322 if [ -f $SRC/$TARBALL ]; then
323 [ -d $tmpsrc ] && rm -rf $tmpsrc
324 fi
325 fi
326 fi
328 # This is to make sure if PATCH equals something it will be downloaded
329 # checks are done in download functions
330 if [ "$PATCH" ] && [ ! "$cook_code" ]; then
331 if [ ! -f "$SRC/$PTARBALL" ]; then
332 separator && download
333 fi
334 fi
336 _ "Tarball: \$SRC/\$TARBALL"
337 [ "$PATCH" ] && _ "Patch: \$SRC/\$PTARBALL"
338 }
340 # the base function to download sources when offline
341 # This is to make sure source can be download when local-mirror
342 # script is in use.
343 download_base() {
344 local URLS url alt_url orig_url orig_url_patch
345 url="$ONLINE_SRC_REPOSITORY"
346 if [ "$SOURCE" ]; then
347 alt_url="${url}${SOURCE:0:1}/$SOURCE-${KBASEVER:-$VERSION}.tar.lzma"
348 else
349 alt_url="${url}${PACKAGE:0:1}/$PACKAGE-${KBASEVER:-$VERSION}.tar.lzma"
350 fi
351 orig_url="${url}${TARBALL:0:1}/$TARBALL"
352 [ "$PATCH" ] && orig_url_patch="${url}${PTARBALL:0:1}/$PTARBALL"
353 URLS="$@ $alt_url $orig_url $orig_url_patch"
354 [ "$LAN_MIRROR" ] && URLS="$alt_url $orig_url $orig_url_patch $@"
355 if [ "$WGET_URL" = "$orig_url" ]; then
356 [ "$TARBALL" = "$lzma_tarball" ] && LZMA_SRC=""
357 get_source $@
358 elif [ "$WGET_URL" = "$alt_url" ]; then
359 LZMA_SRC=""
360 get_source $@
361 else
362 for i in $URLS; do
363 if [ "$1" = "$PATCH" ]; then
364 [ ! -f "$SRC/$PTARBALL" ] || continue
365 else
366 [ ! -f "$SRC/$TARBALL" ] || continue
367 fi
368 case $i in
369 ${url}*)
370 [ "$i" = "$alt_url" ] && TARBALL="$(basename $alt_url)"
371 [ "$i" = "$alt_url" ] && LZMA_SRC=""
372 get_source $i
373 ;;
374 *)
375 get_source $i ;;
376 esac
377 done
378 fi
379 }
381 # Get source from multible urls
382 download() {
383 if [ ! -s "$SRC/$TARBALL" ]; then
384 download_base $WGET_URL
385 [ -f "$SRC/$TARBALL" ] || broken
386 fi
388 if [ "$PATCH" ]; then
389 if [ ! -s "$SRC/$PTARBALL" ]; then
390 download_base $PATCH
391 [ -f "$SRC/$PTARBALL" ] || broken
392 fi
393 fi
394 }
396 # Extract source package.
397 extract_source() {
398 _ "Extracting: \$TARBALL"
399 case "$TARBALL" in
400 *.tar.gz|*.tgz) tar xzf $SRC/$TARBALL 2>/dev/null ;;
401 *.tar.bz2|*.tbz|*.tbz2) tar xjf $SRC/$TARBALL 2>/dev/null ;;
402 *.tar.lzma) tar xaf $SRC/$TARBALL ;;
403 *.tar.lz|*.tlz) lzip -d < $SRC/$TARBALL | tar xf - 2>/dev/null ;;
404 *.tar) tar xf $SRC/$TARBALL ;;
405 *.zip|*.xpi) unzip -o $SRC/$TARBALL ;;
406 *.xz) unxz -c $SRC/$TARBALL | tar xf - ;;
407 *.Z) uncompress -c $SRC/$TARBALL | tar xf - ;;
408 *.rpm) rpm2cpio $SRC/$TARBALL | cpio -idm --quiet ;;
409 *.deb) ar vx $SRC/$TARBALL
410 [ ! -d $tmpsrc/$PACKAGE-$VERSION ] && mkdir -p $tmpsrc/$PACKAGE-$VERSION
411 cd $tmpsrc/$PACKAGE-$VERSION
412 tar -xvzf $tmpsrc/data.tar.gz
413 [ -f $tmpsrc/data.tar.gz ] && rm -f $tmpsrc/data.tar.gz
414 [ -f $tmpsrc/control.tar.gz ] && rm -f $tmpsrc/control.tar.gz
415 [ -f $tmpsrc/debian-binary ] && rm -f $tmpsrc/debian-binary ;;
416 *.run) /bin/sh $SRC/$TARBALL $RUN_OPTS ;;
417 *.7z) 7zr x $SRC/$TARBALL ;;
418 *) cp $SRC/$TARBALL $(pwd) ;;
419 esac
420 chown -R 0.0 $(pwd)
421 }
423 # Repack source tarball as .tar.lzma
424 # The source tarball is extracted as $tmpsrc/$pkgsrc path
425 # This way the source has a clean path when building
426 repack_source() {
428 # Some archives are not well done and don't extract to one dir (ex lzma).
429 files=$(ls | wc -l)
430 [ "$files" == 1 ] && [ -d "$(ls)" ] && [ ! -d "$pkgsrc" ] && mv * $tmpsrc/$pkgsrc
431 if [ ! -d "$tmpsrc/$pkgsrc" ]; then
432 cd $basesrc
433 if [ "$(ls -A tmp | wc -l)" -gt 1 ] || [ -f "$(echo tmp/*)" ]; then
434 mv tmp tmp-1 && mkdir tmp
435 mv tmp-1 tmp/$pkgsrc
436 fi
437 fi
438 if [ -d "$tmpsrc/$pkgsrc" ]; then
439 _ "Repacking source is enabled: LZMA_SRC"
440 TARBALL=$lzma_tarball
441 cd $tmpsrc
442 if [ -x /usr/bin/optipng ]; then
443 [ "$SHRINKPNG" ] && find -name "*.png" -type f | xargs -i optipng "{}"
444 fi
445 tar -c * | lzma e $SRC/$TARBALL -si $LZMA_SET_DIR
446 if [ $REMOVE_ORIG_TARBALL ]; then
447 if [ -f $SRC/$TARBALL ]; then
448 [ -f $SRC/$orig_tarball ] && rm -f $SRC/$orig_tarball
449 fi
450 fi
451 fi
452 }
454 # Display cooked package summary.
455 summary() {
456 [ -d $WOK/$pkg/install ] && prod=$(du -sh $WOK/$pkg/install | awk '{print $1}' 2>/dev/null)
457 [ -d $WOK/$pkg/source ] && srcdir=$(du -sh $WOK/$pkg/source | awk '{print $1}' 2>/dev/null)
458 fs=$(du -sh $WOK/$pkg/taz/* | awk '{print $1}')
459 size=$(du -sh $INCOMING/$pkg-${VERSION}*.tazpkg | awk '{print $1}')
460 files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l)
461 [ "$TARBALL" ] && srcsize=$(du -sh $SRC/$TARBALL | awk '{print $1}')
462 cookdate=$(date "$(_ '+%Y-%m-%d %H:%M')")
463 sec=$time
464 div=$(( ($time + 30) / 60))
465 # L10n: 'm' is for minutes (approximate cooking time)
466 min=$(_n "~ \${div}m"); [ "$div" = 0 ] && min=""
467 _ "Summary for: \$PACKAGE \$VERSION"
468 separator
469 # L10n: keep the same width of translations to get a consistent view
470 [ "$srcdir" ] && _ "Source dir : \$srcdir"
471 [ "$TARBALL" ] && _ "Src file : \$TARBALL"
472 [ "$srcsize" ] && _ "Src size : \$srcsize"
473 [ "$prod" ] && _ "Produced : \$prod"
474 _ "Packed : \$fs"
475 _ "Compressed : \$size"
476 _ "Files : \$files"
477 # L10n: 's' is for seconds (cooking time)
478 _ "Cook time : \${sec}s \$min"
479 _ "Cook date : \$cookdate"
480 _ "Host arch : \$ARCH"
481 separator
482 }
484 # Display debugging error info.
485 debug_info() {
486 newline; _ "Debug information"; separator
487 # L10n: specify your format of date and time (to help: man date)
488 # L10n: not bad one is '+%x %R'
489 datenow=$(date "$(_ '+%Y-%m-%d %H:%M')")
490 _ "Cook date: \$datenow"
491 # L10n: Please, translate all messages beginning with ERROR in a same way
492 lerror=$(_n "ERROR")
493 for error in \
494 ERROR $lerror "No package" "cp: can't" "can't open" "can't cd" \
495 "error:" "fatal error:" "undefined reference to" \
496 "Unable to connect to" "link: cannot find the library" \
497 "CMake Error" ": No such file or directory" \
498 "rm: can't remove" "cp: can't stat"
499 do
500 fgrep "$error" $LOGS/$pkg.log
501 done > $LOGS/$pkg.log.debug_info 2>&1
502 cat $LOGS/$pkg.log.debug_info
503 rm -f $LOGS/$pkg.log.debug_info
504 separator; newline
505 }
507 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
508 # so some packages need to copy these files with the receipt and genpkg_rules.
509 copy_generic_files()
510 {
511 # $LOCALE is set in cook.conf
512 if [ "$LOCALE" -a "$WANTED" = "" ]; then
513 if [ -d "$install/usr/share/locale" ]; then
514 mkdir -p $fs/usr/share/locale
515 for i in $LOCALE
516 do
517 if [ -d "$install/usr/share/locale/$i" ]; then
518 cp -a $install/usr/share/locale/$i $fs/usr/share/locale
519 fi
520 done
521 fi
522 fi
524 # Generic pixmaps copy can be disabled with GENERIC_PIXMAPS="no"
525 if [ "$GENERIC_PIXMAPS" != "no" ]; then
526 if [ -d "$install/usr/share/pixmaps" ]; then
527 mkdir -p $fs/usr/share/pixmaps
528 if [ -f "$install/usr/share/pixmaps/$PACKAGE.png" ]; then
529 cp -a $install/usr/share/pixmaps/$PACKAGE.png \
530 $fs/usr/share/pixmaps
531 elif [ -f "$install/usr/share/pixmaps/$PACKAGE.xpm" ]; then
532 cp -a $install/usr/share/pixmaps/$PACKAGE.xpm \
533 $fs/usr/share/pixmaps
534 fi
535 fi
537 # Custom or homemade PNG pixmap can be in stuff.
538 if [ -f "$stuff/$PACKAGE.png" ]; then
539 mkdir -p $fs/usr/share/pixmaps
540 cp -a $stuff/$PACKAGE.png $fs/usr/share/pixmaps
541 fi
542 fi
544 # Desktop entry (.desktop).
545 # Generic desktop entry copy can be disabled with GENERIC_MENUS="no"
546 if [ "$GENERIC_MENUS" != "no" ]; then
547 if [ -d "$install/usr/share/applications" ] && [ "$WANTED" == "" ]; then
548 mkdir -p $fs/usr/share
549 cp -a $install/usr/share/applications $fs/usr/share
550 fi
551 fi
553 # Homemade desktop file(s) can be in stuff.
554 if [ -d "$stuff/applications" ]; then
555 mkdir -p $fs/usr/share
556 cp -a $stuff/applications $fs/usr/share
557 fi
558 if [ -f "$stuff/$PACKAGE.desktop" ]; then
559 mkdir -p $fs/usr/share/applications
560 cp -a $stuff/$PACKAGE.desktop $fs/usr/share/applications
561 fi
563 # Add custom licenses
564 if [ -d "$stuff/licenses" ]; then
565 mkdir -p $fs/usr/share/licenses
566 cp -a $stuff/licenses $fs/usr/share/licenses/$PACKAGE
567 fi
568 }
570 # Find and strip: --strip-all (-s) or --strip-debug on static libs as well
571 # as removing unneeded files like in Python packages. Cross compiled binaries
572 # must be stripped with cross-tools aka $ARCH-slitaz-*-strip
573 strip_package()
574 {
575 case "$ARCH" in
576 arm*|x86_64) export STRIP=${HOST_SYSTEM}-strip ;;
577 *) export STRIP=strip ;;
578 esac
579 _n "Executing strip on all files..."
580 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
581 do
582 if [ -d "$dir" ]; then
583 find $dir -type f -exec $STRIP -s '{}' 2>/dev/null \;
584 fi
585 done
586 find $fs -name "*.so*" -exec $STRIP -s '{}' 2>/dev/null \;
587 find $fs -name "*.a" -exec $STRIP --strip-debug '{}' 2>/dev/null \;
588 status
590 # Remove Python .pyc and .pyo from packages.
591 if echo "$PACKAGE $DEPENDS" | fgrep -q "python"; then
592 _n "Removing Python compiled files..."
593 find $fs -type f -name "*.pyc" -delete 2>/dev/null
594 find $fs -type f -name "*.pyo" -delete 2>/dev/null
595 status
596 fi
598 # Remove Perl perllocal.pod and .packlist from packages.
599 if echo "$DEPENDS" | fgrep -q "perl"; then
600 _n "Removing Perl compiled files..."
601 find $fs -type f -name "perllocal.pod" -delete 2>/dev/null
602 find $fs -type f -name ".packlist" -delete 2>/dev/null
603 status
604 fi
605 }
607 # Remove installed deps.
608 remove_deps() {
609 # Now remove installed build deps.
610 diff="$CACHE/installed.cook.diff"
611 if [ -s "$diff" ]; then
612 deps=$(cat $diff | grep ^+[a-zA-Z0-9] | sed s/^+//)
613 nb=$(cat $diff | grep ^+[a-zA-Z0-9] | wc -l)
614 _n "Build dependencies to remove: "; echo $nb $root
615 _n "Removing:"
616 for dep in $deps
617 do
618 echo -n " $dep"
619 echo 'y' | tazpkg remove $dep --auto --root=$root >/dev/null
620 done
621 newline; newline
622 # Keep the last diff for debug and info.
623 mv -f $diff $CACHE/installed.diff
624 fi
625 }
627 # extract path of source tarball
628 # This is for the getsrc --extract option
629 extract_path()
630 {
631 # Some archives are not well done and don't extract to one dir (ex lzma).
632 files=$(ls | wc -l)
633 [ "$files" == 1 ] && [ -d "$(ls)" ] && mv * ../$PACKAGE-$VERSION
634 [ "$files" == 1 ] && [ -f "$(ls)" ] && mkdir -p ../$PACKAGE-$VERSION && \
635 mv * ../$PACKAGE-$VERSION/$TARBALL
636 [ "$files" -gt 1 ] && mkdir -p ../$PACKAGE-$VERSION && \
637 mv * ../$PACKAGE-$VERSION
638 cd .. && rm -rf tmp
639 if [ "$TOUCH_FILES" ]; then
640 echo "Touching source files to update timestamp"
641 echo "May take a bit"
642 find $src -type f -exec touch "{}" \;
643 fi
644 }
646 # The main cook function.
647 cookit() {
648 _ "Cook: \$PACKAGE \$VERSION"; separator
649 set_paths
651 # Handle cross-tools.
652 case "$ARCH" in
653 arm*|x86_64)
654 # CROSS_COMPILE is used by at least Busybox and the kernel to set
655 # the cross-tools prefix. Sysroot is the root of our target arch
656 sysroot=$CROSS_TREE/sysroot
657 tools=$CROSS_TREE/tools
658 # Set root path when cross compiling. ARM tested but not x86_64
659 # When cross compiling we must install build deps in $sysroot.
660 arch="-${ARCH}"
661 root=$sysroot
662 _ "\$ARCH sysroot: \$sysroot"
663 _ "Adding \$tools/bin to PATH"
664 export PATH=$PATH:$tools/bin
665 export PKG_CONFIG_PATH=$sysroot/usr/lib/pkgconfig
666 export CROSS_COMPILE=${HOST_SYSTEM}-
667 _ "Using cross-tools: \$CROSS_COMPILE"
668 if [ "$ARCH" == "x86_64" ]; then
669 export CC="${HOST_SYSTEM}-gcc -m64"
670 export CXX="${HOST_SYSTEM}-g++ -m64"
671 else
672 export CC=${HOST_SYSTEM}-gcc
673 export CXX=${HOST_SYSTEM}-g++
674 fi
675 export AR=${HOST_SYSTEM}-ar
676 export AS=${HOST_SYSTEM}-as
677 export RANLIB=${HOST_SYSTEM}-ranlib
678 export LD=${HOST_SYSTEM}-ld
679 export STRIP=${HOST_SYSTEM}-strip
680 export LIBTOOL=${HOST_SYSTEM}-libtool ;;
681 *)
682 root="/" ;;
683 esac
685 [ "$QA" ] && receipt_quality
686 cd $pkgdir
687 [ "$continue" ] || rm -rf source 2> /dev/null
688 rm -rf install taz 2> /dev/null
690 # Disable -pipe if less than 512Mb free RAM.
691 free=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
692 if [ "$free" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then
693 _ "Disabling -pipe compile flag: \$free RAM"
694 CFLAGS="${CFLAGS/-pipe}" && CFLAGS=$(echo "$CFLAGS" | tr -s ' ')
695 CXXFLAGS="${CXXFLAGS/-pipe}" && CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ')
696 fi
697 unset free
699 # Export flags and path to be used by make and receipt.
700 DESTDIR=$pkgdir/install
701 # FIXME: L10n: Is this the right time for 'LC_ALL=C LANG=C'?
702 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS CONFIG_SITE LC_ALL=C LANG=C
703 #export LDFLAGS
705 if [ ! "$WANTED" ] && [ "$TARBALL" ]; then
706 getsrc --extract
707 fi
709 # Check for build deps and handle implicit depends of *-dev packages
710 # (ex: libusb-dev :: libusb).
711 rm -f $CACHE/installed.local $CACHE/installed.web $CACHE/missing.dep
712 touch $CACHE/installed.local $CACHE/installed.web
713 look_for_cookopt !auto_dep && AUTO_DEP=""
714 if [ "$AUTO_DEP" -a ! "$WANTED" ]; then
715 BDEPS=$(scan $PACKAGE --look_for=bdep --with_dev | \
716 grep -v $(for i in $(look_for_rwanted) $PACKAGE; do echo " -e ^$i$"; done))
717 else
718 BDEPS="$BUILD_DEPENDS"
719 fi
720 [ "$BDEPS" ] && _ "Checking build dependencies..."
721 [ "$root" != "/" ] && _ "Using packages DB: \${root}\$DB"
722 for dep in $BDEPS
723 do
724 for i in $dep
725 do
726 if [ ! -f "${root}$INSTALLED/$i/receipt" ]; then
727 # Try local package first. In some cases implicit doesn't exist, ex:
728 # libboost-dev exists but not libboost, so check if we got vers.
729 unset vers
730 [ -f $WOK/$i/receipt ] || continue
731 vers=$(. $WOK/$i/receipt 2>/dev/null ; echo $VERSION)
732 if [ -f "$INCOMING/$i-${vers}_${kbasevers}.tazpkg" ]; then
733 echo $i-${vers}_${kbasevers}.tazpkg >> $CACHE/installed.local
734 elif [ -f "$PKGS/$i-${vers}_${kbasevers}.tazpkg" ]; then
735 echo $i-${vers}_${kbasevers}.tazpkg >> $CACHE/installed.local
736 elif [ -f "$INCOMING/$i-$vers.tazpkg" ]; then
737 echo $i-$vers.tazpkg >> $CACHE/installed.local
738 elif [ -f "$PKGS/$i-$vers.tazpkg" ]; then
739 echo $i-$vers.tazpkg >> $CACHE/installed.local
740 else
741 # Priority to package version in wok (maybe more up-to-date)
742 # than the mirrored one.
743 if [ "$vers" ]; then
744 if fgrep -q $i-${vers}${arch} ${root}$DB/packages.list; then
745 echo $i >> $CACHE/installed.web
746 else
747 # So package exists in wok but not available.
748 _ "Missing dep (wok/pkg): \$i \$vers"
749 echo $i >> $CACHE/missing.dep
750 fi
751 else
752 # Package is not in wok but may be in online repo.
753 if fgrep -q $i-${vers}${arch} ${root}$DB/packages.list; then
754 echo $i >> $CACHE/installed.web
755 else
756 _ "ERROR: unknown dep \$i"; exit 1
757 fi
758 fi
759 fi
760 fi
761 done
762 done
764 # Get the list of installed packages
765 ls -1 ${root}$INSTALLED > $CACHE/installed.list
767 # Have we a missing build dep to cook ?
768 if [ -s "$CACHE/missing.dep" ] && [ "$AUTO_COOK" ]; then
769 _ "Auto cook config is set: AUTO_COOK"
770 cp -f $LOGS/$PACKAGE.log $LOGS/$PACKAGE.log.$$
771 for i in $(uniq $CACHE/missing.dep)
772 do
773 (_ "Building dep (wok/pkg) : \$i \$vers") | \
774 tee -a $LOGS/$PACKAGE.log.$$
775 cook $i || (echo -e "ERROR: can't cook dep '$i'\n" && \
776 fgrep "remove: " $LOGS/$i.log && \
777 fgrep "Removing: " $LOGS/$i.log && newline) | \
778 tee -a $LOGS/$PACKAGE.log.$$ && break
779 done
780 rm -f $CACHE/missing.dep
781 mv $LOGS/$PACKAGE.log.$$ $LOGS/$PACKAGE.log
782 fi
784 # QA: Exit on missing dep errors. We exit in both cases, if AUTO_COOK
785 # is enabled and cook fails we have ERROR in log, if no auto cook we have
786 # missing dep in cached file.
787 lerror=$(_n "ERROR")
788 if fgrep -q ^$lerror $LOGS/$pkg.log || [ -s "$CACHE/missing.dep" ]; then
789 [ -s "$CACHE/missing.dep" ] && nb=$(cat $CACHE/missing.dep | wc -l)
790 _ "ERROR: missing dep \$nb" && exit 1
791 fi
793 # Install local packages: package-version${arch}
794 for i in $(uniq $CACHE/installed.local)
795 do
796 if [ -f "$INCOMING/$i" ]; then
797 _ "Installing dep (pkg/local): \$i"
798 tazpkg install $INCOMING/$i --root=$root >/dev/null
799 elif [ -f "$PKGS/$i" ]; then
800 _ "Installing dep (pkg/local): \$i"
801 tazpkg install $PKGS/$i --root=$root >/dev/null
802 fi
803 done
805 # Install web or cached packages (if mirror is set to $PKGS we only
806 # use local packages).
807 for i in $(uniq $CACHE/installed.web)
808 do
809 _ "Installing dep (web/cache): \$i"
810 tazpkg get-install $i --root=$root >/dev/null
811 done
813 # If a cook failed deps are removed.
814 ls -1 ${root}$INSTALLED > $CACHE/installed.cook
815 [ ! -s "$CACHE/installed.cook.diff" ] && \
816 busybox diff $CACHE/installed.list $CACHE/installed.cook > $CACHE/installed.cook.diff
817 deps=$(cat $CACHE/installed.cook.diff | grep ^+[a-zA-Z0-9] | wc -l)
819 # Execute receipt rules.
820 if [ $(grep ^compile_rules $receipt) ] && [ "$cook_code" = "" ]; then
821 echo "Executing: compile_rules"
822 echo "CFLAGS : $CFLAGS"
823 #echo "LDFLAGS : $LDFLAGS"
824 [ -d "$src" ] && cd $src
825 compile_rules $@ || broken
826 [ "$cook_code" ] && exit 1
827 # Stay compatible with _pkg
828 [ -d "$src/_pkg" ] && mv $src/_pkg $install
829 # QA: compile_rules success so valid.
830 mkdir -p $install
831 else
832 # QA: no compile_rules so no error, valid.
833 mkdir -p $install
834 fi
835 separator; newline
837 # Execute testsuite.
838 if grep -q ^testsuite $receipt; then
839 _ "Running testsuite"; separator
840 testsuite $@ || exit 1
841 separator; newline
842 fi
843 }
845 # Cook quality assurance.
846 cookit_quality() {
847 if [ ! -d "$WOK/$pkg/install" ] && [ ! "$WANTED" ]; then
848 _ "ERROR: cook failed" | tee -a $LOGS/$pkg.log
849 fi
850 # ERROR can be echoed any time in cookit()
851 lerror=$(_n "ERROR")
852 if grep -Ev "(conftest|configtest)" $LOGS/$pkg.log | \
853 grep -Eq "(^$lerror|undefined reference to)" ; then
854 debug_info | tee -a $LOGS/$pkg.log
855 rm -f $command && exit 1
856 fi
857 }
859 # Create the package. Wanted to use Tazpkg to create a tazpkg package at first,
860 # but it doesn't handle EXTRAVERSION.
861 packit() {
862 set_paths
864 # Handle cross compilation
865 case "$ARCH" in
866 arm*|x86_64) arch="-$ARCH" ;;
867 esac
869 _ "Pack: $PACKAGE \${VERSION}\${arch}"; separator
871 if grep -q ^genpkg_rules $receipt; then
872 _ "Executing: genpkg_rules"; newline
873 set -e && cd $pkgdir && mkdir -p $fs
874 genpkg_rules || (newline; _ "ERROR: genpkg_rules failed"; newline) >> \
875 $LOGS/$pkg.log
876 else
877 _ "No packages rules: meta package"
878 mkdir -p $fs
879 fi
881 # First QA check to stop now if genpkg_rules failed.
882 lerror=$(_n "ERROR")
883 if fgrep -q ^$lerror $LOGS/$pkg.log; then
884 exit 1
885 fi
887 cd $taz
888 for file in receipt description.txt
889 do
890 [ ! -f "../$file" ] && continue
891 _n "Copying \$file..."
892 cp -f ../$file $pack && chown 0.0 $pack/$file && status
893 done
894 copy_generic_files
896 # Create files.list with redirecting find output.
897 _n "Creating the list of files..."
898 cd $fs
899 find . -type f -print > ../files.list
900 find . -type l -print >> ../files.list
901 cd .. && sed -i s/'^.'/''/ files.list
902 status
904 # Strip and stuff files.
905 look_for_cookopt !strip && STRIP="n"
906 [ "$STRIP" ] || strip_package
908 # Md5sum of files.
909 _n "Creating \$CHECKSUM of files..."
910 while read file; do
911 [ -L "fs$file" ] && continue
912 [ -f "fs$file" ] || continue
913 case "$file" in
914 /lib/modules/*/modules.*|*.pyc) continue ;;
915 esac
916 $CHECKSUM "fs$file" | sed 's/ fs/ /'
917 done < files.list > "$CHECKSUM"
918 status
919 UNPACKED_SIZE=$(du -chs fs receipt files.list $CHECKSUM \
920 description.txt 2> /dev/null | awk \
921 '{ sz=$1 } END { print sz }')
923 if [ "$UPCOOKLIST" ]; then
924 check_so_files
925 fi
927 # Generate md5 of cooking stuff to look for commit later.
928 gen_cookmd5
929 echo -e "\n# md5sum of cooking stuff :" >> receipt
930 cat $WOK/$PACKAGE/md5 | sed 's/^/# /' >> receipt
932 # Build cpio archives.
933 _n "Compressing the fs..."
934 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si $LZMA_SET_DIR
935 rm -rf fs
936 status
937 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list \
938 $CHECKSUM description.txt 2> /dev/null | awk \
939 '{ sz=$1 } END { print sz }')
940 _n "Updating receipt sizes..."
941 sed -i s/^PACKED_SIZE.*$// receipt
942 sed -i s/^UNPACKED_SIZE.*$// receipt
943 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
944 status
946 # Set extra version.
947 if [ "$EXTRAVERSION" ]; then
948 _n "Updating receipt EXTRAVERSION: \$EXTRAVERSION"
949 sed -i s/^EXTRAVERSION.*$// receipt
950 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
951 status
952 fi
954 # Compress.
955 _n "Creating full cpio archive..."
956 find . -print | cpio -o -H newc --quiet > \
957 ../$PACKAGE-${VERSION}${EXTRAVERSION}${arch}.tazpkg
958 status
959 _n "Restoring original package tree..."
960 unlzma -c fs.cpio.lzma | cpio -idm --quiet
961 status
962 rm fs.cpio.lzma && cd ..
964 if [ "$UPCOOKLIST" ]; then
965 check_recook_rdeps
966 fi
968 # QA and give info.
969 tazpkg=$(ls *.tazpkg)
970 packit_quality
971 separator; _ "Package: \$tazpkg"; newline
972 }
974 # Verify package quality and consistency.
975 packit_quality() {
976 #gettext "QA: checking for broken link..."
977 #link=$(find $fs/usr -type l -follow)
978 #[ "$link" ] && echo -e "\nERROR: broken link in filesystem"
979 #status
981 # Exit if any error found in log file.
982 lerror=$(_n "ERROR")
983 if fgrep -q ^$lerror $LOGS/$pkg.log; then
984 rm -f $command && exit 1
985 fi
987 _n "QA: checking for empty package..."
988 files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l)
989 if [ "$files" == 0 ] && [ "$CATEGORY" != "meta" ]; then
990 newline; _ "ERROR: empty package"
991 rm -f $command && exit 1
992 else
993 # Ls sort by name so the first file is the one we want.
994 old=$(ls $INCOMING/$pkg-[0-9]*.tazpkg 2>/dev/null | head -n 1)
995 status
996 if [ -f "$old" ]; then
997 old_pkg=$(basename $old)
998 _n "Removing old: \$old_pkg"
999 rm -f $old && status
1000 fi
1001 mv -f $pkgdir/taz/$pkg-*.tazpkg $INCOMING
1002 sed -i /^${pkg}$/d $broken
1003 fi
1006 # Install package on --install or update the chroot.
1007 install_package()
1009 local pkg build
1010 case "$ARCH" in
1011 arm*|x86_64)
1012 arch="-${ARCH}"
1013 root=$CROSS_TREE/sysroot ;;
1014 *)
1015 root="/" ;;
1016 esac
1017 # Install package if requested but skip install if target host doesn't
1018 # match build system or it will break the build chroot.
1019 build=$(echo $BUILD_SYSTEM | cut -d "-" -f 1)
1020 for pkg in $PACKAGE; do
1021 if [ -f "$inst" ] && [ "$build" == "$ARCH" ]; then
1022 if [ -f "$INCOMING/$pkg-${VERSION}${EXTRAVERSION}${arch}.tazpkg" ]; then
1023 echo "Updating $ARCH chroot environment..."
1024 echo "Updating chroot: $pkg (${VERSION}${EXTRAVERSION}${arch})" | log
1025 tazpkg install \
1026 $INCOMING/$pkg-${VERSION}${EXTRAVERSION}${arch}.tazpkg --root=$root --forced
1027 else
1028 _ "Unable to install package, build has failed."; newline
1029 exit 1
1030 fi
1031 fi
1032 done
1034 # Install package if part of the chroot to keep env up-to-date.
1035 if [ -f "${root}$INSTALLED/$pkg/receipt" ]; then
1036 . /etc/slitaz/cook.conf
1037 . $WOK/$pkg/taz/$pkg-*/receipt
1038 _ "Updating \$ARCH chroot environment..."
1039 _ "Updating chroot: \$pkg (${VERSION}${EXTRAVERSION}${arch})" | log
1040 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}${arch}.tazpkg" ]; then
1041 tazpkg install \
1042 $PKGS/$pkg-${VERSION}${EXTRAVERSION}${arch}.tazpkg \
1043 --forced --root=$root
1044 elif [ -f "$INCOMING/$PACKAGE-${VERSION}${EXTRAVERSION}${arch}.tazpkg" ]; then
1045 tazpkg install \
1046 $INCOMING/$pkg-${VERSION}${EXTRAVERSION}${arch}.tazpkg \
1047 --forced --root=$root
1048 fi
1049 fi
1052 tac()
1054 sed '1!G;h;$!d' $1
1057 # this function is to build the unbuild list
1058 unbuild()
1060 check_root
1061 get_options_list="full list"
1062 get_options
1063 [ -f $unbuild ] && rm -rf $unbuild
1064 LIST="$fullco"
1065 [ -f "$1" ] && LIST="$1"
1066 #[ "$full" ] && LIST=$(ls $WOK)
1067 if [ -f "$1" -a "$full" ]; then
1068 COMMAND=gen-cooklist
1069 gen_cook_list
1070 LIST="$tmp/cooklist"
1071 fi
1072 for pkg in $(cat $LIST | grep -v ^#); do
1073 unset VERSION PACKAGE
1074 [ -f $WOK/$pkg/receipt ] || continue
1075 . $WOK/$pkg/receipt
1076 if [ ! -f $INCOMING/$PACKAGE-${VERSION}*.tazpkg -a ! -f $PKGS/$PACKAGE-${VERSION}*.tazpkg ]; then
1077 echo "$PACKAGE" && echo "$PACKAGE" >> $unbuild
1078 fi
1079 done
1080 unset pkg
1081 [ "$list" ] && cp -a $unbuild $cooklist
1084 # Launch the cook command into a chroot jail protected by aufs.
1085 # The current filesystems are used read-only and updates are
1086 # stored in a separate branch.
1087 try_aufs_chroot() {
1089 base=/dev/shm/aufsmnt$$
1091 # Can we setup the chroot? Is it already done?
1092 grep -q ^AUFS_NOT_SUPPORTED $receipt && return
1093 [ -n "$AUFS_MOUNTS" -a ! -f /aufs-umount.sh ] || return
1094 lsmod | grep -q aufs || modprobe aufs 2> /dev/null || return
1095 mkdir ${base}root ${base}rw || return
1097 _ "Setup aufs chroot..."
1099 # Sanity check
1100 for i in / /proc /sys /dev/shm /dev/pts /home ; do
1101 case " $AUFS_MOUNTS " in
1102 *\ $i\ *) ;;
1103 *) AUFS_MOUNTS="$AUFS_MOUNTS $i" ;;
1104 esac
1105 done
1106 for mnt in $(echo $AUFS_MOUNTS | sort | uniq); do
1107 mount --bind $mnt ${base}root$mnt
1108 if [ $mnt == / ] && ! mount -t aufs -o br=${base}rw:/ none ${base}root; then
1109 _ "Aufs mountage failure"
1110 umount ${base}root
1111 rmdir ${base}*
1112 return
1113 fi
1114 echo "umount ${base}root$mnt" >> ${base}rw/aufs-umount.sh
1115 done
1117 chroot ${base}root $(cd $(dirname $0); pwd)/$(basename $0) "$@"
1118 status=$?
1120 _ "Leaving aufs chroot..."
1121 tac ${base}rw/aufs-umount.sh | sh
1122 rm -rf ${base}rw
1123 umount ${base}root
1124 rmdir $base*
1126 # Install package if requested
1127 install_package
1128 exit $status
1131 # Encode predefined XML entities
1132 xml_ent() {
1133 sed -e 's|&|\&amp;|g; s|<|\&lt;|g; s|>|\&gt;|g; s|"|\&quot;|g' -e "s|'|\&apos;|g"
1136 # Create a XML feed for freshly built packages.
1137 gen_rss() {
1138 pubdate=$(date "+%a, %d %b %Y %X")
1139 cat > $FEEDS/$pkg.xml << EOT
1140 <item>
1141 <title>$PACKAGE $VERSION${EXTRAVERSION}</title>
1142 <link>${COOKER_URL}?pkg=$PACKAGE</link>
1143 <guid>$PACKAGE-$VERSION${EXTRAVERSION}</guid>
1144 <pubDate>$pubdate</pubDate>
1145 <description>$(echo -n "$SHORT_DESC" | xml_ent)</description>
1146 </item>
1147 EOT
1150 # Truncate stdout log file to $1 Mb.
1151 loglimit()
1153 if [ -n "$DEFAULT_LOG_LIMIT" ]; then
1154 tee /dev/stderr | dd bs=1024k count=${1:-$DEFAULT_LOG_LIMIT} 2> /dev/null
1155 else
1156 tee /dev/stderr
1157 fi
1161 # Receipt functions to ease packaging
1164 get_dev_files() {
1165 _n "Getting standard devel files..."
1166 mkdir -p $fs/usr/lib
1167 cp -a $install/usr/lib/pkgconfig $fs/usr/lib
1168 cp -a $install/usr/include $fs/usr
1169 status
1173 # Commands
1176 case "$COMMAND" in
1177 usage|help|-u|-h)
1178 usage ;;
1179 list-wok)
1180 newline; _ "List of \$ARCH packages in: \$WOK"; separator
1181 cd $WOK && ls -1
1182 if [ "$ARCH" != "i486" ]; then
1183 count=0
1184 for pkg in $(fgrep 'HOST_ARCH=' */receipt | egrep "$ARCH|any" | cut -d : -f 1)
1185 do
1186 unset HOST_ARCH
1187 . $pkg
1188 count=$(($count + 1))
1189 colorize 34 "$PACKAGE"
1190 done
1191 else
1192 count=$(ls | wc -l)
1193 ls -1
1194 fi
1195 separator
1196 _n "Packages:"; colorize 32 " $count"
1197 newline ;;
1198 activity)
1199 cat $activity ;;
1200 search)
1201 # Just a simple search function, we dont need more actually.
1202 query="$2"
1203 newline; _ "Search results for: \$query"; separator
1204 cd $WOK && ls -1 | grep "$query"
1205 separator; newline ;;
1206 setup)
1207 # Setup a build environment
1208 check_root
1209 _ "Cook: setup environment" | log
1210 newline; _ "Setting up your environment"; separator
1211 cd $SLITAZ
1212 init_db_files
1213 _ "Checking for packages to install..."
1214 # Use setup pkgs from cross.conf or cook.conf. When cross compiling
1215 # ARCH-setup or 'cross check' should be used before: cook setup
1216 case "$ARCH" in
1217 arm*|x86_64)
1218 if [ ! -x "/usr/bin/cross" ]; then
1219 _ "ERROR: cross is not installed"
1220 exit 1
1221 fi
1222 _ "Using config file: /etc/slitaz/cross.conf"
1223 . /etc/slitaz/cross.conf ;;
1224 esac
1225 for pkg in $INSTALL_PKGS; do
1226 if [ "$forced" ]; then
1227 tazpkg -gi $pkg --forced
1228 else
1229 [ -f "$INSTALLED/$pkg/receipt" ] || tazpkg get-install $pkg
1230 fi
1231 done
1232 # chroot list
1233 ls -1 "$INSTALLED" > $CACHE/chroot-pkgs
1234 # Handle --options
1235 case "$2" in
1236 --wok)
1237 hg clone $WOK_URL $WOKHG || exit 1 ;;
1238 --stable)
1239 hg clone $WOK_URL-stable $WOKHG || exit 1 ;;
1240 --undigest)
1241 hg clone $WOK_URL-undigest $WOKHG || exit 1 ;;
1242 --tiny)
1243 hg clone $WOK_URL-tiny $WOKHG || exit 1 ;;
1244 esac
1246 rsync_wok
1248 # SliTaz group and permissions
1249 if ! grep -q ^slitaz /etc/group; then
1250 _ "Adding group: slitaz"
1251 addgroup slitaz
1252 fi
1253 _ "Setting permissions for slitaz group..."
1254 find $SLITAZ -maxdepth 2 -exec chown root.slitaz {} \;
1255 find $SLITAZ -maxdepth 2 -exec chmod g+w {} \;
1256 separator; _ "All done, ready to cook packages :-)"; newline ;;
1257 *-setup)
1258 # Setup for cross compiling.
1259 arch=${1%-setup}
1260 check_root
1261 _ "Cook: setup \$arch cross environment" | log
1262 newline; boldify $(_n "Setting up your \$arch cross environment"); separator
1263 init_db_files
1264 sed -i \
1265 -e s"/ARCH=.*/ARCH=\"$arch\"/" \
1266 -e s"/CROSS_TREE=.*/CROSS_TREE=\"\/cross\/$arch\"/" \
1267 -e s'/BUILD_SYSTEM=.*/BUILD_SYSTEM=i486-slitaz-linux/' \
1268 /etc/slitaz/cook.conf
1269 case "$arch" in
1270 arm)
1271 sed -i \
1272 -e s'/CFLAGS=.*/CFLAGS="-march=armv6 -O2"/' \
1273 -e s'/HOST_SYSTEM=.*/HOST_SYSTEM=$ARCH-slitaz-linux-gnueabi/' \
1274 -e s'/xorg-dev/""/' \
1275 /etc/slitaz/cook.conf ;;
1276 x86_64)
1277 sed -i \
1278 -e s'/CFLAGS=.*/CFLAGS=""/' \
1279 -e s'/HOST_SYSTEM=.*/HOST_SYSTEM=$ARCH-slitaz-linux/' \
1280 /etc/slitaz/cook.conf ;;
1281 esac
1282 . /etc/slitaz/cook.conf
1283 sysroot=$CROSS_TREE/sysroot
1284 tools=/cross/$arch/tools
1285 root=$sysroot
1286 # L10n: keep the same width of translations to get a consistent view
1287 CC=$tools/bin/${HOST_SYSTEM}-gcc
1288 _ "Target arch : \$ARCH"
1289 _ "Configure args : \$CONFIGURE_ARGS"
1290 _ "Build flags : \$flags"
1291 _ "Arch sysroot : \$sysroot"
1292 _ "Tools prefix : \$tools/bin"
1293 # Tell the packages manager where to find packages.
1294 _ "Packages DB : \${root}\$DB"
1295 mkdir -p ${root}$INSTALLED
1296 cd ${root}$DB && rm -f *.bak
1297 for list in packages.list packages.desc packages.equiv packages.md5
1298 do
1299 rm -f $list && ln -s $SLITAZ/packages/$list $list
1300 done
1301 # We must have the cross compiled glibc-base installed or default
1302 # i486 package will be used as dep by tazpkg and then break the
1303 # cross environment
1304 if [ ! -f "${root}$INSTALLED/glibc-base/receipt" ]; then
1305 colorize 36 $(_ "WARNING: (e)glibc-base is not installed in sysroot")
1306 fi
1307 # Show GCC version or warn if not yet compiled.
1308 if [ -x $CC ]; then
1309 _ "Cross compiler : \${HOST_SYSTEM}-gcc"
1310 else
1311 colorize 36 $(_ "C compiler is missing: \${HOST_SYSTEM}-gcc")
1312 _ "Run 'cross compile' to cook a toolchain"
1313 fi
1314 separator; newline ;;
1315 upwok)
1316 case "$2" in
1317 --local)
1318 _ "Updating local chanages in wok-hg to wok..."
1319 rsync_wok || exit 1
1320 exit 1 ;;
1321 esac
1323 _ "Updating wok-hg..."
1324 if [ -d $WOKHG/.hg ]; then
1325 cd $WOKHG
1326 hg pull -u || exit 1
1327 fi
1328 cd $SLITAZ
1329 rsync_wok || exit 1 ;;
1330 test)
1331 # Test a cook environment.
1332 _ "Cook test: testing the cook environment" | log
1333 [ ! -d "$WOK" ] && exit 1
1334 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK
1335 cook cooktest ;;
1336 new)
1337 # Create the package folder and an empty receipt.
1338 pkg="$2"
1339 [ "$pkg" ] || usage
1340 newline
1341 if [ -d "$WOKHG/$pkg" ]; then
1342 _ "\$pkg package already exists."
1343 exit 1
1344 fi
1345 _n "Creating \$WOKHG/\$pkg"
1346 mkdir $WOKHG/$pkg && cd $WOKHG/$pkg && status
1347 _n "Preparing the package receipt..."
1348 cp $DATA/receipt .
1349 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
1350 status && newline
1352 # Interactive mode, asking and seding.
1353 case "$3" in
1354 --interactive|-x)
1355 _ "Entering interactive mode..."
1356 separator
1357 _ "Package : \$pkg"
1358 _n "Version : " ; read answer
1359 sed -i s/'VERSION=\"\"'/"VERSION=\"$answer\""/ receipt
1360 _n "Category : " ; read answer
1361 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$answer\""/ receipt
1362 # L10n: Short description
1363 _n "Short desc : " ; read answer
1364 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$answer\""/ receipt
1365 # Maintainer.
1366 _n "Maintainer : " ; read answer
1367 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$answer\""/ receipt
1368 # License.
1369 _n "License : " ; read answer
1370 sed -i s/'LICENSE=\"\"'/"LICENSE=\"$answer\""/ receipt
1371 # Web site.
1372 _n "Web site : " ; read answer
1373 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$answer\""# receipt
1374 newline
1375 # Wget URL.
1376 _ "Wget URL to download source tarball."
1377 _n "Example : " ; echo '$GNU_MIRROR/$PACKAGE/$TARBALL'
1378 _n "Wget url : " ; read answer
1379 sed -i s#'WGET_URL=\"$TARBALL\"'#"WGET_URL=\"$answer\""# receipt
1380 # Ask for a stuff dir.
1381 _n "Do you need a stuff directory ? (y/N) : " ; read answer
1382 if [ "$answer" = "y" ]; then
1383 _n "Creating the stuff directory..."
1384 mkdir -p $WOKHG/$pkg/stuff && status
1385 fi
1386 # Ask for a description file.
1387 _n "Are you going to write a description ? (y/N) : " ; read answer
1388 if [ "$answer" = "y" ]; then
1389 _n "Creating the description.txt file..."
1390 newline > $WOKHG/$pkg/description.txt && status
1391 fi
1392 separator; _ "Receipt is ready to use."; newline ;;
1393 esac ;;
1394 list)
1395 # Cook a list of packages (better use the Cooker since it will order
1396 # packages before executing cook).
1397 check_root
1398 [ -z "$2" ] && (newline; _ "No list in argument."; newline) && exit 1
1399 list2=$2
1400 [ ! -f "$2" ] && (newline; _ "No list found: \$list2"; newline) && exit 1
1401 _ "Cook list starting: \$list2" | log
1402 for pkg in $(cat $2)
1403 do
1404 cook $pkg || broken
1405 done ;;
1406 clean-wok)
1407 check_root
1408 newline; _n "Cleaning all packages files..."
1409 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
1410 status; newline ;;
1411 clean-src)
1412 check_root
1413 newline; _n "Cleaning all packages sources..."
1414 rm -rf $WOK/*/source
1415 status; newline ;;
1416 gen-cooklist)
1417 check_root
1418 [ -f "$2" ] && LIST="$2"
1419 get_options_list="pkg wok missing"
1420 get_options
1421 if ! [ "$pkg" ]; then
1422 if [ ! "$LIST" ] || [ "$LIST" = "toolchain" ]; then
1423 pkg="$TOOLCHAIN $TOOLCHAIN_EXTRA"
1424 else
1425 check_for_list
1426 fi
1427 fi
1428 gen_cook_list
1429 if [ "$missing" ]; then
1430 cooklist=${LIST:-$cooklist}
1431 for pkgname in $(cat $cooklist)
1432 do
1433 unset EXTRAVERSION
1434 [ -f $wok/$pkgname/receipt ] || continue
1435 . $wok/$pkgname/receipt
1436 if [ -f $INCOMING/$PACKAGE-${VERSION}*.tazpkg -o -f $PKGS/$PACKAGE-${VERSION}*.tazpkg ]; then
1437 if grep "^$pkgname" $cooklist; then
1438 sed -i "s|^$pkgname$||g" $cooklist
1439 sed -i /^$/d $cooklist
1440 fi
1441 fi
1442 done
1443 fi
1445 #rm -f $command
1446 ;;
1447 gen-wok-db)
1448 check_root
1449 #echo "cook:gen-wok-db" > $command
1450 [ -d "$WOKHG" ] && WOK="$WOKHG"
1451 [ "$2" ] && WOK="$2"
1452 gen_wok_db ;;
1453 check-incoming)
1454 check_root
1455 get_options_list="forced"
1456 get_options
1457 echo "cook:check-incoming" > $command
1458 check_for_incoming
1459 rm -f $command ;;
1460 gen-src)
1461 check_root
1462 [ "$2" ] && src_repository="$2"
1463 [ -d "$src_repository" ] || src_repository="$SRC"
1464 gettext -e "Rebulding sources.list file: $src_repository"
1465 gen_sources_list $src_repository
1466 status ;;
1467 maintainers)
1468 check_root
1469 newline
1470 _ "List of maintainers for: $WOK"
1471 separator
1472 tmp="/tmp/slitaz-maintainers"
1473 touch $tmp
1474 for pkg in $WOK/*
1475 do
1476 [ -f $pkg/receipt ] || continue
1477 . $pkg/receipt
1478 if ! fgrep -q "$MAINTAINER" $tmp; then
1479 echo "$MAINTAINER" >> $tmp
1480 echo "$MAINTAINER"
1481 fi
1482 done
1483 separator
1484 echo "Maintainers: `cat $tmp | wc -l`"
1485 newline
1486 # Remove tmp files
1487 [ -f $tmp ] && rm -f $tmp
1488 ;;
1489 tags)
1490 check_root
1491 echo -e "\n\033[1mTags list :\033[0m"
1492 separator
1493 tmp="/tmp/tags"
1494 touch $tmp
1495 for pkg in $WOK/*; do
1496 unset TAGS
1497 [ -f $pkg/receipt ] || continue
1498 source $pkg/receipt
1499 for t in $TAGS; do
1500 grep -q ^$t$ $tmp && continue
1501 echo $t | tee -a $tmp
1502 done
1503 done
1504 separator
1505 echo "$(wc -l $tmp | cut -f1 -d ' ') tags listed."
1506 [ -f $tmp ] && rm -rf $tmp
1507 ;;
1508 maintained-by)
1509 # Search for packages maintained by a contributor.
1510 check_root
1511 if [ ! -n "$2" ]; then
1512 echo "Specify a name or email of a maintainer." >&2
1513 exit 1
1514 fi
1515 echo "Maintainer packages"
1516 separator
1517 for pkg in $WOK/*
1518 do
1519 [ -f $pkg/receipt ] || continue
1520 . $pkg/receipt
1521 if echo "$MAINTAINER" | fgrep -q "$2"; then
1522 echo "$PACKAGE"
1523 packages=$(($packages+1))
1524 fi
1525 done
1526 separator
1527 echo "Packages maintained by $2: $packages"
1528 newline
1529 ;;
1530 check-src)
1531 # Verify if upstream package is still available.
1533 check_root
1534 PACKAGE="$2"
1535 receipt="$WOK/$PACKAGE/receipt"
1536 if [ ! -f $receipt ]; then
1537 gettext -e "\nUnable to find package in the wok:"
1538 echo -e " $PACKAGE\n" && exit 1
1539 fi
1540 unset_receipt
1541 source $receipt
1542 check_src()
1544 for url in $@; do
1545 busybox wget -s $url 2>/dev/null && break
1546 done
1548 if [ "$WGET_URL" ];then
1549 echo -n "$PACKAGE : "
1550 check_src $WGET_URL
1551 status
1552 else
1553 echo "No tarball to check for $PACKAGE"
1554 fi
1555 ;;
1556 unbuild)
1557 unbuild "$2" "$3" ;;
1558 pkgdb)
1559 # Create suitable packages list for TazPKG and only for built packages
1560 # as well as flavors files for TazLiTo. We dont need logs since we do it
1561 # manually to ensure everything is fine before syncing the mirror.
1562 pkgdb "$2"
1563 if [ "$3" == "--flavors" ]; then
1564 cook flavors
1565 fi
1566 exit 0 ;;
1567 flavors)
1568 [ -d "$flavors" ] || $(echo -e "Missing flavors: $flavors\n" && exit 1)
1569 [ -d "$live" ] || mkdir -p $live
1570 _ "Creating flavors files in: \$live"
1571 echo "Cook pkgdb: Creating all flavors" | log
1572 separator
1573 _ "Recharging lists to use latest packages..."
1574 tazpkg recharge >/dev/null 2>/dev/null
1576 if [ ! -f "$live/cookiso.conf" ]; then
1577 echo "Creating configuration file: tazlito.conf"
1578 cp /etc/slitaz/cookiso.conf $live
1579 sed -i "s|WORK_DIR=.*|WORK_DIR="$SLITAZ"|g" $live/cookiso.conf
1580 fi
1582 #[ -d "$flavors/.hg" ] && $flavors && hg pull -u
1584 cd $live
1585 _ "Starting to generate flavors..."
1586 rm -f flavors.list *.flavor
1587 for i in $flavors/*
1588 do
1589 fl=$(basename $i)
1590 _ "Packing flavor: \$fl"
1591 pack_flavor $fl >/dev/null || exit 1
1592 show_flavor $fl --brief --noheader 2> \
1593 /dev/null >> flavors.list
1594 done
1595 cp -f $live/*.flavor $live/flavors.list $PKGS
1596 separator && gettext "Flavors size: "; du -sh $live | awk '{print $1}'
1597 exit 0 ;;
1598 clean-chroot)
1599 clean_chroot ;;
1600 *)
1601 # Just cook and generate a package.
1602 check_root
1603 time=$(date +%s)
1604 pkg="$1"
1605 [ -z "$pkg" ] && usage
1606 receipt="$WOK/$pkg/receipt"
1607 check_pkg_in_wok && newline
1609 unset inst
1610 unset_receipt
1611 . $receipt
1613 # Handle cross compilation.
1615 # CROSS_NOTE: Actually we are running an ARM cooker but running
1616 # the cooker and build each commit in wok is not possible since
1617 # we dont cook the full wok for this arch. For ARM we need a set
1618 # of packages to handle a touch screen desktop, servers but not
1619 # erland.
1621 # The temporary solution is to build only reviewed and tested
1622 # packages with HOST_ARCH set in receipt.
1623 case "$ARCH" in
1624 arm)
1625 if [ ! "$HOST_ARCH" ]; then
1626 echo "cook: HOST_ARCH is not set in $pkg receipt"
1627 echo "cook: This package is not included in: $ARCH"
1628 [ "$CROSS_BUGS" ] && echo "bugs: $CROSS_BUGS"
1629 echo "Cook skip: $pkg is not included in: $ARCH" | log
1630 newline && exit 1
1631 fi ;;
1632 esac
1634 # Some packages are not included in some arch or fail to cross compile.
1635 : ${HOST_ARCH=i486}
1636 if ! $(echo "$HOST_ARCH" | fgrep -q $ARCH); then
1637 echo "cook: HOST_ARCH=$HOST_ARCH"
1638 echo "cook: $pkg doesn't cook or is not included in: $ARCH"
1639 [ "$CROSS_BUGS" ] && echo "bugs: $CROSS_BUGS"
1640 echo "Cook skip: $pkg doesn't cook or is not included in: $ARCH" | log
1641 newline && exit 1
1642 fi
1644 # Skip blocked, 3 lines also for the Cooker.
1645 if grep -q "^$pkg$" $blocked && [ "$2" != "--unblock" ]; then
1646 _ "Blocked package: \$pkg"; newline
1647 exit 0
1648 fi
1650 if [ "$AUFS_MODE" ]; then
1651 try_aufs_chroot "$@"
1652 fi
1654 # Log and source receipt.
1655 _ "Cook started for: <a href='cooker.cgi?pkg=$pkg'>$pkg</a>" | log
1656 echo "cook:$pkg" > $command
1658 # Display and log info if cook process stopped.
1659 # FIXME: gettext not working (in single quotes) here!
1660 trap '_ "\n\nCook stopped: control-C\n\n" | \
1661 tee -a $LOGS/$pkg.log' INT
1663 set_paths
1665 # Handle --options
1666 case "$2" in
1667 --clean|-c)
1668 _n "Cleaning: \$pkg"
1669 cd $WOK/$pkg && rm -rf install taz source
1670 status && newline && exit 0 ;;
1671 --install|-i)
1672 inst='yes' ;;
1673 --noupdate|-nu)
1674 UPCHROOT="" ;;
1675 --nocleanchroot|-ncc)
1676 CLEAN_CHROOT="" ;;
1677 --getsrc|-gs)
1678 getsrc "$3"
1679 exit 0 ;;
1680 --block|-b)
1681 _n "Blocking: \$pkg"
1682 [ $(grep "^$pkg$" $blocked) ] || echo "$pkg" >> $blocked
1683 status && newline && exit 0 ;;
1684 --unblock|-ub)
1685 _n "Unblocking: \$pkg"
1686 sed -i "/^${pkg}$/"d $blocked
1687 status && newline && exit 0 ;;
1688 --pack)
1689 if [ -d $WOK/$pkg/taz ]; then
1690 rm -rf $WOK/$pkg/taz
1691 [ -f $LOGS/$pkg-pack.log ] && rm -rf $LOGS/$pkg-pack.log
1692 packit 2>&1 | tee -a $LOGS/$pkg-pack.log
1693 clean_log
1694 else
1695 _ "Need to build \$pkg." && exit 0
1696 fi
1697 exit 0 ;;
1698 esac
1700 # Check if wanted is built now so we have separate log files.
1701 if [ "$WANTED" ]; then
1702 if grep -q "^$WANTED$" $blocked; then
1703 echo "WANTED package $PACKAGE is blocked: $WANTED" | tee $LOGS/$pkg.log
1704 newline && rm -f $command && exit 1
1705 fi
1706 if grep -q "^$WANTED$" $broken; then
1707 echo "WANTED package $PACKAGE is broken: $WANTED" | tee $LOGS/$pkg.log
1708 newline && rm -f $command && exit 1
1709 fi
1710 if [ ! "$COOK_WANTED" ]; then
1711 if [ ! -d "$WOK/$WANTED/install" ]; then
1712 cook "$WANTED" || exit 1
1713 fi
1714 fi
1715 fi
1717 if [ "$UPCOOKLIST" ]; then
1718 db_md5=$(md5sum $dep_db $wan_db)
1719 echo "update_wok_db"
1720 update_wan_db
1721 echo "check_for_commit"
1722 check_for_commit
1723 sort -o $dep_db $dep_db
1724 sort -o $wan_db $wan_db
1725 if [ "$db_md5" != "$(md5sum $dep_db $wan_db)" ]; then
1726 grep -q "^#" $fullco || sed 1i"#PlanSort" -i $fullco
1727 fi
1728 fi
1730 # Cook and pack or exit on error and log everything.
1731 cookit $@ 2>&1 | loglimit 50 > $LOGS/$pkg.log
1732 remove_deps | tee -a $LOGS/$pkg.log
1733 if [ "$CLEAN_CHROOT" ]; then
1734 clean_chroot | tee -a $LOGS/$pkg.log
1735 fi
1736 cookit_quality
1737 packit 2>&1 | loglimit 5 >> $LOGS/$pkg.log
1738 clean_log
1740 # Exit if any error in packing.
1741 if grep -q ^ERROR $LOGS/$pkg.log; then
1742 debug_info | tee -a $LOGS/$pkg.log
1743 broken
1744 rm -f $command && exit 1
1745 fi
1747 # This is needed cause unset and source receipt again
1748 if [ -f "$SRC/$lzma_tarball" ]; then
1749 TARBALL="$lzma_tarball"
1750 fi
1752 # Create an XML feed
1753 gen_rss
1755 # Time and summary
1756 time=$(($(date +%s) - $time))
1757 summary | tee -a $LOGS/$pkg.log
1758 newline
1760 if [ "$AUTO_PURGE_SRC" ]; then
1761 if [ -f "$SRC/$TARBALL" ]; then
1762 previous_tarball=$(grep ^$PACKAGE:incoming $SRC/sources.list | cut -f2)
1763 if [ -f "$SRC/$previous_tarball" ]; then
1764 sed "/^$PACKAGE:incoming/ s/.*/$PACKAGE:incoming\t$TARBALL/" \
1765 -i $SRC/sources.list
1766 grep -q $'\t'$previous_tarball$ $SRC/sources.list || \
1767 rm -f $SRC/$previous_tarball
1768 else
1769 echo -e "$PACKAGE:incoming\t$TARBALL" >> $SRC/sources.list
1770 fi
1771 fi
1772 fi
1774 # remove source folder if its not used in
1775 # genpkg_rules in all wanted packages
1776 remove_src
1778 install_package
1780 # Regen the cooklist if it was planned and command is not cook.
1781 [ "$regen_cooklist" -a "$UPCOOKLIST" ] && unset regen_cooklist && sort_cooklist
1783 if [ $(grep -l "^$pkg$" $broken) ]; then
1784 sed -i "^$pkg$" $broken
1785 fi
1786 # Finally we DONT WANT to build the *-dev or packages with WANTED="$pkg"
1787 # You want automation: use the Cooker Build Bot.
1788 rm -f $command ;;
1789 esac
1791 exit 0