tazwok view tazwok @ rev 293

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