tazwok view tazwok @ rev 354

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