tazwok view tazwok @ rev 446

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