tazwok view tazwok @ rev 357

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