tazwok view tazwok @ rev 443

tazwok, configure_tazchroot(): setup chroot'ed /etc/slitaz-release to make tazlito works correctly
author Antoine Bodin <gokhlayeh@slitaz.org>
date Tue Mar 15 00:23:25 2011 +0100 (2011-03-15)
parents d2189908cd1b
children d1f0d5d127a7
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 echo \$SLITAZ_VERSION > \$chroot_dir/etc/slitaz-release
2238 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
2239 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
2240 # The build bot may run in a sandbox: link sandbox lockfile.
2241 ln -s \$LOCAL_REPOSITORY/sandbox/proc/1 \$chroot_dir/proc/1
2244 mount_chroot()
2246 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
2247 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCALSTATE/mirror
2248 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
2249 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
2250 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION
2251 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror' )
2252 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
2253 mount -o bind /proc \$chroot_dir/proc
2254 mount -o bind /sys \$chroot_dir/sys
2255 mount -o bind /dev/pts \$chroot_dir/dev/pts
2256 mount -o bind /dev/shm \$chroot_dir/dev/shm
2257 for dir in \$list_dir; do
2258 mkdir -p \$dir \$chroot_dir\$dir
2259 mount \$dir \$chroot_dir\$dir
2260 done
2263 umount_chroot()
2265 for dir in \$list_dir; do
2266 umount \$chroot_dir\$dir
2267 done
2268 umount \$chroot_dir/dev/shm
2269 umount \$chroot_dir/dev/pts
2270 umount \$chroot_dir/sys
2271 umount \$chroot_dir/proc
2273 EOF
2276 ########################################################################
2277 ######################### END OF NEW FUNCTIONS #########################
2278 ########################################################################
2280 # List packages providing a virtual package.
2281 whoprovide()
2283 local i;
2284 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
2285 . $i
2286 case " $PROVIDE " in
2287 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
2288 esac
2289 done
2292 ########################################################################
2293 # TAZWOK COMMANDS
2294 ########################
2296 case "$COMMAND" in
2297 stats)
2298 # Tazwok general statistics from the wok config file.
2300 get_tazwok_config
2301 echo -e "\n\033[1mTazwok configuration statistics\033[0m
2302 ================================================================================
2303 Wok directory : $WOK
2304 Packages repository : $PACKAGES_REPOSITORY
2305 Incoming repository : $INCOMING_REPOSITORY
2306 Sources repository : $SOURCES_REPOSITORY
2307 Log directory : $LOCAL_REPOSITORY/log
2308 Packages in the wok : `ls -1 $WOK | wc -l`
2309 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2310 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2311 ================================================================================\n"
2312 ;;
2313 edit)
2314 get_tazwok_config
2315 check_for_package_on_cmdline
2316 check_for_receipt
2317 $EDITOR $WOK/$PACKAGE/receipt
2318 ;;
2319 build-depends)
2320 # List dependencies to rebuild wok, or only a package.
2321 get_tazwok_config
2322 report(){ : ; }
2323 if [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
2324 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
2325 --look_for=dep --with_dev --with_args
2326 else
2327 check_for_package_on_cmdline
2328 scan $PACKAGE --look_for=bdep --with_dev
2329 fi
2330 ;;
2331 gen-cooklist)
2332 check_root
2333 get_options_list="pkg"
2334 get_tazwok_config
2335 report(){ : ; }
2336 if ! [ "$pkg" ]; then
2337 if [ ! "$LIST" ] || [ "$LIST" = toolchain ]; then
2338 pkg="$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA"
2339 else
2340 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2341 fi
2342 fi
2343 gen_cook_list
2344 ;;
2345 check-depends)
2346 # Check package depends /!\.
2347 get_tazwok_config
2348 echo ""
2349 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
2350 ================================================================================"
2351 TMPDIR=/tmp/tazwok$$
2352 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
2354 # Build ALL_DEPENDS variable.
2355 scan_dep()
2357 local i
2358 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
2359 for i in $DEPENDS $SUGGESTED ; do
2360 case " $ALL_DEPENDS " in
2361 *\ $i\ *) continue;;
2362 esac
2363 [ -d $WOK/$i ] || {
2364 ALL_DEPENDS="$ALL_DEPENDS$i "
2365 continue
2367 DEPENDS=""
2368 SUGGESTED=""
2369 . $WOK/$i/receipt
2370 scan_dep
2371 done
2374 # Check for ELF file.
2375 is_elf()
2377 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ]
2380 # Print shared library dependencies.
2381 ldd()
2383 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
2386 mkdir $TMPDIR
2387 cd $TMPDIR
2388 for i in $LOCALSTATE/files.list.lzma \
2389 $LOCALSTATE/undigest/*/files.list.lzma ; do
2390 [ -f $i ] && lzma d $i -so >> files.list
2391 done
2392 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
2393 tazpkg extract $pkg > /dev/null 2>&1
2394 . */receipt
2395 ALL_DEPENDS="$DEFAULT_DEPENDS "
2396 scan_dep
2397 find */fs -type f | while read file ; do
2398 is_elf $file || continue
2399 case "$file" in
2400 *.o|*.ko|*.ko.gz) continue;;
2401 esac
2402 ldd $file | while read lib rem; do
2403 case "$lib" in
2404 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
2405 continue;;
2406 esac
2407 for dep in $(fgrep $lib files.list | cut -d: -f1); do
2408 case " $ALL_DEPENDS " in
2409 *\ $dep\ *) continue 2;;
2410 esac
2411 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
2412 case " $ALL_DEPENDS " in
2413 *\ $vdep\ *) continue 3;;
2414 esac
2415 done
2416 done
2417 [ -n "$dep" ] || dep="UNKNOWN"
2418 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
2419 done
2420 done
2421 rm -rf */
2422 done
2423 cd /tmp
2424 rm -rf $TMPDIR
2425 ;;
2426 check)
2427 # Check wok consistency.
2428 get_tazwok_config
2429 echo ""
2430 echo -e "\033[1mWok and packages checking\033[0m
2431 ================================================================================"
2432 cd $WOK
2433 for pkg in $(ls)
2434 do
2435 [ -f $pkg/receipt ] || continue
2436 RECEIPT= $pkg/receipt
2437 source_receipt
2438 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
2439 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
2440 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
2441 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
2442 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
2443 if [ -n "$WANTED" ]; then
2444 if [ ! -f $WANTED/receipt ]; then
2445 echo "Package $PACKAGE wants unknown $WANTED package" >&2
2446 else
2447 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
2448 if [ "$VERSION" = "$WANTED" ]; then
2449 # BASEVERSION is computed in receipt
2450 fgrep -q '_pkg=' $pkg/receipt &&
2451 BASEVERSION=$VERSION
2452 fi
2453 if [ "$VERSION" != "$BASEVERSION" ]; then
2454 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
2455 fi
2456 fi
2457 fi
2459 if [ -n "$CATEGORY" ]; then
2460 case " $(echo $CATEGORIES) " in
2461 *\ $CATEGORY\ *);;
2462 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
2463 esac
2464 else
2465 echo"Package $PACKAGE has no CATEGORY" >&2
2466 fi
2467 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
2468 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
2469 case "$WGET_URL" in
2470 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
2471 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
2472 '') ;;
2473 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
2474 esac
2475 case "$WEB_SITE" in
2476 ftp*|http*);;
2477 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
2478 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
2479 esac
2480 case "$MAINTAINER" in
2481 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
2482 esac
2483 case "$MAINTAINER" in
2484 *@*);;
2485 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
2486 esac
2487 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2488 for i in $DEPENDS; do
2489 [ -d $i ] && continue
2490 [ -n "$(whoprovide $i)" ] && continue
2491 echo -e "$MSG $i"
2492 MSG=""
2493 done
2494 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2495 for i in $BUILD_DEPENDS; do
2496 [ -d $i ] && continue
2497 [ -n "$(whoprovide $i)" ] && continue
2498 echo -e "$MSG $i"
2499 MSG=""
2500 done
2501 MSG="Dependency loop between $PACKAGE and :\n"
2502 ALL_DEPS=""
2503 check_for_deps_loop $PACKAGE $DEPENDS
2504 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
2505 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
2506 echo "$pkg should be rebuilt after $i installation"
2507 done
2508 done
2509 ;;
2510 list)
2511 # List packages in wok directory. User can specify a category.
2513 get_tazwok_config
2514 if [ "$2" = "category" ]; then
2515 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
2516 exit 0
2517 fi
2518 # Check for an asked category.
2519 if [ -n "$2" ]; then
2520 ASKED_CATEGORY=$2
2521 echo ""
2522 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
2523 echo "================================================================================"
2524 for pkg in $WOK/*
2525 do
2526 [ ! -f $pkg/receipt ] && continue
2527 . $pkg/receipt
2528 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
2529 echo -n "$PACKAGE"
2530 echo -e "\033[28G $VERSION"
2531 packages=$(($packages+1))
2532 fi
2533 done
2534 echo "================================================================================"
2535 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
2536 else
2537 # By default list all packages and version.
2538 echo ""
2539 echo -e "\033[1mList of packages in the wok\033[0m"
2540 echo "================================================================================"
2541 for pkg in $WOK/*
2542 do
2543 [ ! -f $pkg/receipt ] && continue
2544 . $pkg/receipt
2545 echo -n "$PACKAGE"
2546 echo -en "\033[28G $VERSION"
2547 echo -e "\033[42G $CATEGORY"
2548 packages=$(($packages+1))
2549 done
2550 echo "================================================================================"
2551 echo -e "$packages packages available in the wok.\n"
2552 fi
2553 ;;
2554 info)
2555 # Information about a package.
2557 get_tazwok_config
2558 check_for_package_on_cmdline
2559 check_for_receipt
2560 . $WOK/$PACKAGE/receipt
2561 echo ""
2562 echo -e "\033[1mTazwok package information\033[0m
2563 ================================================================================
2564 Package : $PACKAGE
2565 Version : $VERSION
2566 Category : $CATEGORY
2567 Short desc : $SHORT_DESC
2568 Maintainer : $MAINTAINER"
2569 if [ ! "$WEB_SITE" = "" ]; then
2570 echo "Web site : $WEB_SITE"
2571 fi
2572 if [ ! "$DEPENDS" = "" ]; then
2573 echo "Depends : $DEPENDS"
2574 fi
2575 if [ ! "$WANTED" = "" ]; then
2576 echo "Wanted src : $WANTED"
2577 fi
2578 echo "================================================================================"
2579 echo ""
2580 ;;
2581 check-log)
2582 # We just cat the file log to view process info.
2584 get_tazwok_config
2585 if [ ! -f "$LOG" ]; then
2586 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
2587 exit 1
2588 else
2589 echo ""
2590 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
2591 echo "================================================================================"
2592 cat $LOG
2593 echo "================================================================================"
2594 echo ""
2595 if [ -s "$WOK/$PACKAGE/warning.txt" ]; then
2596 echo -e "\033[1mCook warning(s) for :\033[0m $PACKAGE"
2597 echo "================================================================================"
2598 cat "$WOK/$PACKAGE/warning.txt"
2599 echo "================================================================================"
2600 echo ""
2601 fi
2602 fi
2603 ;;
2604 search)
2605 # Search for a package by pattern or name.
2607 get_tazwok_config
2608 if [ -z "$2" ]; then
2609 echo -e "\nPlease specify a pattern or a package name to search." >&2
2610 echo -e "Example : 'tazwok search gcc'.\n" >&2
2611 exit 1
2612 fi
2613 echo ""
2614 echo -e "\033[1mSearch result for :\033[0m $2"
2615 echo "================================================================================"
2616 list=`ls -1 $WOK | fgrep $2`
2617 for pkg in $list
2618 do
2619 . $WOK/$pkg/receipt
2620 echo -n "$PACKAGE "
2621 echo -en "\033[24G $VERSION"
2622 echo -e "\033[42G $CATEGORY"
2623 packages=$(($PACKAGEs+1))
2624 done
2625 echo "================================================================================"
2626 echo "$packages packages found for : $2"
2627 echo ""
2628 ;;
2629 compile)
2630 # Configure and make a package with the receipt.
2632 get_tazwok_config
2633 source_lib report
2634 report start
2635 compile_package
2636 ;;
2637 genpkg)
2638 # Generate a package.
2640 get_tazwok_config
2641 source_lib report
2642 report start
2643 gen_package
2644 ;;
2645 cook)
2646 # Compile and generate a package. Just execute tazwok with
2647 # the good commands.
2649 check_root
2650 get_tazwok_config
2651 source_lib report
2652 report start
2653 update_wan_db
2654 check_for_commit
2655 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
2656 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
2657 if [ "$plan_regen_cookorder" ]; then
2658 [ "$(sed 1!d $PACKAGES_REPOSITORY/cookorder.txt)" = "#PlanSort" ] || \
2659 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
2660 fi
2661 cook
2662 ;;
2663 sort-cooklist)
2664 if [ ! -f "$LIST" ]; then
2665 echo "Usage : tazwok sort-cooklist cooklist" >&2
2666 exit 1
2667 fi
2668 check_root
2669 get_tazwok_config
2670 report(){ : ; }
2671 # When using sort-cooklist, the script should behave as for gen-cooklist
2672 # The only difference between these two is where the output is sent.
2673 COMMAND=gen-cooklist
2674 cooklist=$LIST
2675 gen_cook_list
2676 cp -af $tmp/cooklist $cooklist
2677 ;;
2678 cook-list)
2679 # Cook all packages listed in a file or in default cooklist.
2680 check_root
2681 get_options_list="pkg forced"
2682 get_tazwok_config
2683 source_lib report
2684 report start
2685 if ! [ "$pkg" ]; then
2686 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2687 fi
2688 gen_cook_list
2689 cook_list
2690 ;;
2691 clean)
2692 # Clean up a package work directory + those which want it.
2694 get_tazwok_config
2695 check_for_package_on_cmdline
2696 check_for_receipt
2697 source_lib report
2698 report start
2699 . $RECEIPT
2700 clean
2701 ;;
2702 gen-clean-wok)
2703 # Generate a clean wok from the current wok by copying all receipts
2704 # and stuff directory.
2706 get_tazwok_config
2707 source_lib report
2708 report start
2709 if [ -z "$ARG" ]; then
2710 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
2711 exit 1
2712 else
2713 dest=$ARG
2714 mkdir -p $dest
2715 fi
2716 report step "Creating clean wok in : $dest"
2717 for pkg in `ls -1 $WOK`
2718 do
2719 mkdir -p $dest/$pkg
2720 cp -a $WOK/$pkg/receipt $dest/$pkg
2721 [ -f $WOK/$pkg/description.txt ] && \
2722 cp -a $WOK/$pkg/description.txt $dest/$pkg
2723 if [ -d "$WOK/$pkg/stuff" ]; then
2724 cp -a $WOK/$pkg/stuff $dest/$pkg
2725 fi
2726 done
2727 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
2728 report end-step
2729 echo "Packages cleaned : `ls -1 $dest | wc -l`"
2730 echo ""
2731 ;;
2732 clean-wok)
2733 # Clean all packages in the work directory.
2735 get_tazwok_config
2736 source_lib report
2737 report start
2738 report step "Cleaning wok"
2739 for PACKAGE in `ls -1 $WOK`
2740 do
2741 set_common_path
2742 source_receipt
2743 clean
2744 done
2745 echo "`ls -1 $WOK | wc -l` packages cleaned."
2746 ;;
2747 clean-src)
2748 # Remove tarball unrelated to wok receipts from src repo.
2749 check_root
2750 get_options_list="forced"
2751 get_tazwok_config
2752 cd $SOURCES_REPOSITORY
2753 echo -n "Checking $SOURCES_REPOSITORY..."
2754 for TARBALL in *; do
2755 [ "$TARBALL" = sources.list ] && continue
2756 grep -q $'\t'$TARBALL$ $SOURCES_REPOSITORY/sources.list || \
2757 echo $TARBALL >> $tmp/obsolete
2758 done
2759 status
2760 if ! [ -f $tmp/obsolete ]; then
2761 echo "No sources need to be removed."
2762 exit 1
2763 fi
2764 echo ""
2765 echo -e "\033[1mObsolete/unrelated-to-wok sources :\033[0m"
2766 horizontal_line
2767 cat $tmp/obsolete
2768 horizontal_line
2769 echo "$(wc -l $tmp/obsolete | cut -f1 -d' ') tarballs to remove."
2770 echo ""
2771 echo -n "Please confirm before removing (type uppercase YES): "
2772 read answer
2773 if [ "$answer" = YES ]; then
2774 echo -n "Removing old sources..."
2775 cat $tmp/obsolete | while read i; do
2776 rm -f $SOURCES_REPOSITORY/$i
2777 done
2778 status
2779 fi
2780 ;;
2781 gen-list)
2782 get_tazwok_config
2783 if [ "$2" ]; then
2784 if [ -d "$2" ]; then
2785 pkg_repository=$2
2786 else
2787 echo -e "\nUnable to find directory : $2\n" >&2
2788 exit 1
2789 fi
2790 fi
2792 source_lib report
2793 report start
2794 if [ "$pkg_repository" ]; then
2795 gen_packages_db
2796 else
2797 pkg_repository=$PACKAGES_REPOSITORY && gen_packages_db
2798 pkg_repository=$INCOMING_REPOSITORY && gen_packages_db
2799 fi
2800 ;;
2801 check-list)
2802 # The directory to move into by default is the repository,
2803 # if $2 is not empty cd into $2.
2805 get_tazwok_config
2806 if [ "$2" ]; then
2807 if [ -d "$2" ]; then
2808 pkg_repository=$2
2809 else
2810 echo -e "\nUnable to find directory : $2\n" >&2
2811 exit 1
2812 fi
2813 fi
2815 source_lib report
2816 report start
2817 if [ "$pkg_repository" ]; then
2818 update_packages_db
2819 else
2820 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
2821 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
2822 fi
2823 ;;
2824 new-tree)
2825 # Just create a few directories and generate an empty receipt to prepare
2826 # the creation of a new package.
2828 get_tazwok_config
2829 check_for_package_on_cmdline
2830 clean_wok=$LOCAL_REPOSITORY/clean-wok
2831 if [ -d $clean_wok/$PACKAGE ]; then
2832 echo -e "\n$PACKAGE package tree already exists.\n" >&2
2833 exit 1
2834 fi
2835 echo "Creating : $clean_wok/$PACKAGE"
2836 mkdir $clean_wok/$PACKAGE
2837 cd $clean_wok/$PACKAGE
2838 echo -n "Preparing the receipt..."
2840 # Default receipt begin.
2842 echo "# SliTaz package receipt." > receipt
2843 echo "" >> receipt
2844 echo "PACKAGE=\"$PACKAGE\"" >> receipt
2845 # Finish the empty receipt.
2846 cat >> receipt << "EOF"
2847 VERSION=""
2848 CATEGORY=""
2849 SHORT_DESC=""
2850 MAINTAINER=""
2851 DEPENDS=""
2852 TARBALL="$PACKAGE-$VERSION.tar.gz"
2853 WEB_SITE=""
2854 WGET_URL=""
2856 # Rules to configure and make the package.
2857 compile_rules()
2859 cd $src
2860 ./configure && make && make install
2863 # Rules to gen a SliTaz package suitable for Tazpkg.
2864 genpkg_rules()
2866 mkdir -p $fs/usr
2867 cp -a $_pkg/usr/bin $fs/usr
2870 EOF
2872 # Default receipt end.
2874 status
2875 # Interactive mode, asking and seding.
2876 if [ "$3" = "--interactive" ]; then
2877 echo "Entering interactive mode..."
2878 echo "================================================================================"
2879 echo "Package : $PACKAGE"
2880 # Version.
2881 echo -n "Version : " ; read anser
2882 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
2883 # Category.
2884 echo -n "Category : " ; read anser
2885 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
2886 # Short description.
2887 echo -n "Short desc : " ; read anser
2888 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
2889 # Maintainer.
2890 echo -n "Maintainer : " ; read anser
2891 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
2892 # Web site.
2893 echo -n "Web site : " ; read anser
2894 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
2895 echo ""
2896 # Wget URL.
2897 echo "Wget URL to download source tarball."
2898 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
2899 echo -n "Wget url : " ; read anser
2900 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
2901 # Ask for a stuff dir.
2902 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
2903 if [ "$anser" = "y" ]; then
2904 echo -n "Creating the stuff directory..."
2905 mkdir stuff && status
2906 fi
2907 # Ask for a description file.
2908 echo -n "Are you going to write a description ? (y/N) : " ; read anser
2909 if [ "$anser" = "y" ]; then
2910 echo -n "Creating the description.txt file..."
2911 echo "" > description.txt && status
2912 fi
2913 echo "================================================================================"
2914 echo ""
2915 fi
2916 ;;
2917 remove)
2918 # Remove a package from the wok.
2920 get_tazwok_config
2921 check_for_package_on_cmdline
2922 echo ""
2923 echo -n "Please confirm deletion (y/N) : "; read anser
2924 if [ "$anser" = "y" ]; then
2925 echo -n "Removing $PACKAGE..."
2926 rm -rf $WOK/$PACKAGE && status
2927 echo ""
2928 fi
2929 ;;
2930 update-wok)
2931 # Pull and update a Hg wok.
2932 get_options_list="local"
2933 get_tazwok_config
2934 source_lib report
2935 report start
2936 clean_wok=$LOCAL_REPOSITORY/clean-wok
2937 cd $clean_wok
2938 if ! [ "$local" ]; then
2939 if [ "$WOK_UPDATE_METHOD" = hg ]; then
2940 if ! [ -f "$INSTALLED/mercurial/receipt" ]; then
2942 # Auto-install only if we are in a cook chroot.
2943 if [ -x /usr/bin/clean-chroot ]; then
2944 tazpkg get-install mercurial
2945 else
2946 echo "" >&2
2947 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
2948 echo "">&2
2949 exit 1
2950 fi
2951 fi
2953 report step "Getting wok changes using hg"
2954 if [ -d .hg ]; then
2955 hg pull -u || exit 1
2956 else
2957 hg clone $HG_WOK . || exit 1
2958 fi
2959 report end-step
2960 [ -x /usr/bin/clean-chroot ] && clean-chroot
2961 else
2962 report step "Getting wok changes using tarball"
2963 { mkdir .tmp && cd .tmp
2964 wget "$TARBALL_WOK" &&
2965 case $TARBALL_WOK in
2966 *bz2) tar xjf *.bz2 -C wok; rm *.bz2;;
2967 *lzma) unlzma -c *.lzma | tar xf - -C wok; rm *.lzma ;;
2968 *gz) tar xzf *.gz -C wok; rm*.gz ;;
2969 esac &&
2970 rm -r $(ls -d $clean_wok/*) &&
2971 cp -a wok/* $clean_wok &&
2972 cd .. &&
2973 rm -r .tmp
2974 } || { echo "That's not cool: it fails!" >&2
2975 report end-step
2976 exit 1; }
2977 report end-step
2978 fi
2979 fi
2980 report step "Appending changes to wok"
2982 # Handle removed files/dir.
2983 cd $WOK
2984 for dir in *; do
2985 [ -d "$clean_wok/$dir" ] || rm -rf $dir
2986 done
2987 for file in */receipt */description.txt; do
2988 [ -f "$clean_wok/$file" ] || rm -rf $file
2989 done
2990 for i in $(find */stuff 2>/dev/null); do
2991 [ -e "$clean_wok/$i" ] || rm -rf $i
2992 done
2994 cp -a $clean_wok/* $WOK
2995 report end-step
2996 ;;
2997 maintainers)
2998 get_tazwok_config
2999 echo ""
3000 echo "List of maintainers for: $WOK"
3001 echo "================================================================================"
3002 touch /tmp/slitaz-maintainers
3003 for pkg in $WOK/*
3004 do
3005 . $pkg/receipt
3006 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
3007 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
3008 echo "$MAINTAINER"
3009 fi
3010 done
3011 echo "================================================================================"
3012 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
3013 echo ""
3014 # Remove tmp files
3015 rm -f /tmp/slitaz-maintainers
3016 ;;
3017 maintained-by)
3018 # Search for packages maintained by a contributor.
3019 get_tazwok_config
3020 if [ ! -n "$2" ]; then
3021 echo "Specify a name or email of a maintainer." >&2
3022 exit 1
3023 fi
3024 echo "Maintainer packages"
3025 echo "================================================================================"
3026 for pkg in $WOK/*
3027 do
3028 . $pkg/receipt
3029 if echo "$MAINTAINER" | fgrep -q "$2"; then
3030 echo "$PACKAGE"
3031 packages=$(($PACKAGEs+1))
3032 fi
3033 done
3034 echo "================================================================================"
3035 echo "Packages maintained by $2: $PACKAGEs"
3036 echo ""
3037 ;;
3038 tags)
3039 get_tazwok_config
3040 echo -e "\n\033[1mTags list :\033[0m"
3041 horizontal_line
3042 cd $WOK
3043 for i in */receipt; do
3044 unset TAGS
3045 source $i
3046 for t in $TAGS; do
3047 grep -q ^$t$ $tmp/tags && continue
3048 echo $t | tee -a $tmp/tags
3049 done
3050 done
3051 horizontal_line
3052 echo "$(wc -l $tmp/tags | cut -f1 -d ' ') tags listed."
3053 ;;
3054 check-src)
3055 # Verify if upstream package is still available.
3057 get_tazwok_config
3058 check_for_package_on_cmdline
3059 check_for_receipt
3060 source_receipt
3061 check_src()
3063 for url in $@; do
3064 busybox wget -s $url 2>/dev/null && break
3065 done
3067 if [ "$WGET_URL" ];then
3068 echo -n "$PACKAGE : "
3069 check_src $WGET_URL
3070 status
3071 else
3072 echo "No tarball to check for $PACKAGE"
3073 fi
3074 ;;
3075 get-src)
3076 check_root
3077 get_options_list="target nounpack"
3078 get_tazwok_config
3079 check_for_package_on_cmdline
3080 check_for_receipt
3081 source_receipt
3082 if [ "$WGET_URL" ];then
3083 source_lib report
3084 report start
3085 check_for_tarball
3086 else
3087 echo "No tarball to download for $PACKAGE"
3088 fi
3089 ;;
3090 check-commit)
3091 check_root
3092 get_options_list="missing forced"
3093 get_tazwok_config
3094 source_lib report
3095 report start
3096 if [ "$forced" ]; then
3097 rm -f $WOK/*/md5
3098 unset forced
3099 fi
3100 if [ "$missing" ]; then
3101 pkg=$(ls -1 $WOK)
3102 else
3103 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3104 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3105 } | sort -u)"
3106 fi
3107 cooklist=$PACKAGES_REPOSITORY/cooklist
3108 gen_cook_list
3109 ;;
3110 cook-commit)
3111 check_root
3112 get_options_list="missing forced"
3113 get_tazwok_config
3114 source_lib report
3115 report start
3116 if [ "$forced" ]; then
3117 rm -f $WOK/*/md5
3118 unset forced
3119 fi
3120 if [ "$missing" ]; then
3121 pkg=$(ls -1 $WOK)
3122 else
3123 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3124 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3125 } | sort -u)"
3126 fi
3127 cooklist=$PACKAGES_REPOSITORY/cooklist
3128 gen_cook_list
3129 cook_list
3130 ;;
3131 cook-all)
3132 check_root
3133 get_options_list="forced missing"
3134 get_tazwok_config
3135 source_lib report
3136 report start
3137 if [ "$missing" ]; then
3138 pkg=$(ls -1 $WOK)
3139 else
3140 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3141 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3142 } | sort -u)"
3143 fi
3144 cooklist=$PACKAGES_REPOSITORY/cooklist
3145 gen_cook_list
3146 cook_list
3147 ;;
3148 gen-wok-db)
3149 check_root
3150 get_tazwok_config
3151 source_lib report
3152 report start
3153 gen_wok_db
3154 ;;
3155 report)
3156 get_tazwok_config
3157 cd $PACKAGES_REPOSITORY
3158 if [ "$2" ]; then
3159 case $2 in
3160 commit|cooklist|incoming|broken|blocked)
3161 show="$2"
3162 ;;
3163 *)
3164 echo "usage : tazwok report [commit|cooklist|incoming|broken|blocked]" >&2
3165 exit 1
3166 ;;
3167 esac
3168 else
3169 show="commit cooklist incoming broken blocked"
3170 fi
3171 for i in $show; do
3172 if [ -s $i ]; then
3173 echo ""
3174 echo -e "\033[1m$i\033[0m"
3175 echo "================================================================================"
3176 cat $i
3177 echo "================================================================================"
3178 echo ""
3179 fi
3180 done
3181 ;;
3182 check-incoming)
3183 check_root
3184 get_options_list="forced"
3185 get_tazwok_config
3186 source_lib report
3187 report start
3188 [ -f $LOCAL_RESOSITORY/incoming ] && rm [ -f $LOCAL_REPOSITORY/incoming ]
3189 report step "Checking $INCOMING_REPOSITORY"
3190 report open-bloc
3191 [ -f $LOCAL_REPOSITORY/log/incoming.html ] && rm $LOCAL_REPOSITORY/log/incoming.html
3192 report sublog $LOCAL_REPOSITORY/log/incoming.html
3193 echo "incoming" > $LOCAL_REPOSITORY/log/package
3194 check_for_incoming
3195 report end-sublog
3196 report close-bloc
3197 ;;
3198 configure-chroot)
3199 check_root
3200 get_tazwok_config
3201 if [ -f /usr/bin/tazchroot ]; then
3202 cd $LOCAL_REPOSITORY
3203 configure_tazchroot
3204 else
3205 echo "The package tazchroot needs to be installed" >&2
3206 exit 1
3207 fi
3208 ;;
3209 chroot)
3210 check_root
3211 get_tazwok_config
3212 # Merge this and the other chroot function ?.
3213 if [ -f /usr/bin/tazchroot ]; then
3214 cd $LOCAL_REPOSITORY
3215 [ ! -f tazchroot.conf ] && configure_tazchroot
3216 tazchroot
3217 else
3218 echo "The package tazchroot needs to be installed" >&2
3219 exit 1
3220 fi
3221 ;;
3222 cook-toolchain)
3223 check_root
3224 get_tazwok_config
3225 echo -n "" > $PACKAGES_REPOSITORY/broken
3226 if [ -f /usr/bin/tazchroot ]; then
3227 cd $LOCAL_REPOSITORY
3228 [ ! -f tazchroot.conf ] && configure_tazchroot
3229 tazchroot cook-toolchain
3230 # Buggy : chroot can be elsewhere.
3231 rm -r $LOCAL_REPOSITORY/chroot
3232 # /!\ to be written :
3233 # next rm chroot and plan cook-all by pushing all packages
3234 # in cooklist.
3235 else
3236 echo "The package tazchroot needs to be installed" >&2
3237 exit 1
3238 fi
3239 ;;
3240 webserver)
3241 check_root
3242 get_tazwok_config
3243 if [ "$ARG" = on ]; then
3244 if [ "$WEBSERVER" ] && [ -f "$WEBSERVER/repositories.list" ] && \
3245 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3246 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3247 exit 1
3248 fi
3249 if ! [ -f $LOCAL_REPOSITORY/tazchroot.conf ]; then
3250 tazwok configure-chroot ${undigest:+--undigest=$undigest} --SLITAZ_VERSION=$SLITAZ_VERSION --SLITAZ_DIR=$SLITAZ_DIR
3251 fi
3252 for pkg in php lighttpd; do
3253 [ -d $INSTALLED/$pkg ] || missing="$missing $pkg"
3254 done
3255 if [ "$missing" ]; then
3256 echo "You need to install these packages to start webserver: $missing." >&2
3257 exit 1
3258 fi
3259 if [ ! -f "$LOCAL_REPOSITORY/tazwok.conf" ]; then
3260 echo "Copying /etc/slitaz/tazwok.conf to $LOCAL_REPOSITORY/tazwok.conf: webserver is configured repository-by-repository."
3261 cp /etc/slitaz/tazwok.conf $LOCAL_REPOSITORY
3262 fi
3263 if ! [ "$WEBSERVER" ]; then
3264 echo -n "Where to store php pages (default: /var/www/vhosts/bb)? "
3265 read WEBSERVER
3266 [ "$WEBSERVER" ] || WEBSERVER="/var/www/vhosts/bb"
3267 fi
3268 if [ -f "$WEBSERVER/repositories.list" ] && \
3269 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3270 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3271 exit 1
3272 fi
3273 mkdir -p $WEBSERVER
3274 echo "${undigest:-$SLITAZ_VERSION}" >> $WEBSERVER/repositories.list
3275 for file in index.php log.php download.php; do
3276 [ -f "$WEBSERVER/$file" ] || ln -s /usr/share/slitaz/web-bb/$file $WEBSERVER
3277 done
3278 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3279 ln -s $dir $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3280 done
3281 source $LOCAL_REPOSITORY/tazchroot.conf
3282 echo "<?php
3284 // Web interface configuration
3286 \$version=\"${undigest:-$SLITAZ_VERSION}\";
3287 \$chroot=\"$chroot_dir\";
3288 \$lockfile=\"\$chroot/proc/1/status\";
3289 \$db_dir=\"$PACKAGES_REPOSITORY\";
3290 \$log_dir=\"$LOCAL_REPOSITORY/log\";
3291 \$packages=\"$PACKAGES_REPOSITORY\";
3292 \$incoming=\"$INCOMING_REPOSITORY\";
3293 \$wok=\"$WOK\";
3295 ?>" > $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3296 [ -L "$WEBSERVER/web" ] || ln -s /usr/share/slitaz/web $WEBSERVER
3297 echo "WEBSERVER=\"$WEBSERVER\"" >> $LOCAL_REPOSITORY/tazwok.conf
3298 if [ -L "$WEBSERVER/conf.php" ]; then
3299 echo "Do you want to make ${undigest:-$SLITAZ_VERSION} the default page (y/N) ? "
3300 read answer
3301 if [ "$answer" = y ]; then
3302 rm $WEBSERVER/conf.php
3303 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3304 fi
3305 else
3306 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3307 fi
3308 elif [ "$ARG" = off ]; then
3309 if ! [ "$WEBSERVER" ]; then
3310 echo "No webserver running for ${undigest:-$SLITAZ_VERSION}" >&2
3311 exit 1
3312 fi
3313 sed '/^WEBSERVER/d' -i $LOCAL_REPOSITORY/tazwok.conf
3314 sed "/^${undigest:-$SLITAZ_VERSION}$/d" -i $WEBSERVER/repositories.list
3315 rm $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3316 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3317 rm $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3318 done
3319 if ! [ -s "$WEBSERVER/repositories.list" ]; then
3320 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"
3321 rm $WEBSERVER/conf.php
3322 elif [ "$(readlink $WEBSERVER/conf.php)" = "$WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php" ]; then
3323 echo "${undigest:-$SLITAZ_VERSION} was the default version to use; switched to : $(sed 1!d $WEBSERVER/repositories.list)"
3324 rm $WEBSERVER/conf.php
3325 ln -s $WEBSERVER/conf-$(sed 1!d $WEBSERVER/repositories.list).php $WEBSERVER/conf.php
3326 fi
3327 else
3328 echo "Usage: tazwok webserver on/off" >&2
3329 exit 1
3330 fi
3331 ;;
3332 block)
3333 # Add a pkg name to the list of blocked packages.
3334 get_tazwok_config
3335 check_root
3336 check_for_package_on_cmdline
3337 if ! [ -f $WOK/$PACKAGE/receipt ]; then
3338 echo "Can't find $PACKAGE in wok." >&2
3339 echo ""
3340 exit 1
3341 fi
3342 echo ""
3343 if grep -qs "^$PACKAGE$" $PACKAGES_REPOSITORY/blocked; then
3344 echo "$PACKAGE is already in the blocked packages list." >&2
3345 echo ""
3346 exit 1
3347 else
3348 echo -n "Adding $PACKAGE to : $PACKAGES_REPOSITORY/blocked... "
3349 echo "$PACKAGE" >> $PACKAGES_REPOSITORY/blocked
3350 status
3351 if grep -q "^$PACKAGE$" $PACKAGES_REPOSITORY/cooklist; then
3352 echo -n "Removing $PACKAGE from : $PACKAGES_REPOSITORY/cooklist... "
3353 sed -i /"^$PACKAGE$"/d $PACKAGES_REPOSITORY/cooklist
3354 status
3355 fi
3356 fi
3357 echo "" ;;
3358 unblock)
3359 # Remove a pkg name from the list of blocked packages.
3360 get_tazwok_config
3361 check_root
3362 check_for_package_on_cmdline
3363 if ! [ -f $WOK/$PACKAGE/receipt ]; then
3364 echo "Can't find $PACKAGE in wok." >&2
3365 echo ""
3366 exit 1
3367 fi
3368 echo ""
3369 if grep -qs "^$PACKAGE$" $PACKAGES_REPOSITORY/blocked; then
3370 echo -n "Removing $PACKAGE from : $PACKAGES_REPOSITORY/blocked... "
3371 sed -i /"^$PACKAGE$"/d $PACKAGES_REPOSITORY/blocked
3372 sed -i '/^$/d' $PACKAGES_REPOSITORY/blocked
3373 status
3374 else
3375 echo "$PACKAGE is not in the blocked packages list." >&2
3376 echo ""
3377 exit 1
3378 fi
3379 echo "" ;;
3380 usage|*)
3381 # Print usage also for all unknown commands.
3383 usage
3384 ;;
3385 esac
3387 report stop 2>/dev/null
3388 exit 0