tazwok view tazwok @ rev 305

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