tazwok view tazwok @ rev 300

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