tazwok view tazwok @ rev 297

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