tazwok view tazwok @ rev 272

Don't install build_depends if package doesn't have compile_rules and doesn't have BUILD_DEPENDS (thanks Godane)
author Antoine Bodin <gokhlayeh@slitaz.org>
date Mon Feb 14 03:59:00 2011 +0100 (2011-02-14)
parents 6b093970f4f9
children 5ab102a2359a
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 [ ! "$BUILD_DEPENDS" ] && ! fgrep -q compile_rules $RECEIPT && return
296 report step "Looking for build dependencies"
298 # Keep the list of previously installed build_depends then compare
299 # it with new build_depends to know what to install and what to
300 # what to remove.
301 plan_remove=" $MISSING_PACKAGE $remove_later "
302 [ ! "${plan_remove// }" ] && unset plan_remove
303 unset MISSING_PACKAGE remove_later
304 rwanted=$(look_for_rwanted)
306 for pkg in $(scan $PACKAGE --look_for=bdep --with_dev | \
307 fgrep -v $(for i in $(look_for_rwanted) $PACKAGE; do echo " -e $i"; done))
308 do
310 # Delay the removing of previous cook depends if they are needed
311 # for next cook too.
312 if [ ! -d "$INSTALLED/$pkg" ] ; then
313 MISSING_PACKAGE="$MISSING_PACKAGE $pkg"
314 fi
315 if [ "$plan_remove" != "${plan_remove/ $pkg }" ]; then
316 plan_remove="${plan_remove/ $pkg / }"
317 remove_later="$remove_later $pkg"
318 fi
319 if grep -q ^$pkg$ $PACKAGES_REPOSITORY/broken; then
320 broken="$broken$pkg "
321 fi
322 done
324 # Don't cook if a depend is broken.
325 if [ "$broken" ]; then
326 MISSING_PACKAGE=$plan_remove
327 echo "Can't cook $PACKAGE because broken depend(s) : $broken" >&2
328 unset plan_remove broken
330 # Set report step to failed.
331 report_return_code=1
332 report end-step
333 return 1
334 fi
335 if [ "$MISSING_PACKAGE" ]; then
336 install_missing()
337 {
338 echo "Installing missing packages : $MISSING_PACKAGE"
339 for pkg in $MISSING_PACKAGE; do
340 [ -d "$INSTALLED/$pkg" ] || tazpkg get-install $pkg
341 done
342 }
343 if [ "$auto_install" = yes ]; then
344 install_missing
345 else
346 echo "================================================================================"
347 for pkg in $MISSING_PACKAGE
348 do
349 echo "Missing : $pkg"
350 done
351 echo "================================================================================"
352 echo "You can continue, exit or install missing dependencies."
353 echo -n "Install, continue or exit (install/y/N) ? "; read answer
354 case $answer in
355 install)
356 install_missing ;;
357 y|yes)
358 unset MISSING_PACKAGE;;
359 *)
360 report stop
361 exit 0 ;;
362 esac
363 fi
364 fi
365 report end-step
366 remove_build_depends $plan_remove
367 unset plan_remove
368 }
370 remove_build_depends()
371 {
372 [ "$1" ] || return
373 report step "Removing previous build dependencies"
374 echo "Removing theses packages : $@"
375 for pkg in $@; do
376 [ -d "$INSTALLED/$pkg" ] && tazpkg remove $pkg --auto
377 done
378 report end-step
379 }
381 # Check if we can use the new way to handle tarball
382 # or if we keep the previous method by check for
383 # _pkg=/src= in receipt and reverse-wanted.
384 check_for_var_modification()
385 {
386 for var in $@; do
387 for pkg in $PACKAGE $(look_for_wanted) $(look_for_rwanted); do
388 [ -f $WOK/$pkg/receipt ] || continue
389 fgrep -q "$var=" $WOK/$pkg/receipt && return 1
390 done
391 done
393 # Tweak to make if; then...; fi function working with this one.
394 echo -n ""
395 }
397 set_src_path()
398 {
399 if check_for_var_modification src _pkg; then
400 src=$WOK/${WANTED:-$PACKAGE}/${WANTED:-$PACKAGE}-$VERSION
401 else
402 tazwok_warning "Use original name or tarball root directory because src/_pkg are defined into the receipt (this is no more needed!)."
403 src=$WOK/${WANTED:-$PACKAGE}/${SOURCE:-${WANTED:-$PACKAGE}}-$VERSION
404 fi
405 }
407 set_pkg_path()
408 {
409 if [ -d $WOK/${WANTED:-$PACKAGE}/install ] ; then
410 _pkg=$WOK/${WANTED:-$PACKAGE}/install
411 else
412 _pkg=$src/_pkg
413 fi
414 }
416 # Output $VERSION-$EXTRAVERSION using packages.txt
417 get_pkg_version()
418 {
419 [ "$PACKAGE" ] || return
420 grep -m1 -A1 -sh ^$PACKAGE$ $1/packages.txt | tail -1 | sed 's/ *//'
421 }
423 remove_previous_package()
424 {
425 [ "$prev_VERSION" ] || return
426 if [ "$VERSION$EXTRAVERSION" != "$prev_VERSION" ]; then
427 rm -f $1/$PACKAGE-$prev_VERSION.tazpkg
428 fi
429 return
430 }
432 # Check for src tarball and wget if needed.
433 check_for_tarball()
434 {
435 [ "$WGET_URL" ] || return 0
436 report step "Checking for source tarball"
437 local repack_src TARBALL
438 if [ "$repack_src" = yes ] && look_for_cookopt !repack_src; then
439 repack_src=no
440 fi
441 if [ "$target" ]; then
442 src="$target"
443 else
444 set_src_path
445 fi
446 tmp_src=$tmp/tarball-$$
447 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
448 [ ! -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] ; then
449 cd $SOURCES_REPOSITORY
450 if [ "$SOURCE" ]; then
451 alt_url="http://mirror.slitaz.org/sources/packages/${SOURCE:0:1}/$SOURCE-$VERSION.tar.lzma"
452 else
453 alt_url="http://mirror.slitaz.org/sources/packages/${PACKAGE:0:1}/$PACKAGE-$VERSION.tar.lzma"
454 fi
455 download $WGET_URL $alt_url http://mirror.slitaz.org/sources/packages/${file:0:1}/$file
456 unset alt_url
457 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
458 [ ! -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && \
459 [ ! -d $tmp_src ]; then
460 echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n" >&2
461 report end-step
462 return 1
463 fi
464 fi
465 report end-step
466 if [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && [ "$nounpack" ]; then
467 [ -d "$tmp_src" ] && rm -r $tmp_src
468 return
469 fi
471 # Untaring source if necessary. We don't need to extract source if
472 # the package is built with a wanted source package.
473 if [ "$WANTED" ]; then
474 [ -d "$tmp_src" ] && rm -r $tmp_src
475 return
476 fi
478 report step "Untaring source tarball"
480 # Log process.
481 echo "untaring source tarball" >> $LOG
483 # If $tmp_src exists, there's already the unpacked tarball into it.
484 if ! [ -d $tmp_src ]; then
485 mkdir $tmp_src
486 if [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && [ "$repack_src" = yes ]; then
487 lzma d $SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma -so | \
488 tar xf - -C $tmp_src
489 repack_src=no
490 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
491 elif [ -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
492 case "$TARBALL" in
493 *zip|*xpi) cd $tmp_src && unzip -o $SOURCES_REPOSITORY/$TARBALL ;;
494 *bz2|*tbz|*gem) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
495 *tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
496 *lzma|*lz) unlzma -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
497 *xz) unxz -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
498 *Z|*taz) uncompress -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
499 *gz) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
500 *rpm) cd $tmp_src && rpm2cpio $SOURCES_REPOSITORY/$TARBALL | cpio -idm --quiet;;
502 # It's a plain file or something receipt unpack itself.
503 *)
504 mkdir $tmp_src/${SOURCE:-$PACKAGE}-$VERSION
505 cp $SOURCES_REPOSITORY/$TARBALL $tmp_src/${src##*/}
506 ;;
508 esac || { report end-step
509 rm -f $SOURCES_REPOSITORY/$TARBALL
510 rm -r $tmp_src
511 return 1
512 }
513 fi
515 # Check if uncompressed tarball is in a root dir or not.
516 if [ "$(ls -A $tmp_src | wc -l)" -gt 1 ] || [ -f $(echo $tmp_src/*) ]; then
517 if check_for_var_modification src _pkg; then
518 mv $tmp_src $tmp_src-1
519 mkdir $tmp_src
520 mv $tmp_src-1 $tmp_src/${SOURCE:-$PACKAGE}-$VERSION
521 else
522 mv $tmp_src/* $WOK/$PACKAGE
523 repack_src=no
524 rm -r $tmp_src
525 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."
526 fi
527 fi
528 fi
530 if [ "$repack_src" = yes ]; then
531 report step "Repacking sources in .tar.lzma format"
532 [ "$TARBALL" ] && rm -f $SOURCES_REPOSITORY/$TARBALL
533 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
534 cd $tmp_src
535 tar -c * | lzma e $SOURCES_REPOSITORY/$TARBALL -si
536 fi
538 # Remove previous tarball if no other package needs it. We take care to
539 # keep tarball if the same package use it into main repository.
540 if [ "$TARBALL" ]; then
541 previous_tarball=$(grep ^$PACKAGE:incoming $SOURCES_REPOSITORY/sources.list | cut -f2)
542 if [ "$previous_tarball" ]; then
543 sed "/^$PACKAGE:incoming/ s/.*/$PACKAGE:incoming\t$TARBALL/" \
544 -i $SOURCES_REPOSITORY/sources.list
545 grep -q $'\t'$previous_tarball$ $SOURCES_REPOSITORY/sources.list || \
546 rm -f $SOURCES_REPOSITORY/$previous_tarball
547 else
548 echo -e "$PACKAGE:incoming\t$TARBALL" >> $SOURCES_REPOSITORY/sources.list
549 fi
550 fi
552 if [ "$nounpack" ]; then
553 [ -d "$tmp_src" ] && rm -r $tmp_src
554 return
555 fi
556 if [ ! -d "$src" ]; then
557 if ! check_for_var_modification src _pkg; then
558 src="${src%/*}/$(ls $tmp_src)"
559 fi
560 mv $(echo $tmp_src/*) "$src"
561 rm -r $tmp_src
563 # Permissions settings.
564 chown -R root.root "$src"
565 else
566 [ -d "$tmp_src" ] && rm -r $tmp_src
567 echo "There's already something at $src. Abort." >&2
568 fi
569 }
571 # Log and execute compile_rules function if it exists, to configure and
572 # make the package if it exists.
573 check_for_compile_rules()
574 {
575 if grep -q ^compile_rules $RECEIPT; then
576 echo "executing compile_rules" >> $LOG
577 report step "Executing compile_rules"
578 cd $WOK/$PACKAGE
579 rm -f /tmp/config.site
581 # Free some RAM by cleaning cache if option is enabled.
582 freeram=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
584 # Disable -pipe in CFLAGS/CXXFLAGS if less than 512Mb of free
585 # RAM are available.
586 if [ "$freeram" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" -o \
587 "$CXXFLAGS" != "${CXXFLAGS/-pipe}" ]; then
588 tazwok_warning "Disabling -pipe compile flag because only ${freeram}b of RAM are available."
589 CFLAGS="${CFLAGS/-pipe}"
590 CXXFLAGS="${CXXFLAGS/-pipe}"
591 fi
592 unset freeram
594 # Set cook environnement variables.
595 [ "$src" ] || set_src_path
596 [ "$DESTDIR" ] || DESTDIR="$WOK/$PACKAGE/install"
597 [ "$CONFIG_SITE" ] || CONFIG_SITE=/etc/config.site
598 export CFLAGS CXXFLAGS MAKEFLAGS DESTDIR BUILD_HOST \
599 CONFIG_SITE default_prefix \
600 default_datarootdir default_datadir default_localedir \
601 default_infodir default_mandir default_build default_host
602 local LC_ALL=POSIX LANG=POSIX
603 compile_rules
605 # Check if config.site has been used.
606 # /!\ disabled since it screw the return_code of the step.
607 #if [ -f /tmp/config.site ]; then
608 # rm /tmp/config.site
609 #else
610 # tazwok_warning "config.site hasn't been used during \
611 #configuration process."
612 #fi
614 report end-step
615 fi
616 }
618 # Check for loop in deps tree. /!\ can be removed
619 check_for_deps_loop()
620 {
621 local list
622 local pkg
623 local deps
624 pkg=$1
625 shift
626 [ -n "$1" ] || return
627 list=""
629 # Filter out already processed deps
630 for i in $@; do
631 case " $ALL_DEPS" in
632 *\ $i\ *);;
633 *) list="$list $i";;
634 esac
635 done
636 ALL_DEPS="$ALL_DEPS$list "
637 for i in $list; do
638 [ -f $i/receipt ] || continue
639 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
640 case " $deps " in
641 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
642 *) check_for_deps_loop $pkg $deps;;
643 esac
644 done
645 }
647 # Function used by download().
648 revert_vcs_failure()
649 {
650 cd $SOURCES_REPOSITORY
651 rm -r $tmp_src
652 }
654 download()
655 {
656 for file in $@; do
657 echo "Downloading from ${file#*|}..."
658 case "$file" in
659 git\|*)
660 file=${file#git|}
661 if [ -d $INSTALLED/git ]; then
662 mkdir $tmp_src
663 cd $tmp_src
664 if [ "$BRANCH" ]; then
665 git clone $file ${src##*/} && cd ${src##*/} && \
666 git checkout $BRANCH && rm -rf .git* && break
667 else
668 git clone $file ${src##*/} && rm -rf ${src##*/}/.git* && break
669 fi
670 revert_vcs_failure
671 else
672 tazwok_warning "Needs git to download the source tarball from $file, please add it as build-depend."
673 continue
674 fi
675 ;;
676 subversion\|*)
677 file=${file#subversion|}
678 if [ -d $INSTALLED/subversion ]; then
679 mkdir $tmp_src
680 cd $tmp_src
681 if [ "$BRANCH" ]; then
682 echo t | svn co $file -r $BRANCH ${src##*/} && rm -rf ${src##*/}/.svn* && break
683 else
684 echo t | svn co $file ${src##*/} && rm -rf ${src##*/}/.svn* && break
685 fi
686 revert_vcs_failure
687 else
688 tazwok_warning "Needs subversion to download the source tarball from $file, please add it as build-depend."
689 continue
690 fi
691 ;;
692 mercurial\|*)
693 file=${file#mercurial|}
694 if [ -d $INSTALLED/mercurial ]; then
695 mkdir $tmp_src
696 cd $tmp_src
697 if [ "$BRANCH" ]; then
698 hg clone $file --rev $BRANCH ${src##*/} && rm -rf ${src##*/}/.hg* && break
699 else
700 hg clone $file ${src##*/} && rm -rf ${src##*/}/.hg* && break
701 fi
702 revert_vcs_failure
703 else
704 tazwok_warning "Needs mercurial to download the source tarball from $file, please add it as build-depend."
705 continue
706 fi
707 ;;
708 https*)
709 if [ -d $INSTALLED/wget ]; then
710 if [ "${WGET_URL%$TARBALL}" = "$WGET_URL" ] && [ "$file" = "$WGET_URL" ]; then
711 wget -q --no-check-certificate -O $TARBALL $file && break
712 else
713 wget -q $file && break
714 fi
715 else
716 tazwok_warning "Needs wget to download the source tarball from $file, please add it as build-depend."
717 continue
718 fi
719 ;;
720 http*|ftp*)
721 # Handle crappy URL.
722 if [ "${WGET_URL%$TARBALL}" = "$WGET_URL" ] && [ "$file" = "$WGET_URL" ]; then
723 wget -q -O $TARBALL $file && break
724 else
725 wget -q $file && break
726 fi
727 ;;
728 esac
729 done
730 }
732 # Regenerate every package that wants a PACKAGE compiled
733 refresh_packages_from_compile()
734 {
735 # make tazwok genpkg happy
736 mkdir $WOK/$PACKAGE/taz
738 # Cook rwanted in default or specied order
739 genlist=" $(look_for_rwanted | tr '\n' ' ') "
740 for i in $(look_for_cookopt genpkg | tac); do
741 [ "${genlist/ $i }" = "$genlist" ] && continue
742 genlist=" $i${genlist/ $i / }"
743 done
744 if [ "$genlist" ]; then
745 local PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
746 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
747 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
748 src _pkg DESTDIR CONFIG_SITE RECEIPT LOG
749 for PACKAGE in $genlist; do
750 set_common_path
751 gen_package
752 done
753 fi
754 }
756 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
757 # so some packages need to copy these files with the receipt and genpkg_rules.
758 # This function is executed by gen_package when 'tazwok genpkg'.
759 copy_generic_files()
760 {
761 # In most cases, locales are in $_pkg/usr/share/locale so we copy files
762 # using generic variables and $LOCALE from Tazwok config file.
763 if [ "$LOCALE" ]; then
764 if [ -d "$_pkg/usr/share/locale" ]; then
765 for i in $LOCALE
766 do
767 if [ -d "$_pkg/usr/share/locale/$i" ]; then
768 mkdir -p $fs/usr/share/locale
769 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
770 fi
771 done
772 fi
773 fi
775 # Pixmaps (PNG or/and XPM only). Some icons/images can be added through
776 # genpkg_rules and generic copy can be disabled with GENERIC_PIXMAPS="no"
777 # in pkg receipt.
778 if [ "$GENERIC_PIXMAPS" != "no" ]; then
779 if [ -d "$_pkg/usr/share/pixmaps" ]; then
780 mkdir -p $fs/usr/share/pixmaps
781 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
782 $fs/usr/share/pixmaps 2>/dev/null
783 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
784 $fs/usr/share/pixmaps 2>/dev/null
785 fi
787 # Custom or homemade PNG pixmap can be in stuff.
788 if [ -f "stuff/$PACKAGE.png" ]; then
789 mkdir -p $fs/usr/share/pixmaps
790 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
791 fi
792 fi
794 # Desktop entry (.desktop).
795 if [ -d "$_pkg/usr/share/applications" ]; then
796 cp -a $_pkg/usr/share/applications $fs/usr/share
797 fi
799 # Homemade desktop file(s) can be in stuff.
800 if [ -d "stuff/applications" ]; then
801 mkdir -p $fs/usr/share
802 cp -a stuff/applications $fs/usr/share
803 fi
804 if [ -f "stuff/$PACKAGE.desktop" ]; then
805 mkdir -p $fs/usr/share/applications
806 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
807 fi
808 }
810 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
811 strip_package()
812 {
813 report step "Executing strip on all files"
815 # Binaries.
816 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
817 do
818 if [ -d "$dir" ]; then
819 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
820 fi
821 done
823 # Libraries.
824 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
825 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
826 report end-step
827 }
829 # Remove .pyc and .pyo files from packages
830 py_compiled_files_remove()
831 {
832 report step "Removing all .pyc and .pyo files from package ..."
833 find $fs -type f -name "*.pyc" -delete 2>/dev/null
834 find $fs -type f -name "*.pyo" -delete 2>/dev/null
835 report end-step
836 }
838 # Check FSH in a slitaz package (Path: /:/usr)
839 check_fsh()
840 {
841 cd $WOK/$PACKAGE/taz/*/fs
842 [ -n "$FSH" ] || FSH="bin boot dev etc home init lib media mnt proc \
843 root sbin share sys tmp usr var vz usr/bin usr/games usr/include usr/lib \
844 usr/local usr/sbin usr/share usr/src"
845 for i in `ls -d * usr/* 2>/dev/null`
846 do
847 if ! echo $FSH | fgrep -q $i; then
848 echo "Wrong path: /$i" >&2
849 error=1
850 fi
851 done
852 if [ "$error" = "1" ]; then
853 cat << _EOT_
855 Package will install files in a non standard directory and won't be generated.
856 You may have a wrong copy path in genpkg_rules or need to add some options to
857 configure in compile_rules. Some valid options for SliTaz (Linux FSH):
859 --prefix=/usr
860 --sysconfdir=/etc
861 --libexecdir=/usr/lib/(pkgname)
862 --localstatedir=/var
863 --mandir=/usr/share/man
864 --infodir=/usr/share/info
866 For more information please read SliTaz docs and run: ./configure --help
867 ================================================================================
868 $PACKAGE package generation aborted.
870 _EOT_
872 # Dont generate a corrupted package.
873 cd $WOK/$PACKAGE && rm -rf taz
874 report exit
875 fi
876 }
878 gen_cookmd5()
879 {
880 # md5sum of cooking stuff make tazwok able to check for changes
881 # without hg.
882 cd $WOK/$PACKAGE
883 md5sum receipt > md5
884 [ -f description.txt ] && md5sum description.txt >> md5
885 if [ -d stuff ]; then
886 find stuff | while read file; do
887 md5sum $file >> md5
888 done
889 fi
890 }
892 # Create a package tree and build the gziped cpio archive
893 # to make a SliTaz (.tazpkg) package.
894 gen_package()
895 {
896 check_root
897 check_for_package_on_cmdline
898 check_for_receipt
899 EXTRAVERSION=""
900 . $RECEIPT
902 # May compute VERSION
903 if grep -q ^get_version $RECEIPT; then
904 get_version
905 fi
906 check_for_wanted
907 cd $WOK/$PACKAGE
909 # Remove old Tazwok package files.
910 [ -d "taz" ] && rm -rf taz
912 # Create the package tree and set useful variables.
913 mkdir -p $WOK/$PACKAGE/taz/$PACKAGE-$VERSION/fs
914 fs=$WOK/$PACKAGE/taz/$PACKAGE-$VERSION/fs
916 # Set $src for standard package and $_pkg variables.
917 set_src_path && set_pkg_path
919 # Execute genpkg_rules, check package and copy generic files to build
920 # the package.
921 report step "Building $PACKAGE with the receipt"
922 report open-bloc
923 if grep -q ^genpkg_rules $RECEIPT; then
925 # Log process.
926 echo "executing genpkg_rules" >> $LOG
927 report step "Executing genpkg_rules"
928 genpkg_rules
929 report end-step
930 check_fsh
931 cd $WOK/$PACKAGE
933 # Skip generic files for packages with a WANTED variable
934 # (dev and splited pkgs).
935 if [ ! "$WANTED" ]; then
936 copy_generic_files
937 fi
938 look_for_cookopt !strip || strip_package
939 py_compiled_files_remove
940 else
941 echo "No package rules to gen $PACKAGE..." >&2
942 report exit
943 fi
945 # Copy the receipt and description (if exists) into the binary package tree.
946 cd $WOK/$PACKAGE
947 report step "Copying the receipt"
948 cp receipt taz/$PACKAGE-$VERSION
949 report end-step
950 if grep -q ^get_version $RECEIPT; then
951 report step "Updating version in receipt"
952 sed -i "s/^VERSION=.*/VERSION=\"$VERSION\"/" \
953 taz/$PACKAGE-$VERSION/receipt
954 report end-step
955 fi
956 if [ -f "description.txt" ]; then
957 report step "Copying the description file"
958 cp description.txt taz/$PACKAGE-$VERSION
959 report end-step
960 fi
962 # Generate md5 of cooking stuff to look for commit later.
963 gen_cookmd5
964 echo -e "\n# md5sum of cooking stuff :" >> taz/$PACKAGE-$VERSION/receipt
965 cat md5 | sed 's/^/# /' >> taz/$PACKAGE-$VERSION/receipt
967 # Create the files.list by redirecting find output.
968 report step "Creating the list of files"
969 cd taz/$PACKAGE-$VERSION
970 LAST_FILE=""
971 { find fs -print; echo; } | while read file; do
972 if [ "$LAST_FILE" ]; then
973 case "$file" in
974 $LAST_FILE/*)
975 case "$(ls -ld "$LAST_FILE")" in
976 drwxr-xr-x\ *\ root\ *\ root\ *);;
977 *) echo ${LAST_FILE#fs};;
978 esac;;
979 *) echo ${LAST_FILE#fs};;
980 esac
981 fi
982 LAST_FILE="$file"
983 done > files.list
985 # Next, check if something has changed in lib files.
986 if fgrep -q '.so' files.list; then
987 report step "Look for major/minor update in libraries"
988 for rep in $INCOMING_REPOSITORY $PACKAGES_REPOSITORY \
989 $([ "$undigest" ] && echo SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming && \
990 echo $SLITAZ_DIR/$SLITAZ_VERSION/packages); do
991 prev_VERSION=$(get_pkg_version $rep)
992 [ "$prev_VERSION" ] && pkg_file=$rep/$PACKAGE-$prev_VERSION.tazpkg && break
993 done
994 if [ "$pkg_file" ]; then
995 get_pkg_files $pkg_file
996 cd $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
997 fgrep ".so" files.list | egrep -v "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*" | \
998 while read lib; do
999 fgrep -q "$lib" $pkg_files_dir/files.list && continue
1000 echo "A minor/major update in libraries is detected, planning re-cook of reverse-depends of $PACKAGE."
1001 for rdep in $(scan $PACKAGE --look_for=rdep | use_wanted); do
1002 [ "$rdep" = "${WANTED:-$PACKAGE}" ] && continue
1003 grep -q ^$rdep$ $PACKAGES_REPOSITORY/blocked \
1004 $PACKAGES_REPOSITORY/cooklist && continue
1005 echo $rdep >> $PACKAGES_REPOSITORY/cooklist
1006 done
1007 regen_cooklist=yes
1008 break
1009 done
1010 rm -r $pkg_files_dir
1011 fi
1012 report end-step
1013 fi
1014 if [ ! "$EXTRAVERSION" ]; then
1015 case "$PACKAGE" in
1016 linux*);;
1017 *) EXTRAVERSION="$(grep '/lib/modules/.*-slitaz/' files.list |\
1018 head -1 | sed 's|/lib/modules/\(.*\)-slitaz/.*|_\1|')";;
1019 esac
1020 fi
1021 rm -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
1022 report step "Creating md5sum of files"
1023 while read file; do
1024 [ -L "fs$file" ] && continue
1025 [ -f "fs$file" ] || continue
1026 md5sum "fs$file" | sed 's/ fs/ /'
1027 done < files.list > md5sum
1028 report end-step
1029 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
1030 2> /dev/null | awk '{ sz=$1 } END { print sz }')
1032 # Build cpio archives. Find, cpio and gzip the fs, finish by
1033 # removing the fs tree.
1034 # Don't log this because compression always output error messages.
1035 find fs -print | cpio -o -H newc | case "$PACKAGE-$COMPRESSION" in
1036 tazpkg-lzma) gzip > fs.cpio.gz;;
1037 *-lzma) lzma e fs.cpio.lzma -si;;
1038 *) gzip > fs.cpio.gz;;
1039 esac && rm -rf fs
1040 PACKED_SIZE=$(du -chs fs.cpio.* receipt files.list md5sum \
1041 description.txt 2> /dev/null | awk '{ sz=$1 } END { print sz }')
1042 report step "Updating receipt sizes"
1043 sed -i '/^PACKED_SIZE/d' receipt
1044 sed -i '/^UNPACKED_SIZE/d' receipt
1045 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
1046 sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
1047 report end-step
1048 if [ "$EXTRAVERSION" ]; then
1049 report step "Updating receipt EXTRAVERSION"
1050 sed -i s/^EXTRAVERSION.*$// receipt
1051 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
1052 fi
1053 prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
1054 remove_previous_package $INCOMING_REPOSITORY
1055 report step "Creating full cpio archive"
1056 find . -print | cpio -o -H newc > $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
1058 # Restore package tree in case we want to browse it.
1059 report step "Restoring original package tree"
1060 { zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma; } | cpio --quiet -id
1061 rm fs.cpio.* && cd ..
1063 # Log process.
1064 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
1065 report close-bloc
1066 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
1067 echo "Size : `du -sh $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
1068 echo ""
1070 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/broken
1071 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/commit
1072 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/cooklist
1075 ########################################################################
1076 # This section contains functions used by several other functions
1077 # bellow.
1078 ########################
1080 # Look for receipt/files.list in wok. If they can't be found, get them
1081 # from package. Accept one argument : absolute path to package.
1082 get_pkg_files()
1084 pkg_files_dir=$tmp/$(basename ${1%.tazpkg})
1085 mkdir -p $pkg_files_dir && \
1086 cd $pkg_files_dir && \
1087 cpio --quiet -idm receipt < $1 && \
1088 cpio --quiet -idm files.list < $1
1091 ########################################################################
1092 # This section contains functions to generate packages databases.
1093 ########################
1096 gen_packages_db()
1098 # pkg_repository can be $PACKAGES_REPOSITORY or $INCOMING_REPOSITORY.
1099 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
1100 cd $pkg_repository
1101 report step "Generating packages lists: $pkg_repository"
1102 report open-bloc
1103 report step "Removing old files"
1104 for file in files.list.lzma packages.list packages.txt \
1105 packages.desc packages.equiv packages.md5; do
1106 [ -f $file ] && rm $file
1107 done
1108 touch files.list
1110 packages_db_start
1111 unset RECEIPT
1112 report step "Reading datas from all packages"
1113 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1114 get_packages_info
1115 done
1116 report end-step
1117 packages_db_end
1118 report close-bloc
1121 update_packages_db()
1123 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
1124 cd $pkg_repository
1125 for file in packages.list packages.equiv packages.md5 packages.desc \
1126 packages.txt; do
1127 if [ ! -f "$file" ]; then
1128 gen_packages_db
1129 return
1130 fi
1131 done
1132 if [ -f files.list.lzma ]; then
1133 lzma d files.list.lzma files.list
1134 else
1135 gen_packages_db
1136 fi
1137 report step "Updating packages lists: $pkg_repository"
1138 packages_db_start
1140 # Look for removed/update packages.
1141 for PACKAGE in $(grep ^[0-9,a-z,A-Z] packages.txt); do
1142 pkg="$pkg_repository/$(grep -m1 ^$PACKAGE- packages.list).tazpkg"
1143 if ! [ -f "$pkg" ]; then
1144 erase_package_info
1145 else
1146 if [ "$pkg" -nt "packages.list" ]; then
1147 updated_pkg="$updated_pkg
1148 $PACKAGE $pkg"
1149 elif [ ! -f $WOK/$PACKAGE/receipt ] && \
1150 [ "$COMMAND" = check-incoming -o "$pkg_repository" = "$INCOMING_REPOSITORY" ]; then
1151 erase_package_info
1152 echo "Removing $PACKAGE from $pkg_repository."
1153 rm $pkg
1154 [ -d $WOK/$PACKAGE ] && rm -r $WOK/$PACKAGE
1155 if [ "$pkg_repository" = "$INCOMING_REPOSITORY" ]; then
1156 sed "/^$PACKAGE\t/d" -i $wan_db $dep_db
1157 for i in cookorder.txt cooklist commit blocked broken; do
1158 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/$i
1159 done
1160 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
1161 regen_cooklist=yes
1162 else
1163 echo "$PACKAGE" >> $PACKAGES_REPOSITORY/removed
1164 sed -n '1,10p' -i $PACKAGES_REPOSITORY/removed
1165 fi
1166 fi
1167 fi
1168 done
1169 echo "$updated_pkg" | sed 1d | while read PACKAGE pkg; do
1170 erase_package_info
1171 get_packages_info
1172 done
1173 unset updated_pkg
1175 # Look for new packages.
1176 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1177 if ! fgrep -q " ${pkg##*/}" $pkg_repository/packages.md5; then
1178 get_packages_info
1179 fi
1180 done
1181 report end-step
1182 packages_db_end
1185 packages_db_start()
1187 if [ ! -s packages.txt ]; then
1188 echo "# SliTaz GNU/Linux - Packages list
1190 # Packages : unknow
1191 # Date : $(date +%Y-%m-%d\ \%H:%M:%S)
1193 " > packages.txt
1194 else
1195 sed -e 's/^# Packages :.*/# Packages : unknow/' \
1196 -e "s/# Date :.*/# Date : $(date +%Y-%m-%d\ \%H:%M:%S)/" \
1197 -i packages.txt
1198 fi
1200 # Needed in some case as tazwok define RECEIPT at configuration time
1201 # in this particular case it can broke the script.
1202 unset RECEIPT
1205 erase_package_info()
1207 cd $pkg_repository
1208 sed "/^$PACKAGE$/,/^$/d" -i packages.txt
1209 sed "/^$PACKAGE /d" -i packages.desc
1210 sed -e "s/=$PACKAGE /= /" -e "s/ $PACKAGE / /" -e "s/ $PACKAGE$//" \
1211 -e "/=$PACKAGE$/d" -e "s/=[0-9,a-z,A-Z]:$PACKAGE /= /" \
1212 -e "s/ [0-9,a-z,A-Z]:$PACKAGE / /" -e "s/ [0-9,a-z,A-Z]:$PACKAGE$/ /" \
1213 -e "/=[0-9,a-z,A-Z]:$PACKAGE$/d" \
1214 -i packages.equiv
1215 sed "/^$PACKAGE:/d" -i files.list
1216 sed "/^$(basename ${pkg%.tazpkg})$/d" -i packages.list
1217 sed "/ $(basename $pkg)$/d" -i packages.md5
1220 get_packages_info()
1222 # If there's no taz folder in the wok, extract infos from the
1223 # package.
1224 get_pkg_files $pkg
1225 source_receipt
1226 echo "Getting datas from $PACKAGE"
1228 cat >> $pkg_repository/packages.txt << _EOT_
1229 $PACKAGE
1230 $VERSION$EXTRAVERSION
1231 $SHORT_DESC
1232 _EOT_
1233 if [ "$PACKED_SIZE" ]; then
1234 cat >> $pkg_repository/packages.txt << _EOT_
1235 $PACKED_SIZE ($UNPACKED_SIZE installed)
1237 _EOT_
1238 else
1239 echo "" >> $pkg_repository/packages.txt
1240 fi
1242 # Packages.desc is used by Tazpkgbox <tree>.
1243 echo "$PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> $pkg_repository/packages.desc
1245 # Packages.equiv is used by tazpkg install to check depends
1246 for i in $PROVIDE; do
1247 DEST=""
1248 echo $i | fgrep -q : && DEST="${i#*:}:"
1249 if grep -qs ^${i%:*}= $pkg_repository/packages.equiv; then
1250 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" $pkg_repository/packages.equiv
1251 else
1252 echo "${i%:*}=$DEST$PACKAGE" >> $pkg_repository/packages.equiv
1253 fi
1254 done
1256 if [ -f files.list ]; then
1257 { echo "$PACKAGE"; cat files.list; } | awk '
1258 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }' >> $pkg_repository/files.list
1259 fi
1261 cd .. && rm -r "$pkg_files_dir"
1263 cd $pkg_repository
1264 echo $(basename ${pkg%.tazpkg}) >> packages.list
1265 [ ! "$package_md5" ] && package_md5=$(md5sum $(basename $pkg))
1266 echo "$package_md5" >> packages.md5
1267 unset package_md5
1270 source_receipt()
1272 unset PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
1273 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
1274 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
1275 src _pkg DESTDIR CONFIG_SITE BRANCH TARBALL
1276 . ${RECEIPT:-$PWD/receipt}
1279 packages_db_end()
1281 cd $pkg_repository
1282 pkgs=$(wc -l packages.list | sed 's/ .*//')
1283 sed "s/# Packages : .*/# Packages : $pkgs/" -i packages.txt
1285 # If lists was updated it's generally needed to sort them well.
1286 if ! sort -c packages.list 2> /dev/null; then
1287 report step "Sorting packages lists"
1288 for file in packages.list packages.desc packages.equiv; do
1289 [ -f $file ] || continue
1290 sort -o $file $file
1291 done
1292 report end-step
1293 fi
1295 # Dont log this because lzma always output error.
1296 lzma e files.list files.list.lzma
1297 rm -f files.list
1298 [ -f packages.equiv ] || touch packages.equiv
1301 ########################################################################
1302 # This section contains functions to generate wok database.
1303 ########################
1305 gen_wok_db()
1307 report step "Generating wok database"
1308 report open-bloc
1309 report step "Removing old files"
1310 for file in $wan_db $dep_db $PACKAGES_REPOSITORY/cookorder.txt; do
1311 [ -f $file ] && rm $file
1312 done
1313 report step "Generating wok-wanted.txt"
1314 gen_wan_db
1315 report step "Generating wok-depends.txt"
1316 for PACKAGE in $(cut -f1 -d '|' $PACKAGES_REPOSITORY/packages.desc \
1317 $INCOMING_REPOSITORY/packages.desc | sort -u); do
1318 RECEIPT=$WOK/$PACKAGE/receipt
1319 if [ -s $RECEIPT ]; then
1320 source_receipt
1321 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
1322 fi
1323 done
1324 sort_db
1325 report close-bloc
1328 gen_wan_db()
1330 for RECEIPT in $(fgrep -l WANTED $WOK/*/receipt); do
1331 WANTED=
1332 source $RECEIPT
1333 [ "$WANTED" ] || continue
1334 echo -e $PACKAGE"\t"$WANTED >> $tmp/wan_db
1335 done
1336 if ! [ -f $wan_db ] || [ "$(diff -q $tmp/wan_db $wan_db)" ]; then
1337 mv -f $tmp/wan_db $wan_db
1338 plan_regen_cookorder=yes
1339 else
1340 rm $tmp/wan_db
1341 fi
1344 update_wan_db()
1346 local PACKAGE
1347 for RECEIPT in $(fgrep WANTED $WOK/*/receipt | \
1348 fgrep $PACKAGE | cut -f1 -d ':'); do
1349 WANTED=
1350 source $RECEIPT
1351 [ "$WANTED" ] || continue
1352 wan_info=$(echo -e $PACKAGE"\t"$WANTED)
1353 [ "$wan_info" = "$(grep -m1 ^$PACKAGE$'\t' $wan_db 2>/dev/null)" ] && return
1354 sed "/^$PACKAGE\t/d" -i $wan_db
1355 echo "$wan_info" >> $wan_db
1356 plan_regen_cookorder=yes
1357 plan_sort_wandb=yes
1358 done
1361 update_dep_db()
1363 dep_info=$(echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ')
1364 [ "$dep_info" = "$(grep -m1 ^$PACKAGE$'\t' $dep_db 2>/dev/null)" ] && return
1365 sed "/^$PACKAGE\t/d" -i $dep_db
1366 echo "$dep_info" >> $dep_db
1367 plan_regen_cookorder=yes
1368 plan_sort_depdb=yes
1371 sort_db()
1373 report step "Generating cookorder.txt"
1374 cat $dep_db | sed 's/ \t / /' | while read PACKAGE BUILD_DEPENDS; do
1375 grep -q ^$PACKAGE$'\t' $wan_db && continue
1377 # Replace each BUILD_DEPENDS with a WANTED package by it's
1378 # WANTED package.
1379 replace_by_wanted()
1381 for p in $BUILD_DEPENDS; do
1382 if grep -q ^$p$'\t' $wan_db; then
1383 echo -n $(grep ^$p$'\t' $wan_db | cut -f 2)' '
1384 else
1385 echo -n $p' '
1386 fi
1387 done | tr ' ' '\n' | sort -u | sed "/^$PACKAGE$/d" | tr '\n' ' '
1389 echo -e $PACKAGE"\t $(replace_by_wanted) "
1390 done > $tmp/db
1391 while [ -s "$tmp/db" ]; do
1392 status=start
1393 for pkg in $(cut -f 1 $tmp/db); do
1394 if ! fgrep -q ' '$pkg' ' $tmp/db; then
1395 echo $pkg >> $tmp/cookorder
1396 sed -e "/^$pkg\t/d" -e "s/ $pkg / /g" -i $tmp/db
1397 status=proceed
1398 fi
1399 done
1400 if [ "$status" = start ]; then
1401 cp -f $tmp/db /tmp/remain-depends.txt
1402 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
1403 for blocked in $(cut -f 1 $tmp/db); do
1404 echo "$blocked" >> $PACKAGES_REPOSITORY/blocked
1405 done
1406 break
1407 fi
1408 done
1409 [ -s $tmp/cookorder ] || touch $tmp/cookorder
1411 # The toolchain packages are moved in first position.
1412 grep $(for pkg in `scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1413 --look_for=all --with_args`; do echo " -e ^$pkg$"; done) \
1414 $tmp/cookorder | tac > $PACKAGES_REPOSITORY/cookorder.txt
1415 for pkg in $(cat $PACKAGES_REPOSITORY/cookorder.txt); do
1416 sed "/^$pkg$/d" -i $tmp/cookorder
1417 done
1419 tac $tmp/cookorder >> $PACKAGES_REPOSITORY/cookorder.txt
1420 unset plan_regen_cookorder
1421 report end-step
1424 ########################################################################
1425 # SCAN CORE
1426 ########################
1427 # Include various scan core-functions. It's not intended to be used
1428 # directly : prefer scan wrappers in next section.
1430 look_for_dep()
1432 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1433 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt \
1434 | cut -f 2
1435 else
1436 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1437 cut -f 2
1438 fi
1441 look_for_bdep()
1443 look_for_all
1446 look_for_all()
1448 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1449 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt \
1450 | cut -f 2,3 | sed 's/ / /'
1451 else
1452 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1453 cut -f 2,3 | sed 's/ / /'
1454 fi
1457 look_for_rdep()
1459 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | cut -f 1
1460 if [ "$undigest" ]; then
1461 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt | cut -f 1); do
1462 if [ ! -f "WOK$/$rdep/receipt" ]; then
1463 echo "$rdep"
1464 fi
1465 done
1466 fi
1469 look_for_rbdep()
1471 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | \
1472 cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
1473 if [ "$undigest" ]; then
1474 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt \
1475 | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1); do
1476 if [ ! -f "WOK$/$rdep/receipt" ]; then
1477 echo "$rdep"
1478 fi
1479 done
1480 fi
1483 # Return WANTED if it exists.
1484 look_for_wanted()
1486 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1487 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-wanted.txt | cut -f 2
1488 else
1489 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 2
1490 fi
1493 # Return packages which wants PACKAGE.
1494 look_for_rwanted()
1496 grep $'\t'$PACKAGE$ $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 1
1497 if [ "$undigest" ]; then
1498 for rwanted in $(grep $'\t'$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-wanted.txt | cut -f 1); do
1499 if [ ! -f "$WOK/$rwanted/receipt" ]; then
1500 echo "$rwanted"
1501 fi
1502 done
1503 fi
1506 look_for_dev()
1508 WANTED=$(look_for_wanted)
1509 if [ "$WANTED" ]; then
1510 if [ "$undigest" ] && [ ! -f "$WOK/$WANTED/receipt" ]; then
1511 [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$WANTED-dev/receipt" ] && echo $WANTED-dev
1512 else
1513 [ -f "$WOK/$WANTED-dev/receipt" ] && echo $WANTED-dev
1514 fi
1515 fi
1516 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1517 [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
1518 else
1519 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
1520 fi
1523 with_dev()
1525 for PACKAGE in $(cat); do
1526 echo $PACKAGE
1527 look_for_dev
1528 done
1531 with_wanted()
1533 for PACKAGE in $(cat); do
1534 echo $PACKAGE
1535 look_for_wanted
1536 done
1539 use_wanted()
1541 for input in $(cat); do
1542 { grep ^$input$'\t' $wan_db || echo $input
1543 } | sed 's/.*\t//'
1544 done
1547 ########################################################################
1548 # SCAN
1549 ########################
1550 # Use wok-wanted.txt and wok-depeds.txt to scan depends.
1551 # Option in command line (must be first arg) :
1552 # --look_for=bdep/rbdep - Look for depends or reverse depends.
1553 # --with_dev - Add development packages (*-dev) in the result.
1554 # --with_wanted - Add package+reverse wanted in the result.
1555 # --with_args - Include packages in argument in the result.
1557 scan()
1559 # Get packages in argument.
1560 local PACKAGE WANTED pkg_list=
1561 for arg in $@; do
1562 [ "$arg" = "${arg#--}" ] || continue
1563 pkg_list="$pkg_list $arg"
1564 done
1566 # Get options.
1567 [ "$pkg_list" ] || return
1568 local cooklist= look_for= with_dev= with_wanted= with_args= log_command="$0 $@" \
1569 get_options_list="look_for with_dev with_wanted with_args cooklist use_wanted"
1570 get_options
1572 # Cooklist is a special case where we need to modify a little
1573 # scan behavior
1574 if [ "$cooklist" ]; then
1575 gen_wan_db
1576 look_for=all && with_args=yes && with_dev= && with_wanted=
1577 filter=use_wanted
1578 if [ "$COMMAND" = gen-cooklist ]; then
1579 for PACKAGE in $pkg_list; do
1580 grep -q ^$PACKAGE$'\t' $dep_db && continue
1581 [ -d "$WOK/$p" ] || continue
1582 check_for_missing
1583 done
1584 append_to_dep()
1586 if ! grep -q ^$PACKAGE$'\t' $dep_db; then
1587 check_for_missing && echo $PACKAGE >> $tmp/dep
1588 else
1589 echo $PACKAGE >> $tmp/dep
1590 fi
1592 else
1593 append_to_dep()
1595 check_for_commit && echo $PACKAGE >> $tmp/dep
1597 fi
1598 else
1599 append_to_dep()
1601 echo $PACKAGE >> $tmp/dep
1603 # If requested packages are not in dep_db, partial generation of this db is needed.
1604 for PACKAGE in $pkg_list; do
1605 grep -q ^$PACKAGE$'\t' $dep_db && continue
1606 [ -d "$WOK/$p" ] || continue
1607 plan_check_for_missing=yes
1608 check_for_missing
1609 done
1610 if [ "$plan_check_for_missing" ]; then
1611 append_to_dep()
1613 if ! grep -q ^$PACKAGE$'\t' $dep_db; then
1614 check_for_missing && echo $PACKAGE >> $tmp/dep
1615 else
1616 echo $PACKAGE >> $tmp/dep
1617 fi
1619 check_db_status=yes
1620 unset plan_check_for_missing
1621 fi
1622 fi
1624 [ "$with_dev" ] && filter=with_dev
1625 [ "$with_wanted" ] && filter=with_wanted
1626 if [ "$filter" ]; then
1627 pkg_list=$(echo $pkg_list | $filter)
1628 scan_pkg()
1630 look_for_$look_for | $filter
1632 else
1633 scan_pkg()
1635 look_for_$look_for
1637 fi
1638 touch $tmp/dep
1639 for PACKAGE in $pkg_list; do
1640 [ "$with_args" ] && append_to_dep
1641 scan_pkg
1642 done | tr ' ' '\n' | sort -u > $tmp/list
1643 [ "$look_for" = bdep ] && look_for=dep
1644 while [ -s $tmp/list ]; do
1645 PACKAGE=$(sed 1!d $tmp/list)
1646 sed 1d -i $tmp/list
1647 append_to_dep
1648 for pkg in $(scan_pkg); do
1649 if ! grep -q ^$pkg$ $tmp/list $tmp/dep; then
1650 echo $pkg >> $tmp/list
1651 fi
1652 done
1653 done
1654 if [ "$cooklist" ]; then
1655 mv $tmp/dep $tmp/cooklist
1656 else
1657 cat $tmp/dep | sort -u
1658 fi
1659 rm -f $tmp/dep $tmp/list
1660 if [ "$check_db_status" ]; then
1661 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
1662 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
1663 if [ "$plan_regen_cookorder" ]; then
1664 grep -q "^#" $PACKAGES_REPOSITORY/cookorder.txt || \
1665 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
1666 fi
1667 fi
1670 ########################################################################
1671 # This section contains functions to check package repository and
1672 # find which packages to cook.
1673 ########################
1675 check_for_missing()
1677 local PACKAGE
1678 if ! check_for_pkg_in_wok; then
1679 [ "$?" = 2 ] && return 1
1680 return
1681 fi
1682 RECEIPT=$WOK/$PACKAGE/receipt
1683 source_receipt
1684 PACKAGE=${WANTED:-$PACKAGE}
1685 update_wan_db
1686 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
1687 RECEIPT=$WOK/$PACKAGE/receipt
1688 source_receipt
1689 update_dep_db
1690 done
1693 check_for_commit()
1695 if ! check_for_pkg_in_wok; then
1696 [ "$?" = 2 ] && return 1
1697 return
1698 fi
1699 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
1700 RECEIPT=$WOK/$PACKAGE/receipt
1701 source_receipt
1703 # We use md5 of cooking stuff in the packaged receipt to check
1704 # commit. We look consecutively in 3 different locations :
1705 # - in the wok/PACKAGE/taz/* folder
1706 # - in the receipt in the package in incoming repository
1707 # - in the receipt in the package in packages repository
1708 # If md5sum match, there's no commit.
1709 check_for_commit_using_md5sum()
1711 if [ ! -f $WOK/$PACKAGE/md5 ]; then
1712 sed -n '/# md5sum of cooking stuff :/,$p' receipt | \
1713 sed -e 1d -e 's/^# //' > $WOK/$PACKAGE/md5
1714 cd $WOK/$PACKAGE
1715 fi
1717 if [ -s md5 ]; then
1718 if md5sum -cs md5; then
1720 # If md5sum check if ok, check for new/missing files in
1721 # cooking stuff.
1722 for file in $([ -f receipt ] && echo receipt; \
1723 [ -f description.txt ] && echo description.txt; \
1724 [ -d stuff ] && find stuff); do
1725 if ! fgrep -q " $file" md5; then
1726 set_commited
1727 fi
1728 done
1729 else
1730 set_commited
1731 fi
1732 else
1733 set_commited
1734 fi
1736 set_commited()
1738 ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/commit &&
1739 echo $PACKAGE >> $PACKAGES_REPOSITORY/commit
1740 gen_cookmd5
1741 update_dep_db
1743 taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | fgrep -v '*')
1744 if [ -f $WOK/$PACKAGE/md5 ]; then
1745 cd $WOK/$PACKAGE
1746 check_for_commit_using_md5sum
1747 elif [ "$taz_dir" ]; then
1748 cd $taz_dir
1749 check_for_commit_using_md5sum
1750 else
1751 pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1752 [ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1753 if [ "$pkg" ]; then
1754 get_pkg_files $pkg
1755 check_for_commit_using_md5sum
1756 rm -r $pkg_files_dir
1757 else
1758 set_commited
1759 fi
1760 fi
1761 [ "$forced" ] || echo $PACKAGE >> $tmp/checked
1762 done
1763 return
1766 gen_cook_list()
1768 report step "Scanning wok"
1769 if [ "$pkg" ]; then
1770 scan $pkg --cooklist
1771 else
1772 scan `cat $cooklist` --cooklist
1773 fi
1774 report end-step
1776 [ -s $tmp/checked ] || [ -s $tmp/cooklist ] || return
1778 # Core toolchain should not be cooked unless cook-toolchain is used.
1779 if ! [ -f /etc/config.site.tmptoolchain ] ; then
1780 for PACKAGE in $(scan gcc --look_for=all --with_args --with_wanted); do
1781 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/blocked || \
1782 echo $PACKAGE >> $PACKAGES_REPOSITORY/blocked
1783 done
1784 fi
1786 if [ -s $PACKAGES_REPOSITORY/commit ] && [ "$COMMAND" != gen-cooklist ]; then
1787 cd $PACKAGES_REPOSITORY
1788 for PACKAGE in $(cat commit); do
1789 WANTED="$(look_for_wanted)"
1790 if [ "$WANTED" ]; then
1791 grep -q ^$WANTED$ broken cooklist blocked commit && continue
1792 fi
1793 grep -q ^$PACKAGE$ blocked cooklist && continue
1794 echo $PACKAGE >> cooklist
1795 done
1796 fi
1797 sort_cooklist
1800 sort_cooklist()
1802 if [ "$(sed 1!d $PACKAGES_REPOSITORY/cookorder.txt)" = "#PlanSort" ]; then
1803 sed 1d -i $PACKAGES_REPOSITORY/cookorder.txt
1804 plan_regen_cookorder=yes
1805 fi
1806 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
1807 [ "$plan_regen_cookorder" ] && sort_db
1808 report step "Sorting cooklist"
1809 if [ -f "$tmp/checked" ]; then
1810 rm -f $tmp/cooklist
1811 cat $tmp/checked | while read PACKAGE; do
1812 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/cooklist && \
1813 echo $PACKAGE >> $tmp/cooklist
1814 done
1815 elif ! [ "$COMMAND" = gen-cooklist ]; then
1816 cat $PACKAGES_REPOSITORY/blocked | while read PACKAGE; do
1817 sed "/^$PACKAGE/d" -i $tmp/cooklist
1818 done
1819 fi
1821 for PACKAGE in $(cat $tmp/cooklist); do
1822 WANTED="$(look_for_wanted)"
1823 [ "$WANTED" ] || continue
1824 if grep -q ^$WANTED$ $PACKAGES_REPOSITORY/broken $tmp/cooklist; then
1825 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1826 elif [ ! -d $WOK/$WANTED/install ]; then
1827 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1828 echo $WANTED >> $tmp/cooklist
1829 fi
1830 done
1832 # Use cookorder.txt to sort cooklist.
1833 if [ -s $tmp/cooklist ]; then
1834 cat $PACKAGES_REPOSITORY/cookorder.txt | while read PACKAGE; do
1835 if grep -q ^$PACKAGE$ $tmp/cooklist; then
1836 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1837 echo $PACKAGE >> $tmp/cooklist.tmp
1838 fi
1839 done
1841 # Remaining packages in cooklist are thoses without compile_rules.
1842 # They can be cooked first in any order.
1843 if [ -f $tmp/cooklist.tmp ]; then
1844 cat $tmp/cooklist.tmp >> $tmp/cooklist
1845 rm $tmp/cooklist.tmp
1846 fi
1848 cat $tmp/cooklist
1849 [ "$cooklist" = "$PACKAGES_REPOSITORY/cooklist" ] && \
1850 cat $tmp/cooklist > $cooklist
1851 fi
1853 report end-step
1856 check_for_incoming()
1858 [ -s $INCOMING_REPOSITORY/packages.desc ] || {
1859 echo "No packages in $INCOMING_REPOSITORY."
1860 return; }
1861 if [ -s $PACKAGES_REPOSITORY/broken ]; then
1862 echo "Don't move incoming packages to main repository because theses ones are broken:
1863 $(cat $PACKAGES_REPOSITORY/broken)" >&2
1864 return
1865 fi
1866 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
1867 echo "Don't move incoming packages to main repository because some of them need to be cooked:
1868 $(cat $PACKAGES_REPOSITORY/cooklist)" >&2
1869 return
1870 fi
1871 pkg="$(cut -f 1 -d '|' $INCOMING_REPOSITORY/packages.desc)"
1872 if ! [ "$forced" ]; then
1873 cooklist=$PACKAGES_REPOSITORY/cooklist
1874 gen_cook_list
1875 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
1876 echo "Don't move incoming packages to main repository because some of them need to be cooked." >&2
1877 return
1878 fi
1879 fi
1880 report step "Moving incoming packages to main repository"
1881 unset EXTRAVERSION
1882 for PACKAGE in $pkg; do
1883 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
1884 VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
1885 remove_previous_package $PACKAGES_REPOSITORY
1886 echo "Moving $PACKAGE..."
1887 mv -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION.tazpkg $PACKAGES_REPOSITORY
1888 touch $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
1889 previous_tarball=$(grep ^$PACKAGE:main $SOURCES_REPOSITORY/sources.list | cut -f2)
1890 sed -e "/^$PACKAGE:main/d" \
1891 -e "s/^$PACKAGE:incoming/$PACKAGE:main/"
1892 -i $SOURCES_REPOSITORY/sources.list
1893 if [ "$previous_tarball" ]; then
1894 grep -q $'\t'$previous_tarball$ $SOURCES_REPOSITORY/sources.list || \
1895 rm -f $SOURCES_REPOSITORY/$previous_tarball
1896 fi
1897 done
1898 report end-step
1899 for file in packages.list packages.equiv packages.md5 packages.desc \
1900 packages.txt; do
1901 echo -n "" > $INCOMING_REPOSITORY/$file
1902 done
1903 rm -r $INCOMING_REPOSITORY/files.list.lzma
1904 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
1907 ########################################################################
1908 # TAZWOK MAIN FUNCTIONS
1909 ########################
1911 clean()
1913 cd $WOK/$PACKAGE
1914 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
1915 -e ^stuff$ || return
1917 [ "$COMMAND" = clean-wok ] || report step "Cleaning $PACKAGE"
1918 # Check for clean_wok function.
1919 if grep -q ^clean_wok $RECEIPT; then
1920 clean_wok
1921 fi
1922 # Clean should only have a receipt, stuff and optional desc.
1923 for f in `ls .`
1924 do
1925 case $f in
1926 receipt|stuff|description.txt|md5)
1927 continue ;;
1928 *)
1929 rm -rf $f ;;
1930 esac
1931 done
1932 [ "$COMMAND" != clean-wok ] && report end-step
1935 # Configure and make a package with the receipt.
1936 compile_package()
1938 check_for_package_on_cmdline
1940 # Include the receipt to get all needed variables and functions
1941 # and cd into the work directory to start the work.
1942 check_for_receipt
1943 source_receipt
1945 # Log the package name and date.
1946 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
1947 echo "package $PACKAGE (compile)" >> $LOG
1949 # Set wanted $src variable to help compiling.
1950 [ ! "$src" ] && set_src_path
1951 check_for_build_depends || return 1
1952 check_for_wanted
1953 unset target
1954 check_for_tarball && check_for_compile_rules
1957 # Cook command also include all features to manage lists which keep
1958 # track of wok/packages state.
1959 cook()
1961 cook_code=
1962 set_common_path
1963 check_for_receipt
1964 source_receipt
1966 # Define log path and start report.
1967 [ -f $LOCAL_REPOSITORY/log/$PACKAGE.html ] && rm $LOCAL_REPOSITORY/log/$PACKAGE.html
1968 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
1969 report step "Cooking $PACKAGE"
1970 report open-bloc
1972 clean $PACKAGE
1973 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
1975 if compile_package; then
1976 remove_src
1977 refresh_packages_from_compile
1978 gen_package
1980 # Update packages-incoming repository.
1981 store_pkgname=$PACKAGE
1982 pkg_repository=$INCOMING_REPOSITORY
1983 update_packages_db
1985 PACKAGE=$store_pkgname
1986 unset store_pkgname
1988 # Upgrade to cooked packages if it was previously installed.
1989 report step "Look for package(s) to upgrade"
1990 for pkg in $(look_for_rwanted) $PACKAGE; do
1991 if [ -d $INSTALLED/$pkg ]; then
1992 tazpkg get-install $pkg --forced
1993 fi
1994 done
1995 report end-step
1996 else
1998 # Set package as broken.
1999 if ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then
2000 echo $PACKAGE >> $PACKAGES_REPOSITORY/broken
2001 fi
2002 gen_cookmd5
2003 cook_code=1
2004 fi
2006 # Remove build_depends in cook mode (if in cooklist, it's done when
2007 # checking build_depends of next package and we remove only unneeded
2008 # packages to keep chroot minimal and gain some time).
2009 if [ "$COMMAND" = cook ]; then
2010 remove_build_depends $MISSING_PACKAGE
2011 [ -x /usr/bin/clean-chroot ] && clean-chroot
2012 fi
2014 # Regen the cooklist if it was planned and command is not cook.
2015 [ "$regen_cooklist" ] && unset regen_cooklist && \
2016 [ "$COMMAND" != cook ] && sort_cooklist
2018 # Some hacks to set the bloc & function status as failed if cook was
2019 # failed.
2020 report_return_code=$cook_code
2021 report close-bloc
2022 report end-sublog
2023 return $cook_code
2026 cook_list()
2028 if [ -s $tmp/cooklist ]; then
2029 if [ -f /usr/bin/tazchroot ]; then
2030 # Note : options -main variables- are automatically keeped by
2031 # the sub-applications tazchroot/tazwok; as well as report data.
2032 cd $LOCAL_REPOSITORY
2033 [ ! -f tazchroot.conf ] && configure_tazchroot
2034 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
2035 return
2036 fi
2037 while [ -s $tmp/cooklist ]; do
2038 PACKAGE=$(sed 1!d $tmp/cooklist)
2039 cook
2040 done
2041 remove_build_depends $MISSING_PACKAGE $remove_later
2042 [ -x /usr/bin/clean-chroot ] && clean-chroot
2043 else
2044 echo "Nothing to cook."
2045 return
2046 fi
2049 configure_tazchroot()
2051 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
2052 # Tazchroot configuration file - created by tazwok.
2054 # Default chroot path
2055 SLITAZ_DIR=$SLITAZ_DIR
2056 SLITAZ_VERSION=$SLITAZ_VERSION
2057 $( [ "$undigest" ] && echo "undigest=$undigest" )
2058 LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
2059 chroot_dir=\$LOCAL_REPOSITORY/chroot
2061 # Default scripts path (theses scripts are added in the
2062 # $chroot_dir/usr/bin and can be called with tazchroot script)
2063 script_dir=/var/lib/tazchroot
2065 # List of directories to mount.
2066 list_dir="$(for dir in packages wok src packages-incoming log flavors iso; do echo $LOCAL_REPOSITORY/$dir; done)
2067 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
2069 create_chroot()
2071 mkdir -p \$chroot_dir
2072 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
2073 tazpkg get-install \$pkg --root="\$chroot_dir"
2074 done
2076 # Store list of installed packages needed by cleanchroot.
2077 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
2079 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
2080 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
2081 -i \$chroot_dir/etc/slitaz/slitaz.conf
2082 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
2083 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
2086 mount_chroot()
2088 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
2089 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCALSTATE/mirror
2090 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
2091 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
2092 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION
2093 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror' )
2094 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
2095 mount -t proc proc \$chroot_dir/proc
2096 mount -t sysfs sysfs \$chroot_dir/sys
2097 mount -t devpts devpts \$chroot_dir/dev/pts
2098 mount -t tmpfs shm \$chroot_dir/dev/shm
2099 for dir in \$list_dir; do
2100 mkdir -p \$dir \$chroot_dir\$dir
2101 mount \$dir \$chroot_dir\$dir
2102 done
2105 umount_chroot()
2107 for dir in \$list_dir; do
2108 umount \$chroot_dir\$dir
2109 done
2110 umount \$chroot_dir/dev/shm
2111 umount \$chroot_dir/dev/pts
2112 umount \$chroot_dir/sys
2113 umount \$chroot_dir/proc
2115 EOF
2118 ########################################################################
2119 ######################### END OF NEW FUNCTIONS #########################
2120 ########################################################################
2122 # List packages providing a virtual package
2123 whoprovide()
2125 local i;
2126 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
2127 . $i
2128 case " $PROVIDE " in
2129 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
2130 esac
2131 done
2134 ########################################################################
2135 # TAZWOK COMMANDS
2136 ########################
2138 case "$COMMAND" in
2139 stats)
2140 # Tazwok general statistics from the wok config file.
2142 get_tazwok_config
2143 echo -e "\n\033[1mTazwok configuration statistics\033[0m
2144 ================================================================================
2145 Wok directory : $WOK
2146 Packages repository : $PACKAGES_REPOSITORY
2147 Incoming repository : $INCOMING_REPOSITORY
2148 Sources repository : $SOURCES_REPOSITORY
2149 Log directory : $LOCAL_REPOSITORY/log
2150 Packages in the wok : `ls -1 $WOK | wc -l`
2151 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2152 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2153 ================================================================================\n"
2154 ;;
2155 edit)
2156 get_tazwok_config
2157 check_for_package_on_cmdline
2158 check_for_receipt
2159 $EDITOR $WOK/$PACKAGE/receipt
2160 ;;
2161 build-depends)
2162 # List dependencies to rebuild wok, or only a package
2163 get_tazwok_config
2164 report(){ : ; }
2165 if [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
2166 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
2167 --look_for=dep --with_dev --with_args
2168 else
2169 check_for_package_on_cmdline
2170 scan $PACKAGE --look_for=bdep --with_dev
2171 fi
2172 ;;
2173 gen-cooklist)
2174 check_root
2175 get_options_list="pkg"
2176 get_tazwok_config
2177 report(){ : ; }
2178 if ! [ "$pkg" ]; then
2179 if [ ! "$LIST" ] || [ "$LIST" = toolchain ]; then
2180 pkg="$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA"
2181 else
2182 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2183 fi
2184 fi
2185 gen_cook_list
2186 ;;
2187 check-depends)
2188 # Check package depends /!\
2189 get_tazwok_config
2190 echo ""
2191 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
2192 ================================================================================"
2193 TMPDIR=/tmp/tazwok$$
2194 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
2196 # Build ALL_DEPENDS variable
2197 scan_dep()
2199 local i
2200 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
2201 for i in $DEPENDS $SUGGESTED ; do
2202 case " $ALL_DEPENDS " in
2203 *\ $i\ *) continue;;
2204 esac
2205 [ -d $WOK/$i ] || {
2206 ALL_DEPENDS="$ALL_DEPENDS$i "
2207 continue
2209 DEPENDS=""
2210 SUGGESTED=""
2211 . $WOK/$i/receipt
2212 scan_dep
2213 done
2216 # Check for ELF file
2217 is_elf()
2219 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" \
2220 = "ELF" ]
2223 # Print shared library dependencies
2224 ldd()
2226 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
2229 mkdir $TMPDIR
2230 cd $TMPDIR
2231 for i in $LOCALSTATE/files.list.lzma \
2232 $LOCALSTATE/undigest/*/files.list.lzma ; do
2233 [ -f $i ] && lzma d $i -so >> files.list
2234 done
2235 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
2236 tazpkg extract $pkg > /dev/null 2>&1
2237 . */receipt
2238 ALL_DEPENDS="$DEFAULT_DEPENDS "
2239 scan_dep
2240 find */fs -type f | while read file ; do
2241 is_elf $file || continue
2242 case "$file" in
2243 *.o|*.ko|*.ko.gz) continue;;
2244 esac
2245 ldd $file | while read lib rem; do
2246 case "$lib" in
2247 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
2248 continue;;
2249 esac
2250 for dep in $(fgrep $lib files.list | cut -d: -f1); do
2251 case " $ALL_DEPENDS " in
2252 *\ $dep\ *) continue 2;;
2253 esac
2254 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
2255 case " $ALL_DEPENDS " in
2256 *\ $vdep\ *) continue 3;;
2257 esac
2258 done
2259 done
2260 [ -n "$dep" ] || dep="UNKNOWN"
2261 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
2262 done
2263 done
2264 rm -rf */
2265 done
2266 cd /tmp
2267 rm -rf $TMPDIR
2268 ;;
2269 check)
2270 # Check wok consistency
2271 get_tazwok_config
2272 echo ""
2273 echo -e "\033[1mWok and packages checking\033[0m
2274 ================================================================================"
2275 cd $WOK
2276 for pkg in $(ls)
2277 do
2278 [ -f $pkg/receipt ] || continue
2279 RECEIPT= $pkg/receipt
2280 source_receipt
2281 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
2282 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
2283 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
2284 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
2285 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
2286 if [ -n "$WANTED" ]; then
2287 if [ ! -f $WANTED/receipt ]; then
2288 echo "Package $PACKAGE wants unknown $WANTED package" >&2
2289 else
2290 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
2291 if [ "$VERSION" = "$WANTED" ]; then
2292 # BASEVERSION is computed in receipt
2293 fgrep -q '_pkg=' $pkg/receipt &&
2294 BASEVERSION=$VERSION
2295 fi
2296 if [ "$VERSION" != "$BASEVERSION" ]; then
2297 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
2298 fi
2299 fi
2300 fi
2302 if [ -n "$CATEGORY" ]; then
2303 case " $(echo $CATEGORIES) " in
2304 *\ $CATEGORY\ *);;
2305 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
2306 esac
2307 else
2308 echo"Package $PACKAGE has no CATEGORY" >&2
2309 fi
2310 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
2311 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
2312 case "$WGET_URL" in
2313 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
2314 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
2315 '') ;;
2316 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
2317 esac
2318 case "$WEB_SITE" in
2319 ftp*|http*);;
2320 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
2321 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
2322 esac
2323 case "$MAINTAINER" in
2324 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
2325 esac
2326 case "$MAINTAINER" in
2327 *@*);;
2328 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
2329 esac
2330 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2331 for i in $DEPENDS; do
2332 [ -d $i ] && continue
2333 [ -n "$(whoprovide $i)" ] && continue
2334 echo -e "$MSG $i"
2335 MSG=""
2336 done
2337 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2338 for i in $BUILD_DEPENDS; do
2339 [ -d $i ] && continue
2340 [ -n "$(whoprovide $i)" ] && continue
2341 echo -e "$MSG $i"
2342 MSG=""
2343 done
2344 MSG="Dependencies loop between $PACKAGE and :\n"
2345 ALL_DEPS=""
2346 check_for_deps_loop $PACKAGE $DEPENDS
2347 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
2348 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
2349 echo "$pkg should be rebuilt after $i installation"
2350 done
2351 done
2352 ;;
2353 list)
2354 # List packages in wok directory. User can specify a category.
2356 get_tazwok_config
2357 if [ "$2" = "category" ]; then
2358 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
2359 exit 0
2360 fi
2361 # Check for an asked category.
2362 if [ -n "$2" ]; then
2363 ASKED_CATEGORY=$2
2364 echo ""
2365 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
2366 echo "================================================================================"
2367 for pkg in $WOK/*
2368 do
2369 [ ! -f $pkg/receipt ] && continue
2370 . $pkg/receipt
2371 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
2372 echo -n "$PACKAGE"
2373 echo -e "\033[28G $VERSION"
2374 packages=$(($packages+1))
2375 fi
2376 done
2377 echo "================================================================================"
2378 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
2379 else
2380 # By default list all packages and version.
2381 echo ""
2382 echo -e "\033[1mList of packages in the wok\033[0m"
2383 echo "================================================================================"
2384 for pkg in $WOK/*
2385 do
2386 [ ! -f $pkg/receipt ] && continue
2387 . $pkg/receipt
2388 echo -n "$PACKAGE"
2389 echo -en "\033[28G $VERSION"
2390 echo -e "\033[42G $CATEGORY"
2391 packages=$(($packages+1))
2392 done
2393 echo "================================================================================"
2394 echo -e "$packages packages available in the wok.\n"
2395 fi
2396 ;;
2397 info)
2398 # Information about a package.
2400 get_tazwok_config
2401 check_for_package_on_cmdline
2402 check_for_receipt
2403 . $WOK/$PACKAGE/receipt
2404 echo ""
2405 echo -e "\033[1mTazwok package information\033[0m
2406 ================================================================================
2407 Package : $PACKAGE
2408 Version : $VERSION
2409 Category : $CATEGORY
2410 Short desc : $SHORT_DESC
2411 Maintainer : $MAINTAINER"
2412 if [ ! "$WEB_SITE" = "" ]; then
2413 echo "Web site : $WEB_SITE"
2414 fi
2415 if [ ! "$DEPENDS" = "" ]; then
2416 echo "Depends : $DEPENDS"
2417 fi
2418 if [ ! "$WANTED" = "" ]; then
2419 echo "Wanted src : $WANTED"
2420 fi
2421 echo "================================================================================"
2422 echo ""
2423 ;;
2424 check-log)
2425 # We just cat the file log to view process info.
2427 get_tazwok_config
2428 if [ ! -f "$LOG" ]; then
2429 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
2430 exit 1
2431 else
2432 echo ""
2433 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
2434 echo "================================================================================"
2435 cat $LOG
2436 echo "================================================================================"
2437 echo ""
2438 if [ -s "$WOK/$PACKAGE/warning.txt" ]; then
2439 echo -e "\033[1mCook warning(s) for :\033[0m $PACKAGE"
2440 echo "================================================================================"
2441 cat "$WOK/$PACKAGE/warning.txt"
2442 echo "================================================================================"
2443 echo ""
2444 fi
2445 fi
2446 ;;
2447 search)
2448 # Search for a package by pattern or name.
2450 get_tazwok_config
2451 if [ -z "$2" ]; then
2452 echo -e "\nPlease specify a pattern or a package name to search." >&2
2453 echo -e "Example : 'tazwok search gcc'.\n" >&2
2454 exit 1
2455 fi
2456 echo ""
2457 echo -e "\033[1mSearch result for :\033[0m $2"
2458 echo "================================================================================"
2459 list=`ls -1 $WOK | fgrep $2`
2460 for pkg in $list
2461 do
2462 . $WOK/$pkg/receipt
2463 echo -n "$PACKAGE "
2464 echo -en "\033[24G $VERSION"
2465 echo -e "\033[42G $CATEGORY"
2466 packages=$(($PACKAGEs+1))
2467 done
2468 echo "================================================================================"
2469 echo "$packages packages found for : $2"
2470 echo ""
2471 ;;
2472 compile)
2473 # Configure and make a package with the receipt.
2475 get_tazwok_config
2476 source_lib report
2477 report start
2478 compile_package
2479 ;;
2480 genpkg)
2481 # Generate a package.
2483 get_tazwok_config
2484 source_lib report
2485 report start
2486 gen_package
2487 ;;
2488 cook)
2489 # Compile and generate a package. Just execute tazwok with
2490 # the good commands.
2492 check_root
2493 get_tazwok_config
2494 source_lib report
2495 report start
2496 update_wan_db
2497 check_for_commit
2498 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
2499 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
2500 if [ "$plan_regen_cookorder" ]; then
2501 grep -q "^#" $PACKAGES_REPOSITORY/cookorder.txt || \
2502 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
2503 fi
2504 cook
2505 ;;
2506 sort-cooklist)
2507 if [ ! "$LIST" ]; then
2508 echo "Usage : tazwok sort-cooklist cooklist" >&2\
2509 exit 1
2510 fi
2511 get_tazwok_config
2512 source_lib report
2513 report start
2514 cooklist=$LIST
2515 sort_cooklist
2516 cp -af $tmp/cooklist $cooklist
2517 ;;
2518 cook-list)
2519 # Cook all packages listed in a file or in default cooklist.
2520 check_root
2521 get_options_list="pkg forced"
2522 get_tazwok_config
2523 source_lib report
2524 report start
2525 if ! [ "$pkg" ]; then
2526 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2527 fi
2528 gen_cook_list
2529 cook_list
2530 ;;
2531 clean)
2532 # Clean up a package work directory + thoses which want it.
2534 get_tazwok_config
2535 check_for_package_on_cmdline
2536 check_for_receipt
2537 source_lib report
2538 report start
2539 . $RECEIPT
2540 clean
2541 ;;
2542 gen-clean-wok)
2543 # Generate a clean wok from the current wok by copying all receipts
2544 # and stuff directory.
2546 get_tazwok_config
2547 source_lib report
2548 report start
2549 if [ -z "$ARG" ]; then
2550 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
2551 exit 1
2552 else
2553 dest=$ARG
2554 mkdir -p $dest
2555 fi
2556 report step "Creating clean wok in : $dest"
2557 for pkg in `ls -1 $WOK`
2558 do
2559 mkdir -p $dest/$pkg
2560 cp -a $WOK/$pkg/receipt $dest/$pkg
2561 [ -f $WOK/$pkg/description.txt ] && \
2562 cp -a $WOK/$pkg/description.txt $dest/$pkg
2563 if [ -d "$WOK/$pkg/stuff" ]; then
2564 cp -a $WOK/$pkg/stuff $dest/$pkg
2565 fi
2566 done
2567 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
2568 report end-step
2569 echo "Packages cleaned : `ls -1 $dest | wc -l`"
2570 echo ""
2571 ;;
2572 clean-wok)
2573 # Clean all packages in the work directory
2575 get_tazwok_config
2576 source_lib report
2577 report start
2578 report step "Cleaning wok"
2579 for PACKAGE in `ls -1 $WOK`
2580 do
2581 set_common_path
2582 source_receipt
2583 clean
2584 done
2585 echo "`ls -1 $WOK | wc -l` packages cleaned."
2586 ;;
2587 clean-src)
2588 # Remove tarball unrelated to wok receipts from src repo.
2589 check_root
2590 get_options_list="forced"
2591 get_tazwok_config
2592 cd $SOURCES_REPOSITORY
2593 echo -n "Checking $SOURCES_REPOSITORY..."
2594 for TARBALL in *; do
2595 [ "$TARBALL" = sources.list ] && continue
2596 grep -q $'\t'$TARBALL$ $SOURCES_REPOSITORY/sources.list || \
2597 echo $TARBALL >> $tmp/obsolete
2598 done
2599 status
2600 echo ""
2601 echo -e "\033[1mObsolete/unrelated-to-wok sourcess :\033[0m"
2602 horizontal_line
2603 cat $tmp/obsolete
2604 horizontal_line
2605 echo "$(wc -l $tmp/obsolete | cut -f1 -d' ') tarballs to remove."
2606 echo ""
2607 echo -n "Please confirm removing (type uppercase YES): "
2608 read answer
2609 if [ "$answer" = YES ]; then
2610 echo -n "Removing old sources..."
2611 cat $tmp/obsolete | while read i; do
2612 rm -f $SOURCES_REPOSITORY/$i
2613 done
2614 status
2615 fi
2616 ;;
2617 gen-list)
2618 get_tazwok_config
2619 if [ "$2" ]; then
2620 if [ -d "$2" ]; then
2621 pkg_repository=$2
2622 else
2623 echo -e "\nUnable to find directory : $2\n" >&2
2624 exit 1
2625 fi
2626 fi
2628 source_lib report
2629 report start
2630 if [ "$pkg_repository" ]; then
2631 gen_packages_db
2632 else
2633 pkg_repository=$PACKAGES_REPOSITORY && gen_packages_db
2634 pkg_repository=$INCOMING_REPOSITORY && gen_packages_db
2635 fi
2636 ;;
2637 check-list)
2638 # The directory to move into by default is the repository,
2639 # if $2 is not empty cd into $2.
2641 get_tazwok_config
2642 if [ "$2" ]; then
2643 if [ -d "$2" ]; then
2644 pkg_repository=$2
2645 else
2646 echo -e "\nUnable to find directory : $2\n" >&2
2647 exit 1
2648 fi
2649 fi
2651 source_lib report
2652 report start
2653 if [ "$pkg_repository" ]; then
2654 update_packages_db
2655 else
2656 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
2657 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
2658 fi
2659 ;;
2660 new-tree)
2661 # Just create a few directories and generate an empty receipt to prepare
2662 # the creation of a new package.
2664 get_tazwok_config
2665 check_for_package_on_cmdline
2666 if [ -d $WOK/$PACKAGE ]; then
2667 echo -e "\n$PACKAGE package tree already exists.\n" >&2
2668 exit 1
2669 fi
2670 echo "Creating : $WOK/$PACKAGE"
2671 mkdir $WOK/$PACKAGE
2672 cd $WOK/$PACKAGE
2673 echo -n "Preparing the receipt..."
2675 # Default receipt begin.
2677 echo "# SliTaz package receipt." > receipt
2678 echo "" >> receipt
2679 echo "PACKAGE=\"$PACKAGE\"" >> receipt
2680 # Finish the empty receipt.
2681 cat >> receipt << "EOF"
2682 VERSION=""
2683 CATEGORY=""
2684 SHORT_DESC=""
2685 MAINTAINER=""
2686 DEPENDS=""
2687 TARBALL="$PACKAGE-$VERSION.tar.gz"
2688 WEB_SITE=""
2689 WGET_URL=""
2691 # Rules to configure and make the package.
2692 compile_rules()
2694 cd $src
2695 ./configure && make && make install
2698 # Rules to gen a SliTaz package suitable for Tazpkg.
2699 genpkg_rules()
2701 mkdir -p $fs/usr
2702 cp -a $_pkg/usr/bin $fs/usr
2705 EOF
2707 # Default receipt end.
2709 status
2710 # Interactive mode, asking and seding.
2711 if [ "$3" = "--interactive" ]; then
2712 echo "Entering into interactive mode..."
2713 echo "================================================================================"
2714 echo "Package : $PACKAGE"
2715 # Version.
2716 echo -n "Version : " ; read anser
2717 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
2718 # Category.
2719 echo -n "Category : " ; read anser
2720 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
2721 # Short description.
2722 echo -n "Short desc : " ; read anser
2723 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
2724 # Maintainer.
2725 echo -n "Maintainer : " ; read anser
2726 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
2727 # Web site.
2728 echo -n "Web site : " ; read anser
2729 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
2730 echo ""
2731 # Wget URL.
2732 echo "Wget URL to download source tarball."
2733 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
2734 echo -n "Wget url : " ; read anser
2735 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
2736 # Ask for a stuff dir.
2737 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
2738 if [ "$anser" = "y" ]; then
2739 echo -n "Creating the stuff directory..."
2740 mkdir stuff && status
2741 fi
2742 # Ask for a description file.
2743 echo -n "Are you going to write a description ? (y/N) : " ; read anser
2744 if [ "$anser" = "y" ]; then
2745 echo -n "Creating the description.txt file..."
2746 echo "" > description.txt && status
2747 fi
2748 echo "================================================================================"
2749 echo ""
2750 fi
2751 ;;
2752 remove)
2753 # Remove a package from the wok.
2755 get_tazwok_config
2756 check_for_package_on_cmdline
2757 echo ""
2758 echo -n "Please confirm deletion (y/N) : "; read anser
2759 if [ "$anser" = "y" ]; then
2760 echo -n "Removing $PACKAGE..."
2761 rm -rf $WOK/$PACKAGE && status
2762 echo ""
2763 fi
2764 ;;
2765 hgup)
2766 # Pull and update a Hg wok.
2767 get_tazwok_config
2768 if ls -l $WOK/.hg/hgrc | fgrep -q "root"; then
2769 check_root
2770 fi
2771 cd $WOK
2772 hg pull && hg update
2773 ;;
2774 maintainers)
2775 get_tazwok_config
2776 echo ""
2777 echo "List of maintainers for: $WOK"
2778 echo "================================================================================"
2779 touch /tmp/slitaz-maintainers
2780 for pkg in $WOK/*
2781 do
2782 . $pkg/receipt
2783 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
2784 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
2785 echo "$MAINTAINER"
2786 fi
2787 done
2788 echo "================================================================================"
2789 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
2790 echo ""
2791 # Remove tmp files
2792 rm -f /tmp/slitaz-maintainers
2793 ;;
2794 maintained-by)
2795 # Search for packages maintained by a contributor.
2796 get_tazwok_config
2797 if [ ! -n "$2" ]; then
2798 echo "Specify a name or email of a maintainer." >&2
2799 exit 1
2800 fi
2801 echo "Maintainer packages"
2802 echo "================================================================================"
2803 for pkg in $WOK/*
2804 do
2805 . $pkg/receipt
2806 if echo "$MAINTAINER" | fgrep -q "$2"; then
2807 echo "$PACKAGE"
2808 packages=$(($PACKAGEs+1))
2809 fi
2810 done
2811 echo "================================================================================"
2812 echo "Packages maintained by $2: $PACKAGEs"
2813 echo ""
2814 ;;
2815 tags)
2816 get_tazwok_config
2817 echo -e "\n\033[1mTags list :\033[0m"
2818 horizontal_line
2819 cd $WOK
2820 for i in */receipt; do
2821 unset TAGS
2822 source $i
2823 for t in $TAGS; do
2824 grep -q ^$t$ $tmp/tags && continue
2825 echo $t | tee -a $tmp/tags
2826 done
2827 done
2828 horizontal_line
2829 echo "$(wc -l $tmp/tags | cut -f1 -d ' ') tags listed."
2830 ;;
2831 check-src)
2832 # Verify if upstream package is still available
2834 get_tazwok_config
2835 check_for_package_on_cmdline
2836 check_for_receipt
2837 source_receipt
2838 check_src()
2840 for url in $@; do
2841 busybox wget -s $url 2>/dev/null && break
2842 done
2844 if [ "$WGET_URL" ];then
2845 echo -n "$PACKAGE : "
2846 check_src $WGET_URL
2847 status
2848 else
2849 echo "No tarball to check for $PACKAGE"
2850 fi
2851 ;;
2852 get-src)
2853 check_root
2854 get_options_list="target nounpack"
2855 get_tazwok_config
2856 check_for_package_on_cmdline
2857 check_for_receipt
2858 source_receipt
2859 if [ "$WGET_URL" ];then
2860 source_lib report
2861 report start
2862 check_for_tarball
2863 else
2864 echo "No tarball to download for $PACKAGE"
2865 fi
2866 ;;
2867 check-commit)
2868 check_root
2869 get_options_list="missing forced"
2870 get_tazwok_config
2871 source_lib report
2872 report start
2873 if [ "$forced" ]; then
2874 rm -f $WOK/*/md5
2875 unset forced
2876 fi
2877 if [ "$missing" ]; then
2878 pkg=$(ls -1 $WOK)
2879 else
2880 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2881 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2882 } | sort -u)"
2883 fi
2884 cooklist=$PACKAGES_REPOSITORY/cooklist
2885 gen_cook_list
2886 ;;
2887 cook-commit)
2888 check_root
2889 get_options_list="missing forced"
2890 get_tazwok_config
2891 source_lib report
2892 report start
2893 if [ "$forced" ]; then
2894 rm -f $WOK/*/md5
2895 unset forced
2896 fi
2897 if [ "$missing" ]; then
2898 pkg=$(ls -1 $WOK)
2899 else
2900 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2901 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2902 } | sort -u)"
2903 fi
2904 cooklist=$PACKAGES_REPOSITORY/cooklist
2905 gen_cook_list
2906 cook_list
2907 ;;
2908 cook-all)
2909 check_root
2910 get_options_list="forced missing"
2911 get_tazwok_config
2912 source_lib report
2913 report start
2914 if [ "$missing" ]; then
2915 pkg=$(ls -1 $WOK)
2916 else
2917 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2918 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2919 } | sort -u)"
2920 fi
2921 cooklist=$PACKAGES_REPOSITORY/cooklist
2922 gen_cook_list
2923 cook_list
2924 ;;
2925 gen-wok-db)
2926 check_root
2927 get_tazwok_config
2928 source_lib report
2929 report start
2930 gen_wok_db
2931 ;;
2932 report)
2933 check_root
2934 get_tazwok_config
2935 cd $PACKAGES_REPOSITORY
2936 if [ "$2" ]; then
2937 case $2 in
2938 commit|cooklist|incoming|broken|blocked)
2939 show="$2"
2940 ;;
2941 *)
2942 echo "usage : tazwok report [commit|cooklist|incoming|broken|blocked]" >&2
2943 exit 1
2944 ;;
2945 esac
2946 else
2947 show="commit cooklist incoming broken blocked"
2948 fi
2949 for i in $show; do
2950 if [ -s $i ]; then
2951 echo ""
2952 echo -e "\033[1m$i\033[0m"
2953 echo "================================================================================"
2954 cat $i
2955 echo "================================================================================"
2956 echo ""
2957 fi
2958 done
2959 ;;
2960 check-incoming)
2961 check_root
2962 get_options_list="forced"
2963 get_tazwok_config
2964 source_lib report
2965 report start
2966 check_for_incoming
2967 ;;
2968 configure-chroot)
2969 check_root
2970 get_tazwok_config
2971 if [ -f /usr/bin/tazchroot ]; then
2972 cd $LOCAL_REPOSITORY
2973 configure_tazchroot
2974 else
2975 echo "The packages tazchroot need to be installed" >&2
2976 exit 1
2977 fi
2978 ;;
2979 chroot)
2980 check_root
2981 get_tazwok_config
2982 # Merge this and the other chroot function ?.
2983 if [ -f /usr/bin/tazchroot ]; then
2984 cd $LOCAL_REPOSITORY
2985 [ ! -f tazchroot.conf ] && configure_tazchroot
2986 tazchroot
2987 else
2988 echo "The packages tazchroot need to be installed" >&2
2989 exit 1
2990 fi
2991 ;;
2992 cook-toolchain)
2993 check_root
2994 get_tazwok_config
2995 echo -n "" > $PACKAGES_REPOSITORY/broken
2996 if [ -f /usr/bin/tazchroot ]; then
2997 cd $LOCAL_REPOSITORY
2998 [ ! -f tazchroot.conf ] && configure_tazchroot
2999 tazchroot cook-toolchain
3000 # Buggy : chroot can be elsewhere.
3001 rm -r $LOCAL_REPOSITORY/chroot
3002 # /!\ to be writed :
3003 # next rm chroot and plan cook-all by pushing all packages
3004 # in cooklist.
3005 else
3006 echo "The packages tazchroot need to be installed" >&2
3007 exit 1
3008 fi
3009 ;;
3010 webserver)
3011 check_root
3012 get_tazwok_config
3013 if [ "$ARG" = on ]; then
3014 if [ "$WEBSERVER" ] && [ -f "$WEBSERVER/repositories.list" ] && \
3015 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3016 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3017 exit 1
3018 fi
3019 if ! [ -f $LOCAL_REPOSITORY/tazchroot.conf ]; then
3020 tazwok configure-chroot ${undigest:+--undigest=$undigest} --SLITAZ_VERSION=$SLITAZ_VERSION --SLITAZ_DIR=$SLITAZ_DIR
3021 fi
3022 for pkg in php lighttpd; do
3023 [ -d $INSTALLED/$pkg ] || missing="$missing $pkg"
3024 done
3025 if [ "$missing" ]; then
3026 echo "You need to install those packages to start webserver: $missing." >&2
3027 exit 1
3028 fi
3029 if [ ! -f "$LOCAL_REPOSITORY/tazwok.conf" ]; then
3030 echo "Copying /etc/slitaz/tazwok.conf to $LOCAL_REPOSITORY/tazwok.conf: webserver is configured repository-by-repository."
3031 cp /etc/slitaz/tazwok.conf $LOCAL_REPOSITORY
3032 fi
3033 if ! [ "$WEBSERVER" ]; then
3034 echo -n "Where to store php pages (default: /var/www/vhosts/bb)? "
3035 read WEBSERVER
3036 [ "$WEBSERVER" ] || WEBSERVER="/var/www/vhosts/bb"
3037 fi
3038 if [ -f "$WEBSERVER/repositories.list" ] && \
3039 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3040 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3041 exit 1
3042 fi
3043 mkdir -p $WEBSERVER
3044 echo "${undigest:-$SLITAZ_VERSION}" >> $WEBSERVER/repositories.list
3045 for file in index.php log.php download.php; do
3046 [ -f "$WEBSERVER/$file" ] || ln -s /usr/share/slitaz/web-bb/$file $WEBSERVER
3047 done
3048 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3049 ln -s $dir $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3050 done
3051 source $LOCAL_REPOSITORY/tazchroot.conf
3052 echo "<?php
3054 // Web interface configuration
3056 \$version=\"${undigest:-$SLITAZ_VERSION}\";
3057 \$chroot=\"$chroot_dir\";
3058 \$lockfile=\"\$chroot/proc/1\";
3059 \$db_dir=\"$PACKAGES_REPOSITORY\";
3060 \$log_dir=\"$LOCAL_REPOSITORY/log\";
3061 \$packages=\"$PACKAGES_REPOSITORY\";
3062 \$incoming=\"$INCOMING_REPOSITORY\";
3063 \$wok=\"$WOK\";
3065 ?>" > $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3066 [ -L "$WEBSERVER/web" ] || ln -s /usr/share/slitaz/web $WEBSERVER
3067 echo "WEBSERVER=\"$WEBSERVER\"" >> $LOCAL_REPOSITORY/tazwok.conf
3068 if [ -L "$WEBSERVER/conf.php" ]; then
3069 echo "Do yo want to make ${undigest:-$SLITAZ_VERSION} the default page (y/N) ? "
3070 read answer
3071 if [ "$answer" = y ]; then
3072 rm $WEBSERVER/conf.php
3073 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3074 fi
3075 else
3076 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3077 fi
3078 elif [ "$ARG" = off ]; then
3079 if ! [ "$WEBSERVER" ]; then
3080 echo "No webserver running for ${undigest:-$SLITAZ_VERSION}" >&2
3081 exit 1
3082 fi
3083 sed '/^WEBSERVER/d' -i $LOCAL_REPOSITORY/tazwok.conf
3084 sed "/^${undigest:-$SLITAZ_VERSION}$/d" -i $WEBSERVER/repositories.list
3085 rm $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3086 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3087 rm $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3088 done
3089 if ! [ -s "$WEBSERVER/repositories.list" ]; then
3090 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"
3091 rm $WEBSERVER/conf.php
3092 elif [ "$(readlink $WEBSERVER/conf.php)" = "$WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php" ]; then
3093 echo "${undigest:-$SLITAZ_VERSION} was the default version to use; switched to : $(sed 1!d $WEBSERVER/repositories.list)"
3094 rm $WEBSERVER/conf.php
3095 ln -s $WEBSERVER/conf-$(sed 1!d $WEBSERVER/repositories.list).php $WEBSERVER/conf.php
3096 fi
3097 else
3098 echo "Usage: tazwok webserver on/off" >&2
3099 exit 1
3100 fi
3101 ;;
3102 usage|*)
3103 # Print usage also for all unknown commands.
3105 usage
3106 ;;
3107 esac
3109 report stop 2>/dev/null || exit 0