tazwok view tazwok @ rev 426

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