tazwok view tazwok @ rev 331

Finx a syntax error.
author Antoine Bodin <gokhlayeh@slitaz.org>
date Sun Feb 20 18:25:47 2011 +0100 (2011-02-20)
parents 14d4617ed3d2
children 30fbac111125
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=$repack_src TARBALL=$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=$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=$PACKAGE WANTED=$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=$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 "Generating 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
1846 report end-step
1847 [ -s $tmp/cooklist ] || return
1849 report step "Sorting cooklist"
1850 for PACKAGE in $(cat $tmp/cooklist); do
1851 WANTED="$(look_for_wanted)"
1852 [ "$WANTED" ] || continue
1853 if grep -q ^$WANTED$ $PACKAGES_REPOSITORY/broken $tmp/cooklist; then
1854 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1855 elif [ ! -d $WOK/$WANTED/install ]; then
1856 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1857 echo $WANTED >> $tmp/cooklist
1858 fi
1859 done
1861 # Use cookorder.txt to sort cooklist.
1862 if [ -s $tmp/cooklist ]; then
1863 cat $PACKAGES_REPOSITORY/cookorder.txt | while read PACKAGE; do
1864 if grep -q ^$PACKAGE$ $tmp/cooklist; then
1865 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1866 echo $PACKAGE >> $tmp/cooklist.tmp
1867 fi
1868 done
1870 # Remaining packages in cooklist are thoses without compile_rules.
1871 # They can be cooked first in any order.
1872 if [ -f $tmp/cooklist.tmp ]; then
1873 cat $tmp/cooklist.tmp >> $tmp/cooklist
1874 rm $tmp/cooklist.tmp
1875 fi
1877 cat $tmp/cooklist
1878 [ "$cooklist" = "$PACKAGES_REPOSITORY/cooklist" ] && \
1879 cat $tmp/cooklist > $cooklist
1880 fi
1882 report end-step
1885 look_for_missing_pkg()
1887 for pkg in $(cat $PACKAGES_REPOSITORY/$1); do
1888 grep -q ^$pkg$ $INCOMING_REPOSITORY/packages.txt \
1889 $PACKAGES_REPOSITORY/packages.txt || \
1890 continue
1891 echo $pkg
1892 done
1895 check_for_incoming()
1897 report step "Check that all packages were cooked fine"
1898 [ -s $INCOMING_REPOSITORY/packages.desc ] || {
1899 echo "No packages in $INCOMING_REPOSITORY."
1900 report end-step; return; }
1901 if [ -s $PACKAGES_REPOSITORY/broken ]; then
1902 missingpkg=$(look_for_missing_pkg broken)
1903 if [ "$missingpkg" ]; then
1904 echo "Don't move incoming packages to main repository because theses ones are broken:" >&2
1905 echo "$missingpkg"
1906 report end-step
1907 return 1
1908 fi
1909 fi
1910 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
1911 missingpkg=$(look_for_missing_pkg cooklist)
1912 if [ "$missingpkg" ]; then
1913 echo "Don't move incoming packages to main repository because theses ones needs to be cooked:" >&2
1914 echo "$missingpkg"
1915 report end-step
1916 return 1
1917 fi
1918 fi
1919 incoming_pkgs="$(cut -f 1 -d '|' $INCOMING_REPOSITORY/packages.desc)"
1920 if ! [ "$forced" ]; then
1921 cooklist=$PACKAGES_REPOSITORY/cooklist
1922 pkg="$incoming_pkgs"
1923 gen_cook_list
1924 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
1925 missingpkg=$(look_for_missing_pkg cooklist)
1926 if [ "$missingpkg" ]; then
1927 echo "Don't move incoming packages to main repository because theses ones needs to be cooked:" >&2
1928 echo "$missingpkg"
1929 report end-step
1930 return 1
1931 fi
1932 fi
1933 fi
1935 report step "Moving incoming packages to main repository"
1936 unset EXTRAVERSION
1937 for PACKAGE in $incoming_pkgs; do
1938 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
1939 VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
1940 remove_previous_package $PACKAGES_REPOSITORY
1941 echo "Moving $PACKAGE..."
1942 mv -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION.tazpkg $PACKAGES_REPOSITORY
1943 touch $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
1944 previous_tarball=$(grep ^$PACKAGE:main $SOURCES_REPOSITORY/sources.list | cut -f2)
1945 sed -e "/^$PACKAGE:main/d" \
1946 -e "s/^$PACKAGE:incoming/$PACKAGE:main/" \
1947 -i $SOURCES_REPOSITORY/sources.list
1948 if [ "$previous_tarball" ]; then
1949 grep -q $'\t'$previous_tarball$ $SOURCES_REPOSITORY/sources.list || \
1950 rm -f $SOURCES_REPOSITORY/$previous_tarball
1951 fi
1952 done
1953 for file in packages.list packages.equiv packages.md5 packages.desc \
1954 packages.txt; do
1955 echo -n "" > $INCOMING_REPOSITORY/$file
1956 done
1957 rm -r $INCOMING_REPOSITORY/files.list.lzma
1958 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
1960 report step "Updating flavors"
1961 if [ -x /usr/bin/tazlito ] || [ -x /usr/bin/clean-chroot ]; then
1962 if ! [ -x /usr/bin/tazlito ]; then
1963 tazpkg get-install tazlito
1964 fi
1966 # Handle cases where tazwok is used into main system;
1967 # Handle cases where SLITAZ_DIR is not /home/slitaz.
1968 [ -L /home/slitaz/flavors ] && rm /home/slitaz/flavors
1969 mkdir -p /home/slitaz
1970 ln -s $LOCAL_REPOSITORY/flavors /home/slitaz/flavors
1972 cd $LOCAL_REPOSITORY/packages
1973 for i in $LOCAL_REPOSITORY/flavors/*; do
1974 [ -d "$i" ] || continue
1975 tazlito pack-flavor ${i##*/}
1976 done
1978 noheader=""
1979 for i in *.flavor; do
1980 tazlito show-flavor $i --brief $noheader
1981 noheader="--noheader"
1982 done > flavors.list
1983 [ -x /usr/bin/clean-chroot ] && clean-chroot
1984 else
1985 echo "Can't create up-to-date flavors because tazlito package is missing." >&2
1986 fi
1987 report end-step
1990 ########################################################################
1991 # TAZWOK MAIN FUNCTIONS
1992 ########################
1994 clean()
1996 cd $WOK/$PACKAGE
1997 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
1998 -e ^stuff$ || return
2000 [ "$COMMAND" = clean-wok ] || report step "Cleaning $PACKAGE"
2001 # Check for clean_wok function.
2002 if grep -q ^clean_wok $RECEIPT; then
2003 clean_wok
2004 fi
2005 # Clean should only have a receipt, stuff and optional desc.
2006 for f in `ls .`
2007 do
2008 case $f in
2009 receipt|stuff|description.txt|md5)
2010 continue ;;
2011 *)
2012 rm -rf $f ;;
2013 esac
2014 done
2015 [ "$COMMAND" != clean-wok ] && report end-step
2018 # Configure and make a package with the receipt.
2019 compile_package()
2021 check_for_package_on_cmdline
2023 # Include the receipt to get all needed variables and functions
2024 # and cd into the work directory to start the work.
2025 check_for_receipt
2026 source_receipt
2028 # Log the package name and date.
2029 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
2030 echo "package $PACKAGE (compile)" >> $LOG
2032 # Set wanted $src variable to help compiling.
2033 [ ! "$src" ] && set_src_path
2034 check_for_build_depends || return 1
2035 check_for_wanted
2036 unset target
2037 check_for_tarball && check_for_compile_rules
2040 # Cook command also include all features to manage lists which keep
2041 # track of wok/packages state.
2042 cook()
2044 cook_code=
2045 set_common_path
2046 check_for_receipt
2047 source_receipt
2049 # Define log path and start report.
2050 [ -f $LOCAL_REPOSITORY/log/$PACKAGE.html ] && rm $LOCAL_REPOSITORY/log/$PACKAGE.html
2051 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
2052 report step "Cooking $PACKAGE"
2053 report open-bloc
2055 clean $PACKAGE
2056 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
2058 if compile_package; then
2059 remove_src
2060 refresh_packages_from_compile
2061 gen_package
2063 # Update packages-incoming repository.
2064 store_pkgname=$PACKAGE
2065 pkg_repository=$INCOMING_REPOSITORY
2066 update_packages_db
2068 PACKAGE=$store_pkgname
2069 unset store_pkgname
2071 # Upgrade to cooked packages if it was previously installed.
2072 report step "Look for package(s) to upgrade"
2073 for pkg in $(look_for_rwanted) $PACKAGE; do
2074 if [ -d $INSTALLED/$pkg ]; then
2075 tazpkg get-install $pkg --forced
2076 fi
2077 done
2078 report end-step
2079 else
2081 # Set package as broken.
2082 if ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then
2083 echo $PACKAGE >> $PACKAGES_REPOSITORY/broken
2084 fi
2085 gen_cookmd5
2086 cook_code=1
2087 fi
2089 # Remove build_depends in cook mode (if in cooklist, it's done when
2090 # checking build_depends of next package and we remove only unneeded
2091 # packages to keep chroot minimal and gain some time).
2092 if [ "$COMMAND" = cook ]; then
2093 remove_build_depends $MISSING_PACKAGE
2094 [ -x /usr/bin/clean-chroot ] && clean-chroot
2095 fi
2097 # Regen the cooklist if it was planned and command is not cook.
2098 [ "$regen_cooklist" ] && unset regen_cooklist && \
2099 [ "$COMMAND" != cook ] && sort_cooklist
2101 # Some hacks to set the bloc & function status as failed if cook was
2102 # failed.
2103 report_return_code=$cook_code
2104 report close-bloc
2105 report end-sublog
2106 return $cook_code
2109 cook_list()
2111 if [ -s $tmp/cooklist ]; then
2112 if [ -f /usr/bin/tazchroot ]; then
2113 # Note : options -main variables- are automatically keeped by
2114 # the sub-applications tazchroot/tazwok; as well as report data.
2115 cd $LOCAL_REPOSITORY
2116 [ ! -f tazchroot.conf ] && configure_tazchroot
2117 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
2118 return
2119 fi
2120 while [ -s $tmp/cooklist ]; do
2121 PACKAGE=$(sed 1!d $tmp/cooklist)
2122 cook
2123 done
2124 remove_build_depends $MISSING_PACKAGE $remove_later
2125 [ -x /usr/bin/clean-chroot ] && clean-chroot
2126 else
2127 echo "Nothing to cook."
2128 return
2129 fi
2132 configure_tazchroot()
2134 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
2135 # Tazchroot configuration file - created by tazwok.
2137 # Default chroot path
2138 SLITAZ_DIR=$SLITAZ_DIR
2139 SLITAZ_VERSION=$SLITAZ_VERSION
2140 $( [ "$undigest" ] && echo "undigest=$undigest" )
2141 LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
2142 chroot_dir=\$LOCAL_REPOSITORY/chroot
2144 # Default scripts path (theses scripts are added in the
2145 # $chroot_dir/usr/bin and can be called with tazchroot script)
2146 script_dir=/usr/lib/slitaz/chroot-scripts/tazwok
2148 # List of directories to mount.
2149 list_dir="$(for dir in packages wok src packages-incoming log flavors iso clean-wok; do echo $LOCAL_REPOSITORY/$dir; done)
2150 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
2152 create_chroot()
2154 mkdir -p \$chroot_dir
2155 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
2156 tazpkg get-install \$pkg --root="\$chroot_dir"
2157 done
2159 # Store list of installed packages needed by cleanchroot.
2160 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
2162 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
2163 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
2164 -i \$chroot_dir/etc/slitaz/slitaz.conf
2165 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
2166 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
2169 mount_chroot()
2171 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
2172 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCALSTATE/mirror
2173 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
2174 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
2175 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION
2176 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror' )
2177 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
2178 mount -t proc proc \$chroot_dir/proc
2179 mount -t sysfs sysfs \$chroot_dir/sys
2180 mount -t devpts devpts \$chroot_dir/dev/pts
2181 mount -t tmpfs shm \$chroot_dir/dev/shm
2182 for dir in \$list_dir; do
2183 mkdir -p \$dir \$chroot_dir\$dir
2184 mount \$dir \$chroot_dir\$dir
2185 done
2188 umount_chroot()
2190 for dir in \$list_dir; do
2191 umount \$chroot_dir\$dir
2192 done
2193 umount \$chroot_dir/dev/shm
2194 umount \$chroot_dir/dev/pts
2195 umount \$chroot_dir/sys
2196 umount \$chroot_dir/proc
2198 EOF
2201 ########################################################################
2202 ######################### END OF NEW FUNCTIONS #########################
2203 ########################################################################
2205 # List packages providing a virtual package
2206 whoprovide()
2208 local i;
2209 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
2210 . $i
2211 case " $PROVIDE " in
2212 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
2213 esac
2214 done
2217 ########################################################################
2218 # TAZWOK COMMANDS
2219 ########################
2221 case "$COMMAND" in
2222 stats)
2223 # Tazwok general statistics from the wok config file.
2225 get_tazwok_config
2226 echo -e "\n\033[1mTazwok configuration statistics\033[0m
2227 ================================================================================
2228 Wok directory : $WOK
2229 Packages repository : $PACKAGES_REPOSITORY
2230 Incoming repository : $INCOMING_REPOSITORY
2231 Sources repository : $SOURCES_REPOSITORY
2232 Log directory : $LOCAL_REPOSITORY/log
2233 Packages in the wok : `ls -1 $WOK | wc -l`
2234 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2235 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2236 ================================================================================\n"
2237 ;;
2238 edit)
2239 get_tazwok_config
2240 check_for_package_on_cmdline
2241 check_for_receipt
2242 $EDITOR $WOK/$PACKAGE/receipt
2243 ;;
2244 build-depends)
2245 # List dependencies to rebuild wok, or only a package
2246 get_tazwok_config
2247 report(){ : ; }
2248 if [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
2249 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
2250 --look_for=dep --with_dev --with_args
2251 else
2252 check_for_package_on_cmdline
2253 scan $PACKAGE --look_for=bdep --with_dev
2254 fi
2255 ;;
2256 gen-cooklist)
2257 check_root
2258 get_options_list="pkg"
2259 get_tazwok_config
2260 report(){ : ; }
2261 if ! [ "$pkg" ]; then
2262 if [ ! "$LIST" ] || [ "$LIST" = toolchain ]; then
2263 pkg="$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA"
2264 else
2265 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2266 fi
2267 fi
2268 gen_cook_list
2269 ;;
2270 check-depends)
2271 # Check package depends /!\
2272 get_tazwok_config
2273 echo ""
2274 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
2275 ================================================================================"
2276 TMPDIR=/tmp/tazwok$$
2277 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
2279 # Build ALL_DEPENDS variable
2280 scan_dep()
2282 local i
2283 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
2284 for i in $DEPENDS $SUGGESTED ; do
2285 case " $ALL_DEPENDS " in
2286 *\ $i\ *) continue;;
2287 esac
2288 [ -d $WOK/$i ] || {
2289 ALL_DEPENDS="$ALL_DEPENDS$i "
2290 continue
2292 DEPENDS=""
2293 SUGGESTED=""
2294 . $WOK/$i/receipt
2295 scan_dep
2296 done
2299 # Check for ELF file
2300 is_elf()
2302 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ]
2305 # Print shared library dependencies
2306 ldd()
2308 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
2311 mkdir $TMPDIR
2312 cd $TMPDIR
2313 for i in $LOCALSTATE/files.list.lzma \
2314 $LOCALSTATE/undigest/*/files.list.lzma ; do
2315 [ -f $i ] && lzma d $i -so >> files.list
2316 done
2317 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
2318 tazpkg extract $pkg > /dev/null 2>&1
2319 . */receipt
2320 ALL_DEPENDS="$DEFAULT_DEPENDS "
2321 scan_dep
2322 find */fs -type f | while read file ; do
2323 is_elf $file || continue
2324 case "$file" in
2325 *.o|*.ko|*.ko.gz) continue;;
2326 esac
2327 ldd $file | while read lib rem; do
2328 case "$lib" in
2329 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
2330 continue;;
2331 esac
2332 for dep in $(fgrep $lib files.list | cut -d: -f1); do
2333 case " $ALL_DEPENDS " in
2334 *\ $dep\ *) continue 2;;
2335 esac
2336 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
2337 case " $ALL_DEPENDS " in
2338 *\ $vdep\ *) continue 3;;
2339 esac
2340 done
2341 done
2342 [ -n "$dep" ] || dep="UNKNOWN"
2343 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
2344 done
2345 done
2346 rm -rf */
2347 done
2348 cd /tmp
2349 rm -rf $TMPDIR
2350 ;;
2351 check)
2352 # Check wok consistency
2353 get_tazwok_config
2354 echo ""
2355 echo -e "\033[1mWok and packages checking\033[0m
2356 ================================================================================"
2357 cd $WOK
2358 for pkg in $(ls)
2359 do
2360 [ -f $pkg/receipt ] || continue
2361 RECEIPT= $pkg/receipt
2362 source_receipt
2363 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
2364 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
2365 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
2366 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
2367 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
2368 if [ -n "$WANTED" ]; then
2369 if [ ! -f $WANTED/receipt ]; then
2370 echo "Package $PACKAGE wants unknown $WANTED package" >&2
2371 else
2372 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
2373 if [ "$VERSION" = "$WANTED" ]; then
2374 # BASEVERSION is computed in receipt
2375 fgrep -q '_pkg=' $pkg/receipt &&
2376 BASEVERSION=$VERSION
2377 fi
2378 if [ "$VERSION" != "$BASEVERSION" ]; then
2379 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
2380 fi
2381 fi
2382 fi
2384 if [ -n "$CATEGORY" ]; then
2385 case " $(echo $CATEGORIES) " in
2386 *\ $CATEGORY\ *);;
2387 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
2388 esac
2389 else
2390 echo"Package $PACKAGE has no CATEGORY" >&2
2391 fi
2392 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
2393 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
2394 case "$WGET_URL" in
2395 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
2396 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
2397 '') ;;
2398 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
2399 esac
2400 case "$WEB_SITE" in
2401 ftp*|http*);;
2402 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
2403 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
2404 esac
2405 case "$MAINTAINER" in
2406 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
2407 esac
2408 case "$MAINTAINER" in
2409 *@*);;
2410 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
2411 esac
2412 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2413 for i in $DEPENDS; do
2414 [ -d $i ] && continue
2415 [ -n "$(whoprovide $i)" ] && continue
2416 echo -e "$MSG $i"
2417 MSG=""
2418 done
2419 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2420 for i in $BUILD_DEPENDS; do
2421 [ -d $i ] && continue
2422 [ -n "$(whoprovide $i)" ] && continue
2423 echo -e "$MSG $i"
2424 MSG=""
2425 done
2426 MSG="Dependencies loop between $PACKAGE and :\n"
2427 ALL_DEPS=""
2428 check_for_deps_loop $PACKAGE $DEPENDS
2429 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
2430 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
2431 echo "$pkg should be rebuilt after $i installation"
2432 done
2433 done
2434 ;;
2435 list)
2436 # List packages in wok directory. User can specify a category.
2438 get_tazwok_config
2439 if [ "$2" = "category" ]; then
2440 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
2441 exit 0
2442 fi
2443 # Check for an asked category.
2444 if [ -n "$2" ]; then
2445 ASKED_CATEGORY=$2
2446 echo ""
2447 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
2448 echo "================================================================================"
2449 for pkg in $WOK/*
2450 do
2451 [ ! -f $pkg/receipt ] && continue
2452 . $pkg/receipt
2453 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
2454 echo -n "$PACKAGE"
2455 echo -e "\033[28G $VERSION"
2456 packages=$(($packages+1))
2457 fi
2458 done
2459 echo "================================================================================"
2460 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
2461 else
2462 # By default list all packages and version.
2463 echo ""
2464 echo -e "\033[1mList of packages in the wok\033[0m"
2465 echo "================================================================================"
2466 for pkg in $WOK/*
2467 do
2468 [ ! -f $pkg/receipt ] && continue
2469 . $pkg/receipt
2470 echo -n "$PACKAGE"
2471 echo -en "\033[28G $VERSION"
2472 echo -e "\033[42G $CATEGORY"
2473 packages=$(($packages+1))
2474 done
2475 echo "================================================================================"
2476 echo -e "$packages packages available in the wok.\n"
2477 fi
2478 ;;
2479 info)
2480 # Information about a package.
2482 get_tazwok_config
2483 check_for_package_on_cmdline
2484 check_for_receipt
2485 . $WOK/$PACKAGE/receipt
2486 echo ""
2487 echo -e "\033[1mTazwok package information\033[0m
2488 ================================================================================
2489 Package : $PACKAGE
2490 Version : $VERSION
2491 Category : $CATEGORY
2492 Short desc : $SHORT_DESC
2493 Maintainer : $MAINTAINER"
2494 if [ ! "$WEB_SITE" = "" ]; then
2495 echo "Web site : $WEB_SITE"
2496 fi
2497 if [ ! "$DEPENDS" = "" ]; then
2498 echo "Depends : $DEPENDS"
2499 fi
2500 if [ ! "$WANTED" = "" ]; then
2501 echo "Wanted src : $WANTED"
2502 fi
2503 echo "================================================================================"
2504 echo ""
2505 ;;
2506 check-log)
2507 # We just cat the file log to view process info.
2509 get_tazwok_config
2510 if [ ! -f "$LOG" ]; then
2511 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
2512 exit 1
2513 else
2514 echo ""
2515 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
2516 echo "================================================================================"
2517 cat $LOG
2518 echo "================================================================================"
2519 echo ""
2520 if [ -s "$WOK/$PACKAGE/warning.txt" ]; then
2521 echo -e "\033[1mCook warning(s) for :\033[0m $PACKAGE"
2522 echo "================================================================================"
2523 cat "$WOK/$PACKAGE/warning.txt"
2524 echo "================================================================================"
2525 echo ""
2526 fi
2527 fi
2528 ;;
2529 search)
2530 # Search for a package by pattern or name.
2532 get_tazwok_config
2533 if [ -z "$2" ]; then
2534 echo -e "\nPlease specify a pattern or a package name to search." >&2
2535 echo -e "Example : 'tazwok search gcc'.\n" >&2
2536 exit 1
2537 fi
2538 echo ""
2539 echo -e "\033[1mSearch result for :\033[0m $2"
2540 echo "================================================================================"
2541 list=`ls -1 $WOK | fgrep $2`
2542 for pkg in $list
2543 do
2544 . $WOK/$pkg/receipt
2545 echo -n "$PACKAGE "
2546 echo -en "\033[24G $VERSION"
2547 echo -e "\033[42G $CATEGORY"
2548 packages=$(($PACKAGEs+1))
2549 done
2550 echo "================================================================================"
2551 echo "$packages packages found for : $2"
2552 echo ""
2553 ;;
2554 compile)
2555 # Configure and make a package with the receipt.
2557 get_tazwok_config
2558 source_lib report
2559 report start
2560 compile_package
2561 ;;
2562 genpkg)
2563 # Generate a package.
2565 get_tazwok_config
2566 source_lib report
2567 report start
2568 gen_package
2569 ;;
2570 cook)
2571 # Compile and generate a package. Just execute tazwok with
2572 # the good commands.
2574 check_root
2575 get_tazwok_config
2576 source_lib report
2577 report start
2578 update_wan_db
2579 check_for_commit
2580 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
2581 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
2582 if [ "$plan_regen_cookorder" ]; then
2583 grep -q "^#" $PACKAGES_REPOSITORY/cookorder.txt || \
2584 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
2585 fi
2586 cook
2587 ;;
2588 sort-cooklist)
2589 if [ ! -f "$LIST" ]; then
2590 echo "Usage : tazwok sort-cooklist cooklist" >&2
2591 exit 1
2592 fi
2593 check_root
2594 get_tazwok_config
2595 report(){ : ; }
2596 # When using sort-cooklist, the script should behave as for gen-cooklist
2597 # The only difference between theses two is where the output is sended.
2598 COMMAND=gen-cooklist
2599 cooklist=$LIST
2600 gen_cook_list
2601 cp -af $tmp/cooklist $cooklist
2602 ;;
2603 cook-list)
2604 # Cook all packages listed in a file or in default cooklist.
2605 check_root
2606 get_options_list="pkg forced"
2607 get_tazwok_config
2608 source_lib report
2609 report start
2610 if ! [ "$pkg" ]; then
2611 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2612 fi
2613 gen_cook_list
2614 cook_list
2615 ;;
2616 clean)
2617 # Clean up a package work directory + thoses which want it.
2619 get_tazwok_config
2620 check_for_package_on_cmdline
2621 check_for_receipt
2622 source_lib report
2623 report start
2624 . $RECEIPT
2625 clean
2626 ;;
2627 gen-clean-wok)
2628 # Generate a clean wok from the current wok by copying all receipts
2629 # and stuff directory.
2631 get_tazwok_config
2632 source_lib report
2633 report start
2634 if [ -z "$ARG" ]; then
2635 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
2636 exit 1
2637 else
2638 dest=$ARG
2639 mkdir -p $dest
2640 fi
2641 report step "Creating clean wok in : $dest"
2642 for pkg in `ls -1 $WOK`
2643 do
2644 mkdir -p $dest/$pkg
2645 cp -a $WOK/$pkg/receipt $dest/$pkg
2646 [ -f $WOK/$pkg/description.txt ] && \
2647 cp -a $WOK/$pkg/description.txt $dest/$pkg
2648 if [ -d "$WOK/$pkg/stuff" ]; then
2649 cp -a $WOK/$pkg/stuff $dest/$pkg
2650 fi
2651 done
2652 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
2653 report end-step
2654 echo "Packages cleaned : `ls -1 $dest | wc -l`"
2655 echo ""
2656 ;;
2657 clean-wok)
2658 # Clean all packages in the work directory
2660 get_tazwok_config
2661 source_lib report
2662 report start
2663 report step "Cleaning wok"
2664 for PACKAGE in `ls -1 $WOK`
2665 do
2666 set_common_path
2667 source_receipt
2668 clean
2669 done
2670 echo "`ls -1 $WOK | wc -l` packages cleaned."
2671 ;;
2672 clean-src)
2673 # Remove tarball unrelated to wok receipts from src repo.
2674 check_root
2675 get_options_list="forced"
2676 get_tazwok_config
2677 cd $SOURCES_REPOSITORY
2678 echo -n "Checking $SOURCES_REPOSITORY..."
2679 for TARBALL in *; do
2680 [ "$TARBALL" = sources.list ] && continue
2681 grep -q $'\t'$TARBALL$ $SOURCES_REPOSITORY/sources.list || \
2682 echo $TARBALL >> $tmp/obsolete
2683 done
2684 status
2685 if ! [ -f $tmp/obsolete ]; then
2686 echo "No sources need to be removed."
2687 exit 1
2688 fi
2689 echo ""
2690 echo -e "\033[1mObsolete/unrelated-to-wok sourcess :\033[0m"
2691 horizontal_line
2692 cat $tmp/obsolete
2693 horizontal_line
2694 echo "$(wc -l $tmp/obsolete | cut -f1 -d' ') tarballs to remove."
2695 echo ""
2696 echo -n "Please confirm removing (type uppercase YES): "
2697 read answer
2698 if [ "$answer" = YES ]; then
2699 echo -n "Removing old sources..."
2700 cat $tmp/obsolete | while read i; do
2701 rm -f $SOURCES_REPOSITORY/$i
2702 done
2703 status
2704 fi
2705 ;;
2706 gen-list)
2707 get_tazwok_config
2708 if [ "$2" ]; then
2709 if [ -d "$2" ]; then
2710 pkg_repository=$2
2711 else
2712 echo -e "\nUnable to find directory : $2\n" >&2
2713 exit 1
2714 fi
2715 fi
2717 source_lib report
2718 report start
2719 if [ "$pkg_repository" ]; then
2720 gen_packages_db
2721 else
2722 pkg_repository=$PACKAGES_REPOSITORY && gen_packages_db
2723 pkg_repository=$INCOMING_REPOSITORY && gen_packages_db
2724 fi
2725 ;;
2726 check-list)
2727 # The directory to move into by default is the repository,
2728 # if $2 is not empty cd into $2.
2730 get_tazwok_config
2731 if [ "$2" ]; then
2732 if [ -d "$2" ]; then
2733 pkg_repository=$2
2734 else
2735 echo -e "\nUnable to find directory : $2\n" >&2
2736 exit 1
2737 fi
2738 fi
2740 source_lib report
2741 report start
2742 if [ "$pkg_repository" ]; then
2743 update_packages_db
2744 else
2745 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
2746 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
2747 fi
2748 ;;
2749 new-tree)
2750 # Just create a few directories and generate an empty receipt to prepare
2751 # the creation of a new package.
2753 get_tazwok_config
2754 check_for_package_on_cmdline
2755 if [ -d $WOK/$PACKAGE ]; then
2756 echo -e "\n$PACKAGE package tree already exists.\n" >&2
2757 exit 1
2758 fi
2759 echo "Creating : $WOK/$PACKAGE"
2760 mkdir $WOK/$PACKAGE
2761 cd $WOK/$PACKAGE
2762 echo -n "Preparing the receipt..."
2764 # Default receipt begin.
2766 echo "# SliTaz package receipt." > receipt
2767 echo "" >> receipt
2768 echo "PACKAGE=\"$PACKAGE\"" >> receipt
2769 # Finish the empty receipt.
2770 cat >> receipt << "EOF"
2771 VERSION=""
2772 CATEGORY=""
2773 SHORT_DESC=""
2774 MAINTAINER=""
2775 DEPENDS=""
2776 TARBALL="$PACKAGE-$VERSION.tar.gz"
2777 WEB_SITE=""
2778 WGET_URL=""
2780 # Rules to configure and make the package.
2781 compile_rules()
2783 cd $src
2784 ./configure && make && make install
2787 # Rules to gen a SliTaz package suitable for Tazpkg.
2788 genpkg_rules()
2790 mkdir -p $fs/usr
2791 cp -a $_pkg/usr/bin $fs/usr
2794 EOF
2796 # Default receipt end.
2798 status
2799 # Interactive mode, asking and seding.
2800 if [ "$3" = "--interactive" ]; then
2801 echo "Entering into interactive mode..."
2802 echo "================================================================================"
2803 echo "Package : $PACKAGE"
2804 # Version.
2805 echo -n "Version : " ; read anser
2806 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
2807 # Category.
2808 echo -n "Category : " ; read anser
2809 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
2810 # Short description.
2811 echo -n "Short desc : " ; read anser
2812 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
2813 # Maintainer.
2814 echo -n "Maintainer : " ; read anser
2815 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
2816 # Web site.
2817 echo -n "Web site : " ; read anser
2818 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
2819 echo ""
2820 # Wget URL.
2821 echo "Wget URL to download source tarball."
2822 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
2823 echo -n "Wget url : " ; read anser
2824 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
2825 # Ask for a stuff dir.
2826 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
2827 if [ "$anser" = "y" ]; then
2828 echo -n "Creating the stuff directory..."
2829 mkdir stuff && status
2830 fi
2831 # Ask for a description file.
2832 echo -n "Are you going to write a description ? (y/N) : " ; read anser
2833 if [ "$anser" = "y" ]; then
2834 echo -n "Creating the description.txt file..."
2835 echo "" > description.txt && status
2836 fi
2837 echo "================================================================================"
2838 echo ""
2839 fi
2840 ;;
2841 remove)
2842 # Remove a package from the wok.
2844 get_tazwok_config
2845 check_for_package_on_cmdline
2846 echo ""
2847 echo -n "Please confirm deletion (y/N) : "; read anser
2848 if [ "$anser" = "y" ]; then
2849 echo -n "Removing $PACKAGE..."
2850 rm -rf $WOK/$PACKAGE && status
2851 echo ""
2852 fi
2853 ;;
2854 update-wok)
2855 # Pull and update a Hg wok.
2856 get_options_list="local"
2857 get_tazwok_config
2858 source_lib report
2859 report start
2860 clean_wok=$LOCAL_REPOSITORY/clean-wok
2861 cd $clean_wok
2862 if ! [ "$local" ]; then
2863 if [ "$WOK_UPDATE_METHOD" = hg ]; then
2864 if ! [ -f "$INSTALLED/mercurial/receipt" ]; then
2866 # Auto-install only if we are in a cook chroot.
2867 if [ -x /usr/bin/clean-chroot ]; then
2868 echo "" >&2
2869 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 -s >&2
2870 echo "">&2
2871 exit 1
2872 else
2873 tazpkg get-install mercurial
2874 fi
2875 fi
2877 report step "Getting wok changes using hg"
2878 if [ -d .hg ]; then
2879 hg pull -u || exit 1
2880 else
2881 hg clone $HG_WOK . || exit 1
2882 fi
2883 report end-step
2884 [ -x /usr/bin/clean-chroot ] && clean-chroot
2885 else
2886 report step "Getting wok changes using tarball"
2887 { mkdir .tmp && cd .tmp
2888 wget "$TARBALL_WOK" &&
2889 case $TARBALL_WOK in
2890 *bz2) tar xjf *.bz2 -C wok; rm *.bz2;;
2891 *lzma) unlzma -c *.lzma | tar xf - -C wok; rm *.lzma ;;
2892 *gz) tar xzf *.gz -C wok; rm*.gz ;;
2893 esac &&
2894 rm -r $(ls -d $clean_wok/*) &&
2895 cp -a wok/* $clean_wok &&
2896 cd .. &&
2897 rm -r .tmp
2898 } || { echo "That's not cool: it fails!" >&2
2899 report end-step
2900 exit 1; }
2901 report end-step
2902 fi
2903 fi
2904 report step "Appending changes to wok"
2906 # Handle removed files/dir.
2907 cd $WOK
2908 for dir in *; do
2909 [ -d "$clean_wok/$dir" ] || rm -rf $dir
2910 done
2911 for file in */receipt */description.txt; do
2912 [ -f "$clean_wok/$file" ] || rm -rf $file
2913 done
2914 for i in $(find */stuff 2>/dev/null); do
2915 [ -e "$clean_wok/$i" ] || rm -rf $i
2916 done
2918 cp -a $clean_wok/* $WOK
2919 report end-step
2920 ;;
2921 maintainers)
2922 get_tazwok_config
2923 echo ""
2924 echo "List of maintainers for: $WOK"
2925 echo "================================================================================"
2926 touch /tmp/slitaz-maintainers
2927 for pkg in $WOK/*
2928 do
2929 . $pkg/receipt
2930 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
2931 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
2932 echo "$MAINTAINER"
2933 fi
2934 done
2935 echo "================================================================================"
2936 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
2937 echo ""
2938 # Remove tmp files
2939 rm -f /tmp/slitaz-maintainers
2940 ;;
2941 maintained-by)
2942 # Search for packages maintained by a contributor.
2943 get_tazwok_config
2944 if [ ! -n "$2" ]; then
2945 echo "Specify a name or email of a maintainer." >&2
2946 exit 1
2947 fi
2948 echo "Maintainer packages"
2949 echo "================================================================================"
2950 for pkg in $WOK/*
2951 do
2952 . $pkg/receipt
2953 if echo "$MAINTAINER" | fgrep -q "$2"; then
2954 echo "$PACKAGE"
2955 packages=$(($PACKAGEs+1))
2956 fi
2957 done
2958 echo "================================================================================"
2959 echo "Packages maintained by $2: $PACKAGEs"
2960 echo ""
2961 ;;
2962 tags)
2963 get_tazwok_config
2964 echo -e "\n\033[1mTags list :\033[0m"
2965 horizontal_line
2966 cd $WOK
2967 for i in */receipt; do
2968 unset TAGS
2969 source $i
2970 for t in $TAGS; do
2971 grep -q ^$t$ $tmp/tags && continue
2972 echo $t | tee -a $tmp/tags
2973 done
2974 done
2975 horizontal_line
2976 echo "$(wc -l $tmp/tags | cut -f1 -d ' ') tags listed."
2977 ;;
2978 check-src)
2979 # Verify if upstream package is still available
2981 get_tazwok_config
2982 check_for_package_on_cmdline
2983 check_for_receipt
2984 source_receipt
2985 check_src()
2987 for url in $@; do
2988 busybox wget -s $url 2>/dev/null && break
2989 done
2991 if [ "$WGET_URL" ];then
2992 echo -n "$PACKAGE : "
2993 check_src $WGET_URL
2994 status
2995 else
2996 echo "No tarball to check for $PACKAGE"
2997 fi
2998 ;;
2999 get-src)
3000 check_root
3001 get_options_list="target nounpack"
3002 get_tazwok_config
3003 check_for_package_on_cmdline
3004 check_for_receipt
3005 source_receipt
3006 if [ "$WGET_URL" ];then
3007 source_lib report
3008 report start
3009 check_for_tarball
3010 else
3011 echo "No tarball to download for $PACKAGE"
3012 fi
3013 ;;
3014 check-commit)
3015 check_root
3016 get_options_list="missing forced"
3017 get_tazwok_config
3018 source_lib report
3019 report start
3020 if [ "$forced" ]; then
3021 rm -f $WOK/*/md5
3022 unset forced
3023 fi
3024 if [ "$missing" ]; then
3025 pkg=$(ls -1 $WOK)
3026 else
3027 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3028 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3029 } | sort -u)"
3030 fi
3031 cooklist=$PACKAGES_REPOSITORY/cooklist
3032 gen_cook_list
3033 ;;
3034 cook-commit)
3035 check_root
3036 get_options_list="missing forced"
3037 get_tazwok_config
3038 source_lib report
3039 report start
3040 if [ "$forced" ]; then
3041 rm -f $WOK/*/md5
3042 unset forced
3043 fi
3044 if [ "$missing" ]; then
3045 pkg=$(ls -1 $WOK)
3046 else
3047 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3048 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3049 } | sort -u)"
3050 fi
3051 cooklist=$PACKAGES_REPOSITORY/cooklist
3052 gen_cook_list
3053 cook_list
3054 ;;
3055 cook-all)
3056 check_root
3057 get_options_list="forced missing"
3058 get_tazwok_config
3059 source_lib report
3060 report start
3061 if [ "$missing" ]; then
3062 pkg=$(ls -1 $WOK)
3063 else
3064 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3065 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3066 } | sort -u)"
3067 fi
3068 cooklist=$PACKAGES_REPOSITORY/cooklist
3069 gen_cook_list
3070 cook_list
3071 ;;
3072 gen-wok-db)
3073 check_root
3074 get_tazwok_config
3075 source_lib report
3076 report start
3077 gen_wok_db
3078 ;;
3079 report)
3080 get_tazwok_config
3081 cd $PACKAGES_REPOSITORY
3082 if [ "$2" ]; then
3083 case $2 in
3084 commit|cooklist|incoming|broken|blocked)
3085 show="$2"
3086 ;;
3087 *)
3088 echo "usage : tazwok report [commit|cooklist|incoming|broken|blocked]" >&2
3089 exit 1
3090 ;;
3091 esac
3092 else
3093 show="commit cooklist incoming broken blocked"
3094 fi
3095 for i in $show; do
3096 if [ -s $i ]; then
3097 echo ""
3098 echo -e "\033[1m$i\033[0m"
3099 echo "================================================================================"
3100 cat $i
3101 echo "================================================================================"
3102 echo ""
3103 fi
3104 done
3105 ;;
3106 check-incoming)
3107 check_root
3108 get_options_list="forced"
3109 get_tazwok_config
3110 source_lib report
3111 report start
3112 [ -f $LOCAL_RESOSITORY/incoming ] && rm [ -f $LOCAL_REPOSITORY/incoming ]
3113 report step "Checking $INCOMING_REPOSITORY"
3114 report open-bloc
3115 [ -f $LOCAL_REPOSITORY/log/incoming.html ] && rm $LOCAL_REPOSITORY/log/incoming.html
3116 report sublog $LOCAL_REPOSITORY/log/incoming.html
3117 check_for_incoming
3118 report end-sublog
3119 report close-bloc
3120 ;;
3121 configure-chroot)
3122 check_root
3123 get_tazwok_config
3124 if [ -f /usr/bin/tazchroot ]; then
3125 cd $LOCAL_REPOSITORY
3126 configure_tazchroot
3127 else
3128 echo "The packages tazchroot need to be installed" >&2
3129 exit 1
3130 fi
3131 ;;
3132 chroot)
3133 check_root
3134 get_tazwok_config
3135 # Merge this and the other chroot function ?.
3136 if [ -f /usr/bin/tazchroot ]; then
3137 cd $LOCAL_REPOSITORY
3138 [ ! -f tazchroot.conf ] && configure_tazchroot
3139 tazchroot
3140 else
3141 echo "The packages tazchroot need to be installed" >&2
3142 exit 1
3143 fi
3144 ;;
3145 cook-toolchain)
3146 check_root
3147 get_tazwok_config
3148 echo -n "" > $PACKAGES_REPOSITORY/broken
3149 if [ -f /usr/bin/tazchroot ]; then
3150 cd $LOCAL_REPOSITORY
3151 [ ! -f tazchroot.conf ] && configure_tazchroot
3152 tazchroot cook-toolchain
3153 # Buggy : chroot can be elsewhere.
3154 rm -r $LOCAL_REPOSITORY/chroot
3155 # /!\ to be writed :
3156 # next rm chroot and plan cook-all by pushing all packages
3157 # in cooklist.
3158 else
3159 echo "The packages tazchroot need to be installed" >&2
3160 exit 1
3161 fi
3162 ;;
3163 webserver)
3164 check_root
3165 get_tazwok_config
3166 if [ "$ARG" = on ]; then
3167 if [ "$WEBSERVER" ] && [ -f "$WEBSERVER/repositories.list" ] && \
3168 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3169 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3170 exit 1
3171 fi
3172 if ! [ -f $LOCAL_REPOSITORY/tazchroot.conf ]; then
3173 tazwok configure-chroot ${undigest:+--undigest=$undigest} --SLITAZ_VERSION=$SLITAZ_VERSION --SLITAZ_DIR=$SLITAZ_DIR
3174 fi
3175 for pkg in php lighttpd; do
3176 [ -d $INSTALLED/$pkg ] || missing="$missing $pkg"
3177 done
3178 if [ "$missing" ]; then
3179 echo "You need to install those packages to start webserver: $missing." >&2
3180 exit 1
3181 fi
3182 if [ ! -f "$LOCAL_REPOSITORY/tazwok.conf" ]; then
3183 echo "Copying /etc/slitaz/tazwok.conf to $LOCAL_REPOSITORY/tazwok.conf: webserver is configured repository-by-repository."
3184 cp /etc/slitaz/tazwok.conf $LOCAL_REPOSITORY
3185 fi
3186 if ! [ "$WEBSERVER" ]; then
3187 echo -n "Where to store php pages (default: /var/www/vhosts/bb)? "
3188 read WEBSERVER
3189 [ "$WEBSERVER" ] || WEBSERVER="/var/www/vhosts/bb"
3190 fi
3191 if [ -f "$WEBSERVER/repositories.list" ] && \
3192 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3193 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3194 exit 1
3195 fi
3196 mkdir -p $WEBSERVER
3197 echo "${undigest:-$SLITAZ_VERSION}" >> $WEBSERVER/repositories.list
3198 for file in index.php log.php download.php; do
3199 [ -f "$WEBSERVER/$file" ] || ln -s /usr/share/slitaz/web-bb/$file $WEBSERVER
3200 done
3201 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3202 ln -s $dir $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3203 done
3204 source $LOCAL_REPOSITORY/tazchroot.conf
3205 echo "<?php
3207 // Web interface configuration
3209 \$version=\"${undigest:-$SLITAZ_VERSION}\";
3210 \$chroot=\"$chroot_dir\";
3211 \$lockfile=\"\$chroot/proc/1\";
3212 \$db_dir=\"$PACKAGES_REPOSITORY\";
3213 \$log_dir=\"$LOCAL_REPOSITORY/log\";
3214 \$packages=\"$PACKAGES_REPOSITORY\";
3215 \$incoming=\"$INCOMING_REPOSITORY\";
3216 \$wok=\"$WOK\";
3218 ?>" > $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3219 [ -L "$WEBSERVER/web" ] || ln -s /usr/share/slitaz/web $WEBSERVER
3220 echo "WEBSERVER=\"$WEBSERVER\"" >> $LOCAL_REPOSITORY/tazwok.conf
3221 if [ -L "$WEBSERVER/conf.php" ]; then
3222 echo "Do yo want to make ${undigest:-$SLITAZ_VERSION} the default page (y/N) ? "
3223 read answer
3224 if [ "$answer" = y ]; then
3225 rm $WEBSERVER/conf.php
3226 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3227 fi
3228 else
3229 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3230 fi
3231 elif [ "$ARG" = off ]; then
3232 if ! [ "$WEBSERVER" ]; then
3233 echo "No webserver running for ${undigest:-$SLITAZ_VERSION}" >&2
3234 exit 1
3235 fi
3236 sed '/^WEBSERVER/d' -i $LOCAL_REPOSITORY/tazwok.conf
3237 sed "/^${undigest:-$SLITAZ_VERSION}$/d" -i $WEBSERVER/repositories.list
3238 rm $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3239 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3240 rm $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3241 done
3242 if ! [ -s "$WEBSERVER/repositories.list" ]; then
3243 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"
3244 rm $WEBSERVER/conf.php
3245 elif [ "$(readlink $WEBSERVER/conf.php)" = "$WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php" ]; then
3246 echo "${undigest:-$SLITAZ_VERSION} was the default version to use; switched to : $(sed 1!d $WEBSERVER/repositories.list)"
3247 rm $WEBSERVER/conf.php
3248 ln -s $WEBSERVER/conf-$(sed 1!d $WEBSERVER/repositories.list).php $WEBSERVER/conf.php
3249 fi
3250 else
3251 echo "Usage: tazwok webserver on/off" >&2
3252 exit 1
3253 fi
3254 ;;
3255 usage|*)
3256 # Print usage also for all unknown commands.
3258 usage
3259 ;;
3260 esac
3262 report stop 2>/dev/null
3263 exit 0