tazwok view tazwok @ rev 440

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