tazwok view tazwok @ rev 283

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