tazwok view tazwok @ rev 281

Fix usage display
author Antoine Bodin <gokhlayeh@slitaz.org>
date Mon Feb 14 17:50:17 2011 +0100 (2011-02-14)
parents 605c10e63e93
children 69d6e8e81872
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.
64 tags List all tags used in wok receipts.\n
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 if [ "$COMMAND" = get-src ]; then
657 if [ "${DEPENDS/tar}" != "$DEPENDS" ] || [ "${BUILD_DEPENDS/tar}" != "$BUILD_DEPENDS" ]; then
658 [ -f $INSALLED/tar/receipt ] || tazpkg get-install tar --forced
659 fi
660 fi
661 for file in $@; do
662 echo "Downloading from ${file#*|}..."
663 case "$file" in
664 git\|*)
665 file=${file#git|}
666 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/git/receipt ] && tazpkg get-install git --forced
667 if [ -f $INSTALLED/git/receipt ]; then
668 mkdir $tmp_src
669 cd $tmp_src
670 if [ "$BRANCH" ]; then
671 git clone $file ${src##*/} && cd ${src##*/} && \
672 git checkout $BRANCH && rm -rf .git* && break
673 else
674 git clone $file ${src##*/} && rm -rf ${src##*/}/.git* && break
675 fi
676 revert_vcs_failure
677 else
678 tazwok_warning "Needs git to download the source tarball from $file, please add it as build-depend."
679 continue
680 fi
681 ;;
682 subversion\|*)
683 file=${file#subversion|}
684 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/subversion/receipt ] && tazpkg get-install subversion --forced
685 if [ -f $INSTALLED/subversion/receipt ]; then
686 mkdir $tmp_src
687 cd $tmp_src
688 if [ "$BRANCH" ]; then
689 echo t | svn co $file -r $BRANCH ${src##*/} && rm -rf ${src##*/}/.svn* && break
690 else
691 echo t | svn co $file ${src##*/} && rm -rf ${src##*/}/.svn* && break
692 fi
693 revert_vcs_failure
694 else
695 tazwok_warning "Needs subversion to download the source tarball from $file, please add it as build-depend."
696 continue
697 fi
698 ;;
699 mercurial\|*)
700 file=${file#mercurial|}
701 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/mercurial/receipt ] && tazpkg get-install mercurial --forced
702 if [ -f $INSTALLED/mercurial/receipt ]; then
703 mkdir $tmp_src
704 cd $tmp_src
705 if [ "$BRANCH" ]; then
706 hg clone $file --rev $BRANCH ${src##*/} && rm -rf ${src##*/}/.hg* && break
707 else
708 hg clone $file ${src##*/} && rm -rf ${src##*/}/.hg* && break
709 fi
710 revert_vcs_failure
711 else
712 tazwok_warning "Needs mercurial to download the source tarball from $file, please add it as build-depend."
713 continue
714 fi
715 ;;
716 https*)
717 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/wget/receipt ] && tazpkg get-install wget --forced
718 if [ -d $INSTALLED/wget ]; then
719 if [ "${WGET_URL%$TARBALL}" = "$WGET_URL" ] && [ "$file" = "$WGET_URL" ]; then
720 wget -q --no-check-certificate -O $TARBALL $file && break
721 else
722 wget -q $file && break
723 fi
724 else
725 tazwok_warning "Needs wget to download the source tarball from $file, please add it as build-depend."
726 continue
727 fi
728 ;;
729 http*|ftp*)
730 # Handle crappy URL.
731 if [ "$COMMAND" = get-src ]; then
732 if [ "${DEPENDS/wget}" != "$DEPENDS" ] || [ "${BUILD_DEPENDS/wget}" != "$BUILD_DEPENDS" ]; then
733 [ -f $INSALLED/wget/receipt ] || tazpkg get-install wget --forced
734 fi
735 fi
736 if [ "${WGET_URL%$TARBALL}" = "$WGET_URL" ] && [ "$file" = "$WGET_URL" ]; then
737 wget -q -O $TARBALL $file && break
738 else
739 wget -q $file && break
740 fi
741 ;;
742 esac
743 done
744 }
746 # Regenerate every package that wants a PACKAGE compiled
747 refresh_packages_from_compile()
748 {
749 # make tazwok genpkg happy
750 mkdir $WOK/$PACKAGE/taz
752 # Cook rwanted in default or specied order
753 genlist=" $(look_for_rwanted | tr '\n' ' ') "
754 for i in $(look_for_cookopt genpkg | tac); do
755 [ "${genlist/ $i }" = "$genlist" ] && continue
756 genlist=" $i${genlist/ $i / }"
757 done
758 if [ "$genlist" ]; then
759 local PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
760 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
761 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
762 src _pkg DESTDIR CONFIG_SITE RECEIPT LOG
763 for PACKAGE in $genlist; do
764 set_common_path
765 gen_package
766 done
767 fi
768 }
770 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
771 # so some packages need to copy these files with the receipt and genpkg_rules.
772 # This function is executed by gen_package when 'tazwok genpkg'.
773 copy_generic_files()
774 {
775 # In most cases, locales are in $_pkg/usr/share/locale so we copy files
776 # using generic variables and $LOCALE from Tazwok config file.
777 if [ "$LOCALE" ]; then
778 if [ -d "$_pkg/usr/share/locale" ]; then
779 for i in $LOCALE
780 do
781 if [ -d "$_pkg/usr/share/locale/$i" ]; then
782 mkdir -p $fs/usr/share/locale
783 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
784 fi
785 done
786 fi
787 fi
789 # Pixmaps (PNG or/and XPM only). Some icons/images can be added through
790 # genpkg_rules and generic copy can be disabled with GENERIC_PIXMAPS="no"
791 # in pkg receipt.
792 if [ "$GENERIC_PIXMAPS" != "no" ]; then
793 if [ -d "$_pkg/usr/share/pixmaps" ]; then
794 mkdir -p $fs/usr/share/pixmaps
795 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
796 $fs/usr/share/pixmaps 2>/dev/null
797 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
798 $fs/usr/share/pixmaps 2>/dev/null
799 fi
801 # Custom or homemade PNG pixmap can be in stuff.
802 if [ -f "stuff/$PACKAGE.png" ]; then
803 mkdir -p $fs/usr/share/pixmaps
804 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
805 fi
806 fi
808 # Desktop entry (.desktop).
809 if [ -d "$_pkg/usr/share/applications" ]; then
810 cp -a $_pkg/usr/share/applications $fs/usr/share
811 fi
813 # Homemade desktop file(s) can be in stuff.
814 if [ -d "stuff/applications" ]; then
815 mkdir -p $fs/usr/share
816 cp -a stuff/applications $fs/usr/share
817 fi
818 if [ -f "stuff/$PACKAGE.desktop" ]; then
819 mkdir -p $fs/usr/share/applications
820 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
821 fi
822 }
824 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
825 strip_package()
826 {
827 report step "Executing strip on all files"
829 # Binaries.
830 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
831 do
832 if [ -d "$dir" ]; then
833 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
834 fi
835 done
837 # Libraries.
838 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
839 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
840 report end-step
841 }
843 # Remove .pyc and .pyo files from packages
844 py_compiled_files_remove()
845 {
846 report step "Removing all .pyc and .pyo files from package ..."
847 find $fs -type f -name "*.pyc" -delete 2>/dev/null
848 find $fs -type f -name "*.pyo" -delete 2>/dev/null
849 report end-step
850 }
852 # Check FSH in a slitaz package (Path: /:/usr)
853 check_fsh()
854 {
855 cd $WOK/$PACKAGE/taz/*/fs
856 [ -n "$FSH" ] || FSH="bin boot dev etc home init lib media mnt proc \
857 root sbin share sys tmp usr var vz usr/bin usr/games usr/include usr/lib \
858 usr/local usr/sbin usr/share usr/src"
859 for i in `ls -d * usr/* 2>/dev/null`
860 do
861 if ! echo $FSH | fgrep -q $i; then
862 echo "Wrong path: /$i" >&2
863 error=1
864 fi
865 done
866 if [ "$error" = "1" ]; then
867 cat << _EOT_
869 Package will install files in a non standard directory and won't be generated.
870 You may have a wrong copy path in genpkg_rules or need to add some options to
871 configure in compile_rules. Some valid options for SliTaz (Linux FSH):
873 --prefix=/usr
874 --sysconfdir=/etc
875 --libexecdir=/usr/lib/(pkgname)
876 --localstatedir=/var
877 --mandir=/usr/share/man
878 --infodir=/usr/share/info
880 For more information please read SliTaz docs and run: ./configure --help
881 ================================================================================
882 $PACKAGE package generation aborted.
884 _EOT_
886 # Dont generate a corrupted package.
887 cd $WOK/$PACKAGE && rm -rf taz
888 report exit
889 fi
890 }
892 gen_cookmd5()
893 {
894 # md5sum of cooking stuff make tazwok able to check for changes
895 # without hg.
896 cd $WOK/$PACKAGE
897 md5sum receipt > md5
898 [ -f description.txt ] && md5sum description.txt >> md5
899 if [ -d stuff ]; then
900 find stuff | while read file; do
901 md5sum $file >> md5
902 done
903 fi
904 }
906 # Create a package tree and build the gziped cpio archive
907 # to make a SliTaz (.tazpkg) package.
908 gen_package()
909 {
910 check_root
911 check_for_package_on_cmdline
912 check_for_receipt
913 EXTRAVERSION=""
914 . $RECEIPT
916 # May compute VERSION
917 if grep -q ^get_version $RECEIPT; then
918 get_version
919 fi
920 check_for_wanted
921 cd $WOK/$PACKAGE
923 # Remove old Tazwok package files.
924 [ -d "taz" ] && rm -rf taz
926 # Create the package tree and set useful variables.
927 mkdir -p $WOK/$PACKAGE/taz/$PACKAGE-$VERSION/fs
928 fs=$WOK/$PACKAGE/taz/$PACKAGE-$VERSION/fs
930 # Set $src for standard package and $_pkg variables.
931 set_src_path && set_pkg_path
933 # Execute genpkg_rules, check package and copy generic files to build
934 # the package.
935 report step "Building $PACKAGE with the receipt"
936 report open-bloc
937 if grep -q ^genpkg_rules $RECEIPT; then
939 # Log process.
940 echo "executing genpkg_rules" >> $LOG
941 report step "Executing genpkg_rules"
942 genpkg_rules
943 report end-step
944 check_fsh
945 cd $WOK/$PACKAGE
947 # Skip generic files for packages with a WANTED variable
948 # (dev and splited pkgs).
949 if [ ! "$WANTED" ]; then
950 copy_generic_files
951 fi
952 look_for_cookopt !strip || strip_package
953 py_compiled_files_remove
954 else
955 echo "No package rules to gen $PACKAGE..." >&2
956 report exit
957 fi
959 # Copy the receipt and description (if exists) into the binary package tree.
960 cd $WOK/$PACKAGE
961 report step "Copying the receipt"
962 cp receipt taz/$PACKAGE-$VERSION
963 report end-step
964 if grep -q ^get_version $RECEIPT; then
965 report step "Updating version in receipt"
966 sed -i "s/^VERSION=.*/VERSION=\"$VERSION\"/" \
967 taz/$PACKAGE-$VERSION/receipt
968 report end-step
969 fi
970 if [ -f "description.txt" ]; then
971 report step "Copying the description file"
972 cp description.txt taz/$PACKAGE-$VERSION
973 report end-step
974 fi
976 # Generate md5 of cooking stuff to look for commit later.
977 gen_cookmd5
978 echo -e "\n# md5sum of cooking stuff :" >> taz/$PACKAGE-$VERSION/receipt
979 cat md5 | sed 's/^/# /' >> taz/$PACKAGE-$VERSION/receipt
981 # Create the files.list by redirecting find output.
982 report step "Creating the list of files"
983 cd taz/$PACKAGE-$VERSION
984 LAST_FILE=""
985 { find fs -print; echo; } | while read file; do
986 if [ "$LAST_FILE" ]; then
987 case "$file" in
988 $LAST_FILE/*)
989 case "$(ls -ld "$LAST_FILE")" in
990 drwxr-xr-x\ *\ root\ *\ root\ *);;
991 *) echo ${LAST_FILE#fs};;
992 esac;;
993 *) echo ${LAST_FILE#fs};;
994 esac
995 fi
996 LAST_FILE="$file"
997 done > files.list
999 # Next, check if something has changed in lib files.
1000 if fgrep -q '.so' files.list; then
1001 report step "Look for major/minor update in libraries"
1002 for rep in $INCOMING_REPOSITORY $PACKAGES_REPOSITORY \
1003 $([ "$undigest" ] && echo SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming && \
1004 echo $SLITAZ_DIR/$SLITAZ_VERSION/packages); do
1005 prev_VERSION=$(get_pkg_version $rep)
1006 [ "$prev_VERSION" ] && pkg_file=$rep/$PACKAGE-$prev_VERSION.tazpkg && break
1007 done
1008 if [ "$pkg_file" ]; then
1009 get_pkg_files $pkg_file
1010 cd $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
1011 fgrep ".so" files.list | egrep -v "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*" | \
1012 while read lib; do
1013 fgrep -q "$lib" $pkg_files_dir/files.list && continue
1014 echo "A minor/major update in libraries is detected, planning re-cook of reverse-depends of $PACKAGE."
1015 for rdep in $(scan $PACKAGE --look_for=rdep | use_wanted); do
1016 [ "$rdep" = "${WANTED:-$PACKAGE}" ] && continue
1017 grep -q ^$rdep$ $PACKAGES_REPOSITORY/blocked \
1018 $PACKAGES_REPOSITORY/cooklist && continue
1019 echo $rdep >> $PACKAGES_REPOSITORY/cooklist
1020 done
1021 regen_cooklist=yes
1022 break
1023 done
1024 rm -r $pkg_files_dir
1025 fi
1026 report end-step
1027 fi
1028 if [ ! "$EXTRAVERSION" ]; then
1029 case "$PACKAGE" in
1030 linux*);;
1031 *) EXTRAVERSION="$(grep '/lib/modules/.*-slitaz/' files.list |\
1032 head -1 | sed 's|/lib/modules/\(.*\)-slitaz/.*|_\1|')";;
1033 esac
1034 fi
1035 rm -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
1036 report step "Creating md5sum of files"
1037 while read file; do
1038 [ -L "fs$file" ] && continue
1039 [ -f "fs$file" ] || continue
1040 md5sum "fs$file" | sed 's/ fs/ /'
1041 done < files.list > md5sum
1042 report end-step
1043 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
1044 2> /dev/null | awk '{ sz=$1 } END { print sz }')
1046 # Build cpio archives. Find, cpio and gzip the fs, finish by
1047 # removing the fs tree.
1048 # Don't log this because compression always output error messages.
1049 find fs -print | cpio -o -H newc | case "$PACKAGE-$COMPRESSION" in
1050 tazpkg-lzma) gzip > fs.cpio.gz;;
1051 *-lzma) lzma e fs.cpio.lzma -si;;
1052 *) gzip > fs.cpio.gz;;
1053 esac && rm -rf fs
1054 PACKED_SIZE=$(du -chs fs.cpio.* receipt files.list md5sum \
1055 description.txt 2> /dev/null | awk '{ sz=$1 } END { print sz }')
1056 report step "Updating receipt sizes"
1057 sed -i '/^PACKED_SIZE/d' receipt
1058 sed -i '/^UNPACKED_SIZE/d' receipt
1059 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
1060 sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
1061 report end-step
1062 if [ "$EXTRAVERSION" ]; then
1063 report step "Updating receipt EXTRAVERSION"
1064 sed -i s/^EXTRAVERSION.*$// receipt
1065 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
1066 fi
1067 prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
1068 remove_previous_package $INCOMING_REPOSITORY
1069 report step "Creating full cpio archive"
1070 find . -print | cpio -o -H newc > $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
1072 # Restore package tree in case we want to browse it.
1073 report step "Restoring original package tree"
1074 { zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma; } | cpio --quiet -id
1075 rm fs.cpio.* && cd ..
1077 # Log process.
1078 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
1079 report close-bloc
1080 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
1081 echo "Size : `du -sh $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
1082 echo ""
1084 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/broken
1085 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/commit
1086 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/cooklist
1089 ########################################################################
1090 # This section contains functions used by several other functions
1091 # bellow.
1092 ########################
1094 # Look for receipt/files.list in wok. If they can't be found, get them
1095 # from package. Accept one argument : absolute path to package.
1096 get_pkg_files()
1098 pkg_files_dir=$tmp/$(basename ${1%.tazpkg})
1099 mkdir -p $pkg_files_dir && \
1100 cd $pkg_files_dir && \
1101 cpio --quiet -idm receipt < $1 && \
1102 cpio --quiet -idm files.list < $1
1105 ########################################################################
1106 # This section contains functions to generate packages databases.
1107 ########################
1110 gen_packages_db()
1112 # pkg_repository can be $PACKAGES_REPOSITORY or $INCOMING_REPOSITORY.
1113 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
1114 cd $pkg_repository
1115 report step "Generating packages lists: $pkg_repository"
1116 report open-bloc
1117 report step "Removing old files"
1118 for file in files.list.lzma packages.list packages.txt \
1119 packages.desc packages.equiv packages.md5; do
1120 [ -f $file ] && rm $file
1121 done
1122 touch files.list
1124 packages_db_start
1125 unset RECEIPT
1126 report step "Reading datas from all packages"
1127 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1128 get_packages_info
1129 done
1130 report end-step
1131 packages_db_end
1132 report close-bloc
1135 update_packages_db()
1137 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
1138 cd $pkg_repository
1139 for file in packages.list packages.equiv packages.md5 packages.desc \
1140 packages.txt; do
1141 if [ ! -f "$file" ]; then
1142 gen_packages_db
1143 return
1144 fi
1145 done
1146 if [ -f files.list.lzma ]; then
1147 lzma d files.list.lzma files.list
1148 else
1149 gen_packages_db
1150 fi
1151 report step "Updating packages lists: $pkg_repository"
1152 packages_db_start
1154 # Look for removed/update packages.
1155 for PACKAGE in $(grep ^[0-9,a-z,A-Z] packages.txt); do
1156 pkg="$pkg_repository/$(grep -m1 ^$PACKAGE- packages.list).tazpkg"
1157 if ! [ -f "$pkg" ]; then
1158 erase_package_info
1159 else
1160 if [ "$pkg" -nt "packages.list" ]; then
1161 updated_pkg="$updated_pkg
1162 $PACKAGE $pkg"
1163 elif [ ! -f $WOK/$PACKAGE/receipt ] && \
1164 [ "$COMMAND" = check-incoming -o "$pkg_repository" = "$INCOMING_REPOSITORY" ]; then
1165 erase_package_info
1166 echo "Removing $PACKAGE from $pkg_repository."
1167 rm $pkg
1168 [ -d $WOK/$PACKAGE ] && rm -r $WOK/$PACKAGE
1169 if [ "$pkg_repository" = "$INCOMING_REPOSITORY" ]; then
1170 sed "/^$PACKAGE\t/d" -i $wan_db $dep_db
1171 for i in cookorder.txt cooklist commit blocked broken; do
1172 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/$i
1173 done
1174 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
1175 regen_cooklist=yes
1176 else
1177 echo "$PACKAGE" >> $PACKAGES_REPOSITORY/removed
1178 sed -n '1,10p' -i $PACKAGES_REPOSITORY/removed
1179 fi
1180 fi
1181 fi
1182 done
1183 echo "$updated_pkg" | sed 1d | while read PACKAGE pkg; do
1184 erase_package_info
1185 get_packages_info
1186 done
1187 unset updated_pkg
1189 # Look for new packages.
1190 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1191 if ! fgrep -q " ${pkg##*/}" $pkg_repository/packages.md5; then
1192 get_packages_info
1193 fi
1194 done
1195 report end-step
1196 packages_db_end
1199 packages_db_start()
1201 if [ ! -s packages.txt ]; then
1202 echo "# SliTaz GNU/Linux - Packages list
1204 # Packages : unknow
1205 # Date : $(date +%Y-%m-%d\ \%H:%M:%S)
1207 " > packages.txt
1208 else
1209 sed -e 's/^# Packages :.*/# Packages : unknow/' \
1210 -e "s/# Date :.*/# Date : $(date +%Y-%m-%d\ \%H:%M:%S)/" \
1211 -i packages.txt
1212 fi
1214 # Needed in some case as tazwok define RECEIPT at configuration time
1215 # in this particular case it can broke the script.
1216 unset RECEIPT
1219 erase_package_info()
1221 cd $pkg_repository
1222 sed "/^$PACKAGE$/,/^$/d" -i packages.txt
1223 sed "/^$PACKAGE /d" -i packages.desc
1224 sed -e "s/=$PACKAGE /= /" -e "s/ $PACKAGE / /" -e "s/ $PACKAGE$//" \
1225 -e "/=$PACKAGE$/d" -e "s/=[0-9,a-z,A-Z]:$PACKAGE /= /" \
1226 -e "s/ [0-9,a-z,A-Z]:$PACKAGE / /" -e "s/ [0-9,a-z,A-Z]:$PACKAGE$/ /" \
1227 -e "/=[0-9,a-z,A-Z]:$PACKAGE$/d" \
1228 -i packages.equiv
1229 sed "/^$PACKAGE:/d" -i files.list
1230 sed "/^$(basename ${pkg%.tazpkg})$/d" -i packages.list
1231 sed "/ $(basename $pkg)$/d" -i packages.md5
1234 get_packages_info()
1236 # If there's no taz folder in the wok, extract infos from the
1237 # package.
1238 get_pkg_files $pkg
1239 source_receipt
1240 echo "Getting datas from $PACKAGE"
1242 cat >> $pkg_repository/packages.txt << _EOT_
1243 $PACKAGE
1244 $VERSION$EXTRAVERSION
1245 $SHORT_DESC
1246 _EOT_
1247 if [ "$PACKED_SIZE" ]; then
1248 cat >> $pkg_repository/packages.txt << _EOT_
1249 $PACKED_SIZE ($UNPACKED_SIZE installed)
1251 _EOT_
1252 else
1253 echo "" >> $pkg_repository/packages.txt
1254 fi
1256 # Packages.desc is used by Tazpkgbox <tree>.
1257 echo "$PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> $pkg_repository/packages.desc
1259 # Packages.equiv is used by tazpkg install to check depends
1260 for i in $PROVIDE; do
1261 DEST=""
1262 echo $i | fgrep -q : && DEST="${i#*:}:"
1263 if grep -qs ^${i%:*}= $pkg_repository/packages.equiv; then
1264 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" $pkg_repository/packages.equiv
1265 else
1266 echo "${i%:*}=$DEST$PACKAGE" >> $pkg_repository/packages.equiv
1267 fi
1268 done
1270 if [ -f files.list ]; then
1271 { echo "$PACKAGE"; cat files.list; } | awk '
1272 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }' >> $pkg_repository/files.list
1273 fi
1275 cd .. && rm -r "$pkg_files_dir"
1277 cd $pkg_repository
1278 echo $(basename ${pkg%.tazpkg}) >> packages.list
1279 [ ! "$package_md5" ] && package_md5=$(md5sum $(basename $pkg))
1280 echo "$package_md5" >> packages.md5
1281 unset package_md5
1284 source_receipt()
1286 unset PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
1287 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
1288 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
1289 src _pkg DESTDIR CONFIG_SITE BRANCH TARBALL
1290 . ${RECEIPT:-$PWD/receipt}
1293 packages_db_end()
1295 cd $pkg_repository
1296 pkgs=$(wc -l packages.list | sed 's/ .*//')
1297 sed "s/# Packages : .*/# Packages : $pkgs/" -i packages.txt
1299 # If lists was updated it's generally needed to sort them well.
1300 if ! sort -c packages.list 2> /dev/null; then
1301 report step "Sorting packages lists"
1302 for file in packages.list packages.desc packages.equiv; do
1303 [ -f $file ] || continue
1304 sort -o $file $file
1305 done
1306 report end-step
1307 fi
1309 # Dont log this because lzma always output error.
1310 lzma e files.list files.list.lzma
1311 rm -f files.list
1312 [ -f packages.equiv ] || touch packages.equiv
1315 ########################################################################
1316 # This section contains functions to generate wok database.
1317 ########################
1319 gen_wok_db()
1321 report step "Generating wok database"
1322 report open-bloc
1323 report step "Removing old files"
1324 for file in $wan_db $dep_db $PACKAGES_REPOSITORY/cookorder.txt; do
1325 [ -f $file ] && rm $file
1326 done
1327 report step "Generating wok-wanted.txt"
1328 gen_wan_db
1329 report step "Generating wok-depends.txt"
1330 for PACKAGE in $(cut -f1 -d '|' $PACKAGES_REPOSITORY/packages.desc \
1331 $INCOMING_REPOSITORY/packages.desc | sort -u); do
1332 RECEIPT=$WOK/$PACKAGE/receipt
1333 if [ -s $RECEIPT ]; then
1334 source_receipt
1335 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
1336 fi
1337 done
1338 sort_db
1339 report close-bloc
1342 gen_wan_db()
1344 for RECEIPT in $(fgrep -l WANTED $WOK/*/receipt); do
1345 WANTED=
1346 source $RECEIPT
1347 [ "$WANTED" ] || continue
1348 echo -e $PACKAGE"\t"$WANTED >> $tmp/wan_db
1349 done
1350 if ! [ -f $wan_db ] || [ "$(diff -q $tmp/wan_db $wan_db)" ]; then
1351 mv -f $tmp/wan_db $wan_db
1352 plan_regen_cookorder=yes
1353 else
1354 rm $tmp/wan_db
1355 fi
1358 update_wan_db()
1360 local PACKAGE
1361 for RECEIPT in $(fgrep WANTED $WOK/*/receipt | \
1362 fgrep $PACKAGE | cut -f1 -d ':'); do
1363 WANTED=
1364 source $RECEIPT
1365 [ "$WANTED" ] || continue
1366 wan_info=$(echo -e $PACKAGE"\t"$WANTED)
1367 [ "$wan_info" = "$(grep -m1 ^$PACKAGE$'\t' $wan_db 2>/dev/null)" ] && return
1368 sed "/^$PACKAGE\t/d" -i $wan_db
1369 echo "$wan_info" >> $wan_db
1370 plan_regen_cookorder=yes
1371 plan_sort_wandb=yes
1372 done
1375 update_dep_db()
1377 dep_info=$(echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ')
1378 [ "$dep_info" = "$(grep -m1 ^$PACKAGE$'\t' $dep_db 2>/dev/null)" ] && return
1379 sed "/^$PACKAGE\t/d" -i $dep_db
1380 echo "$dep_info" >> $dep_db
1381 plan_regen_cookorder=yes
1382 plan_sort_depdb=yes
1385 sort_db()
1387 report step "Generating cookorder.txt"
1388 cat $dep_db | sed 's/ \t / /' | while read PACKAGE BUILD_DEPENDS; do
1389 grep -q ^$PACKAGE$'\t' $wan_db && continue
1391 # Replace each BUILD_DEPENDS with a WANTED package by it's
1392 # WANTED package.
1393 replace_by_wanted()
1395 for p in $BUILD_DEPENDS; do
1396 if grep -q ^$p$'\t' $wan_db; then
1397 echo -n $(grep ^$p$'\t' $wan_db | cut -f 2)' '
1398 else
1399 echo -n $p' '
1400 fi
1401 done | tr ' ' '\n' | sort -u | sed "/^$PACKAGE$/d" | tr '\n' ' '
1403 echo -e $PACKAGE"\t $(replace_by_wanted) "
1404 done > $tmp/db
1405 while [ -s "$tmp/db" ]; do
1406 status=start
1407 for pkg in $(cut -f 1 $tmp/db); do
1408 if ! fgrep -q ' '$pkg' ' $tmp/db; then
1409 echo $pkg >> $tmp/cookorder
1410 sed -e "/^$pkg\t/d" -e "s/ $pkg / /g" -i $tmp/db
1411 status=proceed
1412 fi
1413 done
1414 if [ "$status" = start ]; then
1415 cp -f $tmp/db /tmp/remain-depends.txt
1416 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
1417 for blocked in $(cut -f 1 $tmp/db); do
1418 echo "$blocked" >> $PACKAGES_REPOSITORY/blocked
1419 done
1420 break
1421 fi
1422 done
1423 [ -s $tmp/cookorder ] || touch $tmp/cookorder
1425 # The toolchain packages are moved in first position.
1426 grep $(for pkg in `scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1427 --look_for=all --with_args`; do echo " -e ^$pkg$"; done) \
1428 $tmp/cookorder | tac > $PACKAGES_REPOSITORY/cookorder.txt
1429 for pkg in $(cat $PACKAGES_REPOSITORY/cookorder.txt); do
1430 sed "/^$pkg$/d" -i $tmp/cookorder
1431 done
1433 tac $tmp/cookorder >> $PACKAGES_REPOSITORY/cookorder.txt
1434 unset plan_regen_cookorder
1435 report end-step
1438 ########################################################################
1439 # SCAN CORE
1440 ########################
1441 # Include various scan core-functions. It's not intended to be used
1442 # directly : prefer scan wrappers in next section.
1444 look_for_dep()
1446 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1447 grep -m1 ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt \
1448 | cut -f 2
1449 else
1450 grep -m1 ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1451 cut -f 2
1452 fi
1455 look_for_bdep()
1457 look_for_all
1460 look_for_all()
1462 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1463 grep -m1 ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt \
1464 | cut -f 2,3 | sed 's/ / /'
1465 else
1466 grep -m1 ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1467 cut -f 2,3 | sed 's/ / /'
1468 fi
1471 look_for_rdep()
1473 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | cut -f 1
1474 if [ "$undigest" ]; then
1475 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt | cut -f 1); do
1476 if [ ! -f "WOK$/$rdep/receipt" ]; then
1477 echo "$rdep"
1478 fi
1479 done
1480 fi
1483 look_for_rbdep()
1485 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | \
1486 cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
1487 if [ "$undigest" ]; then
1488 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt \
1489 | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1); do
1490 if [ ! -f "WOK$/$rdep/receipt" ]; then
1491 echo "$rdep"
1492 fi
1493 done
1494 fi
1497 # Return WANTED if it exists.
1498 look_for_wanted()
1500 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1501 grep -m1 ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-wanted.txt | cut -f 2
1502 else
1503 grep -m1 ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 2
1504 fi
1507 # Return packages which wants PACKAGE.
1508 look_for_rwanted()
1510 grep $'\t'$PACKAGE$ $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 1
1511 if [ "$undigest" ]; then
1512 for rwanted in $(grep $'\t'$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-wanted.txt | cut -f 1); do
1513 if [ ! -f "$WOK/$rwanted/receipt" ]; then
1514 echo "$rwanted"
1515 fi
1516 done
1517 fi
1520 look_for_dev()
1522 WANTED=$(look_for_wanted)
1523 if [ "$WANTED" ]; then
1524 if [ "$undigest" ] && [ ! -f "$WOK/$WANTED/receipt" ]; then
1525 [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$WANTED-dev/receipt" ] && echo $WANTED-dev
1526 else
1527 [ -f "$WOK/$WANTED-dev/receipt" ] && echo $WANTED-dev
1528 fi
1529 fi
1530 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1531 [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
1532 else
1533 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
1534 fi
1537 with_dev()
1539 for PACKAGE in $(cat); do
1540 echo $PACKAGE
1541 look_for_dev
1542 done
1545 with_wanted()
1547 for PACKAGE in $(cat); do
1548 echo $PACKAGE
1549 look_for_wanted
1550 done
1553 use_wanted()
1555 for input in $(cat); do
1556 { grep ^$input$'\t' $wan_db || echo $input
1557 } | sed 's/.*\t//'
1558 done
1561 ########################################################################
1562 # SCAN
1563 ########################
1564 # Use wok-wanted.txt and wok-depeds.txt to scan depends.
1565 # Option in command line (must be first arg) :
1566 # --look_for=bdep/rbdep - Look for depends or reverse depends.
1567 # --with_dev - Add development packages (*-dev) in the result.
1568 # --with_wanted - Add package+reverse wanted in the result.
1569 # --with_args - Include packages in argument in the result.
1571 scan()
1573 # Get packages in argument.
1574 local PACKAGE WANTED pkg_list=
1575 for arg in $@; do
1576 [ "$arg" = "${arg#--}" ] || continue
1577 pkg_list="$pkg_list $arg"
1578 done
1580 # Get options.
1581 [ "$pkg_list" ] || return
1582 local cooklist= look_for= with_dev= with_wanted= with_args= log_command="$0 $@" \
1583 get_options_list="look_for with_dev with_wanted with_args cooklist use_wanted"
1584 get_options
1586 # Cooklist is a special case where we need to modify a little
1587 # scan behavior
1588 if [ "$cooklist" ]; then
1589 gen_wan_db
1590 look_for=all && with_args=yes && with_dev= && with_wanted=
1591 filter=use_wanted
1592 if [ "$COMMAND" = gen-cooklist ]; then
1593 for PACKAGE in $pkg_list; do
1594 grep -q ^$PACKAGE$'\t' $dep_db && continue
1595 [ -d "$WOK/$p" ] || continue
1596 check_for_missing
1597 done
1598 append_to_dep()
1600 if ! grep -q ^$PACKAGE$'\t' $dep_db; then
1601 check_for_missing && echo $PACKAGE >> $tmp/dep
1602 else
1603 echo $PACKAGE >> $tmp/dep
1604 fi
1606 else
1607 append_to_dep()
1609 check_for_commit && echo $PACKAGE >> $tmp/dep
1611 fi
1612 else
1613 append_to_dep()
1615 echo $PACKAGE >> $tmp/dep
1617 # If requested packages are not in dep_db, partial generation of this db is needed.
1618 for PACKAGE in $pkg_list; do
1619 grep -q ^$PACKAGE$'\t' $dep_db && continue
1620 [ -d "$WOK/$p" ] || continue
1621 plan_check_for_missing=yes
1622 check_for_missing
1623 done
1624 if [ "$plan_check_for_missing" ]; then
1625 append_to_dep()
1627 if ! grep -q ^$PACKAGE$'\t' $dep_db; then
1628 check_for_missing && echo $PACKAGE >> $tmp/dep
1629 else
1630 echo $PACKAGE >> $tmp/dep
1631 fi
1633 check_db_status=yes
1634 unset plan_check_for_missing
1635 fi
1636 fi
1638 [ "$with_dev" ] && filter=with_dev
1639 [ "$with_wanted" ] && filter=with_wanted
1640 if [ "$filter" ]; then
1641 pkg_list=$(echo $pkg_list | $filter)
1642 scan_pkg()
1644 look_for_$look_for | $filter
1646 else
1647 scan_pkg()
1649 look_for_$look_for
1651 fi
1652 touch $tmp/dep
1653 for PACKAGE in $pkg_list; do
1654 [ "$with_args" ] && append_to_dep
1655 scan_pkg
1656 done | tr ' ' '\n' | sort -u > $tmp/list
1657 [ "$look_for" = bdep ] && look_for=dep
1658 while [ -s $tmp/list ]; do
1659 PACKAGE=$(sed 1!d $tmp/list)
1660 sed 1d -i $tmp/list
1661 append_to_dep
1662 for pkg in $(scan_pkg); do
1663 if ! grep -q ^$pkg$ $tmp/list $tmp/dep; then
1664 echo $pkg >> $tmp/list
1665 fi
1666 done
1667 done
1668 if [ "$cooklist" ]; then
1669 mv $tmp/dep $tmp/cooklist
1670 else
1671 cat $tmp/dep | sort -u
1672 fi
1673 rm -f $tmp/dep $tmp/list
1674 if [ "$check_db_status" ]; then
1675 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
1676 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
1677 if [ "$plan_regen_cookorder" ]; then
1678 grep -q "^#" $PACKAGES_REPOSITORY/cookorder.txt || \
1679 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
1680 fi
1681 fi
1684 ########################################################################
1685 # This section contains functions to check package repository and
1686 # find which packages to cook.
1687 ########################
1689 check_for_missing()
1691 local PACKAGE
1692 if ! check_for_pkg_in_wok; then
1693 [ "$?" = 2 ] && return 1
1694 return
1695 fi
1696 RECEIPT=$WOK/$PACKAGE/receipt
1697 source_receipt
1698 PACKAGE=${WANTED:-$PACKAGE}
1699 update_wan_db
1700 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
1701 RECEIPT=$WOK/$PACKAGE/receipt
1702 source_receipt
1703 update_dep_db
1704 done
1707 check_for_commit()
1709 if ! check_for_pkg_in_wok; then
1710 [ "$?" = 2 ] && return 1
1711 return
1712 fi
1713 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
1714 RECEIPT=$WOK/$PACKAGE/receipt
1715 source_receipt
1717 # We use md5 of cooking stuff in the packaged receipt to check
1718 # commit. We look consecutively in 3 different locations :
1719 # - in the wok/PACKAGE/taz/* folder
1720 # - in the receipt in the package in incoming repository
1721 # - in the receipt in the package in packages repository
1722 # If md5sum match, there's no commit.
1723 check_for_commit_using_md5sum()
1725 if [ ! -f $WOK/$PACKAGE/md5 ]; then
1726 sed -n '/# md5sum of cooking stuff :/,$p' receipt | \
1727 sed -e 1d -e 's/^# //' > $WOK/$PACKAGE/md5
1728 cd $WOK/$PACKAGE
1729 fi
1731 if [ -s md5 ]; then
1732 if md5sum -cs md5; then
1734 # If md5sum check if ok, check for new/missing files in
1735 # cooking stuff.
1736 for file in $([ -f receipt ] && echo receipt; \
1737 [ -f description.txt ] && echo description.txt; \
1738 [ -d stuff ] && find stuff); do
1739 if ! fgrep -q " $file" md5; then
1740 set_commited
1741 fi
1742 done
1743 else
1744 set_commited
1745 fi
1746 else
1747 set_commited
1748 fi
1750 set_commited()
1752 ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/commit &&
1753 echo $PACKAGE >> $PACKAGES_REPOSITORY/commit
1754 gen_cookmd5
1755 update_dep_db
1757 taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | fgrep -v '*')
1758 if [ -f $WOK/$PACKAGE/md5 ]; then
1759 cd $WOK/$PACKAGE
1760 check_for_commit_using_md5sum
1761 elif [ "$taz_dir" ]; then
1762 cd $taz_dir
1763 check_for_commit_using_md5sum
1764 else
1765 pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1766 [ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1767 if [ "$pkg" ]; then
1768 get_pkg_files $pkg
1769 check_for_commit_using_md5sum
1770 rm -r $pkg_files_dir
1771 else
1772 set_commited
1773 fi
1774 fi
1775 [ "$forced" ] || echo $PACKAGE >> $tmp/checked
1776 done
1777 return
1780 gen_cook_list()
1782 report step "Scanning wok"
1783 if [ "$pkg" ]; then
1784 scan $pkg --cooklist
1785 else
1786 scan `cat $cooklist` --cooklist
1787 fi
1788 report end-step
1790 [ -s $tmp/checked ] || [ -s $tmp/cooklist ] || return
1792 # Core toolchain should not be cooked unless cook-toolchain is used.
1793 if ! [ -f /etc/config.site.tmptoolchain ] ; then
1794 for PACKAGE in $(scan gcc --look_for=all --with_args --with_wanted); do
1795 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/blocked || \
1796 echo $PACKAGE >> $PACKAGES_REPOSITORY/blocked
1797 done
1798 fi
1800 if [ -s $PACKAGES_REPOSITORY/commit ] && [ "$COMMAND" != gen-cooklist ]; then
1801 cd $PACKAGES_REPOSITORY
1802 for PACKAGE in $(cat commit); do
1803 WANTED="$(look_for_wanted)"
1804 if [ "$WANTED" ]; then
1805 grep -q ^$WANTED$ broken cooklist blocked commit && continue
1806 fi
1807 grep -q ^$PACKAGE$ blocked cooklist && continue
1808 echo $PACKAGE >> cooklist
1809 done
1810 fi
1811 sort_cooklist
1814 sort_cooklist()
1816 if [ "$(sed 1!d $PACKAGES_REPOSITORY/cookorder.txt)" = "#PlanSort" ]; then
1817 sed 1d -i $PACKAGES_REPOSITORY/cookorder.txt
1818 plan_regen_cookorder=yes
1819 fi
1820 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
1821 [ "$plan_regen_cookorder" ] && sort_db
1822 report step "Sorting cooklist"
1823 if [ -f "$tmp/checked" ]; then
1824 rm -f $tmp/cooklist
1825 cat $tmp/checked | while read PACKAGE; do
1826 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/cooklist && \
1827 echo $PACKAGE >> $tmp/cooklist
1828 done
1829 elif ! [ "$COMMAND" = gen-cooklist ]; then
1830 cat $PACKAGES_REPOSITORY/blocked | while read PACKAGE; do
1831 sed "/^$PACKAGE/d" -i $tmp/cooklist
1832 done
1833 fi
1835 for PACKAGE in $(cat $tmp/cooklist); do
1836 WANTED="$(look_for_wanted)"
1837 [ "$WANTED" ] || continue
1838 if grep -q ^$WANTED$ $PACKAGES_REPOSITORY/broken $tmp/cooklist; then
1839 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1840 elif [ ! -d $WOK/$WANTED/install ]; then
1841 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1842 echo $WANTED >> $tmp/cooklist
1843 fi
1844 done
1846 # Use cookorder.txt to sort cooklist.
1847 if [ -s $tmp/cooklist ]; then
1848 cat $PACKAGES_REPOSITORY/cookorder.txt | while read PACKAGE; do
1849 if grep -q ^$PACKAGE$ $tmp/cooklist; then
1850 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1851 echo $PACKAGE >> $tmp/cooklist.tmp
1852 fi
1853 done
1855 # Remaining packages in cooklist are thoses without compile_rules.
1856 # They can be cooked first in any order.
1857 if [ -f $tmp/cooklist.tmp ]; then
1858 cat $tmp/cooklist.tmp >> $tmp/cooklist
1859 rm $tmp/cooklist.tmp
1860 fi
1862 cat $tmp/cooklist
1863 [ "$cooklist" = "$PACKAGES_REPOSITORY/cooklist" ] && \
1864 cat $tmp/cooklist > $cooklist
1865 fi
1867 report end-step
1870 check_for_incoming()
1872 [ -s $INCOMING_REPOSITORY/packages.desc ] || {
1873 echo "No packages in $INCOMING_REPOSITORY."
1874 return; }
1875 if [ -s $PACKAGES_REPOSITORY/broken ]; then
1876 echo "Don't move incoming packages to main repository because theses ones are broken:
1877 $(cat $PACKAGES_REPOSITORY/broken)" >&2
1878 return
1879 fi
1880 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
1881 echo "Don't move incoming packages to main repository because some of them need to be cooked:
1882 $(cat $PACKAGES_REPOSITORY/cooklist)" >&2
1883 return
1884 fi
1885 pkg="$(cut -f 1 -d '|' $INCOMING_REPOSITORY/packages.desc)"
1886 if ! [ "$forced" ]; then
1887 cooklist=$PACKAGES_REPOSITORY/cooklist
1888 gen_cook_list
1889 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
1890 echo "Don't move incoming packages to main repository because some of them need to be cooked." >&2
1891 return
1892 fi
1893 fi
1894 report step "Moving incoming packages to main repository"
1895 unset EXTRAVERSION
1896 for PACKAGE in $pkg; do
1897 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
1898 VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
1899 remove_previous_package $PACKAGES_REPOSITORY
1900 echo "Moving $PACKAGE..."
1901 mv -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION.tazpkg $PACKAGES_REPOSITORY
1902 touch $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
1903 previous_tarball=$(grep ^$PACKAGE:main $SOURCES_REPOSITORY/sources.list | cut -f2)
1904 sed -e "/^$PACKAGE:main/d" \
1905 -e "s/^$PACKAGE:incoming/$PACKAGE:main/" \
1906 -i $SOURCES_REPOSITORY/sources.list
1907 if [ "$previous_tarball" ]; then
1908 grep -q $'\t'$previous_tarball$ $SOURCES_REPOSITORY/sources.list || \
1909 rm -f $SOURCES_REPOSITORY/$previous_tarball
1910 fi
1911 done
1912 report end-step
1913 for file in packages.list packages.equiv packages.md5 packages.desc \
1914 packages.txt; do
1915 echo -n "" > $INCOMING_REPOSITORY/$file
1916 done
1917 rm -r $INCOMING_REPOSITORY/files.list.lzma
1918 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
1921 ########################################################################
1922 # TAZWOK MAIN FUNCTIONS
1923 ########################
1925 clean()
1927 cd $WOK/$PACKAGE
1928 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
1929 -e ^stuff$ || return
1931 [ "$COMMAND" = clean-wok ] || report step "Cleaning $PACKAGE"
1932 # Check for clean_wok function.
1933 if grep -q ^clean_wok $RECEIPT; then
1934 clean_wok
1935 fi
1936 # Clean should only have a receipt, stuff and optional desc.
1937 for f in `ls .`
1938 do
1939 case $f in
1940 receipt|stuff|description.txt|md5)
1941 continue ;;
1942 *)
1943 rm -rf $f ;;
1944 esac
1945 done
1946 [ "$COMMAND" != clean-wok ] && report end-step
1949 # Configure and make a package with the receipt.
1950 compile_package()
1952 check_for_package_on_cmdline
1954 # Include the receipt to get all needed variables and functions
1955 # and cd into the work directory to start the work.
1956 check_for_receipt
1957 source_receipt
1959 # Log the package name and date.
1960 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
1961 echo "package $PACKAGE (compile)" >> $LOG
1963 # Set wanted $src variable to help compiling.
1964 [ ! "$src" ] && set_src_path
1965 check_for_build_depends || return 1
1966 check_for_wanted
1967 unset target
1968 check_for_tarball && check_for_compile_rules
1971 # Cook command also include all features to manage lists which keep
1972 # track of wok/packages state.
1973 cook()
1975 cook_code=
1976 set_common_path
1977 check_for_receipt
1978 source_receipt
1980 # Define log path and start report.
1981 [ -f $LOCAL_REPOSITORY/log/$PACKAGE.html ] && rm $LOCAL_REPOSITORY/log/$PACKAGE.html
1982 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
1983 report step "Cooking $PACKAGE"
1984 report open-bloc
1986 clean $PACKAGE
1987 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
1989 if compile_package; then
1990 remove_src
1991 refresh_packages_from_compile
1992 gen_package
1994 # Update packages-incoming repository.
1995 store_pkgname=$PACKAGE
1996 pkg_repository=$INCOMING_REPOSITORY
1997 update_packages_db
1999 PACKAGE=$store_pkgname
2000 unset store_pkgname
2002 # Upgrade to cooked packages if it was previously installed.
2003 report step "Look for package(s) to upgrade"
2004 for pkg in $(look_for_rwanted) $PACKAGE; do
2005 if [ -d $INSTALLED/$pkg ]; then
2006 tazpkg get-install $pkg --forced
2007 fi
2008 done
2009 report end-step
2010 else
2012 # Set package as broken.
2013 if ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then
2014 echo $PACKAGE >> $PACKAGES_REPOSITORY/broken
2015 fi
2016 gen_cookmd5
2017 cook_code=1
2018 fi
2020 # Remove build_depends in cook mode (if in cooklist, it's done when
2021 # checking build_depends of next package and we remove only unneeded
2022 # packages to keep chroot minimal and gain some time).
2023 if [ "$COMMAND" = cook ]; then
2024 remove_build_depends $MISSING_PACKAGE
2025 [ -x /usr/bin/clean-chroot ] && clean-chroot
2026 fi
2028 # Regen the cooklist if it was planned and command is not cook.
2029 [ "$regen_cooklist" ] && unset regen_cooklist && \
2030 [ "$COMMAND" != cook ] && sort_cooklist
2032 # Some hacks to set the bloc & function status as failed if cook was
2033 # failed.
2034 report_return_code=$cook_code
2035 report close-bloc
2036 report end-sublog
2037 return $cook_code
2040 cook_list()
2042 if [ -s $tmp/cooklist ]; then
2043 if [ -f /usr/bin/tazchroot ]; then
2044 # Note : options -main variables- are automatically keeped by
2045 # the sub-applications tazchroot/tazwok; as well as report data.
2046 cd $LOCAL_REPOSITORY
2047 [ ! -f tazchroot.conf ] && configure_tazchroot
2048 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
2049 return
2050 fi
2051 while [ -s $tmp/cooklist ]; do
2052 PACKAGE=$(sed 1!d $tmp/cooklist)
2053 cook
2054 done
2055 remove_build_depends $MISSING_PACKAGE $remove_later
2056 [ -x /usr/bin/clean-chroot ] && clean-chroot
2057 else
2058 echo "Nothing to cook."
2059 return
2060 fi
2063 configure_tazchroot()
2065 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
2066 # Tazchroot configuration file - created by tazwok.
2068 # Default chroot path
2069 SLITAZ_DIR=$SLITAZ_DIR
2070 SLITAZ_VERSION=$SLITAZ_VERSION
2071 $( [ "$undigest" ] && echo "undigest=$undigest" )
2072 LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
2073 chroot_dir=\$LOCAL_REPOSITORY/chroot
2075 # Default scripts path (theses scripts are added in the
2076 # $chroot_dir/usr/bin and can be called with tazchroot script)
2077 script_dir=/var/lib/tazchroot
2079 # List of directories to mount.
2080 list_dir="$(for dir in packages wok src packages-incoming log flavors iso; do echo $LOCAL_REPOSITORY/$dir; done)
2081 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
2083 create_chroot()
2085 mkdir -p \$chroot_dir
2086 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
2087 tazpkg get-install \$pkg --root="\$chroot_dir"
2088 done
2090 # Store list of installed packages needed by cleanchroot.
2091 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
2093 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
2094 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
2095 -i \$chroot_dir/etc/slitaz/slitaz.conf
2096 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
2097 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
2100 mount_chroot()
2102 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
2103 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCALSTATE/mirror
2104 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
2105 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
2106 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION
2107 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror' )
2108 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
2109 mount -t proc proc \$chroot_dir/proc
2110 mount -t sysfs sysfs \$chroot_dir/sys
2111 mount -t devpts devpts \$chroot_dir/dev/pts
2112 mount -t tmpfs shm \$chroot_dir/dev/shm
2113 for dir in \$list_dir; do
2114 mkdir -p \$dir \$chroot_dir\$dir
2115 mount \$dir \$chroot_dir\$dir
2116 done
2119 umount_chroot()
2121 for dir in \$list_dir; do
2122 umount \$chroot_dir\$dir
2123 done
2124 umount \$chroot_dir/dev/shm
2125 umount \$chroot_dir/dev/pts
2126 umount \$chroot_dir/sys
2127 umount \$chroot_dir/proc
2129 EOF
2132 ########################################################################
2133 ######################### END OF NEW FUNCTIONS #########################
2134 ########################################################################
2136 # List packages providing a virtual package
2137 whoprovide()
2139 local i;
2140 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
2141 . $i
2142 case " $PROVIDE " in
2143 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
2144 esac
2145 done
2148 ########################################################################
2149 # TAZWOK COMMANDS
2150 ########################
2152 case "$COMMAND" in
2153 stats)
2154 # Tazwok general statistics from the wok config file.
2156 get_tazwok_config
2157 echo -e "\n\033[1mTazwok configuration statistics\033[0m
2158 ================================================================================
2159 Wok directory : $WOK
2160 Packages repository : $PACKAGES_REPOSITORY
2161 Incoming repository : $INCOMING_REPOSITORY
2162 Sources repository : $SOURCES_REPOSITORY
2163 Log directory : $LOCAL_REPOSITORY/log
2164 Packages in the wok : `ls -1 $WOK | wc -l`
2165 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2166 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2167 ================================================================================\n"
2168 ;;
2169 edit)
2170 get_tazwok_config
2171 check_for_package_on_cmdline
2172 check_for_receipt
2173 $EDITOR $WOK/$PACKAGE/receipt
2174 ;;
2175 build-depends)
2176 # List dependencies to rebuild wok, or only a package
2177 get_tazwok_config
2178 report(){ : ; }
2179 if [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
2180 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
2181 --look_for=dep --with_dev --with_args
2182 else
2183 check_for_package_on_cmdline
2184 scan $PACKAGE --look_for=bdep --with_dev
2185 fi
2186 ;;
2187 gen-cooklist)
2188 check_root
2189 get_options_list="pkg"
2190 get_tazwok_config
2191 report(){ : ; }
2192 if ! [ "$pkg" ]; then
2193 if [ ! "$LIST" ] || [ "$LIST" = toolchain ]; then
2194 pkg="$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA"
2195 else
2196 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2197 fi
2198 fi
2199 gen_cook_list
2200 ;;
2201 check-depends)
2202 # Check package depends /!\
2203 get_tazwok_config
2204 echo ""
2205 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
2206 ================================================================================"
2207 TMPDIR=/tmp/tazwok$$
2208 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
2210 # Build ALL_DEPENDS variable
2211 scan_dep()
2213 local i
2214 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
2215 for i in $DEPENDS $SUGGESTED ; do
2216 case " $ALL_DEPENDS " in
2217 *\ $i\ *) continue;;
2218 esac
2219 [ -d $WOK/$i ] || {
2220 ALL_DEPENDS="$ALL_DEPENDS$i "
2221 continue
2223 DEPENDS=""
2224 SUGGESTED=""
2225 . $WOK/$i/receipt
2226 scan_dep
2227 done
2230 # Check for ELF file
2231 is_elf()
2233 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" \
2234 = "ELF" ]
2237 # Print shared library dependencies
2238 ldd()
2240 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
2243 mkdir $TMPDIR
2244 cd $TMPDIR
2245 for i in $LOCALSTATE/files.list.lzma \
2246 $LOCALSTATE/undigest/*/files.list.lzma ; do
2247 [ -f $i ] && lzma d $i -so >> files.list
2248 done
2249 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
2250 tazpkg extract $pkg > /dev/null 2>&1
2251 . */receipt
2252 ALL_DEPENDS="$DEFAULT_DEPENDS "
2253 scan_dep
2254 find */fs -type f | while read file ; do
2255 is_elf $file || continue
2256 case "$file" in
2257 *.o|*.ko|*.ko.gz) continue;;
2258 esac
2259 ldd $file | while read lib rem; do
2260 case "$lib" in
2261 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
2262 continue;;
2263 esac
2264 for dep in $(fgrep $lib files.list | cut -d: -f1); do
2265 case " $ALL_DEPENDS " in
2266 *\ $dep\ *) continue 2;;
2267 esac
2268 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
2269 case " $ALL_DEPENDS " in
2270 *\ $vdep\ *) continue 3;;
2271 esac
2272 done
2273 done
2274 [ -n "$dep" ] || dep="UNKNOWN"
2275 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
2276 done
2277 done
2278 rm -rf */
2279 done
2280 cd /tmp
2281 rm -rf $TMPDIR
2282 ;;
2283 check)
2284 # Check wok consistency
2285 get_tazwok_config
2286 echo ""
2287 echo -e "\033[1mWok and packages checking\033[0m
2288 ================================================================================"
2289 cd $WOK
2290 for pkg in $(ls)
2291 do
2292 [ -f $pkg/receipt ] || continue
2293 RECEIPT= $pkg/receipt
2294 source_receipt
2295 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
2296 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
2297 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
2298 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
2299 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
2300 if [ -n "$WANTED" ]; then
2301 if [ ! -f $WANTED/receipt ]; then
2302 echo "Package $PACKAGE wants unknown $WANTED package" >&2
2303 else
2304 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
2305 if [ "$VERSION" = "$WANTED" ]; then
2306 # BASEVERSION is computed in receipt
2307 fgrep -q '_pkg=' $pkg/receipt &&
2308 BASEVERSION=$VERSION
2309 fi
2310 if [ "$VERSION" != "$BASEVERSION" ]; then
2311 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
2312 fi
2313 fi
2314 fi
2316 if [ -n "$CATEGORY" ]; then
2317 case " $(echo $CATEGORIES) " in
2318 *\ $CATEGORY\ *);;
2319 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
2320 esac
2321 else
2322 echo"Package $PACKAGE has no CATEGORY" >&2
2323 fi
2324 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
2325 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
2326 case "$WGET_URL" in
2327 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
2328 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
2329 '') ;;
2330 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
2331 esac
2332 case "$WEB_SITE" in
2333 ftp*|http*);;
2334 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
2335 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
2336 esac
2337 case "$MAINTAINER" in
2338 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
2339 esac
2340 case "$MAINTAINER" in
2341 *@*);;
2342 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
2343 esac
2344 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2345 for i in $DEPENDS; do
2346 [ -d $i ] && continue
2347 [ -n "$(whoprovide $i)" ] && continue
2348 echo -e "$MSG $i"
2349 MSG=""
2350 done
2351 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2352 for i in $BUILD_DEPENDS; do
2353 [ -d $i ] && continue
2354 [ -n "$(whoprovide $i)" ] && continue
2355 echo -e "$MSG $i"
2356 MSG=""
2357 done
2358 MSG="Dependencies loop between $PACKAGE and :\n"
2359 ALL_DEPS=""
2360 check_for_deps_loop $PACKAGE $DEPENDS
2361 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
2362 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
2363 echo "$pkg should be rebuilt after $i installation"
2364 done
2365 done
2366 ;;
2367 list)
2368 # List packages in wok directory. User can specify a category.
2370 get_tazwok_config
2371 if [ "$2" = "category" ]; then
2372 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
2373 exit 0
2374 fi
2375 # Check for an asked category.
2376 if [ -n "$2" ]; then
2377 ASKED_CATEGORY=$2
2378 echo ""
2379 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
2380 echo "================================================================================"
2381 for pkg in $WOK/*
2382 do
2383 [ ! -f $pkg/receipt ] && continue
2384 . $pkg/receipt
2385 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
2386 echo -n "$PACKAGE"
2387 echo -e "\033[28G $VERSION"
2388 packages=$(($packages+1))
2389 fi
2390 done
2391 echo "================================================================================"
2392 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
2393 else
2394 # By default list all packages and version.
2395 echo ""
2396 echo -e "\033[1mList of packages in the wok\033[0m"
2397 echo "================================================================================"
2398 for pkg in $WOK/*
2399 do
2400 [ ! -f $pkg/receipt ] && continue
2401 . $pkg/receipt
2402 echo -n "$PACKAGE"
2403 echo -en "\033[28G $VERSION"
2404 echo -e "\033[42G $CATEGORY"
2405 packages=$(($packages+1))
2406 done
2407 echo "================================================================================"
2408 echo -e "$packages packages available in the wok.\n"
2409 fi
2410 ;;
2411 info)
2412 # Information about a package.
2414 get_tazwok_config
2415 check_for_package_on_cmdline
2416 check_for_receipt
2417 . $WOK/$PACKAGE/receipt
2418 echo ""
2419 echo -e "\033[1mTazwok package information\033[0m
2420 ================================================================================
2421 Package : $PACKAGE
2422 Version : $VERSION
2423 Category : $CATEGORY
2424 Short desc : $SHORT_DESC
2425 Maintainer : $MAINTAINER"
2426 if [ ! "$WEB_SITE" = "" ]; then
2427 echo "Web site : $WEB_SITE"
2428 fi
2429 if [ ! "$DEPENDS" = "" ]; then
2430 echo "Depends : $DEPENDS"
2431 fi
2432 if [ ! "$WANTED" = "" ]; then
2433 echo "Wanted src : $WANTED"
2434 fi
2435 echo "================================================================================"
2436 echo ""
2437 ;;
2438 check-log)
2439 # We just cat the file log to view process info.
2441 get_tazwok_config
2442 if [ ! -f "$LOG" ]; then
2443 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
2444 exit 1
2445 else
2446 echo ""
2447 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
2448 echo "================================================================================"
2449 cat $LOG
2450 echo "================================================================================"
2451 echo ""
2452 if [ -s "$WOK/$PACKAGE/warning.txt" ]; then
2453 echo -e "\033[1mCook warning(s) for :\033[0m $PACKAGE"
2454 echo "================================================================================"
2455 cat "$WOK/$PACKAGE/warning.txt"
2456 echo "================================================================================"
2457 echo ""
2458 fi
2459 fi
2460 ;;
2461 search)
2462 # Search for a package by pattern or name.
2464 get_tazwok_config
2465 if [ -z "$2" ]; then
2466 echo -e "\nPlease specify a pattern or a package name to search." >&2
2467 echo -e "Example : 'tazwok search gcc'.\n" >&2
2468 exit 1
2469 fi
2470 echo ""
2471 echo -e "\033[1mSearch result for :\033[0m $2"
2472 echo "================================================================================"
2473 list=`ls -1 $WOK | fgrep $2`
2474 for pkg in $list
2475 do
2476 . $WOK/$pkg/receipt
2477 echo -n "$PACKAGE "
2478 echo -en "\033[24G $VERSION"
2479 echo -e "\033[42G $CATEGORY"
2480 packages=$(($PACKAGEs+1))
2481 done
2482 echo "================================================================================"
2483 echo "$packages packages found for : $2"
2484 echo ""
2485 ;;
2486 compile)
2487 # Configure and make a package with the receipt.
2489 get_tazwok_config
2490 source_lib report
2491 report start
2492 compile_package
2493 ;;
2494 genpkg)
2495 # Generate a package.
2497 get_tazwok_config
2498 source_lib report
2499 report start
2500 gen_package
2501 ;;
2502 cook)
2503 # Compile and generate a package. Just execute tazwok with
2504 # the good commands.
2506 check_root
2507 get_tazwok_config
2508 source_lib report
2509 report start
2510 update_wan_db
2511 check_for_commit
2512 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
2513 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
2514 if [ "$plan_regen_cookorder" ]; then
2515 grep -q "^#" $PACKAGES_REPOSITORY/cookorder.txt || \
2516 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
2517 fi
2518 cook
2519 ;;
2520 sort-cooklist)
2521 if [ ! "$LIST" ]; then
2522 echo "Usage : tazwok sort-cooklist cooklist" >&2\
2523 exit 1
2524 fi
2525 get_tazwok_config
2526 source_lib report
2527 report start
2528 cooklist=$LIST
2529 sort_cooklist
2530 cp -af $tmp/cooklist $cooklist
2531 ;;
2532 cook-list)
2533 # Cook all packages listed in a file or in default cooklist.
2534 check_root
2535 get_options_list="pkg forced"
2536 get_tazwok_config
2537 source_lib report
2538 report start
2539 if ! [ "$pkg" ]; then
2540 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2541 fi
2542 gen_cook_list
2543 cook_list
2544 ;;
2545 clean)
2546 # Clean up a package work directory + thoses which want it.
2548 get_tazwok_config
2549 check_for_package_on_cmdline
2550 check_for_receipt
2551 source_lib report
2552 report start
2553 . $RECEIPT
2554 clean
2555 ;;
2556 gen-clean-wok)
2557 # Generate a clean wok from the current wok by copying all receipts
2558 # and stuff directory.
2560 get_tazwok_config
2561 source_lib report
2562 report start
2563 if [ -z "$ARG" ]; then
2564 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
2565 exit 1
2566 else
2567 dest=$ARG
2568 mkdir -p $dest
2569 fi
2570 report step "Creating clean wok in : $dest"
2571 for pkg in `ls -1 $WOK`
2572 do
2573 mkdir -p $dest/$pkg
2574 cp -a $WOK/$pkg/receipt $dest/$pkg
2575 [ -f $WOK/$pkg/description.txt ] && \
2576 cp -a $WOK/$pkg/description.txt $dest/$pkg
2577 if [ -d "$WOK/$pkg/stuff" ]; then
2578 cp -a $WOK/$pkg/stuff $dest/$pkg
2579 fi
2580 done
2581 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
2582 report end-step
2583 echo "Packages cleaned : `ls -1 $dest | wc -l`"
2584 echo ""
2585 ;;
2586 clean-wok)
2587 # Clean all packages in the work directory
2589 get_tazwok_config
2590 source_lib report
2591 report start
2592 report step "Cleaning wok"
2593 for PACKAGE in `ls -1 $WOK`
2594 do
2595 set_common_path
2596 source_receipt
2597 clean
2598 done
2599 echo "`ls -1 $WOK | wc -l` packages cleaned."
2600 ;;
2601 clean-src)
2602 # Remove tarball unrelated to wok receipts from src repo.
2603 check_root
2604 get_options_list="forced"
2605 get_tazwok_config
2606 cd $SOURCES_REPOSITORY
2607 echo -n "Checking $SOURCES_REPOSITORY..."
2608 for TARBALL in *; do
2609 [ "$TARBALL" = sources.list ] && continue
2610 grep -q $'\t'$TARBALL$ $SOURCES_REPOSITORY/sources.list || \
2611 echo $TARBALL >> $tmp/obsolete
2612 done
2613 status
2614 if ! [ -f $tmp/obsolete ]; then
2615 echo "No sources need to be removed."
2616 exit 1
2617 fi
2618 echo ""
2619 echo -e "\033[1mObsolete/unrelated-to-wok sourcess :\033[0m"
2620 horizontal_line
2621 cat $tmp/obsolete
2622 horizontal_line
2623 echo "$(wc -l $tmp/obsolete | cut -f1 -d' ') tarballs to remove."
2624 echo ""
2625 echo -n "Please confirm removing (type uppercase YES): "
2626 read answer
2627 if [ "$answer" = YES ]; then
2628 echo -n "Removing old sources..."
2629 cat $tmp/obsolete | while read i; do
2630 rm -f $SOURCES_REPOSITORY/$i
2631 done
2632 status
2633 fi
2634 ;;
2635 gen-list)
2636 get_tazwok_config
2637 if [ "$2" ]; then
2638 if [ -d "$2" ]; then
2639 pkg_repository=$2
2640 else
2641 echo -e "\nUnable to find directory : $2\n" >&2
2642 exit 1
2643 fi
2644 fi
2646 source_lib report
2647 report start
2648 if [ "$pkg_repository" ]; then
2649 gen_packages_db
2650 else
2651 pkg_repository=$PACKAGES_REPOSITORY && gen_packages_db
2652 pkg_repository=$INCOMING_REPOSITORY && gen_packages_db
2653 fi
2654 ;;
2655 check-list)
2656 # The directory to move into by default is the repository,
2657 # if $2 is not empty cd into $2.
2659 get_tazwok_config
2660 if [ "$2" ]; then
2661 if [ -d "$2" ]; then
2662 pkg_repository=$2
2663 else
2664 echo -e "\nUnable to find directory : $2\n" >&2
2665 exit 1
2666 fi
2667 fi
2669 source_lib report
2670 report start
2671 if [ "$pkg_repository" ]; then
2672 update_packages_db
2673 else
2674 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
2675 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
2676 fi
2677 ;;
2678 new-tree)
2679 # Just create a few directories and generate an empty receipt to prepare
2680 # the creation of a new package.
2682 get_tazwok_config
2683 check_for_package_on_cmdline
2684 if [ -d $WOK/$PACKAGE ]; then
2685 echo -e "\n$PACKAGE package tree already exists.\n" >&2
2686 exit 1
2687 fi
2688 echo "Creating : $WOK/$PACKAGE"
2689 mkdir $WOK/$PACKAGE
2690 cd $WOK/$PACKAGE
2691 echo -n "Preparing the receipt..."
2693 # Default receipt begin.
2695 echo "# SliTaz package receipt." > receipt
2696 echo "" >> receipt
2697 echo "PACKAGE=\"$PACKAGE\"" >> receipt
2698 # Finish the empty receipt.
2699 cat >> receipt << "EOF"
2700 VERSION=""
2701 CATEGORY=""
2702 SHORT_DESC=""
2703 MAINTAINER=""
2704 DEPENDS=""
2705 TARBALL="$PACKAGE-$VERSION.tar.gz"
2706 WEB_SITE=""
2707 WGET_URL=""
2709 # Rules to configure and make the package.
2710 compile_rules()
2712 cd $src
2713 ./configure && make && make install
2716 # Rules to gen a SliTaz package suitable for Tazpkg.
2717 genpkg_rules()
2719 mkdir -p $fs/usr
2720 cp -a $_pkg/usr/bin $fs/usr
2723 EOF
2725 # Default receipt end.
2727 status
2728 # Interactive mode, asking and seding.
2729 if [ "$3" = "--interactive" ]; then
2730 echo "Entering into interactive mode..."
2731 echo "================================================================================"
2732 echo "Package : $PACKAGE"
2733 # Version.
2734 echo -n "Version : " ; read anser
2735 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
2736 # Category.
2737 echo -n "Category : " ; read anser
2738 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
2739 # Short description.
2740 echo -n "Short desc : " ; read anser
2741 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
2742 # Maintainer.
2743 echo -n "Maintainer : " ; read anser
2744 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
2745 # Web site.
2746 echo -n "Web site : " ; read anser
2747 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
2748 echo ""
2749 # Wget URL.
2750 echo "Wget URL to download source tarball."
2751 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
2752 echo -n "Wget url : " ; read anser
2753 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
2754 # Ask for a stuff dir.
2755 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
2756 if [ "$anser" = "y" ]; then
2757 echo -n "Creating the stuff directory..."
2758 mkdir stuff && status
2759 fi
2760 # Ask for a description file.
2761 echo -n "Are you going to write a description ? (y/N) : " ; read anser
2762 if [ "$anser" = "y" ]; then
2763 echo -n "Creating the description.txt file..."
2764 echo "" > description.txt && status
2765 fi
2766 echo "================================================================================"
2767 echo ""
2768 fi
2769 ;;
2770 remove)
2771 # Remove a package from the wok.
2773 get_tazwok_config
2774 check_for_package_on_cmdline
2775 echo ""
2776 echo -n "Please confirm deletion (y/N) : "; read anser
2777 if [ "$anser" = "y" ]; then
2778 echo -n "Removing $PACKAGE..."
2779 rm -rf $WOK/$PACKAGE && status
2780 echo ""
2781 fi
2782 ;;
2783 hgup)
2784 # Pull and update a Hg wok.
2785 get_tazwok_config
2786 if ls -l $WOK/.hg/hgrc | fgrep -q "root"; then
2787 check_root
2788 fi
2789 cd $WOK
2790 hg pull && hg update
2791 ;;
2792 maintainers)
2793 get_tazwok_config
2794 echo ""
2795 echo "List of maintainers for: $WOK"
2796 echo "================================================================================"
2797 touch /tmp/slitaz-maintainers
2798 for pkg in $WOK/*
2799 do
2800 . $pkg/receipt
2801 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
2802 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
2803 echo "$MAINTAINER"
2804 fi
2805 done
2806 echo "================================================================================"
2807 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
2808 echo ""
2809 # Remove tmp files
2810 rm -f /tmp/slitaz-maintainers
2811 ;;
2812 maintained-by)
2813 # Search for packages maintained by a contributor.
2814 get_tazwok_config
2815 if [ ! -n "$2" ]; then
2816 echo "Specify a name or email of a maintainer." >&2
2817 exit 1
2818 fi
2819 echo "Maintainer packages"
2820 echo "================================================================================"
2821 for pkg in $WOK/*
2822 do
2823 . $pkg/receipt
2824 if echo "$MAINTAINER" | fgrep -q "$2"; then
2825 echo "$PACKAGE"
2826 packages=$(($PACKAGEs+1))
2827 fi
2828 done
2829 echo "================================================================================"
2830 echo "Packages maintained by $2: $PACKAGEs"
2831 echo ""
2832 ;;
2833 tags)
2834 get_tazwok_config
2835 echo -e "\n\033[1mTags list :\033[0m"
2836 horizontal_line
2837 cd $WOK
2838 for i in */receipt; do
2839 unset TAGS
2840 source $i
2841 for t in $TAGS; do
2842 grep -q ^$t$ $tmp/tags && continue
2843 echo $t | tee -a $tmp/tags
2844 done
2845 done
2846 horizontal_line
2847 echo "$(wc -l $tmp/tags | cut -f1 -d ' ') tags listed."
2848 ;;
2849 check-src)
2850 # Verify if upstream package is still available
2852 get_tazwok_config
2853 check_for_package_on_cmdline
2854 check_for_receipt
2855 source_receipt
2856 check_src()
2858 for url in $@; do
2859 busybox wget -s $url 2>/dev/null && break
2860 done
2862 if [ "$WGET_URL" ];then
2863 echo -n "$PACKAGE : "
2864 check_src $WGET_URL
2865 status
2866 else
2867 echo "No tarball to check for $PACKAGE"
2868 fi
2869 ;;
2870 get-src)
2871 check_root
2872 get_options_list="target nounpack"
2873 get_tazwok_config
2874 check_for_package_on_cmdline
2875 check_for_receipt
2876 source_receipt
2877 if [ "$WGET_URL" ];then
2878 source_lib report
2879 report start
2880 check_for_tarball
2881 [ -x /usr/bin/clean-chroot ] && clean-chroot
2882 else
2883 echo "No tarball to download for $PACKAGE"
2884 fi
2885 ;;
2886 check-commit)
2887 check_root
2888 get_options_list="missing forced"
2889 get_tazwok_config
2890 source_lib report
2891 report start
2892 if [ "$forced" ]; then
2893 rm -f $WOK/*/md5
2894 unset forced
2895 fi
2896 if [ "$missing" ]; then
2897 pkg=$(ls -1 $WOK)
2898 else
2899 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2900 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2901 } | sort -u)"
2902 fi
2903 cooklist=$PACKAGES_REPOSITORY/cooklist
2904 gen_cook_list
2905 ;;
2906 cook-commit)
2907 check_root
2908 get_options_list="missing forced"
2909 get_tazwok_config
2910 source_lib report
2911 report start
2912 if [ "$forced" ]; then
2913 rm -f $WOK/*/md5
2914 unset forced
2915 fi
2916 if [ "$missing" ]; then
2917 pkg=$(ls -1 $WOK)
2918 else
2919 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2920 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2921 } | sort -u)"
2922 fi
2923 cooklist=$PACKAGES_REPOSITORY/cooklist
2924 gen_cook_list
2925 cook_list
2926 ;;
2927 cook-all)
2928 check_root
2929 get_options_list="forced missing"
2930 get_tazwok_config
2931 source_lib report
2932 report start
2933 if [ "$missing" ]; then
2934 pkg=$(ls -1 $WOK)
2935 else
2936 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2937 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2938 } | sort -u)"
2939 fi
2940 cooklist=$PACKAGES_REPOSITORY/cooklist
2941 gen_cook_list
2942 cook_list
2943 ;;
2944 gen-wok-db)
2945 check_root
2946 get_tazwok_config
2947 source_lib report
2948 report start
2949 gen_wok_db
2950 ;;
2951 report)
2952 check_root
2953 get_tazwok_config
2954 cd $PACKAGES_REPOSITORY
2955 if [ "$2" ]; then
2956 case $2 in
2957 commit|cooklist|incoming|broken|blocked)
2958 show="$2"
2959 ;;
2960 *)
2961 echo "usage : tazwok report [commit|cooklist|incoming|broken|blocked]" >&2
2962 exit 1
2963 ;;
2964 esac
2965 else
2966 show="commit cooklist incoming broken blocked"
2967 fi
2968 for i in $show; do
2969 if [ -s $i ]; then
2970 echo ""
2971 echo -e "\033[1m$i\033[0m"
2972 echo "================================================================================"
2973 cat $i
2974 echo "================================================================================"
2975 echo ""
2976 fi
2977 done
2978 ;;
2979 check-incoming)
2980 check_root
2981 get_options_list="forced"
2982 get_tazwok_config
2983 source_lib report
2984 report start
2985 check_for_incoming
2986 ;;
2987 configure-chroot)
2988 check_root
2989 get_tazwok_config
2990 if [ -f /usr/bin/tazchroot ]; then
2991 cd $LOCAL_REPOSITORY
2992 configure_tazchroot
2993 else
2994 echo "The packages tazchroot need to be installed" >&2
2995 exit 1
2996 fi
2997 ;;
2998 chroot)
2999 check_root
3000 get_tazwok_config
3001 # Merge this and the other chroot function ?.
3002 if [ -f /usr/bin/tazchroot ]; then
3003 cd $LOCAL_REPOSITORY
3004 [ ! -f tazchroot.conf ] && configure_tazchroot
3005 tazchroot
3006 else
3007 echo "The packages tazchroot need to be installed" >&2
3008 exit 1
3009 fi
3010 ;;
3011 cook-toolchain)
3012 check_root
3013 get_tazwok_config
3014 echo -n "" > $PACKAGES_REPOSITORY/broken
3015 if [ -f /usr/bin/tazchroot ]; then
3016 cd $LOCAL_REPOSITORY
3017 [ ! -f tazchroot.conf ] && configure_tazchroot
3018 tazchroot cook-toolchain
3019 # Buggy : chroot can be elsewhere.
3020 rm -r $LOCAL_REPOSITORY/chroot
3021 # /!\ to be writed :
3022 # next rm chroot and plan cook-all by pushing all packages
3023 # in cooklist.
3024 else
3025 echo "The packages tazchroot need to be installed" >&2
3026 exit 1
3027 fi
3028 ;;
3029 webserver)
3030 check_root
3031 get_tazwok_config
3032 if [ "$ARG" = on ]; then
3033 if [ "$WEBSERVER" ] && [ -f "$WEBSERVER/repositories.list" ] && \
3034 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3035 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3036 exit 1
3037 fi
3038 if ! [ -f $LOCAL_REPOSITORY/tazchroot.conf ]; then
3039 tazwok configure-chroot ${undigest:+--undigest=$undigest} --SLITAZ_VERSION=$SLITAZ_VERSION --SLITAZ_DIR=$SLITAZ_DIR
3040 fi
3041 for pkg in php lighttpd; do
3042 [ -d $INSTALLED/$pkg ] || missing="$missing $pkg"
3043 done
3044 if [ "$missing" ]; then
3045 echo "You need to install those packages to start webserver: $missing." >&2
3046 exit 1
3047 fi
3048 if [ ! -f "$LOCAL_REPOSITORY/tazwok.conf" ]; then
3049 echo "Copying /etc/slitaz/tazwok.conf to $LOCAL_REPOSITORY/tazwok.conf: webserver is configured repository-by-repository."
3050 cp /etc/slitaz/tazwok.conf $LOCAL_REPOSITORY
3051 fi
3052 if ! [ "$WEBSERVER" ]; then
3053 echo -n "Where to store php pages (default: /var/www/vhosts/bb)? "
3054 read WEBSERVER
3055 [ "$WEBSERVER" ] || WEBSERVER="/var/www/vhosts/bb"
3056 fi
3057 if [ -f "$WEBSERVER/repositories.list" ] && \
3058 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3059 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3060 exit 1
3061 fi
3062 mkdir -p $WEBSERVER
3063 echo "${undigest:-$SLITAZ_VERSION}" >> $WEBSERVER/repositories.list
3064 for file in index.php log.php download.php; do
3065 [ -f "$WEBSERVER/$file" ] || ln -s /usr/share/slitaz/web-bb/$file $WEBSERVER
3066 done
3067 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3068 ln -s $dir $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3069 done
3070 source $LOCAL_REPOSITORY/tazchroot.conf
3071 echo "<?php
3073 // Web interface configuration
3075 \$version=\"${undigest:-$SLITAZ_VERSION}\";
3076 \$chroot=\"$chroot_dir\";
3077 \$lockfile=\"\$chroot/proc/1\";
3078 \$db_dir=\"$PACKAGES_REPOSITORY\";
3079 \$log_dir=\"$LOCAL_REPOSITORY/log\";
3080 \$packages=\"$PACKAGES_REPOSITORY\";
3081 \$incoming=\"$INCOMING_REPOSITORY\";
3082 \$wok=\"$WOK\";
3084 ?>" > $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3085 [ -L "$WEBSERVER/web" ] || ln -s /usr/share/slitaz/web $WEBSERVER
3086 echo "WEBSERVER=\"$WEBSERVER\"" >> $LOCAL_REPOSITORY/tazwok.conf
3087 if [ -L "$WEBSERVER/conf.php" ]; then
3088 echo "Do yo want to make ${undigest:-$SLITAZ_VERSION} the default page (y/N) ? "
3089 read answer
3090 if [ "$answer" = y ]; then
3091 rm $WEBSERVER/conf.php
3092 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3093 fi
3094 else
3095 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3096 fi
3097 elif [ "$ARG" = off ]; then
3098 if ! [ "$WEBSERVER" ]; then
3099 echo "No webserver running for ${undigest:-$SLITAZ_VERSION}" >&2
3100 exit 1
3101 fi
3102 sed '/^WEBSERVER/d' -i $LOCAL_REPOSITORY/tazwok.conf
3103 sed "/^${undigest:-$SLITAZ_VERSION}$/d" -i $WEBSERVER/repositories.list
3104 rm $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3105 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3106 rm $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3107 done
3108 if ! [ -s "$WEBSERVER/repositories.list" ]; then
3109 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"
3110 rm $WEBSERVER/conf.php
3111 elif [ "$(readlink $WEBSERVER/conf.php)" = "$WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php" ]; then
3112 echo "${undigest:-$SLITAZ_VERSION} was the default version to use; switched to : $(sed 1!d $WEBSERVER/repositories.list)"
3113 rm $WEBSERVER/conf.php
3114 ln -s $WEBSERVER/conf-$(sed 1!d $WEBSERVER/repositories.list).php $WEBSERVER/conf.php
3115 fi
3116 else
3117 echo "Usage: tazwok webserver on/off" >&2
3118 exit 1
3119 fi
3120 ;;
3121 usage|*)
3122 # Print usage also for all unknown commands.
3124 usage
3125 ;;
3126 esac
3128 report stop 2>/dev/null || exit 0