cookutils view cook @ rev 717

cook: Add gettext stuff thats in default branch of cookutils.
author Christopher Rogers <slaxemulator@gmail.com>
date Tue Apr 14 04:30:13 2015 +0000 (2015-04-14)
parents 99372fa1d17e
children e5bb1ba792f8
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 [ -n "$DEFAULT_LOG_LIMIT" ] || return
1154 tee /dev/stderr | dd bs=1024k count=${1:-$DEFAULT_LOG_LIMIT} 2> /dev/null
1158 # Receipt functions to ease packaging
1161 get_dev_files() {
1162 _n "Getting standard devel files..."
1163 mkdir -p $fs/usr/lib
1164 cp -a $install/usr/lib/pkgconfig $fs/usr/lib
1165 cp -a $install/usr/include $fs/usr
1166 status
1170 # Commands
1173 case "$COMMAND" in
1174 usage|help|-u|-h)
1175 usage ;;
1176 list-wok)
1177 newline; _ "List of \$ARCH packages in: \$WOK"; separator
1178 cd $WOK && ls -1
1179 if [ "$ARCH" != "i486" ]; then
1180 count=0
1181 for pkg in $(fgrep 'HOST_ARCH=' */receipt | egrep "$ARCH|any" | cut -d : -f 1)
1182 do
1183 unset HOST_ARCH
1184 . $pkg
1185 count=$(($count + 1))
1186 colorize 34 "$PACKAGE"
1187 done
1188 else
1189 count=$(ls | wc -l)
1190 ls -1
1191 fi
1192 separator
1193 _n "Packages:"; colorize 32 " $count"
1194 newline ;;
1195 activity)
1196 cat $activity ;;
1197 search)
1198 # Just a simple search function, we dont need more actually.
1199 query="$2"
1200 newline; _ "Search results for: \$query"; separator
1201 cd $WOK && ls -1 | grep "$query"
1202 separator; newline ;;
1203 setup)
1204 # Setup a build environment
1205 check_root
1206 _ "Cook: setup environment" | log
1207 newline; _ "Setting up your environment"; separator
1208 cd $SLITAZ
1209 init_db_files
1210 _ "Checking for packages to install..."
1211 # Use setup pkgs from cross.conf or cook.conf. When cross compiling
1212 # ARCH-setup or 'cross check' should be used before: cook setup
1213 case "$ARCH" in
1214 arm*|x86_64)
1215 if [ ! -x "/usr/bin/cross" ]; then
1216 _ "ERROR: cross is not installed"
1217 exit 1
1218 fi
1219 _ "Using config file: /etc/slitaz/cross.conf"
1220 . /etc/slitaz/cross.conf ;;
1221 esac
1222 for pkg in $INSTALL_PKGS; do
1223 if [ "$forced" ]; then
1224 tazpkg -gi $pkg --forced
1225 else
1226 [ -f "$INSTALLED/$pkg/receipt" ] || tazpkg get-install $pkg
1227 fi
1228 done
1229 # chroot list
1230 ls -1 "$INSTALLED" > $CACHE/chroot-pkgs
1231 # Handle --options
1232 case "$2" in
1233 --wok)
1234 hg clone $WOK_URL $WOKHG || exit 1 ;;
1235 --stable)
1236 hg clone $WOK_URL-stable $WOKHG || exit 1 ;;
1237 --undigest)
1238 hg clone $WOK_URL-undigest $WOKHG || exit 1 ;;
1239 --tiny)
1240 hg clone $WOK_URL-tiny $WOKHG || exit 1 ;;
1241 esac
1243 rsync_wok
1245 # SliTaz group and permissions
1246 if ! grep -q ^slitaz /etc/group; then
1247 _ "Adding group: slitaz"
1248 addgroup slitaz
1249 fi
1250 _ "Setting permissions for slitaz group..."
1251 find $SLITAZ -maxdepth 2 -exec chown root.slitaz {} \;
1252 find $SLITAZ -maxdepth 2 -exec chmod g+w {} \;
1253 separator; _ "All done, ready to cook packages :-)"; newline ;;
1254 *-setup)
1255 # Setup for cross compiling.
1256 arch=${1%-setup}
1257 check_root
1258 _ "Cook: setup \$arch cross environment" | log
1259 newline; boldify $(_n "Setting up your \$arch cross environment"); separator
1260 init_db_files
1261 sed -i \
1262 -e s"/ARCH=.*/ARCH=\"$arch\"/" \
1263 -e s"/CROSS_TREE=.*/CROSS_TREE=\"\/cross\/$arch\"/" \
1264 -e s'/BUILD_SYSTEM=.*/BUILD_SYSTEM=i486-slitaz-linux/' \
1265 /etc/slitaz/cook.conf
1266 case "$arch" in
1267 arm)
1268 sed -i \
1269 -e s'/CFLAGS=.*/CFLAGS="-march=armv6 -O2"/' \
1270 -e s'/HOST_SYSTEM=.*/HOST_SYSTEM=$ARCH-slitaz-linux-gnueabi/' \
1271 -e s'/xorg-dev/""/' \
1272 /etc/slitaz/cook.conf ;;
1273 x86_64)
1274 sed -i \
1275 -e s'/CFLAGS=.*/CFLAGS=""/' \
1276 -e s'/HOST_SYSTEM=.*/HOST_SYSTEM=$ARCH-slitaz-linux/' \
1277 /etc/slitaz/cook.conf ;;
1278 esac
1279 . /etc/slitaz/cook.conf
1280 sysroot=$CROSS_TREE/sysroot
1281 tools=/cross/$arch/tools
1282 root=$sysroot
1283 # L10n: keep the same width of translations to get a consistent view
1284 CC=$tools/bin/${HOST_SYSTEM}-gcc
1285 _ "Target arch : \$ARCH"
1286 _ "Configure args : \$CONFIGURE_ARGS"
1287 _ "Build flags : \$flags"
1288 _ "Arch sysroot : \$sysroot"
1289 _ "Tools prefix : \$tools/bin"
1290 # Tell the packages manager where to find packages.
1291 _ "Packages DB : \${root}\$DB"
1292 mkdir -p ${root}$INSTALLED
1293 cd ${root}$DB && rm -f *.bak
1294 for list in packages.list packages.desc packages.equiv packages.md5
1295 do
1296 rm -f $list && ln -s $SLITAZ/packages/$list $list
1297 done
1298 # We must have the cross compiled glibc-base installed or default
1299 # i486 package will be used as dep by tazpkg and then break the
1300 # cross environment
1301 if [ ! -f "${root}$INSTALLED/glibc-base/receipt" ]; then
1302 colorize 36 $(_ "WARNING: (e)glibc-base is not installed in sysroot")
1303 fi
1304 # Show GCC version or warn if not yet compiled.
1305 if [ -x $CC ]; then
1306 _ "Cross compiler : \${HOST_SYSTEM}-gcc"
1307 else
1308 colorize 36 $(_ "C compiler is missing: \${HOST_SYSTEM}-gcc")
1309 _ "Run 'cross compile' to cook a toolchain"
1310 fi
1311 separator; newline ;;
1312 upwok)
1313 case "$2" in
1314 --local)
1315 _ "Updating local chanages in wok-hg to wok..."
1316 rsync_wok || exit 1
1317 exit 1 ;;
1318 esac
1320 _ "Updating wok-hg..."
1321 if [ -d $WOKHG/.hg ]; then
1322 cd $WOKHG
1323 hg pull -u || exit 1
1324 fi
1325 cd $SLITAZ
1326 rsync_wok || exit 1 ;;
1327 test)
1328 # Test a cook environment.
1329 _ "Cook test: testing the cook environment" | log
1330 [ ! -d "$WOK" ] && exit 1
1331 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK
1332 cook cooktest ;;
1333 new)
1334 # Create the package folder and an empty receipt.
1335 pkg="$2"
1336 [ "$pkg" ] || usage
1337 newline
1338 if [ -d "$WOKHG/$pkg" ]; then
1339 _ "\$pkg package already exists."
1340 exit 1
1341 fi
1342 _n "Creating \$WOKHG/\$pkg"
1343 mkdir $WOKHG/$pkg && cd $WOKHG/$pkg && status
1344 _n "Preparing the package receipt..."
1345 cp $DATA/receipt .
1346 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
1347 status && newline
1349 # Interactive mode, asking and seding.
1350 case "$3" in
1351 --interactive|-x)
1352 _ "Entering interactive mode..."
1353 separator
1354 _ "Package : \$pkg"
1355 _n "Version : " ; read answer
1356 sed -i s/'VERSION=\"\"'/"VERSION=\"$answer\""/ receipt
1357 _n "Category : " ; read answer
1358 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$answer\""/ receipt
1359 # L10n: Short description
1360 _n "Short desc : " ; read answer
1361 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$answer\""/ receipt
1362 # Maintainer.
1363 _n "Maintainer : " ; read answer
1364 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$answer\""/ receipt
1365 # License.
1366 _n "License : " ; read answer
1367 sed -i s/'LICENSE=\"\"'/"LICENSE=\"$answer\""/ receipt
1368 # Web site.
1369 _n "Web site : " ; read answer
1370 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$answer\""# receipt
1371 newline
1372 # Wget URL.
1373 _ "Wget URL to download source tarball."
1374 _n "Example : " ; echo '$GNU_MIRROR/$PACKAGE/$TARBALL'
1375 _n "Wget url : " ; read answer
1376 sed -i s#'WGET_URL=\"$TARBALL\"'#"WGET_URL=\"$answer\""# receipt
1377 # Ask for a stuff dir.
1378 _n "Do you need a stuff directory ? (y/N) : " ; read answer
1379 if [ "$answer" = "y" ]; then
1380 _n "Creating the stuff directory..."
1381 mkdir -p $WOKHG/$pkg/stuff && status
1382 fi
1383 # Ask for a description file.
1384 _n "Are you going to write a description ? (y/N) : " ; read answer
1385 if [ "$answer" = "y" ]; then
1386 _n "Creating the description.txt file..."
1387 newline > $WOKHG/$pkg/description.txt && status
1388 fi
1389 separator; _ "Receipt is ready to use."; newline ;;
1390 esac ;;
1391 list)
1392 # Cook a list of packages (better use the Cooker since it will order
1393 # packages before executing cook).
1394 check_root
1395 [ -z "$2" ] && (newline; _ "No list in argument."; newline) && exit 1
1396 list2=$2
1397 [ ! -f "$2" ] && (newline; _ "No list found: \$list2"; newline) && exit 1
1398 _ "Cook list starting: \$list2" | log
1399 for pkg in $(cat $2)
1400 do
1401 cook $pkg || broken
1402 done ;;
1403 clean-wok)
1404 check_root
1405 newline; _n "Cleaning all packages files..."
1406 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
1407 status; newline ;;
1408 clean-src)
1409 check_root
1410 newline; _n "Cleaning all packages sources..."
1411 rm -rf $WOK/*/source
1412 status; newline ;;
1413 gen-cooklist)
1414 check_root
1415 [ -f "$2" ] && LIST="$2"
1416 get_options_list="pkg wok missing"
1417 get_options
1418 if ! [ "$pkg" ]; then
1419 if [ ! "$LIST" ] || [ "$LIST" = "toolchain" ]; then
1420 pkg="$TOOLCHAIN $TOOLCHAIN_EXTRA"
1421 else
1422 check_for_list
1423 fi
1424 fi
1425 gen_cook_list
1426 if [ "$missing" ]; then
1427 cooklist=${LIST:-$cooklist}
1428 for pkgname in $(cat $cooklist)
1429 do
1430 unset EXTRAVERSION
1431 [ -f $wok/$pkgname/receipt ] || continue
1432 . $wok/$pkgname/receipt
1433 if [ -f $INCOMING/$PACKAGE-${VERSION}*.tazpkg -o -f $PKGS/$PACKAGE-${VERSION}*.tazpkg ]; then
1434 if grep "^$pkgname" $cooklist; then
1435 sed -i "s|^$pkgname$||g" $cooklist
1436 sed -i /^$/d $cooklist
1437 fi
1438 fi
1439 done
1440 fi
1442 #rm -f $command
1443 ;;
1444 gen-wok-db)
1445 check_root
1446 #echo "cook:gen-wok-db" > $command
1447 [ -d "$WOKHG" ] && WOK="$WOKHG"
1448 [ "$2" ] && WOK="$2"
1449 gen_wok_db ;;
1450 check-incoming)
1451 check_root
1452 get_options_list="forced"
1453 get_options
1454 echo "cook:check-incoming" > $command
1455 check_for_incoming
1456 rm -f $command ;;
1457 gen-src)
1458 check_root
1459 [ "$2" ] && src_repository="$2"
1460 [ -d "$src_repository" ] || src_repository="$SRC"
1461 gettext -e "Rebulding sources.list file: $src_repository"
1462 gen_sources_list $src_repository
1463 status ;;
1464 maintainers)
1465 check_root
1466 newline
1467 _ "List of maintainers for: $WOK"
1468 separator
1469 tmp="/tmp/slitaz-maintainers"
1470 touch $tmp
1471 for pkg in $WOK/*
1472 do
1473 [ -f $pkg/receipt ] || continue
1474 . $pkg/receipt
1475 if ! fgrep -q "$MAINTAINER" $tmp; then
1476 echo "$MAINTAINER" >> $tmp
1477 echo "$MAINTAINER"
1478 fi
1479 done
1480 separator
1481 echo "Maintainers: `cat $tmp | wc -l`"
1482 newline
1483 # Remove tmp files
1484 [ -f $tmp ] && rm -f $tmp
1485 ;;
1486 tags)
1487 check_root
1488 echo -e "\n\033[1mTags list :\033[0m"
1489 separator
1490 tmp="/tmp/tags"
1491 touch $tmp
1492 for pkg in $WOK/*; do
1493 unset TAGS
1494 [ -f $pkg/receipt ] || continue
1495 source $pkg/receipt
1496 for t in $TAGS; do
1497 grep -q ^$t$ $tmp && continue
1498 echo $t | tee -a $tmp
1499 done
1500 done
1501 separator
1502 echo "$(wc -l $tmp | cut -f1 -d ' ') tags listed."
1503 [ -f $tmp ] && rm -rf $tmp
1504 ;;
1505 maintained-by)
1506 # Search for packages maintained by a contributor.
1507 check_root
1508 if [ ! -n "$2" ]; then
1509 echo "Specify a name or email of a maintainer." >&2
1510 exit 1
1511 fi
1512 echo "Maintainer packages"
1513 separator
1514 for pkg in $WOK/*
1515 do
1516 [ -f $pkg/receipt ] || continue
1517 . $pkg/receipt
1518 if echo "$MAINTAINER" | fgrep -q "$2"; then
1519 echo "$PACKAGE"
1520 packages=$(($packages+1))
1521 fi
1522 done
1523 separator
1524 echo "Packages maintained by $2: $packages"
1525 newline
1526 ;;
1527 check-src)
1528 # Verify if upstream package is still available.
1530 check_root
1531 PACKAGE="$2"
1532 receipt="$WOK/$PACKAGE/receipt"
1533 if [ ! -f $receipt ]; then
1534 gettext -e "\nUnable to find package in the wok:"
1535 echo -e " $PACKAGE\n" && exit 1
1536 fi
1537 unset_receipt
1538 source $receipt
1539 check_src()
1541 for url in $@; do
1542 busybox wget -s $url 2>/dev/null && break
1543 done
1545 if [ "$WGET_URL" ];then
1546 echo -n "$PACKAGE : "
1547 check_src $WGET_URL
1548 status
1549 else
1550 echo "No tarball to check for $PACKAGE"
1551 fi
1552 ;;
1553 unbuild)
1554 unbuild "$2" "$3" ;;
1555 pkgdb)
1556 # Create suitable packages list for TazPKG and only for built packages
1557 # as well as flavors files for TazLiTo. We dont need logs since we do it
1558 # manually to ensure everything is fine before syncing the mirror.
1559 pkgdb "$2"
1560 if [ "$3" == "--flavors" ]; then
1561 cook flavors
1562 fi
1563 exit 0 ;;
1564 flavors)
1565 [ -d "$flavors" ] || $(echo -e "Missing flavors: $flavors\n" && exit 1)
1566 [ -d "$live" ] || mkdir -p $live
1567 _ "Creating flavors files in: \$live"
1568 echo "Cook pkgdb: Creating all flavors" | log
1569 separator
1570 _ "Recharging lists to use latest packages..."
1571 tazpkg recharge >/dev/null 2>/dev/null
1573 if [ ! -f "$live/cookiso.conf" ]; then
1574 echo "Creating configuration file: tazlito.conf"
1575 cp /etc/slitaz/cookiso.conf $live
1576 sed -i "s|WORK_DIR=.*|WORK_DIR="$SLITAZ"|g" $live/cookiso.conf
1577 fi
1579 #[ -d "$flavors/.hg" ] && $flavors && hg pull -u
1581 cd $live
1582 _ "Starting to generate flavors..."
1583 rm -f flavors.list *.flavor
1584 for i in $flavors/*
1585 do
1586 fl=$(basename $i)
1587 _ "Packing flavor: \$fl"
1588 pack_flavor $fl >/dev/null || exit 1
1589 show_flavor $fl --brief --noheader 2> \
1590 /dev/null >> flavors.list
1591 done
1592 cp -f $live/*.flavor $live/flavors.list $PKGS
1593 separator && gettext "Flavors size: "; du -sh $live | awk '{print $1}'
1594 exit 0 ;;
1595 clean-chroot)
1596 clean_chroot ;;
1597 *)
1598 # Just cook and generate a package.
1599 check_root
1600 time=$(date +%s)
1601 pkg="$1"
1602 [ -z "$pkg" ] && usage
1603 receipt="$WOK/$pkg/receipt"
1604 check_pkg_in_wok && newline
1606 unset inst
1607 unset_receipt
1608 . $receipt
1610 # Handle cross compilation.
1612 # CROSS_NOTE: Actually we are running an ARM cooker but running
1613 # the cooker and build each commit in wok is not possible since
1614 # we dont cook the full wok for this arch. For ARM we need a set
1615 # of packages to handle a touch screen desktop, servers but not
1616 # erland.
1618 # The temporary solution is to build only reviewed and tested
1619 # packages with HOST_ARCH set in receipt.
1620 case "$ARCH" in
1621 arm)
1622 if [ ! "$HOST_ARCH" ]; then
1623 echo "cook: HOST_ARCH is not set in $pkg receipt"
1624 echo "cook: This package is not included in: $ARCH"
1625 [ "$CROSS_BUGS" ] && echo "bugs: $CROSS_BUGS"
1626 echo "Cook skip: $pkg is not included in: $ARCH" | log
1627 newline && exit 1
1628 fi ;;
1629 esac
1631 # Some packages are not included in some arch or fail to cross compile.
1632 : ${HOST_ARCH=i486}
1633 if ! $(echo "$HOST_ARCH" | fgrep -q $ARCH); then
1634 echo "cook: HOST_ARCH=$HOST_ARCH"
1635 echo "cook: $pkg doesn't cook or is not included in: $ARCH"
1636 [ "$CROSS_BUGS" ] && echo "bugs: $CROSS_BUGS"
1637 echo "Cook skip: $pkg doesn't cook or is not included in: $ARCH" | log
1638 newline && exit 1
1639 fi
1641 # Skip blocked, 3 lines also for the Cooker.
1642 if grep -q "^$pkg$" $blocked && [ "$2" != "--unblock" ]; then
1643 _ "Blocked package: \$pkg"; newline
1644 exit 0
1645 fi
1647 if [ "$AUFS_MODE" ]; then
1648 try_aufs_chroot "$@"
1649 fi
1651 # Log and source receipt.
1652 _ "Cook started for: <a href='cooker.cgi?pkg=$pkg'>$pkg</a>" | log
1653 echo "cook:$pkg" > $command
1655 # Display and log info if cook process stopped.
1656 # FIXME: gettext not working (in single quotes) here!
1657 trap '_ "\n\nCook stopped: control-C\n\n" | \
1658 tee -a $LOGS/$pkg.log' INT
1660 set_paths
1662 # Handle --options
1663 case "$2" in
1664 --clean|-c)
1665 _n "Cleaning: \$pkg"
1666 cd $WOK/$pkg && rm -rf install taz source
1667 status && newline && exit 0 ;;
1668 --install|-i)
1669 inst='yes' ;;
1670 --noupdate|-nu)
1671 UPCHROOT="" ;;
1672 --nocleanchroot|-ncc)
1673 CLEAN_CHROOT="" ;;
1674 --getsrc|-gs)
1675 getsrc "$3"
1676 exit 0 ;;
1677 --block|-b)
1678 _n "Blocking: \$pkg"
1679 [ $(grep "^$pkg$" $blocked) ] || echo "$pkg" >> $blocked
1680 status && newline && exit 0 ;;
1681 --unblock|-ub)
1682 _n "Unblocking: \$pkg"
1683 sed -i "/^${pkg}$/"d $blocked
1684 status && newline && exit 0 ;;
1685 --pack)
1686 if [ -d $WOK/$pkg/taz ]; then
1687 rm -rf $WOK/$pkg/taz
1688 [ -f $LOGS/$pkg-pack.log ] && rm -rf $LOGS/$pkg-pack.log
1689 packit 2>&1 | tee -a $LOGS/$pkg-pack.log
1690 clean_log
1691 else
1692 _ "Need to build \$pkg." && exit 0
1693 fi
1694 exit 0 ;;
1695 esac
1697 # Check if wanted is built now so we have separate log files.
1698 if [ "$WANTED" ]; then
1699 if grep -q "^$WANTED$" $blocked; then
1700 echo "WANTED package $PACKAGE is blocked: $WANTED" | tee $LOGS/$pkg.log
1701 newline && rm -f $command && exit 1
1702 fi
1703 if grep -q "^$WANTED$" $broken; then
1704 echo "WANTED package $PACKAGE is broken: $WANTED" | tee $LOGS/$pkg.log
1705 newline && rm -f $command && exit 1
1706 fi
1707 if [ ! "$COOK_WANTED" ]; then
1708 if [ ! -d "$WOK/$WANTED/install" ]; then
1709 cook "$WANTED" || exit 1
1710 fi
1711 fi
1712 fi
1714 if [ "$UPCOOKLIST" ]; then
1715 db_md5=$(md5sum $dep_db $wan_db)
1716 echo "update_wok_db"
1717 update_wan_db
1718 echo "check_for_commit"
1719 check_for_commit
1720 sort -o $dep_db $dep_db
1721 sort -o $wan_db $wan_db
1722 if [ "$db_md5" != "$(md5sum $dep_db $wan_db)" ]; then
1723 grep -q "^#" $fullco || sed 1i"#PlanSort" -i $fullco
1724 fi
1725 fi
1727 # Cook and pack or exit on error and log everything.
1728 cookit $@ 2>&1 | loglimit 50 > $LOGS/$pkg.log
1729 remove_deps | tee -a $LOGS/$pkg.log
1730 if [ "$CLEAN_CHROOT" ]; then
1731 clean_chroot | tee -a $LOGS/$pkg.log
1732 fi
1733 cookit_quality
1734 packit 2>&1 | loglimit 5 >> $LOGS/$pkg.log
1735 clean_log
1737 # Exit if any error in packing.
1738 if grep -q ^ERROR $LOGS/$pkg.log; then
1739 debug_info | tee -a $LOGS/$pkg.log
1740 broken
1741 rm -f $command && exit 1
1742 fi
1744 # This is needed cause unset and source receipt again
1745 if [ -f "$SRC/$lzma_tarball" ]; then
1746 TARBALL="$lzma_tarball"
1747 fi
1749 # Create an XML feed
1750 gen_rss
1752 # Time and summary
1753 time=$(($(date +%s) - $time))
1754 summary | tee -a $LOGS/$pkg.log
1755 newline
1757 if [ "$AUTO_PURGE_SRC" ]; then
1758 if [ -f "$SRC/$TARBALL" ]; then
1759 previous_tarball=$(grep ^$PACKAGE:incoming $SRC/sources.list | cut -f2)
1760 if [ -f "$SRC/$previous_tarball" ]; then
1761 sed "/^$PACKAGE:incoming/ s/.*/$PACKAGE:incoming\t$TARBALL/" \
1762 -i $SRC/sources.list
1763 grep -q $'\t'$previous_tarball$ $SRC/sources.list || \
1764 rm -f $SRC/$previous_tarball
1765 else
1766 echo -e "$PACKAGE:incoming\t$TARBALL" >> $SRC/sources.list
1767 fi
1768 fi
1769 fi
1771 # remove source folder if its not used in
1772 # genpkg_rules in all wanted packages
1773 remove_src
1775 install_package
1777 # Regen the cooklist if it was planned and command is not cook.
1778 [ "$regen_cooklist" -a "$UPCOOKLIST" ] && unset regen_cooklist && sort_cooklist
1780 if [ $(grep -l "^$pkg$" $broken) ]; then
1781 sed -i "^$pkg$" $broken
1782 fi
1783 # Finally we DONT WANT to build the *-dev or packages with WANTED="$pkg"
1784 # You want automation: use the Cooker Build Bot.
1785 rm -f $command ;;
1786 esac
1788 exit 0