tazwok view tazwok @ rev 271

Fix: add a missing report end-step
author Antoine Bodin <gokhlayeh@slitaz.org>
date Mon Feb 14 03:06:47 2011 +0100 (2011-02-14)
parents 2c232d0f075a
children 6a0bc1cc0812
line source
1 #!/bin/sh
2 # Tazwok - SliTaz source compiler and binary packages generator/cooker.
3 #
4 # Tazwok can compile source packages and create binary packages suitable for
5 # Tazpkg (Tiny Autonomous zone package manager). You can build individual
6 # packages or a list of packages with one command, rebuild the full distro,
7 # generate a packages repository and also list and get info about packages.
8 #
9 # (C) 2007-2009 SliTaz - GNU General Public License.
10 #
12 VERSION=3.9.0
13 . /usr/lib/slitaz/libtaz
14 source_lib commons
16 # Use text instead of numbers, don't get $2 here if it's an option.
17 [ "$2" = "${2#--}" ] && PACKAGE=$2 && LIST=$2 && ARG=$2
18 COMMAND=$1
20 ########################################################################
21 # TAZWOK USAGE
22 ########################
23 # Print the usage (English).
25 usage()
26 {
27 echo -e "\nSliTaz sources compiler and packages generator - Version: $VERSION\n
28 \033[1mUsage: \033[0m `basename $0` [command] [package|list|category|dir|id] [--option]
29 \033[1mCommands: \033[0m\n
30 usage Print this short usage.
31 stats Print Tazwok statistics from the config file and the wok.
32 edit Edit a package receipt in the current wok.
33 build-depends Generate a list of packages to build a wok.
34 list List all packages in the wok tree or by category.
35 info Get information about a package in the wok.
36 check Check every receipt for common errors.
37 check-log Check the process log file of a package.
38 check-depends* Check every receipt for DEPENDS - doesn't scan ELF files.
39 check-src Check upstream tarball for package in the wok.
40 search Search for a package in the wok by pattern or name.
41 compile Configure and build a package using the receipt rules.
42 genpkg Generate a suitable package for Tazpkg with the rules.
43 cook Compile and generate a package directly.
44 cook-list Cook all packages specified in the list by order.
45 cook-commit Cook all modified receipts.
46 cook-all Cook all packages excepted toolchain.
47 cook-toolchain Cook the toolchain packages.
48 gen-cooklist Generate a sorted cooklist using packages or list.
49 sort-cooklist Sort the cooklist given in argument.
50 get-src Download the tarball of the package given in argument.
51 clean Clean all generated files in the package tree.
52 new-tree Prepare a new package tree and receipt (--interactive).
53 gen-list (Re-)Generate a packages list for a repository.
54 check-list Update packages lists for a repository.
55 gen-wok-db (Re-)Generate wok lists with depends and wanted datas.
56 gen-clean-wok Generate a clean wok in a dir.
57 clean-wok Clean entirely the wok.
58 clean-src Remove old/unrelated-to-wok sources.
59 remove Remove a package from the wok.
60 webserver Enable/disable webserver on localhost.
61 hgup Pull and update a wok under Hg.
62 maintainers List all maintainers in the wok.
63 maintained-by List packages maintained by a contributor.\n
64 tags List all tags used in wok receipts.
66 You can use `basename $0` command --help to list avaible options.
67 \033[1mImportant - *: \033[0m Commands which need a rewrite."
68 }
70 # This function display an error message without returning any error code.
71 # It also log the message in source package's warnings.txt; this file can be
72 # used on an eventual package page on website to display cooking warnings.
73 tazwok_warning()
74 {
75 echo -e "tazwok: $1" >&2
76 echo -e "$1" >> $WOK/${WANTED:-$PACKAGE}/warning.txt
77 return
78 }
80 ########################################################################
81 # TAZWOK VARIABLES & INITIAL CONFIGURATION
82 ########################
84 get_tazwok_config()
85 {
86 # Get configuration file.
87 get_config
89 # Define & get options.
90 get_options_list="$get_options_list SLITAZ_DIR SLITAZ_VERSION undigest"
91 get_options
93 if [ "$undigest" ]; then
94 LOCAL_REPOSITORY=$SLITAZ_DIR/$undigest
95 else
96 LOCAL_REPOSITORY=$SLITAZ_DIR/$SLITAZ_VERSION
97 fi
99 if ! [ "$save_dir" ]; then
100 if [ -f $LOCAL_REPOSITORY/tazwok.conf ] || [ -f $LOCAL_REPOSITORY/slitaz.conf ]; then
101 save_dir=$LOCAL_REPOSITORY
102 [ -f $LOCAL_REPOSITORY/slitaz.conf ] && source $LOCAL_REPOSITORY/slitaz.conf
103 cd $save_dir
104 get_tazwok_config
105 unset save_dir
106 return
107 fi
108 fi
110 # The path to the most important files/dir used by Tazwok.
111 PACKAGES_REPOSITORY=$LOCAL_REPOSITORY/packages
112 WOK=$LOCAL_REPOSITORY/wok
113 INCOMING_REPOSITORY=$LOCAL_REPOSITORY/packages-incoming
114 SOURCES_REPOSITORY=$LOCAL_REPOSITORY/src
115 set_common_path
117 # /!\ This part needs some changes.
118 # Basically, get theses files from the net if they are missing.
119 dep_db=$INCOMING_REPOSITORY/wok-depends.txt
120 wan_db=$INCOMING_REPOSITORY/wok-wanted.txt
121 [ -f $dep_db ] || touch $dep_db
122 [ -f $wan_db ] || touch $wan_db
123 [ -f $PACKAGES_REPOSITORY/cookorder.txt ] || touch $PACKAGES_REPOSITORY/cookorder.txt
125 # Check commons directories, create them if user is root.
126 if test $(id -u) = 0 ; then
127 check_dir $WOK || chmod 777 $WOK
128 check_dir $PACKAGES_REPOSITORY
129 check_dir $SOURCES_REPOSITORY
130 check_dir $INCOMING_REPOSITORY
131 check_dir $LOCAL_REPOSITORY/log
132 fi
134 # Some files are needed by tazwok in PACKAGES_REPOSITORY. Create
135 # them if they are missing.
136 for file in broken blocked commit incoming cooklist; do
137 [ ! -f $PACKAGES_REPOSITORY/$file ] && touch $PACKAGES_REPOSITORY/$file
138 done
139 touch $SOURCES_REPOSITORY/sources.list
141 # Limit memory usage.
142 ulimit -v $(awk '/MemTotal/ { print int(($2*80)/100) }' < /proc/meminfo)
143 }
145 # Used in several functions.
146 set_common_path()
147 {
148 # The receipt is used to compile the source code and
149 # generate suitable packages for Tazpkg.
150 RECEIPT="$WOK/$PACKAGE/receipt"
152 # The path to the process log file.
153 LOG="$WOK/$PACKAGE/process.log"
154 }
156 ########################################################################
157 # TAZWOK CHECK FUNCTIONS
158 ########################
160 # Check for a package name on cmdline.
161 check_for_package_on_cmdline()
162 {
163 if [ ! "$PACKAGE" ]; then
164 echo -e "\nYou must specify a package name on the command line." >&2
165 echo -e "Example : tazwok $COMMAND package\n" >&2
166 exit 1
167 fi
168 }
170 # Check for the receipt of a package used to cook.
171 check_for_receipt()
172 {
173 if [ ! -f "$RECEIPT" ]; then
174 echo -e "\nUnable to find the receipt : $RECEIPT\n" >&2
175 exit 1
176 fi
177 }
179 # Check for a specified file list on cmdline.
180 check_for_list()
181 {
182 if [ ! "$LIST" ]; then
183 echo -e "\nPlease specify the path to the list of packages to cook.\n" >&2
184 exit 1
185 fi
187 # Check if the list of packages exists.
188 if [ -f "$LIST" ]; then
189 LIST=`cat $LIST`
190 else
191 echo -e "\nUnable to find $LIST packages list.\n" >&2
192 exit 1
193 fi
195 if [ ! "$LIST" ]; then
196 echo -e "\nList is empty.\n" >&2
197 exit 1
198 fi
199 }
201 check_for_pkg_in_wok()
202 {
203 [ -f $WOK/$PACKAGE/receipt ] && return
204 if [ "$undigest" ]; then
205 [ -f "$SLITAZ_VERSION/wok/$PACKAGE/receipt" ] && return 1
206 grep -q ^$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages/packages.txt && return 1
207 fi
208 echo "Can't find $PACKAGE in wok or mirror" >&2
209 return 2
210 }
212 ########################################################################
213 # TAZWOK CORE FUNCTIONS
214 ########################
216 remove_src()
217 {
218 [ "$WANTED" ] && return
219 look_for_cookopt !remove_src && return
220 if [ ! -d $WOK/$PACKAGE/install ] && [ "$src" ] && [ -d "$src/_pkg" ]; then
221 check_for_var_modification _pkg src || return
222 mv "$src/_pkg" $WOK/$PACKAGE/install
223 fi
225 # Don't remove sources if a package use src variable in his
226 # genpkg_rules: it maybe need something inside.
227 for i in $PACKAGE $(look_for_rwanted); do
228 sed -n '/^genpkg_rules\(\)/','/}/'p $WOK/$i/receipt | \
229 fgrep -q '$src' && tazwok_warning "Sources will not be removed \
230 because $i use \$src in his receipt." && return
231 done
233 report step "Removing sources directory"
234 rm -fr "$src"
235 report end-step
236 }
238 # Check $COOK_OPT; usage : get_cookopt particular_opt
239 # Return error if not founded
240 # Return args if the opt is in the format opt=arg1:arg2:etc
241 look_for_cookopt()
242 {
243 for arg in $COOK_OPT; do
244 case $arg in
245 $1=*)
246 arg=${arg#$1=}
247 while [ "$arg" ]; do
248 echo "${arg%%:*}"
249 [ "${arg/:}" = "$arg" ] && return
250 arg=${arg#*:}
251 done
252 ;;
253 $1)
254 return
255 ;;
256 esac
257 done
258 return 1
259 }
261 # Check for the wanted package if specified in WANTED
262 # receipt variable. Set the $src/$_pkg variable to help compile
263 # and generate packages.
264 check_for_wanted()
265 {
266 if [ "$WANTED" ]; then
267 report "Checking for the wanted package"
268 if [ ! -d "$WOK/$WANTED" ]; then
269 report exit "\nWanted package is missing in the work directory.\n"
270 fi
272 # Checking for buildtree of Wanted package
273 if [ ! -d "$WOK/$WANTED/taz" ]; then
274 echo -e "\n\nSource files of wanted package is missing in the work directory."
275 echo -n "Would you like to build the missing package (y/N) ? " ; read anser
276 if [ "$anser" == "y" ]; then
277 tazwok cook $WANTED
278 else
279 report exit "\nWanted package source tree is missing in the work directory.\n"
280 fi
281 fi
282 report end-step
284 # Set wanted src path.
285 set_src_path && set_pkg_path
287 fi
288 }
290 # Check for build dependencies, notify user and install if specified.
291 check_for_build_depends()
292 {
293 [ "$WANTED" ] && return
294 [ "$CATEGORY" = meta ] && ! fgrep -q compile_rules $RECEIPT && return
295 report step "Looking for build dependencies"
297 # Keep the list of previously installed build_depends then compare
298 # it with new build_depends to know what to install and what to
299 # what to remove.
300 plan_remove=" $MISSING_PACKAGE $remove_later "
301 [ ! "${plan_remove// }" ] && unset plan_remove
302 unset MISSING_PACKAGE remove_later
303 rwanted=$(look_for_rwanted)
305 for pkg in $(scan $PACKAGE --look_for=bdep --with_dev | \
306 fgrep -v $(for i in $(look_for_rwanted) $PACKAGE; do echo " -e $i"; done))
307 do
309 # Delay the removing of previous cook depends if they are needed
310 # for next cook too.
311 if [ ! -d "$INSTALLED/$pkg" ] ; then
312 MISSING_PACKAGE="$MISSING_PACKAGE $pkg"
313 fi
314 if [ "$plan_remove" != "${plan_remove/ $pkg }" ]; then
315 plan_remove="${plan_remove/ $pkg / }"
316 remove_later="$remove_later $pkg"
317 fi
318 if grep -q ^$pkg$ $PACKAGES_REPOSITORY/broken; then
319 broken="$broken$pkg "
320 fi
321 done
323 # Don't cook if a depend is broken.
324 if [ "$broken" ]; then
325 MISSING_PACKAGE=$plan_remove
326 echo "Can't cook $PACKAGE because broken depend(s) : $broken" >&2
327 unset plan_remove broken
329 # Set report step to failed.
330 report_return_code=1
331 report end-step
332 return 1
333 fi
334 if [ "$MISSING_PACKAGE" ]; then
335 install_missing()
336 {
337 echo "Installing missing packages : $MISSING_PACKAGE"
338 for pkg in $MISSING_PACKAGE; do
339 [ -d "$INSTALLED/$pkg" ] || tazpkg get-install $pkg
340 done
341 }
342 if [ "$auto_install" = yes ]; then
343 install_missing
344 else
345 echo "================================================================================"
346 for pkg in $MISSING_PACKAGE
347 do
348 echo "Missing : $pkg"
349 done
350 echo "================================================================================"
351 echo "You can continue, exit or install missing dependencies."
352 echo -n "Install, continue or exit (install/y/N) ? "; read answer
353 case $answer in
354 install)
355 install_missing ;;
356 y|yes)
357 unset MISSING_PACKAGE;;
358 *)
359 report stop
360 exit 0 ;;
361 esac
362 fi
363 fi
364 report end-step
365 remove_build_depends $plan_remove
366 unset plan_remove
367 }
369 remove_build_depends()
370 {
371 [ "$1" ] || return
372 report step "Removing previous build dependencies"
373 echo "Removing theses packages : $@"
374 for pkg in $@; do
375 [ -d "$INSTALLED/$pkg" ] && tazpkg remove $pkg --auto
376 done
377 report end-step
378 }
380 # Check if we can use the new way to handle tarball
381 # or if we keep the previous method by check for
382 # _pkg=/src= in receipt and reverse-wanted.
383 check_for_var_modification()
384 {
385 for var in $@; do
386 for pkg in $PACKAGE $(look_for_wanted) $(look_for_rwanted); do
387 [ -f $WOK/$pkg/receipt ] || continue
388 fgrep -q "$var=" $WOK/$pkg/receipt && return 1
389 done
390 done
392 # Tweak to make if; then...; fi function working with this one.
393 echo -n ""
394 }
396 set_src_path()
397 {
398 if check_for_var_modification src _pkg; then
399 src=$WOK/${WANTED:-$PACKAGE}/${WANTED:-$PACKAGE}-$VERSION
400 else
401 tazwok_warning "Use original name or tarball root directory because src/_pkg are defined into the receipt (this is no more needed!)."
402 src=$WOK/${WANTED:-$PACKAGE}/${SOURCE:-${WANTED:-$PACKAGE}}-$VERSION
403 fi
404 }
406 set_pkg_path()
407 {
408 if [ -d $WOK/${WANTED:-$PACKAGE}/install ] ; then
409 _pkg=$WOK/${WANTED:-$PACKAGE}/install
410 else
411 _pkg=$src/_pkg
412 fi
413 }
415 # Output $VERSION-$EXTRAVERSION using packages.txt
416 get_pkg_version()
417 {
418 [ "$PACKAGE" ] || return
419 grep -m1 -A1 -sh ^$PACKAGE$ $1/packages.txt | tail -1 | sed 's/ *//'
420 }
422 remove_previous_package()
423 {
424 [ "$prev_VERSION" ] || return
425 if [ "$VERSION$EXTRAVERSION" != "$prev_VERSION" ]; then
426 rm -f $1/$PACKAGE-$prev_VERSION.tazpkg
427 fi
428 return
429 }
431 # Check for src tarball and wget if needed.
432 check_for_tarball()
433 {
434 [ "$WGET_URL" ] || return 0
435 report step "Checking for source tarball"
436 local repack_src TARBALL
437 if [ "$repack_src" = yes ] && look_for_cookopt !repack_src; then
438 repack_src=no
439 fi
440 if [ "$target" ]; then
441 src="$target"
442 else
443 set_src_path
444 fi
445 tmp_src=$tmp/tarball-$$
446 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
447 [ ! -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] ; then
448 cd $SOURCES_REPOSITORY
449 if [ "$SOURCE" ]; then
450 alt_url="http://mirror.slitaz.org/sources/packages/${SOURCE:0:1}/$SOURCE-$VERSION.tar.lzma"
451 else
452 alt_url="http://mirror.slitaz.org/sources/packages/${PACKAGE:0:1}/$PACKAGE-$VERSION.tar.lzma"
453 fi
454 download $WGET_URL $alt_url http://mirror.slitaz.org/sources/packages/${file:0:1}/$file
455 unset alt_url
456 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
457 [ ! -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && \
458 [ ! -d $tmp_src ]; then
459 echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n" >&2
460 report end-step
461 return 1
462 fi
463 fi
464 report end-step
465 if [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && [ "$nounpack" ]; then
466 [ -d "$tmp_src" ] && rm -r $tmp_src
467 return
468 fi
470 # Untaring source if necessary. We don't need to extract source if
471 # the package is built with a wanted source package.
472 if [ "$WANTED" ]; then
473 [ -d "$tmp_src" ] && rm -r $tmp_src
474 return
475 fi
477 report step "Untaring source tarball"
479 # Log process.
480 echo "untaring source tarball" >> $LOG
482 # If $tmp_src exists, there's already the unpacked tarball into it.
483 if ! [ -d $tmp_src ]; then
484 mkdir $tmp_src
485 if [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && [ "$repack_src" = yes ]; then
486 lzma d $SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma -so | \
487 tar xf - -C $tmp_src
488 repack_src=no
489 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
490 elif [ -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
491 case "$TARBALL" in
492 *zip|*xpi) cd $tmp_src && unzip -o $SOURCES_REPOSITORY/$TARBALL ;;
493 *bz2|*tbz|*gem) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
494 *tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
495 *lzma|*lz) unlzma -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
496 *xz) unxz -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
497 *Z|*taz) uncompress -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
498 *gz) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
499 *rpm) cd $tmp_src && rpm2cpio $SOURCES_REPOSITORY/$TARBALL | cpio -idm --quiet;;
501 # It's a plain file or something receipt unpack itself.
502 *)
503 mkdir $tmp_src/${SOURCE:-$PACKAGE}-$VERSION
504 cp $SOURCES_REPOSITORY/$TARBALL $tmp_src/${src##*/}
505 ;;
507 esac || { report end-step
508 rm -f $SOURCES_REPOSITORY/$TARBALL
509 rm -r $tmp_src
510 return 1
511 }
512 fi
514 # Check if uncompressed tarball is in a root dir or not.
515 if [ "$(ls -A $tmp_src | wc -l)" -gt 1 ] || [ -f $(echo $tmp_src/*) ]; then
516 if check_for_var_modification src _pkg; then
517 mv $tmp_src $tmp_src-1
518 mkdir $tmp_src
519 mv $tmp_src-1 $tmp_src/${SOURCE:-$PACKAGE}-$VERSION
520 else
521 mv $tmp_src/* $WOK/$PACKAGE
522 repack_src=no
523 rm -r $tmp_src
524 tazwok_warning "Put all files into $WOK/$PACKAGE; not sure about how to handle this tarball (no root dir)... Please try to remove src/_pkg definition from receipt if you encounter a problem."
525 fi
526 fi
527 fi
529 if [ "$repack_src" = yes ]; then
530 report step "Repacking sources in .tar.lzma format"
531 [ "$TARBALL" ] && rm -f $SOURCES_REPOSITORY/$TARBALL
532 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
533 cd $tmp_src
534 tar -c * | lzma e $SOURCES_REPOSITORY/$TARBALL -si
535 fi
537 # Remove previous tarball if no other package needs it. We take care to
538 # keep tarball if the same package use it into main repository.
539 if [ "$TARBALL" ]; then
540 previous_tarball=$(grep ^$PACKAGE:incoming $SOURCES_REPOSITORY/sources.list | cut -f2)
541 if [ "$previous_tarball" ]; then
542 sed "/^$PACKAGE:incoming/ s/.*/$PACKAGE:incoming\t$TARBALL/" \
543 -i $SOURCES_REPOSITORY/sources.list
544 grep -q $'\t'$previous_tarball$ $SOURCES_REPOSITORY/sources.list || \
545 rm -f $SOURCES_REPOSITORY/$previous_tarball
546 else
547 echo -e "$PACKAGE:incoming\t$TARBALL" >> $SOURCES_REPOSITORY/sources.list
548 fi
549 fi
551 if [ "$nounpack" ]; then
552 [ -d "$tmp_src" ] && rm -r $tmp_src
553 return
554 fi
555 if [ ! -d "$src" ]; then
556 if ! check_for_var_modification src _pkg; then
557 src="${src%/*}/$(ls $tmp_src)"
558 fi
559 mv $(echo $tmp_src/*) "$src"
560 rm -r $tmp_src
562 # Permissions settings.
563 chown -R root.root "$src"
564 else
565 [ -d "$tmp_src" ] && rm -r $tmp_src
566 echo "There's already something at $src. Abort." >&2
567 fi
568 }
570 # Log and execute compile_rules function if it exists, to configure and
571 # make the package if it exists.
572 check_for_compile_rules()
573 {
574 if grep -q ^compile_rules $RECEIPT; then
575 echo "executing compile_rules" >> $LOG
576 report step "Executing compile_rules"
577 cd $WOK/$PACKAGE
578 rm -f /tmp/config.site
580 # Free some RAM by cleaning cache if option is enabled.
581 freeram=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
583 # Disable -pipe in CFLAGS/CXXFLAGS if less than 512Mb of free
584 # RAM are available.
585 if [ "$freeram" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" -o \
586 "$CXXFLAGS" != "${CXXFLAGS/-pipe}" ]; then
587 tazwok_warning "Disabling -pipe compile flag because only ${freeram}b of RAM are available."
588 CFLAGS="${CFLAGS/-pipe}"
589 CXXFLAGS="${CXXFLAGS/-pipe}"
590 fi
591 unset freeram
593 # Set cook environnement variables.
594 [ "$src" ] || set_src_path
595 [ "$DESTDIR" ] || DESTDIR="$WOK/$PACKAGE/install"
596 [ "$CONFIG_SITE" ] || CONFIG_SITE=/etc/config.site
597 export CFLAGS CXXFLAGS MAKEFLAGS DESTDIR BUILD_HOST \
598 CONFIG_SITE default_prefix \
599 default_datarootdir default_datadir default_localedir \
600 default_infodir default_mandir default_build default_host
601 local LC_ALL=POSIX LANG=POSIX
602 compile_rules
604 # Check if config.site has been used.
605 # /!\ disabled since it screw the return_code of the step.
606 #if [ -f /tmp/config.site ]; then
607 # rm /tmp/config.site
608 #else
609 # tazwok_warning "config.site hasn't been used during \
610 #configuration process."
611 #fi
613 report end-step
614 fi
615 }
617 # Check for loop in deps tree. /!\ can be removed
618 check_for_deps_loop()
619 {
620 local list
621 local pkg
622 local deps
623 pkg=$1
624 shift
625 [ -n "$1" ] || return
626 list=""
628 # Filter out already processed deps
629 for i in $@; do
630 case " $ALL_DEPS" in
631 *\ $i\ *);;
632 *) list="$list $i";;
633 esac
634 done
635 ALL_DEPS="$ALL_DEPS$list "
636 for i in $list; do
637 [ -f $i/receipt ] || continue
638 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
639 case " $deps " in
640 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
641 *) check_for_deps_loop $pkg $deps;;
642 esac
643 done
644 }
646 # Function used by download().
647 revert_vcs_failure()
648 {
649 cd $SOURCES_REPOSITORY
650 rm -r $tmp_src
651 }
653 download()
654 {
655 for file in $@; do
656 echo "Downloading from ${file#*|}..."
657 case "$file" in
658 git\|*)
659 file=${file#git|}
660 if [ -d $INSTALLED/git ]; then
661 mkdir $tmp_src
662 cd $tmp_src
663 if [ "$BRANCH" ]; then
664 git clone $file ${src##*/} && cd ${src##*/} && \
665 git checkout $BRANCH && rm -rf .git* && break
666 else
667 git clone $file ${src##*/} && rm -rf ${src##*/}/.git* && break
668 fi
669 revert_vcs_failure
670 else
671 tazwok_warning "Needs git to download the source tarball from $file, please add it as build-depend."
672 continue
673 fi
674 ;;
675 subversion\|*)
676 file=${file#subversion|}
677 if [ -d $INSTALLED/subversion ]; then
678 mkdir $tmp_src
679 cd $tmp_src
680 if [ "$BRANCH" ]; then
681 echo t | svn co $file -r $BRANCH ${src##*/} && rm -rf ${src##*/}/.svn* && break
682 else
683 echo t | svn co $file ${src##*/} && rm -rf ${src##*/}/.svn* && break
684 fi
685 revert_vcs_failure
686 else
687 tazwok_warning "Needs subversion to download the source tarball from $file, please add it as build-depend."
688 continue
689 fi
690 ;;
691 mercurial\|*)
692 file=${file#mercurial|}
693 if [ -d $INSTALLED/mercurial ]; then
694 mkdir $tmp_src
695 cd $tmp_src
696 if [ "$BRANCH" ]; then
697 hg clone $file --rev $BRANCH ${src##*/} && rm -rf ${src##*/}/.hg* && break
698 else
699 hg clone $file ${src##*/} && rm -rf ${src##*/}/.hg* && break
700 fi
701 revert_vcs_failure
702 else
703 tazwok_warning "Needs mercurial to download the source tarball from $file, please add it as build-depend."
704 continue
705 fi
706 ;;
707 https*)
708 if [ -d $INSTALLED/wget ]; then
709 if [ "${WGET_URL%$TARBALL}" = "$WGET_URL" ] && [ "$file" = "$WGET_URL" ]; then
710 wget -q --no-check-certificate -O $TARBALL $file && break
711 else
712 wget -q $file && break
713 fi
714 else
715 tazwok_warning "Needs wget to download the source tarball from $file, please add it as build-depend."
716 continue
717 fi
718 ;;
719 http*|ftp*)
720 # Handle crappy URL.
721 if [ "${WGET_URL%$TARBALL}" = "$WGET_URL" ] && [ "$file" = "$WGET_URL" ]; then
722 wget -q -O $TARBALL $file && break
723 else
724 wget -q $file && break
725 fi
726 ;;
727 esac
728 done
729 }
731 # Regenerate every package that wants a PACKAGE compiled
732 refresh_packages_from_compile()
733 {
734 # make tazwok genpkg happy
735 mkdir $WOK/$PACKAGE/taz
737 # Cook rwanted in default or specied order
738 genlist=" $(look_for_rwanted | tr '\n' ' ') "
739 for i in $(look_for_cookopt genpkg | tac); do
740 [ "${genlist/ $i }" = "$genlist" ] && continue
741 genlist=" $i${genlist/ $i / }"
742 done
743 if [ "$genlist" ]; then
744 local PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
745 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
746 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
747 src _pkg DESTDIR CONFIG_SITE RECEIPT LOG
748 for PACKAGE in $genlist; do
749 set_common_path
750 gen_package
751 done
752 fi
753 }
755 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
756 # so some packages need to copy these files with the receipt and genpkg_rules.
757 # This function is executed by gen_package when 'tazwok genpkg'.
758 copy_generic_files()
759 {
760 # In most cases, locales are in $_pkg/usr/share/locale so we copy files
761 # using generic variables and $LOCALE from Tazwok config file.
762 if [ "$LOCALE" ]; then
763 if [ -d "$_pkg/usr/share/locale" ]; then
764 for i in $LOCALE
765 do
766 if [ -d "$_pkg/usr/share/locale/$i" ]; then
767 mkdir -p $fs/usr/share/locale
768 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
769 fi
770 done
771 fi
772 fi
774 # Pixmaps (PNG or/and XPM only). Some icons/images can be added through
775 # genpkg_rules and generic copy can be disabled with GENERIC_PIXMAPS="no"
776 # in pkg receipt.
777 if [ "$GENERIC_PIXMAPS" != "no" ]; then
778 if [ -d "$_pkg/usr/share/pixmaps" ]; then
779 mkdir -p $fs/usr/share/pixmaps
780 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
781 $fs/usr/share/pixmaps 2>/dev/null
782 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
783 $fs/usr/share/pixmaps 2>/dev/null
784 fi
786 # Custom or homemade PNG pixmap can be in stuff.
787 if [ -f "stuff/$PACKAGE.png" ]; then
788 mkdir -p $fs/usr/share/pixmaps
789 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
790 fi
791 fi
793 # Desktop entry (.desktop).
794 if [ -d "$_pkg/usr/share/applications" ]; then
795 cp -a $_pkg/usr/share/applications $fs/usr/share
796 fi
798 # Homemade desktop file(s) can be in stuff.
799 if [ -d "stuff/applications" ]; then
800 mkdir -p $fs/usr/share
801 cp -a stuff/applications $fs/usr/share
802 fi
803 if [ -f "stuff/$PACKAGE.desktop" ]; then
804 mkdir -p $fs/usr/share/applications
805 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
806 fi
807 }
809 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
810 strip_package()
811 {
812 report step "Executing strip on all files"
814 # Binaries.
815 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
816 do
817 if [ -d "$dir" ]; then
818 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
819 fi
820 done
822 # Libraries.
823 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
824 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
825 report end-step
826 }
828 # Remove .pyc and .pyo files from packages
829 py_compiled_files_remove()
830 {
831 report step "Removing all .pyc and .pyo files from package ..."
832 find $fs -type f -name "*.pyc" -delete 2>/dev/null
833 find $fs -type f -name "*.pyo" -delete 2>/dev/null
834 report end-step
835 }
837 # Check FSH in a slitaz package (Path: /:/usr)
838 check_fsh()
839 {
840 cd $WOK/$PACKAGE/taz/*/fs
841 [ -n "$FSH" ] || FSH="bin boot dev etc home init lib media mnt proc \
842 root sbin share sys tmp usr var vz usr/bin usr/games usr/include usr/lib \
843 usr/local usr/sbin usr/share usr/src"
844 for i in `ls -d * usr/* 2>/dev/null`
845 do
846 if ! echo $FSH | fgrep -q $i; then
847 echo "Wrong path: /$i" >&2
848 error=1
849 fi
850 done
851 if [ "$error" = "1" ]; then
852 cat << _EOT_
854 Package will install files in a non standard directory and won't be generated.
855 You may have a wrong copy path in genpkg_rules or need to add some options to
856 configure in compile_rules. Some valid options for SliTaz (Linux FSH):
858 --prefix=/usr
859 --sysconfdir=/etc
860 --libexecdir=/usr/lib/(pkgname)
861 --localstatedir=/var
862 --mandir=/usr/share/man
863 --infodir=/usr/share/info
865 For more information please read SliTaz docs and run: ./configure --help
866 ================================================================================
867 $PACKAGE package generation aborted.
869 _EOT_
871 # Dont generate a corrupted package.
872 cd $WOK/$PACKAGE && rm -rf taz
873 report exit
874 fi
875 }
877 gen_cookmd5()
878 {
879 # md5sum of cooking stuff make tazwok able to check for changes
880 # without hg.
881 cd $WOK/$PACKAGE
882 md5sum receipt > md5
883 [ -f description.txt ] && md5sum description.txt >> md5
884 if [ -d stuff ]; then
885 find stuff | while read file; do
886 md5sum $file >> md5
887 done
888 fi
889 }
891 # Create a package tree and build the gziped cpio archive
892 # to make a SliTaz (.tazpkg) package.
893 gen_package()
894 {
895 check_root
896 check_for_package_on_cmdline
897 check_for_receipt
898 EXTRAVERSION=""
899 . $RECEIPT
901 # May compute VERSION
902 if grep -q ^get_version $RECEIPT; then
903 get_version
904 fi
905 check_for_wanted
906 cd $WOK/$PACKAGE
908 # Remove old Tazwok package files.
909 [ -d "taz" ] && rm -rf taz
911 # Create the package tree and set useful variables.
912 mkdir -p $WOK/$PACKAGE/taz/$PACKAGE-$VERSION/fs
913 fs=$WOK/$PACKAGE/taz/$PACKAGE-$VERSION/fs
915 # Set $src for standard package and $_pkg variables.
916 set_src_path && set_pkg_path
918 # Execute genpkg_rules, check package and copy generic files to build
919 # the package.
920 report step "Building $PACKAGE with the receipt"
921 report open-bloc
922 if grep -q ^genpkg_rules $RECEIPT; then
924 # Log process.
925 echo "executing genpkg_rules" >> $LOG
926 report step "Executing genpkg_rules"
927 genpkg_rules
928 report end-step
929 check_fsh
930 cd $WOK/$PACKAGE
932 # Skip generic files for packages with a WANTED variable
933 # (dev and splited pkgs).
934 if [ ! "$WANTED" ]; then
935 copy_generic_files
936 fi
937 look_for_cookopt !strip || strip_package
938 py_compiled_files_remove
939 else
940 echo "No package rules to gen $PACKAGE..." >&2
941 report exit
942 fi
944 # Copy the receipt and description (if exists) into the binary package tree.
945 cd $WOK/$PACKAGE
946 report step "Copying the receipt"
947 cp receipt taz/$PACKAGE-$VERSION
948 report end-step
949 if grep -q ^get_version $RECEIPT; then
950 report step "Updating version in receipt"
951 sed -i "s/^VERSION=.*/VERSION=\"$VERSION\"/" \
952 taz/$PACKAGE-$VERSION/receipt
953 report end-step
954 fi
955 if [ -f "description.txt" ]; then
956 report step "Copying the description file"
957 cp description.txt taz/$PACKAGE-$VERSION
958 report end-step
959 fi
961 # Generate md5 of cooking stuff to look for commit later.
962 gen_cookmd5
963 echo -e "\n# md5sum of cooking stuff :" >> taz/$PACKAGE-$VERSION/receipt
964 cat md5 | sed 's/^/# /' >> taz/$PACKAGE-$VERSION/receipt
966 # Create the files.list by redirecting find output.
967 report step "Creating the list of files"
968 cd taz/$PACKAGE-$VERSION
969 LAST_FILE=""
970 { find fs -print; echo; } | while read file; do
971 if [ "$LAST_FILE" ]; then
972 case "$file" in
973 $LAST_FILE/*)
974 case "$(ls -ld "$LAST_FILE")" in
975 drwxr-xr-x\ *\ root\ *\ root\ *);;
976 *) echo ${LAST_FILE#fs};;
977 esac;;
978 *) echo ${LAST_FILE#fs};;
979 esac
980 fi
981 LAST_FILE="$file"
982 done > files.list
984 # Next, check if something has changed in lib files.
985 if fgrep -q '.so' files.list; then
986 report step "Look for major/minor update in libraries"
987 for rep in $INCOMING_REPOSITORY $PACKAGES_REPOSITORY \
988 $([ "$undigest" ] && echo SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming && \
989 echo $SLITAZ_DIR/$SLITAZ_VERSION/packages); do
990 prev_VERSION=$(get_pkg_version $rep)
991 [ "$prev_VERSION" ] && pkg_file=$rep/$PACKAGE-$prev_VERSION.tazpkg && break
992 done
993 if [ "$pkg_file" ]; then
994 get_pkg_files $pkg_file
995 cd $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
996 fgrep ".so" files.list | egrep -v "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*" | \
997 while read lib; do
998 fgrep -q "$lib" $pkg_files_dir/files.list && continue
999 echo "A minor/major update in libraries is detected, planning re-cook of reverse-depends of $PACKAGE."
1000 for rdep in $(scan $PACKAGE --look_for=rdep | use_wanted); do
1001 [ "$rdep" = "${WANTED:-$PACKAGE}" ] && continue
1002 grep -q ^$rdep$ $PACKAGES_REPOSITORY/blocked \
1003 $PACKAGES_REPOSITORY/cooklist && continue
1004 echo $rdep >> $PACKAGES_REPOSITORY/cooklist
1005 done
1006 regen_cooklist=yes
1007 break
1008 done
1009 rm -r $pkg_files_dir
1010 fi
1011 report end-step
1012 fi
1013 if [ ! "$EXTRAVERSION" ]; then
1014 case "$PACKAGE" in
1015 linux*);;
1016 *) EXTRAVERSION="$(grep '/lib/modules/.*-slitaz/' files.list |\
1017 head -1 | sed 's|/lib/modules/\(.*\)-slitaz/.*|_\1|')";;
1018 esac
1019 fi
1020 rm -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
1021 report step "Creating md5sum of files"
1022 while read file; do
1023 [ -L "fs$file" ] && continue
1024 [ -f "fs$file" ] || continue
1025 md5sum "fs$file" | sed 's/ fs/ /'
1026 done < files.list > md5sum
1027 report end-step
1028 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
1029 2> /dev/null | awk '{ sz=$1 } END { print sz }')
1031 # Build cpio archives. Find, cpio and gzip the fs, finish by
1032 # removing the fs tree.
1033 # Don't log this because compression always output error messages.
1034 find fs -print | cpio -o -H newc | case "$PACKAGE-$COMPRESSION" in
1035 tazpkg-lzma) gzip > fs.cpio.gz;;
1036 *-lzma) lzma e fs.cpio.lzma -si;;
1037 *) gzip > fs.cpio.gz;;
1038 esac && rm -rf fs
1039 PACKED_SIZE=$(du -chs fs.cpio.* receipt files.list md5sum \
1040 description.txt 2> /dev/null | awk '{ sz=$1 } END { print sz }')
1041 report step "Updating receipt sizes"
1042 sed -i '/^PACKED_SIZE/d' receipt
1043 sed -i '/^UNPACKED_SIZE/d' receipt
1044 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
1045 sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
1046 report end-step
1047 if [ "$EXTRAVERSION" ]; then
1048 report step "Updating receipt EXTRAVERSION"
1049 sed -i s/^EXTRAVERSION.*$// receipt
1050 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
1051 fi
1052 prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
1053 remove_previous_package $INCOMING_REPOSITORY
1054 report step "Creating full cpio archive"
1055 find . -print | cpio -o -H newc > $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
1057 # Restore package tree in case we want to browse it.
1058 report step "Restoring original package tree"
1059 { zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma; } | cpio --quiet -id
1060 rm fs.cpio.* && cd ..
1062 # Log process.
1063 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
1064 report close-bloc
1065 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
1066 echo "Size : `du -sh $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
1067 echo ""
1069 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/broken
1070 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/commit
1071 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/cooklist
1074 ########################################################################
1075 # This section contains functions used by several other functions
1076 # bellow.
1077 ########################
1079 # Look for receipt/files.list in wok. If they can't be found, get them
1080 # from package. Accept one argument : absolute path to package.
1081 get_pkg_files()
1083 pkg_files_dir=$tmp/$(basename ${1%.tazpkg})
1084 mkdir -p $pkg_files_dir && \
1085 cd $pkg_files_dir && \
1086 cpio --quiet -idm receipt < $1 && \
1087 cpio --quiet -idm files.list < $1
1090 ########################################################################
1091 # This section contains functions to generate packages databases.
1092 ########################
1095 gen_packages_db()
1097 # pkg_repository can be $PACKAGES_REPOSITORY or $INCOMING_REPOSITORY.
1098 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
1099 cd $pkg_repository
1100 report step "Generating packages lists: $pkg_repository"
1101 report open-bloc
1102 report step "Removing old files"
1103 for file in files.list.lzma packages.list packages.txt \
1104 packages.desc packages.equiv packages.md5; do
1105 [ -f $file ] && rm $file
1106 done
1107 touch files.list
1109 packages_db_start
1110 unset RECEIPT
1111 report step "Reading datas from all packages"
1112 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1113 get_packages_info
1114 done
1115 report end-step
1116 packages_db_end
1117 report close-bloc
1120 update_packages_db()
1122 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
1123 cd $pkg_repository
1124 for file in packages.list packages.equiv packages.md5 packages.desc \
1125 packages.txt; do
1126 if [ ! -f "$file" ]; then
1127 gen_packages_db
1128 return
1129 fi
1130 done
1131 if [ -f files.list.lzma ]; then
1132 lzma d files.list.lzma files.list
1133 else
1134 gen_packages_db
1135 fi
1136 report step "Updating packages lists: $pkg_repository"
1137 packages_db_start
1139 # Look for removed/update packages.
1140 for PACKAGE in $(grep ^[0-9,a-z,A-Z] packages.txt); do
1141 pkg="$pkg_repository/$(grep -m1 ^$PACKAGE- packages.list).tazpkg"
1142 if ! [ -f "$pkg" ]; then
1143 erase_package_info
1144 else
1145 if [ "$pkg" -nt "packages.list" ]; then
1146 updated_pkg="$updated_pkg
1147 $PACKAGE $pkg"
1148 elif [ ! -f $WOK/$PACKAGE/receipt ] && \
1149 [ "$COMMAND" = check-incoming -o "$pkg_repository" = "$INCOMING_REPOSITORY" ]; then
1150 erase_package_info
1151 echo "Removing $PACKAGE from $pkg_repository."
1152 rm $pkg
1153 [ -d $WOK/$PACKAGE ] && rm -r $WOK/$PACKAGE
1154 if [ "$pkg_repository" = "$INCOMING_REPOSITORY" ]; then
1155 sed "/^$PACKAGE\t/d" -i $wan_db $dep_db
1156 for i in cookorder.txt cooklist commit blocked broken; do
1157 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/$i
1158 done
1159 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
1160 regen_cooklist=yes
1161 else
1162 echo "$PACKAGE" >> $PACKAGES_REPOSITORY/removed
1163 sed -n '1,10p' -i $PACKAGES_REPOSITORY/removed
1164 fi
1165 fi
1166 fi
1167 done
1168 echo "$updated_pkg" | sed 1d | while read PACKAGE pkg; do
1169 erase_package_info
1170 get_packages_info
1171 done
1172 unset updated_pkg
1174 # Look for new packages.
1175 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1176 if ! fgrep -q " ${pkg##*/}" $pkg_repository/packages.md5; then
1177 get_packages_info
1178 fi
1179 done
1180 report end-step
1181 packages_db_end
1184 packages_db_start()
1186 if [ ! -s packages.txt ]; then
1187 echo "# SliTaz GNU/Linux - Packages list
1189 # Packages : unknow
1190 # Date : $(date +%Y-%m-%d\ \%H:%M:%S)
1192 " > packages.txt
1193 else
1194 sed -e 's/^# Packages :.*/# Packages : unknow/' \
1195 -e "s/# Date :.*/# Date : $(date +%Y-%m-%d\ \%H:%M:%S)/" \
1196 -i packages.txt
1197 fi
1199 # Needed in some case as tazwok define RECEIPT at configuration time
1200 # in this particular case it can broke the script.
1201 unset RECEIPT
1204 erase_package_info()
1206 cd $pkg_repository
1207 sed "/^$PACKAGE$/,/^$/d" -i packages.txt
1208 sed "/^$PACKAGE /d" -i packages.desc
1209 sed -e "s/=$PACKAGE /= /" -e "s/ $PACKAGE / /" -e "s/ $PACKAGE$//" \
1210 -e "/=$PACKAGE$/d" -e "s/=[0-9,a-z,A-Z]:$PACKAGE /= /" \
1211 -e "s/ [0-9,a-z,A-Z]:$PACKAGE / /" -e "s/ [0-9,a-z,A-Z]:$PACKAGE$/ /" \
1212 -e "/=[0-9,a-z,A-Z]:$PACKAGE$/d" \
1213 -i packages.equiv
1214 sed "/^$PACKAGE:/d" -i files.list
1215 sed "/^$(basename ${pkg%.tazpkg})$/d" -i packages.list
1216 sed "/ $(basename $pkg)$/d" -i packages.md5
1219 get_packages_info()
1221 # If there's no taz folder in the wok, extract infos from the
1222 # package.
1223 get_pkg_files $pkg
1224 source_receipt
1225 echo "Getting datas from $PACKAGE"
1227 cat >> $pkg_repository/packages.txt << _EOT_
1228 $PACKAGE
1229 $VERSION$EXTRAVERSION
1230 $SHORT_DESC
1231 _EOT_
1232 if [ "$PACKED_SIZE" ]; then
1233 cat >> $pkg_repository/packages.txt << _EOT_
1234 $PACKED_SIZE ($UNPACKED_SIZE installed)
1236 _EOT_
1237 else
1238 echo "" >> $pkg_repository/packages.txt
1239 fi
1241 # Packages.desc is used by Tazpkgbox <tree>.
1242 echo "$PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> $pkg_repository/packages.desc
1244 # Packages.equiv is used by tazpkg install to check depends
1245 for i in $PROVIDE; do
1246 DEST=""
1247 echo $i | fgrep -q : && DEST="${i#*:}:"
1248 if grep -qs ^${i%:*}= $pkg_repository/packages.equiv; then
1249 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" $pkg_repository/packages.equiv
1250 else
1251 echo "${i%:*}=$DEST$PACKAGE" >> $pkg_repository/packages.equiv
1252 fi
1253 done
1255 if [ -f files.list ]; then
1256 { echo "$PACKAGE"; cat files.list; } | awk '
1257 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }' >> $pkg_repository/files.list
1258 fi
1260 cd .. && rm -r "$pkg_files_dir"
1262 cd $pkg_repository
1263 echo $(basename ${pkg%.tazpkg}) >> packages.list
1264 [ ! "$package_md5" ] && package_md5=$(md5sum $(basename $pkg))
1265 echo "$package_md5" >> packages.md5
1266 unset package_md5
1269 source_receipt()
1271 unset PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
1272 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
1273 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
1274 src _pkg DESTDIR CONFIG_SITE BRANCH TARBALL
1275 . ${RECEIPT:-$PWD/receipt}
1278 packages_db_end()
1280 cd $pkg_repository
1281 pkgs=$(wc -l packages.list | sed 's/ .*//')
1282 sed "s/# Packages : .*/# Packages : $pkgs/" -i packages.txt
1284 # If lists was updated it's generally needed to sort them well.
1285 if ! sort -c packages.list 2> /dev/null; then
1286 report step "Sorting packages lists"
1287 for file in packages.list packages.desc packages.equiv; do
1288 [ -f $file ] || continue
1289 sort -o $file $file
1290 done
1291 report end-step
1292 fi
1294 # Dont log this because lzma always output error.
1295 lzma e files.list files.list.lzma
1296 rm -f files.list
1297 [ -f packages.equiv ] || touch packages.equiv
1300 ########################################################################
1301 # This section contains functions to generate wok database.
1302 ########################
1304 gen_wok_db()
1306 report step "Generating wok database"
1307 report open-bloc
1308 report step "Removing old files"
1309 for file in $wan_db $dep_db $PACKAGES_REPOSITORY/cookorder.txt; do
1310 [ -f $file ] && rm $file
1311 done
1312 report step "Generating wok-wanted.txt"
1313 gen_wan_db
1314 report step "Generating wok-depends.txt"
1315 for PACKAGE in $(cut -f1 -d '|' $PACKAGES_REPOSITORY/packages.desc \
1316 $INCOMING_REPOSITORY/packages.desc | sort -u); do
1317 RECEIPT=$WOK/$PACKAGE/receipt
1318 if [ -s $RECEIPT ]; then
1319 source_receipt
1320 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
1321 fi
1322 done
1323 sort_db
1324 report close-bloc
1327 gen_wan_db()
1329 for RECEIPT in $(fgrep -l WANTED $WOK/*/receipt); do
1330 WANTED=
1331 source $RECEIPT
1332 [ "$WANTED" ] || continue
1333 echo -e $PACKAGE"\t"$WANTED >> $tmp/wan_db
1334 done
1335 if ! [ -f $wan_db ] || [ "$(diff -q $tmp/wan_db $wan_db)" ]; then
1336 mv -f $tmp/wan_db $wan_db
1337 plan_regen_cookorder=yes
1338 else
1339 rm $tmp/wan_db
1340 fi
1343 update_wan_db()
1345 local PACKAGE
1346 for RECEIPT in $(fgrep WANTED $WOK/*/receipt | \
1347 fgrep $PACKAGE | cut -f1 -d ':'); do
1348 WANTED=
1349 source $RECEIPT
1350 [ "$WANTED" ] || continue
1351 wan_info=$(echo -e $PACKAGE"\t"$WANTED)
1352 [ "$wan_info" = "$(grep -m1 ^$PACKAGE$'\t' $wan_db 2>/dev/null)" ] && return
1353 sed "/^$PACKAGE\t/d" -i $wan_db
1354 echo "$wan_info" >> $wan_db
1355 plan_regen_cookorder=yes
1356 plan_sort_wandb=yes
1357 done
1360 update_dep_db()
1362 dep_info=$(echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ')
1363 [ "$dep_info" = "$(grep -m1 ^$PACKAGE$'\t' $dep_db 2>/dev/null)" ] && return
1364 sed "/^$PACKAGE\t/d" -i $dep_db
1365 echo "$dep_info" >> $dep_db
1366 plan_regen_cookorder=yes
1367 plan_sort_depdb=yes
1370 sort_db()
1372 report step "Generating cookorder.txt"
1373 cat $dep_db | sed 's/ \t / /' | while read PACKAGE BUILD_DEPENDS; do
1374 grep -q ^$PACKAGE$'\t' $wan_db && continue
1376 # Replace each BUILD_DEPENDS with a WANTED package by it's
1377 # WANTED package.
1378 replace_by_wanted()
1380 for p in $BUILD_DEPENDS; do
1381 if grep -q ^$p$'\t' $wan_db; then
1382 echo -n $(grep ^$p$'\t' $wan_db | cut -f 2)' '
1383 else
1384 echo -n $p' '
1385 fi
1386 done | tr ' ' '\n' | sort -u | sed "/^$PACKAGE$/d" | tr '\n' ' '
1388 echo -e $PACKAGE"\t $(replace_by_wanted) "
1389 done > $tmp/db
1390 while [ -s "$tmp/db" ]; do
1391 status=start
1392 for pkg in $(cut -f 1 $tmp/db); do
1393 if ! fgrep -q ' '$pkg' ' $tmp/db; then
1394 echo $pkg >> $tmp/cookorder
1395 sed -e "/^$pkg\t/d" -e "s/ $pkg / /g" -i $tmp/db
1396 status=proceed
1397 fi
1398 done
1399 if [ "$status" = start ]; then
1400 cp -f $tmp/db /tmp/remain-depends.txt
1401 echo "Can't go further because there's depency(ies) loop(s). The remaining packages will be commentend in the cookorder and will be unbuild in case of major update until the problem is solved." >&2
1402 for blocked in $(cut -f 1 $tmp/db); do
1403 echo "$blocked" >> $PACKAGES_REPOSITORY/blocked
1404 done
1405 break
1406 fi
1407 done
1408 [ -s $tmp/cookorder ] || touch $tmp/cookorder
1410 # The toolchain packages are moved in first position.
1411 grep $(for pkg in `scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1412 --look_for=all --with_args`; do echo " -e ^$pkg$"; done) \
1413 $tmp/cookorder | tac > $PACKAGES_REPOSITORY/cookorder.txt
1414 for pkg in $(cat $PACKAGES_REPOSITORY/cookorder.txt); do
1415 sed "/^$pkg$/d" -i $tmp/cookorder
1416 done
1418 tac $tmp/cookorder >> $PACKAGES_REPOSITORY/cookorder.txt
1419 unset plan_regen_cookorder
1420 report end-step
1423 ########################################################################
1424 # SCAN CORE
1425 ########################
1426 # Include various scan core-functions. It's not intended to be used
1427 # directly : prefer scan wrappers in next section.
1429 look_for_dep()
1431 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1432 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt \
1433 | cut -f 2
1434 else
1435 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1436 cut -f 2
1437 fi
1440 look_for_bdep()
1442 look_for_all
1445 look_for_all()
1447 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1448 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt \
1449 | cut -f 2,3 | sed 's/ / /'
1450 else
1451 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1452 cut -f 2,3 | sed 's/ / /'
1453 fi
1456 look_for_rdep()
1458 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | cut -f 1
1459 if [ "$undigest" ]; then
1460 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt | cut -f 1); do
1461 if [ ! -f "WOK$/$rdep/receipt" ]; then
1462 echo "$rdep"
1463 fi
1464 done
1465 fi
1468 look_for_rbdep()
1470 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | \
1471 cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
1472 if [ "$undigest" ]; then
1473 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt \
1474 | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1); do
1475 if [ ! -f "WOK$/$rdep/receipt" ]; then
1476 echo "$rdep"
1477 fi
1478 done
1479 fi
1482 # Return WANTED if it exists.
1483 look_for_wanted()
1485 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1486 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-wanted.txt | cut -f 2
1487 else
1488 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 2
1489 fi
1492 # Return packages which wants PACKAGE.
1493 look_for_rwanted()
1495 grep $'\t'$PACKAGE$ $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 1
1496 if [ "$undigest" ]; then
1497 for rwanted in $(grep $'\t'$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-wanted.txt | cut -f 1); do
1498 if [ ! -f "$WOK/$rwanted/receipt" ]; then
1499 echo "$rwanted"
1500 fi
1501 done
1502 fi
1505 look_for_dev()
1507 WANTED=$(look_for_wanted)
1508 if [ "$WANTED" ]; then
1509 if [ "$undigest" ] && [ ! -f "$WOK/$WANTED/receipt" ]; then
1510 [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$WANTED-dev/receipt" ] && echo $WANTED-dev
1511 else
1512 [ -f "$WOK/$WANTED-dev/receipt" ] && echo $WANTED-dev
1513 fi
1514 fi
1515 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1516 [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
1517 else
1518 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
1519 fi
1522 with_dev()
1524 for PACKAGE in $(cat); do
1525 echo $PACKAGE
1526 look_for_dev
1527 done
1530 with_wanted()
1532 for PACKAGE in $(cat); do
1533 echo $PACKAGE
1534 look_for_wanted
1535 done
1538 use_wanted()
1540 for input in $(cat); do
1541 { grep ^$input$'\t' $wan_db || echo $input
1542 } | sed 's/.*\t//'
1543 done
1546 ########################################################################
1547 # SCAN
1548 ########################
1549 # Use wok-wanted.txt and wok-depeds.txt to scan depends.
1550 # Option in command line (must be first arg) :
1551 # --look_for=bdep/rbdep - Look for depends or reverse depends.
1552 # --with_dev - Add development packages (*-dev) in the result.
1553 # --with_wanted - Add package+reverse wanted in the result.
1554 # --with_args - Include packages in argument in the result.
1556 scan()
1558 # Get packages in argument.
1559 local PACKAGE WANTED pkg_list=
1560 for arg in $@; do
1561 [ "$arg" = "${arg#--}" ] || continue
1562 pkg_list="$pkg_list $arg"
1563 done
1565 # Get options.
1566 [ "$pkg_list" ] || return
1567 local cooklist= look_for= with_dev= with_wanted= with_args= log_command="$0 $@" \
1568 get_options_list="look_for with_dev with_wanted with_args cooklist use_wanted"
1569 get_options
1571 # Cooklist is a special case where we need to modify a little
1572 # scan behavior
1573 if [ "$cooklist" ]; then
1574 gen_wan_db
1575 look_for=all && with_args=yes && with_dev= && with_wanted=
1576 filter=use_wanted
1577 if [ "$COMMAND" = gen-cooklist ]; then
1578 for PACKAGE in $pkg_list; do
1579 grep -q ^$PACKAGE$'\t' $dep_db && continue
1580 [ -d "$WOK/$p" ] || continue
1581 check_for_missing
1582 done
1583 append_to_dep()
1585 if ! grep -q ^$PACKAGE$'\t' $dep_db; then
1586 check_for_missing && echo $PACKAGE >> $tmp/dep
1587 else
1588 echo $PACKAGE >> $tmp/dep
1589 fi
1591 else
1592 append_to_dep()
1594 check_for_commit && echo $PACKAGE >> $tmp/dep
1596 fi
1597 else
1598 append_to_dep()
1600 echo $PACKAGE >> $tmp/dep
1602 # If requested packages are not in dep_db, partial generation of this db is needed.
1603 for PACKAGE in $pkg_list; do
1604 grep -q ^$PACKAGE$'\t' $dep_db && continue
1605 [ -d "$WOK/$p" ] || continue
1606 plan_check_for_missing=yes
1607 check_for_missing
1608 done
1609 if [ "$plan_check_for_missing" ]; then
1610 append_to_dep()
1612 if ! grep -q ^$PACKAGE$'\t' $dep_db; then
1613 check_for_missing && echo $PACKAGE >> $tmp/dep
1614 else
1615 echo $PACKAGE >> $tmp/dep
1616 fi
1618 check_db_status=yes
1619 unset plan_check_for_missing
1620 fi
1621 fi
1623 [ "$with_dev" ] && filter=with_dev
1624 [ "$with_wanted" ] && filter=with_wanted
1625 if [ "$filter" ]; then
1626 pkg_list=$(echo $pkg_list | $filter)
1627 scan_pkg()
1629 look_for_$look_for | $filter
1631 else
1632 scan_pkg()
1634 look_for_$look_for
1636 fi
1637 touch $tmp/dep
1638 for PACKAGE in $pkg_list; do
1639 [ "$with_args" ] && append_to_dep
1640 scan_pkg
1641 done | tr ' ' '\n' | sort -u > $tmp/list
1642 [ "$look_for" = bdep ] && look_for=dep
1643 while [ -s $tmp/list ]; do
1644 PACKAGE=$(sed 1!d $tmp/list)
1645 sed 1d -i $tmp/list
1646 append_to_dep
1647 for pkg in $(scan_pkg); do
1648 if ! grep -q ^$pkg$ $tmp/list $tmp/dep; then
1649 echo $pkg >> $tmp/list
1650 fi
1651 done
1652 done
1653 if [ "$cooklist" ]; then
1654 mv $tmp/dep $tmp/cooklist
1655 else
1656 cat $tmp/dep | sort -u
1657 fi
1658 rm -f $tmp/dep $tmp/list
1659 if [ "$check_db_status" ]; then
1660 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
1661 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
1662 if [ "$plan_regen_cookorder" ]; then
1663 grep -q "^#" $PACKAGES_REPOSITORY/cookorder.txt || \
1664 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
1665 fi
1666 fi
1669 ########################################################################
1670 # This section contains functions to check package repository and
1671 # find which packages to cook.
1672 ########################
1674 check_for_missing()
1676 local PACKAGE
1677 if ! check_for_pkg_in_wok; then
1678 [ "$?" = 2 ] && return 1
1679 return
1680 fi
1681 RECEIPT=$WOK/$PACKAGE/receipt
1682 source_receipt
1683 PACKAGE=${WANTED:-$PACKAGE}
1684 update_wan_db
1685 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
1686 RECEIPT=$WOK/$PACKAGE/receipt
1687 source_receipt
1688 update_dep_db
1689 done
1692 check_for_commit()
1694 if ! check_for_pkg_in_wok; then
1695 [ "$?" = 2 ] && return 1
1696 return
1697 fi
1698 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
1699 RECEIPT=$WOK/$PACKAGE/receipt
1700 source_receipt
1702 # We use md5 of cooking stuff in the packaged receipt to check
1703 # commit. We look consecutively in 3 different locations :
1704 # - in the wok/PACKAGE/taz/* folder
1705 # - in the receipt in the package in incoming repository
1706 # - in the receipt in the package in packages repository
1707 # If md5sum match, there's no commit.
1708 check_for_commit_using_md5sum()
1710 if [ ! -f $WOK/$PACKAGE/md5 ]; then
1711 sed -n '/# md5sum of cooking stuff :/,$p' receipt | \
1712 sed -e 1d -e 's/^# //' > $WOK/$PACKAGE/md5
1713 cd $WOK/$PACKAGE
1714 fi
1716 if [ -s md5 ]; then
1717 if md5sum -cs md5; then
1719 # If md5sum check if ok, check for new/missing files in
1720 # cooking stuff.
1721 for file in $([ -f receipt ] && echo receipt; \
1722 [ -f description.txt ] && echo description.txt; \
1723 [ -d stuff ] && find stuff); do
1724 if ! fgrep -q " $file" md5; then
1725 set_commited
1726 fi
1727 done
1728 else
1729 set_commited
1730 fi
1731 else
1732 set_commited
1733 fi
1735 set_commited()
1737 ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/commit &&
1738 echo $PACKAGE >> $PACKAGES_REPOSITORY/commit
1739 gen_cookmd5
1740 update_dep_db
1742 taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | fgrep -v '*')
1743 if [ -f $WOK/$PACKAGE/md5 ]; then
1744 cd $WOK/$PACKAGE
1745 check_for_commit_using_md5sum
1746 elif [ "$taz_dir" ]; then
1747 cd $taz_dir
1748 check_for_commit_using_md5sum
1749 else
1750 pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1751 [ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1752 if [ "$pkg" ]; then
1753 get_pkg_files $pkg
1754 check_for_commit_using_md5sum
1755 rm -r $pkg_files_dir
1756 else
1757 set_commited
1758 fi
1759 fi
1760 [ "$forced" ] || echo $PACKAGE >> $tmp/checked
1761 done
1762 return
1765 gen_cook_list()
1767 report step "Scanning wok"
1768 if [ "$pkg" ]; then
1769 scan $pkg --cooklist
1770 else
1771 scan `cat $cooklist` --cooklist
1772 fi
1773 report end-step
1775 [ -s $tmp/checked ] || [ -s $tmp/cooklist ] || return
1777 # Core toolchain should not be cooked unless cook-toolchain is used.
1778 if ! [ -f /etc/config.site.tmptoolchain ] ; then
1779 for PACKAGE in $(scan gcc --look_for=all --with_args --with_wanted); do
1780 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/blocked || \
1781 echo $PACKAGE >> $PACKAGES_REPOSITORY/blocked
1782 done
1783 fi
1785 if [ -s $PACKAGES_REPOSITORY/commit ] && [ "$COMMAND" != gen-cooklist ]; then
1786 cd $PACKAGES_REPOSITORY
1787 for PACKAGE in $(cat commit); do
1788 WANTED="$(look_for_wanted)"
1789 if [ "$WANTED" ]; then
1790 grep -q ^$WANTED$ broken cooklist blocked commit && continue
1791 fi
1792 grep -q ^$PACKAGE$ blocked cooklist && continue
1793 echo $PACKAGE >> cooklist
1794 done
1795 fi
1796 sort_cooklist
1799 sort_cooklist()
1801 if [ "$(sed 1!d $PACKAGES_REPOSITORY/cookorder.txt)" = "#PlanSort" ]; then
1802 sed 1d -i $PACKAGES_REPOSITORY/cookorder.txt
1803 plan_regen_cookorder=yes
1804 fi
1805 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
1806 [ "$plan_regen_cookorder" ] && sort_db
1807 report step "Sorting cooklist"
1808 if [ -f "$tmp/checked" ]; then
1809 rm -f $tmp/cooklist
1810 cat $tmp/checked | while read PACKAGE; do
1811 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/cooklist && \
1812 echo $PACKAGE >> $tmp/cooklist
1813 done
1814 elif ! [ "$COMMAND" = gen-cooklist ]; then
1815 cat $PACKAGES_REPOSITORY/blocked | while read PACKAGE; do
1816 sed "/^$PACKAGE/d" -i $tmp/cooklist
1817 done
1818 fi
1820 for PACKAGE in $(cat $tmp/cooklist); do
1821 WANTED="$(look_for_wanted)"
1822 [ "$WANTED" ] || continue
1823 if grep -q ^$WANTED$ $PACKAGES_REPOSITORY/broken $tmp/cooklist; then
1824 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1825 elif [ ! -d $WOK/$WANTED/install ]; then
1826 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1827 echo $WANTED >> $tmp/cooklist
1828 fi
1829 done
1831 # Use cookorder.txt to sort cooklist.
1832 if [ -s $tmp/cooklist ]; then
1833 cat $PACKAGES_REPOSITORY/cookorder.txt | while read PACKAGE; do
1834 if grep -q ^$PACKAGE$ $tmp/cooklist; then
1835 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1836 echo $PACKAGE >> $tmp/cooklist.tmp
1837 fi
1838 done
1840 # Remaining packages in cooklist are thoses without compile_rules.
1841 # They can be cooked first in any order.
1842 if [ -f $tmp/cooklist.tmp ]; then
1843 cat $tmp/cooklist.tmp >> $tmp/cooklist
1844 rm $tmp/cooklist.tmp
1845 fi
1847 cat $tmp/cooklist
1848 [ "$cooklist" = "$PACKAGES_REPOSITORY/cooklist" ] && \
1849 cat $tmp/cooklist > $cooklist
1850 fi
1852 report end-step
1855 check_for_incoming()
1857 [ -s $INCOMING_REPOSITORY/packages.desc ] || {
1858 echo "No packages in $INCOMING_REPOSITORY."
1859 return; }
1860 if [ -s $PACKAGES_REPOSITORY/broken ]; then
1861 echo "Don't move incoming packages to main repository because theses ones are broken:
1862 $(cat $PACKAGES_REPOSITORY/broken)" >&2
1863 return
1864 fi
1865 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
1866 echo "Don't move incoming packages to main repository because some of them need to be cooked:
1867 $(cat $PACKAGES_REPOSITORY/cooklist)" >&2
1868 return
1869 fi
1870 pkg="$(cut -f 1 -d '|' $INCOMING_REPOSITORY/packages.desc)"
1871 if ! [ "$forced" ]; then
1872 cooklist=$PACKAGES_REPOSITORY/cooklist
1873 gen_cook_list
1874 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
1875 echo "Don't move incoming packages to main repository because some of them need to be cooked." >&2
1876 return
1877 fi
1878 fi
1879 report step "Moving incoming packages to main repository"
1880 unset EXTRAVERSION
1881 for PACKAGE in $pkg; do
1882 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
1883 VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
1884 remove_previous_package $PACKAGES_REPOSITORY
1885 echo "Moving $PACKAGE..."
1886 mv -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION.tazpkg $PACKAGES_REPOSITORY
1887 touch $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
1888 previous_tarball=$(grep ^$PACKAGE:main $SOURCES_REPOSITORY/sources.list | cut -f2)
1889 sed -e "/^$PACKAGE:main/d" \
1890 -e "s/^$PACKAGE:incoming/$PACKAGE:main/"
1891 -i $SOURCES_REPOSITORY/sources.list
1892 if [ "$previous_tarball" ]; then
1893 grep -q $'\t'$previous_tarball$ $SOURCES_REPOSITORY/sources.list || \
1894 rm -f $SOURCES_REPOSITORY/$previous_tarball
1895 fi
1896 done
1897 report end-step
1898 for file in packages.list packages.equiv packages.md5 packages.desc \
1899 packages.txt; do
1900 echo -n "" > $INCOMING_REPOSITORY/$file
1901 done
1902 rm -r $INCOMING_REPOSITORY/files.list.lzma
1903 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
1906 ########################################################################
1907 # TAZWOK MAIN FUNCTIONS
1908 ########################
1910 clean()
1912 cd $WOK/$PACKAGE
1913 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
1914 -e ^stuff$ || return
1916 [ "$COMMAND" = clean-wok ] || report step "Cleaning $PACKAGE"
1917 # Check for clean_wok function.
1918 if grep -q ^clean_wok $RECEIPT; then
1919 clean_wok
1920 fi
1921 # Clean should only have a receipt, stuff and optional desc.
1922 for f in `ls .`
1923 do
1924 case $f in
1925 receipt|stuff|description.txt|md5)
1926 continue ;;
1927 *)
1928 rm -rf $f ;;
1929 esac
1930 done
1931 [ "$COMMAND" != clean-wok ] && report end-step
1934 # Configure and make a package with the receipt.
1935 compile_package()
1937 check_for_package_on_cmdline
1939 # Include the receipt to get all needed variables and functions
1940 # and cd into the work directory to start the work.
1941 check_for_receipt
1942 source_receipt
1944 # Log the package name and date.
1945 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
1946 echo "package $PACKAGE (compile)" >> $LOG
1948 # Set wanted $src variable to help compiling.
1949 [ ! "$src" ] && set_src_path
1950 check_for_build_depends || return 1
1951 check_for_wanted
1952 unset target
1953 check_for_tarball && check_for_compile_rules
1956 # Cook command also include all features to manage lists which keep
1957 # track of wok/packages state.
1958 cook()
1960 cook_code=
1961 set_common_path
1962 check_for_receipt
1963 source_receipt
1965 # Define log path and start report.
1966 [ -f $LOCAL_REPOSITORY/log/$PACKAGE.html ] && rm $LOCAL_REPOSITORY/log/$PACKAGE.html
1967 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
1968 report step "Cooking $PACKAGE"
1969 report open-bloc
1971 clean $PACKAGE
1972 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
1974 if compile_package; then
1975 remove_src
1976 refresh_packages_from_compile
1977 gen_package
1979 # Update packages-incoming repository.
1980 store_pkgname=$PACKAGE
1981 pkg_repository=$INCOMING_REPOSITORY
1982 update_packages_db
1984 PACKAGE=$store_pkgname
1985 unset store_pkgname
1987 # Upgrade to cooked packages if it was previously installed.
1988 report step "Look for package(s) to upgrade"
1989 for pkg in $(look_for_rwanted) $PACKAGE; do
1990 if [ -d $INSTALLED/$pkg ]; then
1991 tazpkg get-install $pkg --forced
1992 fi
1993 done
1994 report end-step
1995 else
1997 # Set package as broken.
1998 if ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then
1999 echo $PACKAGE >> $PACKAGES_REPOSITORY/broken
2000 fi
2001 gen_cookmd5
2002 cook_code=1
2003 fi
2005 # Remove build_depends in cook mode (if in cooklist, it's done when
2006 # checking build_depends of next package and we remove only unneeded
2007 # packages to keep chroot minimal and gain some time).
2008 if [ "$COMMAND" = cook ]; then
2009 remove_build_depends $MISSING_PACKAGE
2010 [ -x /usr/bin/clean-chroot ] && clean-chroot
2011 fi
2013 # Regen the cooklist if it was planned and command is not cook.
2014 [ "$regen_cooklist" ] && unset regen_cooklist && \
2015 [ "$COMMAND" != cook ] && sort_cooklist
2017 # Some hacks to set the bloc & function status as failed if cook was
2018 # failed.
2019 report_return_code=$cook_code
2020 report close-bloc
2021 report end-sublog
2022 return $cook_code
2025 cook_list()
2027 if [ -s $tmp/cooklist ]; then
2028 if [ -f /usr/bin/tazchroot ]; then
2029 # Note : options -main variables- are automatically keeped by
2030 # the sub-applications tazchroot/tazwok; as well as report data.
2031 cd $LOCAL_REPOSITORY
2032 [ ! -f tazchroot.conf ] && configure_tazchroot
2033 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
2034 return
2035 fi
2036 while [ -s $tmp/cooklist ]; do
2037 PACKAGE=$(sed 1!d $tmp/cooklist)
2038 cook
2039 done
2040 remove_build_depends $MISSING_PACKAGE $remove_later
2041 [ -x /usr/bin/clean-chroot ] && clean-chroot
2042 else
2043 echo "Nothing to cook."
2044 return
2045 fi
2048 configure_tazchroot()
2050 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
2051 # Tazchroot configuration file - created by tazwok.
2053 # Default chroot path
2054 SLITAZ_DIR=$SLITAZ_DIR
2055 SLITAZ_VERSION=$SLITAZ_VERSION
2056 $( [ "$undigest" ] && echo "undigest=$undigest" )
2057 LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
2058 chroot_dir=\$LOCAL_REPOSITORY/chroot
2060 # Default scripts path (theses scripts are added in the
2061 # $chroot_dir/usr/bin and can be called with tazchroot script)
2062 script_dir=/var/lib/tazchroot
2064 # List of directories to mount.
2065 list_dir="$(for dir in packages wok src packages-incoming log flavors iso; do echo $LOCAL_REPOSITORY/$dir; done)
2066 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
2068 create_chroot()
2070 mkdir -p \$chroot_dir
2071 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
2072 tazpkg get-install \$pkg --root="\$chroot_dir"
2073 done
2075 # Store list of installed packages needed by cleanchroot.
2076 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
2078 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
2079 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
2080 -i \$chroot_dir/etc/slitaz/slitaz.conf
2081 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
2082 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
2085 mount_chroot()
2087 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
2088 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCALSTATE/mirror
2089 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
2090 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
2091 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION
2092 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror' )
2093 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
2094 mount -t proc proc \$chroot_dir/proc
2095 mount -t sysfs sysfs \$chroot_dir/sys
2096 mount -t devpts devpts \$chroot_dir/dev/pts
2097 mount -t tmpfs shm \$chroot_dir/dev/shm
2098 for dir in \$list_dir; do
2099 mkdir -p \$dir \$chroot_dir\$dir
2100 mount \$dir \$chroot_dir\$dir
2101 done
2104 umount_chroot()
2106 for dir in \$list_dir; do
2107 umount \$chroot_dir\$dir
2108 done
2109 umount \$chroot_dir/dev/shm
2110 umount \$chroot_dir/dev/pts
2111 umount \$chroot_dir/sys
2112 umount \$chroot_dir/proc
2114 EOF
2117 ########################################################################
2118 ######################### END OF NEW FUNCTIONS #########################
2119 ########################################################################
2121 # List packages providing a virtual package
2122 whoprovide()
2124 local i;
2125 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
2126 . $i
2127 case " $PROVIDE " in
2128 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
2129 esac
2130 done
2133 ########################################################################
2134 # TAZWOK COMMANDS
2135 ########################
2137 case "$COMMAND" in
2138 stats)
2139 # Tazwok general statistics from the wok config file.
2141 get_tazwok_config
2142 echo -e "\n\033[1mTazwok configuration statistics\033[0m
2143 ================================================================================
2144 Wok directory : $WOK
2145 Packages repository : $PACKAGES_REPOSITORY
2146 Incoming repository : $INCOMING_REPOSITORY
2147 Sources repository : $SOURCES_REPOSITORY
2148 Log directory : $LOCAL_REPOSITORY/log
2149 Packages in the wok : `ls -1 $WOK | wc -l`
2150 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2151 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2152 ================================================================================\n"
2153 ;;
2154 edit)
2155 get_tazwok_config
2156 check_for_package_on_cmdline
2157 check_for_receipt
2158 $EDITOR $WOK/$PACKAGE/receipt
2159 ;;
2160 build-depends)
2161 # List dependencies to rebuild wok, or only a package
2162 get_tazwok_config
2163 report(){ : ; }
2164 if [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
2165 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
2166 --look_for=dep --with_dev --with_args
2167 else
2168 check_for_package_on_cmdline
2169 scan $PACKAGE --look_for=bdep --with_dev
2170 fi
2171 ;;
2172 gen-cooklist)
2173 check_root
2174 get_options_list="pkg"
2175 get_tazwok_config
2176 report(){ : ; }
2177 if ! [ "$pkg" ]; then
2178 if [ ! "$LIST" ] || [ "$LIST" = toolchain ]; then
2179 pkg="$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA"
2180 else
2181 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2182 fi
2183 fi
2184 gen_cook_list
2185 ;;
2186 check-depends)
2187 # Check package depends /!\
2188 get_tazwok_config
2189 echo ""
2190 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
2191 ================================================================================"
2192 TMPDIR=/tmp/tazwok$$
2193 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
2195 # Build ALL_DEPENDS variable
2196 scan_dep()
2198 local i
2199 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
2200 for i in $DEPENDS $SUGGESTED ; do
2201 case " $ALL_DEPENDS " in
2202 *\ $i\ *) continue;;
2203 esac
2204 [ -d $WOK/$i ] || {
2205 ALL_DEPENDS="$ALL_DEPENDS$i "
2206 continue
2208 DEPENDS=""
2209 SUGGESTED=""
2210 . $WOK/$i/receipt
2211 scan_dep
2212 done
2215 # Check for ELF file
2216 is_elf()
2218 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" \
2219 = "ELF" ]
2222 # Print shared library dependencies
2223 ldd()
2225 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
2228 mkdir $TMPDIR
2229 cd $TMPDIR
2230 for i in $LOCALSTATE/files.list.lzma \
2231 $LOCALSTATE/undigest/*/files.list.lzma ; do
2232 [ -f $i ] && lzma d $i -so >> files.list
2233 done
2234 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
2235 tazpkg extract $pkg > /dev/null 2>&1
2236 . */receipt
2237 ALL_DEPENDS="$DEFAULT_DEPENDS "
2238 scan_dep
2239 find */fs -type f | while read file ; do
2240 is_elf $file || continue
2241 case "$file" in
2242 *.o|*.ko|*.ko.gz) continue;;
2243 esac
2244 ldd $file | while read lib rem; do
2245 case "$lib" in
2246 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
2247 continue;;
2248 esac
2249 for dep in $(fgrep $lib files.list | cut -d: -f1); do
2250 case " $ALL_DEPENDS " in
2251 *\ $dep\ *) continue 2;;
2252 esac
2253 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
2254 case " $ALL_DEPENDS " in
2255 *\ $vdep\ *) continue 3;;
2256 esac
2257 done
2258 done
2259 [ -n "$dep" ] || dep="UNKNOWN"
2260 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
2261 done
2262 done
2263 rm -rf */
2264 done
2265 cd /tmp
2266 rm -rf $TMPDIR
2267 ;;
2268 check)
2269 # Check wok consistency
2270 get_tazwok_config
2271 echo ""
2272 echo -e "\033[1mWok and packages checking\033[0m
2273 ================================================================================"
2274 cd $WOK
2275 for pkg in $(ls)
2276 do
2277 [ -f $pkg/receipt ] || continue
2278 RECEIPT= $pkg/receipt
2279 source_receipt
2280 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
2281 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
2282 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
2283 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
2284 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
2285 if [ -n "$WANTED" ]; then
2286 if [ ! -f $WANTED/receipt ]; then
2287 echo "Package $PACKAGE wants unknown $WANTED package" >&2
2288 else
2289 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
2290 if [ "$VERSION" = "$WANTED" ]; then
2291 # BASEVERSION is computed in receipt
2292 fgrep -q '_pkg=' $pkg/receipt &&
2293 BASEVERSION=$VERSION
2294 fi
2295 if [ "$VERSION" != "$BASEVERSION" ]; then
2296 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
2297 fi
2298 fi
2299 fi
2301 if [ -n "$CATEGORY" ]; then
2302 case " $(echo $CATEGORIES) " in
2303 *\ $CATEGORY\ *);;
2304 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
2305 esac
2306 else
2307 echo"Package $PACKAGE has no CATEGORY" >&2
2308 fi
2309 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
2310 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
2311 case "$WGET_URL" in
2312 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
2313 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
2314 '') ;;
2315 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
2316 esac
2317 case "$WEB_SITE" in
2318 ftp*|http*);;
2319 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
2320 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
2321 esac
2322 case "$MAINTAINER" in
2323 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
2324 esac
2325 case "$MAINTAINER" in
2326 *@*);;
2327 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
2328 esac
2329 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2330 for i in $DEPENDS; do
2331 [ -d $i ] && continue
2332 [ -n "$(whoprovide $i)" ] && continue
2333 echo -e "$MSG $i"
2334 MSG=""
2335 done
2336 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2337 for i in $BUILD_DEPENDS; do
2338 [ -d $i ] && continue
2339 [ -n "$(whoprovide $i)" ] && continue
2340 echo -e "$MSG $i"
2341 MSG=""
2342 done
2343 MSG="Dependencies loop between $PACKAGE and :\n"
2344 ALL_DEPS=""
2345 check_for_deps_loop $PACKAGE $DEPENDS
2346 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
2347 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
2348 echo "$pkg should be rebuilt after $i installation"
2349 done
2350 done
2351 ;;
2352 list)
2353 # List packages in wok directory. User can specify a category.
2355 get_tazwok_config
2356 if [ "$2" = "category" ]; then
2357 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
2358 exit 0
2359 fi
2360 # Check for an asked category.
2361 if [ -n "$2" ]; then
2362 ASKED_CATEGORY=$2
2363 echo ""
2364 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
2365 echo "================================================================================"
2366 for pkg in $WOK/*
2367 do
2368 [ ! -f $pkg/receipt ] && continue
2369 . $pkg/receipt
2370 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
2371 echo -n "$PACKAGE"
2372 echo -e "\033[28G $VERSION"
2373 packages=$(($packages+1))
2374 fi
2375 done
2376 echo "================================================================================"
2377 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
2378 else
2379 # By default list all packages and version.
2380 echo ""
2381 echo -e "\033[1mList of packages in the wok\033[0m"
2382 echo "================================================================================"
2383 for pkg in $WOK/*
2384 do
2385 [ ! -f $pkg/receipt ] && continue
2386 . $pkg/receipt
2387 echo -n "$PACKAGE"
2388 echo -en "\033[28G $VERSION"
2389 echo -e "\033[42G $CATEGORY"
2390 packages=$(($packages+1))
2391 done
2392 echo "================================================================================"
2393 echo -e "$packages packages available in the wok.\n"
2394 fi
2395 ;;
2396 info)
2397 # Information about a package.
2399 get_tazwok_config
2400 check_for_package_on_cmdline
2401 check_for_receipt
2402 . $WOK/$PACKAGE/receipt
2403 echo ""
2404 echo -e "\033[1mTazwok package information\033[0m
2405 ================================================================================
2406 Package : $PACKAGE
2407 Version : $VERSION
2408 Category : $CATEGORY
2409 Short desc : $SHORT_DESC
2410 Maintainer : $MAINTAINER"
2411 if [ ! "$WEB_SITE" = "" ]; then
2412 echo "Web site : $WEB_SITE"
2413 fi
2414 if [ ! "$DEPENDS" = "" ]; then
2415 echo "Depends : $DEPENDS"
2416 fi
2417 if [ ! "$WANTED" = "" ]; then
2418 echo "Wanted src : $WANTED"
2419 fi
2420 echo "================================================================================"
2421 echo ""
2422 ;;
2423 check-log)
2424 # We just cat the file log to view process info.
2426 get_tazwok_config
2427 if [ ! -f "$LOG" ]; then
2428 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
2429 exit 1
2430 else
2431 echo ""
2432 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
2433 echo "================================================================================"
2434 cat $LOG
2435 echo "================================================================================"
2436 echo ""
2437 if [ -s "$WOK/$PACKAGE/warning.txt" ]; then
2438 echo -e "\033[1mCook warning(s) for :\033[0m $PACKAGE"
2439 echo "================================================================================"
2440 cat "$WOK/$PACKAGE/warning.txt"
2441 echo "================================================================================"
2442 echo ""
2443 fi
2444 fi
2445 ;;
2446 search)
2447 # Search for a package by pattern or name.
2449 get_tazwok_config
2450 if [ -z "$2" ]; then
2451 echo -e "\nPlease specify a pattern or a package name to search." >&2
2452 echo -e "Example : 'tazwok search gcc'.\n" >&2
2453 exit 1
2454 fi
2455 echo ""
2456 echo -e "\033[1mSearch result for :\033[0m $2"
2457 echo "================================================================================"
2458 list=`ls -1 $WOK | fgrep $2`
2459 for pkg in $list
2460 do
2461 . $WOK/$pkg/receipt
2462 echo -n "$PACKAGE "
2463 echo -en "\033[24G $VERSION"
2464 echo -e "\033[42G $CATEGORY"
2465 packages=$(($PACKAGEs+1))
2466 done
2467 echo "================================================================================"
2468 echo "$packages packages found for : $2"
2469 echo ""
2470 ;;
2471 compile)
2472 # Configure and make a package with the receipt.
2474 get_tazwok_config
2475 source_lib report
2476 report start
2477 compile_package
2478 ;;
2479 genpkg)
2480 # Generate a package.
2482 get_tazwok_config
2483 source_lib report
2484 report start
2485 gen_package
2486 ;;
2487 cook)
2488 # Compile and generate a package. Just execute tazwok with
2489 # the good commands.
2491 check_root
2492 get_tazwok_config
2493 source_lib report
2494 report start
2495 update_wan_db
2496 check_for_commit
2497 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
2498 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
2499 if [ "$plan_regen_cookorder" ]; then
2500 grep -q "^#" $PACKAGES_REPOSITORY/cookorder.txt || \
2501 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
2502 fi
2503 cook
2504 ;;
2505 sort-cooklist)
2506 if [ ! "$LIST" ]; then
2507 echo "Usage : tazwok sort-cooklist cooklist" >&2\
2508 exit 1
2509 fi
2510 get_tazwok_config
2511 source_lib report
2512 report start
2513 cooklist=$LIST
2514 sort_cooklist
2515 cp -af $tmp/cooklist $cooklist
2516 ;;
2517 cook-list)
2518 # Cook all packages listed in a file or in default cooklist.
2519 check_root
2520 get_options_list="pkg forced"
2521 get_tazwok_config
2522 source_lib report
2523 report start
2524 if ! [ "$pkg" ]; then
2525 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2526 fi
2527 gen_cook_list
2528 cook_list
2529 ;;
2530 clean)
2531 # Clean up a package work directory + thoses which want it.
2533 get_tazwok_config
2534 check_for_package_on_cmdline
2535 check_for_receipt
2536 source_lib report
2537 report start
2538 . $RECEIPT
2539 clean
2540 ;;
2541 gen-clean-wok)
2542 # Generate a clean wok from the current wok by copying all receipts
2543 # and stuff directory.
2545 get_tazwok_config
2546 source_lib report
2547 report start
2548 if [ -z "$ARG" ]; then
2549 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
2550 exit 1
2551 else
2552 dest=$ARG
2553 mkdir -p $dest
2554 fi
2555 report step "Creating clean wok in : $dest"
2556 for pkg in `ls -1 $WOK`
2557 do
2558 mkdir -p $dest/$pkg
2559 cp -a $WOK/$pkg/receipt $dest/$pkg
2560 [ -f $WOK/$pkg/description.txt ] && \
2561 cp -a $WOK/$pkg/description.txt $dest/$pkg
2562 if [ -d "$WOK/$pkg/stuff" ]; then
2563 cp -a $WOK/$pkg/stuff $dest/$pkg
2564 fi
2565 done
2566 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
2567 report end-step
2568 echo "Packages cleaned : `ls -1 $dest | wc -l`"
2569 echo ""
2570 ;;
2571 clean-wok)
2572 # Clean all packages in the work directory
2574 get_tazwok_config
2575 source_lib report
2576 report start
2577 report step "Cleaning wok"
2578 for PACKAGE in `ls -1 $WOK`
2579 do
2580 set_common_path
2581 source_receipt
2582 clean
2583 done
2584 echo "`ls -1 $WOK | wc -l` packages cleaned."
2585 ;;
2586 clean-src)
2587 # Remove tarball unrelated to wok receipts from src repo.
2588 check_root
2589 get_options_list="forced"
2590 get_tazwok_config
2591 cd $SOURCES_REPOSITORY
2592 echo -n "Checking $SOURCES_REPOSITORY..."
2593 for TARBALL in *; do
2594 [ "$TARBALL" = sources.list ] && continue
2595 grep -q $'\t'$TARBALL$ $SOURCES_REPOSITORY/sources.list || \
2596 echo $TARBALL >> $tmp/obsolete
2597 done
2598 status
2599 echo ""
2600 echo -e "\033[1mObsolete/unrelated-to-wok sourcess :\033[0m"
2601 horizontal_line
2602 cat $tmp/obsolete
2603 horizontal_line
2604 echo "$(wc -l $tmp/obsolete | cut -f1 -d' ') tarballs to remove."
2605 echo ""
2606 echo -n "Please confirm removing (type uppercase YES): "
2607 read answer
2608 if [ "$answer" = YES ]; then
2609 echo -n "Removing old sources..."
2610 cat $tmp/obsolete | while read i; do
2611 rm -f $SOURCES_REPOSITORY/$i
2612 done
2613 status
2614 fi
2615 ;;
2616 gen-list)
2617 get_tazwok_config
2618 if [ "$2" ]; then
2619 if [ -d "$2" ]; then
2620 pkg_repository=$2
2621 else
2622 echo -e "\nUnable to find directory : $2\n" >&2
2623 exit 1
2624 fi
2625 fi
2627 source_lib report
2628 report start
2629 if [ "$pkg_repository" ]; then
2630 gen_packages_db
2631 else
2632 pkg_repository=$PACKAGES_REPOSITORY && gen_packages_db
2633 pkg_repository=$INCOMING_REPOSITORY && gen_packages_db
2634 fi
2635 ;;
2636 check-list)
2637 # The directory to move into by default is the repository,
2638 # if $2 is not empty cd into $2.
2640 get_tazwok_config
2641 if [ "$2" ]; then
2642 if [ -d "$2" ]; then
2643 pkg_repository=$2
2644 else
2645 echo -e "\nUnable to find directory : $2\n" >&2
2646 exit 1
2647 fi
2648 fi
2650 source_lib report
2651 report start
2652 if [ "$pkg_repository" ]; then
2653 update_packages_db
2654 else
2655 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
2656 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
2657 fi
2658 ;;
2659 new-tree)
2660 # Just create a few directories and generate an empty receipt to prepare
2661 # the creation of a new package.
2663 get_tazwok_config
2664 check_for_package_on_cmdline
2665 if [ -d $WOK/$PACKAGE ]; then
2666 echo -e "\n$PACKAGE package tree already exists.\n" >&2
2667 exit 1
2668 fi
2669 echo "Creating : $WOK/$PACKAGE"
2670 mkdir $WOK/$PACKAGE
2671 cd $WOK/$PACKAGE
2672 echo -n "Preparing the receipt..."
2674 # Default receipt begin.
2676 echo "# SliTaz package receipt." > receipt
2677 echo "" >> receipt
2678 echo "PACKAGE=\"$PACKAGE\"" >> receipt
2679 # Finish the empty receipt.
2680 cat >> receipt << "EOF"
2681 VERSION=""
2682 CATEGORY=""
2683 SHORT_DESC=""
2684 MAINTAINER=""
2685 DEPENDS=""
2686 TARBALL="$PACKAGE-$VERSION.tar.gz"
2687 WEB_SITE=""
2688 WGET_URL=""
2690 # Rules to configure and make the package.
2691 compile_rules()
2693 cd $src
2694 ./configure && make && make install
2697 # Rules to gen a SliTaz package suitable for Tazpkg.
2698 genpkg_rules()
2700 mkdir -p $fs/usr
2701 cp -a $_pkg/usr/bin $fs/usr
2704 EOF
2706 # Default receipt end.
2708 status
2709 # Interactive mode, asking and seding.
2710 if [ "$3" = "--interactive" ]; then
2711 echo "Entering into interactive mode..."
2712 echo "================================================================================"
2713 echo "Package : $PACKAGE"
2714 # Version.
2715 echo -n "Version : " ; read anser
2716 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
2717 # Category.
2718 echo -n "Category : " ; read anser
2719 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
2720 # Short description.
2721 echo -n "Short desc : " ; read anser
2722 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
2723 # Maintainer.
2724 echo -n "Maintainer : " ; read anser
2725 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
2726 # Web site.
2727 echo -n "Web site : " ; read anser
2728 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
2729 echo ""
2730 # Wget URL.
2731 echo "Wget URL to download source tarball."
2732 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
2733 echo -n "Wget url : " ; read anser
2734 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
2735 # Ask for a stuff dir.
2736 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
2737 if [ "$anser" = "y" ]; then
2738 echo -n "Creating the stuff directory..."
2739 mkdir stuff && status
2740 fi
2741 # Ask for a description file.
2742 echo -n "Are you going to write a description ? (y/N) : " ; read anser
2743 if [ "$anser" = "y" ]; then
2744 echo -n "Creating the description.txt file..."
2745 echo "" > description.txt && status
2746 fi
2747 echo "================================================================================"
2748 echo ""
2749 fi
2750 ;;
2751 remove)
2752 # Remove a package from the wok.
2754 get_tazwok_config
2755 check_for_package_on_cmdline
2756 echo ""
2757 echo -n "Please confirm deletion (y/N) : "; read anser
2758 if [ "$anser" = "y" ]; then
2759 echo -n "Removing $PACKAGE..."
2760 rm -rf $WOK/$PACKAGE && status
2761 echo ""
2762 fi
2763 ;;
2764 hgup)
2765 # Pull and update a Hg wok.
2766 get_tazwok_config
2767 if ls -l $WOK/.hg/hgrc | fgrep -q "root"; then
2768 check_root
2769 fi
2770 cd $WOK
2771 hg pull && hg update
2772 ;;
2773 maintainers)
2774 get_tazwok_config
2775 echo ""
2776 echo "List of maintainers for: $WOK"
2777 echo "================================================================================"
2778 touch /tmp/slitaz-maintainers
2779 for pkg in $WOK/*
2780 do
2781 . $pkg/receipt
2782 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
2783 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
2784 echo "$MAINTAINER"
2785 fi
2786 done
2787 echo "================================================================================"
2788 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
2789 echo ""
2790 # Remove tmp files
2791 rm -f /tmp/slitaz-maintainers
2792 ;;
2793 maintained-by)
2794 # Search for packages maintained by a contributor.
2795 get_tazwok_config
2796 if [ ! -n "$2" ]; then
2797 echo "Specify a name or email of a maintainer." >&2
2798 exit 1
2799 fi
2800 echo "Maintainer packages"
2801 echo "================================================================================"
2802 for pkg in $WOK/*
2803 do
2804 . $pkg/receipt
2805 if echo "$MAINTAINER" | fgrep -q "$2"; then
2806 echo "$PACKAGE"
2807 packages=$(($PACKAGEs+1))
2808 fi
2809 done
2810 echo "================================================================================"
2811 echo "Packages maintained by $2: $PACKAGEs"
2812 echo ""
2813 ;;
2814 tags)
2815 get_tazwok_config
2816 echo -e "\n\033[1mTags list :\033[0m"
2817 horizontal_line
2818 cd $WOK
2819 for i in */receipt; do
2820 unset TAGS
2821 source $i
2822 for t in $TAGS; do
2823 grep -q ^$t$ $tmp/tags && continue
2824 echo $t | tee -a $tmp/tags
2825 done
2826 done
2827 horizontal_line
2828 echo "$(wc -l $tmp/tags | cut -f1 -d ' ') tags listed."
2829 ;;
2830 check-src)
2831 # Verify if upstream package is still available
2833 get_tazwok_config
2834 check_for_package_on_cmdline
2835 check_for_receipt
2836 source_receipt
2837 check_src()
2839 for url in $@; do
2840 busybox wget -s $url 2>/dev/null && break
2841 done
2843 if [ "$WGET_URL" ];then
2844 echo -n "$PACKAGE : "
2845 check_src $WGET_URL
2846 status
2847 else
2848 echo "No tarball to check for $PACKAGE"
2849 fi
2850 ;;
2851 get-src)
2852 check_root
2853 get_options_list="target nounpack"
2854 get_tazwok_config
2855 check_for_package_on_cmdline
2856 check_for_receipt
2857 source_receipt
2858 if [ "$WGET_URL" ];then
2859 source_lib report
2860 report start
2861 check_for_tarball
2862 else
2863 echo "No tarball to download for $PACKAGE"
2864 fi
2865 ;;
2866 check-commit)
2867 check_root
2868 get_options_list="missing forced"
2869 get_tazwok_config
2870 source_lib report
2871 report start
2872 if [ "$forced" ]; then
2873 rm -f $WOK/*/md5
2874 unset forced
2875 fi
2876 if [ "$missing" ]; then
2877 pkg=$(ls -1 $WOK)
2878 else
2879 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2880 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2881 } | sort -u)"
2882 fi
2883 cooklist=$PACKAGES_REPOSITORY/cooklist
2884 gen_cook_list
2885 ;;
2886 cook-commit)
2887 check_root
2888 get_options_list="missing forced"
2889 get_tazwok_config
2890 source_lib report
2891 report start
2892 if [ "$forced" ]; then
2893 rm -f $WOK/*/md5
2894 unset forced
2895 fi
2896 if [ "$missing" ]; then
2897 pkg=$(ls -1 $WOK)
2898 else
2899 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2900 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2901 } | sort -u)"
2902 fi
2903 cooklist=$PACKAGES_REPOSITORY/cooklist
2904 gen_cook_list
2905 cook_list
2906 ;;
2907 cook-all)
2908 check_root
2909 get_options_list="forced missing"
2910 get_tazwok_config
2911 source_lib report
2912 report start
2913 if [ "$missing" ]; then
2914 pkg=$(ls -1 $WOK)
2915 else
2916 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2917 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2918 } | sort -u)"
2919 fi
2920 cooklist=$PACKAGES_REPOSITORY/cooklist
2921 gen_cook_list
2922 cook_list
2923 ;;
2924 gen-wok-db)
2925 check_root
2926 get_tazwok_config
2927 source_lib report
2928 report start
2929 gen_wok_db
2930 ;;
2931 report)
2932 check_root
2933 get_tazwok_config
2934 cd $PACKAGES_REPOSITORY
2935 if [ "$2" ]; then
2936 case $2 in
2937 commit|cooklist|incoming|broken|blocked)
2938 show="$2"
2939 ;;
2940 *)
2941 echo "usage : tazwok report [commit|cooklist|incoming|broken|blocked]" >&2
2942 exit 1
2943 ;;
2944 esac
2945 else
2946 show="commit cooklist incoming broken blocked"
2947 fi
2948 for i in $show; do
2949 if [ -s $i ]; then
2950 echo ""
2951 echo -e "\033[1m$i\033[0m"
2952 echo "================================================================================"
2953 cat $i
2954 echo "================================================================================"
2955 echo ""
2956 fi
2957 done
2958 ;;
2959 check-incoming)
2960 check_root
2961 get_options_list="forced"
2962 get_tazwok_config
2963 source_lib report
2964 report start
2965 check_for_incoming
2966 ;;
2967 configure-chroot)
2968 check_root
2969 get_tazwok_config
2970 if [ -f /usr/bin/tazchroot ]; then
2971 cd $LOCAL_REPOSITORY
2972 configure_tazchroot
2973 else
2974 echo "The packages tazchroot need to be installed" >&2
2975 exit 1
2976 fi
2977 ;;
2978 chroot)
2979 check_root
2980 get_tazwok_config
2981 # Merge this and the other chroot function ?.
2982 if [ -f /usr/bin/tazchroot ]; then
2983 cd $LOCAL_REPOSITORY
2984 [ ! -f tazchroot.conf ] && configure_tazchroot
2985 tazchroot
2986 else
2987 echo "The packages tazchroot need to be installed" >&2
2988 exit 1
2989 fi
2990 ;;
2991 cook-toolchain)
2992 check_root
2993 get_tazwok_config
2994 echo -n "" > $PACKAGES_REPOSITORY/broken
2995 if [ -f /usr/bin/tazchroot ]; then
2996 cd $LOCAL_REPOSITORY
2997 [ ! -f tazchroot.conf ] && configure_tazchroot
2998 tazchroot cook-toolchain
2999 # Buggy : chroot can be elsewhere.
3000 rm -r $LOCAL_REPOSITORY/chroot
3001 # /!\ to be writed :
3002 # next rm chroot and plan cook-all by pushing all packages
3003 # in cooklist.
3004 else
3005 echo "The packages tazchroot need to be installed" >&2
3006 exit 1
3007 fi
3008 ;;
3009 webserver)
3010 check_root
3011 get_tazwok_config
3012 if [ "$ARG" = on ]; then
3013 if [ "$WEBSERVER" ] && [ -f "$WEBSERVER/repositories.list" ] && \
3014 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3015 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3016 exit 1
3017 fi
3018 if ! [ -f $LOCAL_REPOSITORY/tazchroot.conf ]; then
3019 tazwok configure-chroot ${undigest:+--undigest=$undigest} --SLITAZ_VERSION=$SLITAZ_VERSION --SLITAZ_DIR=$SLITAZ_DIR
3020 fi
3021 for pkg in php lighttpd; do
3022 [ -d $INSTALLED/$pkg ] || missing="$missing $pkg"
3023 done
3024 if [ "$missing" ]; then
3025 echo "You need to install those packages to start webserver: $missing." >&2
3026 exit 1
3027 fi
3028 if [ ! -f "$LOCAL_REPOSITORY/tazwok.conf" ]; then
3029 echo "Copying /etc/slitaz/tazwok.conf to $LOCAL_REPOSITORY/tazwok.conf: webserver is configured repository-by-repository."
3030 cp /etc/slitaz/tazwok.conf $LOCAL_REPOSITORY
3031 fi
3032 if ! [ "$WEBSERVER" ]; then
3033 echo -n "Where to store php pages (default: /var/www/vhosts/bb)? "
3034 read WEBSERVER
3035 [ "$WEBSERVER" ] || WEBSERVER="/var/www/vhosts/bb"
3036 fi
3037 if [ -f "$WEBSERVER/repositories.list" ] && \
3038 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3039 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3040 exit 1
3041 fi
3042 mkdir -p $WEBSERVER
3043 echo "${undigest:-$SLITAZ_VERSION}" >> $WEBSERVER/repositories.list
3044 for file in index.php log.php download.php; do
3045 [ -f "$WEBSERVER/$file" ] || ln -s /usr/share/slitaz/web-bb/$file $WEBSERVER
3046 done
3047 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3048 ln -s $dir $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3049 done
3050 source $LOCAL_REPOSITORY/tazchroot.conf
3051 echo "<?php
3053 // Web interface configuration
3055 \$version=\"${undigest:-$SLITAZ_VERSION}\";
3056 \$chroot=\"$chroot_dir\";
3057 \$lockfile=\"\$chroot/proc/1\";
3058 \$db_dir=\"$PACKAGES_REPOSITORY\";
3059 \$log_dir=\"$LOCAL_REPOSITORY/log\";
3060 \$packages=\"$PACKAGES_REPOSITORY\";
3061 \$incoming=\"$INCOMING_REPOSITORY\";
3062 \$wok=\"$WOK\";
3064 ?>" > $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3065 [ -L "$WEBSERVER/web" ] || ln -s /usr/share/slitaz/web $WEBSERVER
3066 echo "WEBSERVER=\"$WEBSERVER\"" >> $LOCAL_REPOSITORY/tazwok.conf
3067 if [ -L "$WEBSERVER/conf.php" ]; then
3068 echo "Do yo want to make ${undigest:-$SLITAZ_VERSION} the default page (y/N) ? "
3069 read answer
3070 if [ "$answer" = y ]; then
3071 rm $WEBSERVER/conf.php
3072 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3073 fi
3074 else
3075 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3076 fi
3077 elif [ "$ARG" = off ]; then
3078 if ! [ "$WEBSERVER" ]; then
3079 echo "No webserver running for ${undigest:-$SLITAZ_VERSION}" >&2
3080 exit 1
3081 fi
3082 sed '/^WEBSERVER/d' -i $LOCAL_REPOSITORY/tazwok.conf
3083 sed "/^${undigest:-$SLITAZ_VERSION}$/d" -i $WEBSERVER/repositories.list
3084 rm $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3085 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3086 rm $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3087 done
3088 if ! [ -s "$WEBSERVER/repositories.list" ]; then
3089 echo "$WEBSERVER/repositories.list is empty; tazwok doesn't remove the server automatically in case you have important stuff in it. If it's not the case, you can remove it using: rm -r $WEBSERVER"
3090 rm $WEBSERVER/conf.php
3091 elif [ "$(readlink $WEBSERVER/conf.php)" = "$WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php" ]; then
3092 echo "${undigest:-$SLITAZ_VERSION} was the default version to use; switched to : $(sed 1!d $WEBSERVER/repositories.list)"
3093 rm $WEBSERVER/conf.php
3094 ln -s $WEBSERVER/conf-$(sed 1!d $WEBSERVER/repositories.list).php $WEBSERVER/conf.php
3095 fi
3096 else
3097 echo "Usage: tazwok webserver on/off" >&2
3098 exit 1
3099 fi
3100 ;;
3101 usage|*)
3102 # Print usage also for all unknown commands.
3104 usage
3105 ;;
3106 esac
3108 report stop 2>/dev/null || exit 0