tazwok view tazwok @ rev 366

Added tag 4.2.1 for changeset 16be5005f449
author Antoine Bodin <gokhlayeh@slitaz.org>
date Fri Feb 25 00:19:26 2011 +0100 (2011-02-25)
parents c2c01e4ea11b ac0c4dea6951
children f29f2029e889
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
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/ { print int(($2*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 fgrep -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 [ -d "$INSTALLED/$pkg" ] && tazpkg remove $pkg --auto
380 done
381 report end-step
382 }
384 # Check if we can use the new way to handle tarball
385 # or if we keep the previous method by check for
386 # _pkg=/src= in receipt and reverse-wanted.
387 check_for_var_modification()
388 {
389 for var in $@; do
390 for pkg in $PACKAGE $(look_for_wanted) $(look_for_rwanted); do
391 [ -f $WOK/$pkg/receipt ] || continue
392 fgrep -q "$var=" $WOK/$pkg/receipt && return 1
393 done
394 done
396 # Tweak to make if; then...; fi function working with this one.
397 echo -n ""
398 }
400 set_src_path()
401 {
402 if check_for_var_modification src _pkg; then
403 src=$WOK/${WANTED:-$PACKAGE}/${WANTED:-$PACKAGE}-$VERSION
404 else
405 tazwok_warning "Use original name or tarball root directory because src/_pkg are defined into the receipt (this is no more needed!)."
406 src=$WOK/${WANTED:-$PACKAGE}/${SOURCE:-${WANTED:-$PACKAGE}}-$VERSION
407 fi
408 stuff=$WOK/$PACKAGE/stuff
409 [ "$WANTED" ] && wanted_stuff=$WOK/$WANTED/stuff
410 }
412 set_pkg_path()
413 {
414 if [ -d $WOK/${WANTED:-$PACKAGE}/install ] ; then
415 _pkg=$WOK/${WANTED:-$PACKAGE}/install
416 else
417 _pkg=$src/_pkg
418 fi
419 }
421 # Output $VERSION-$EXTRAVERSION using packages.txt
422 get_pkg_version()
423 {
424 [ "$PACKAGE" ] || return
425 grep -m1 -A1 -sh ^$PACKAGE$ $1/packages.txt | tail -1 | sed 's/ *//'
426 }
428 remove_previous_package()
429 {
430 [ "$prev_VERSION" ] || return
431 if [ "$VERSION$EXTRAVERSION" != "$prev_VERSION" ]; then
432 rm -f $1/$PACKAGE-$prev_VERSION.tazpkg
433 fi
434 return
435 }
437 # Check for src tarball and wget if needed.
438 check_for_tarball()
439 {
440 [ "$WGET_URL" ] || return 0
441 look_for_cookopt !unpack && nounpack=yes
442 report step "Checking for source tarball: $PACKAGE"
443 local repack_src=$repack_src TARBALL=$TARBALL
444 if [ "$repack_src" = yes ] && look_for_cookopt !repack_src; then
445 repack_src=no
446 fi
447 if [ "$target" ]; then
448 src="$target"
449 else
450 set_src_path
451 fi
452 tmp_src=$tmp/tarball-$$
453 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
454 [ ! -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] ; then
455 cd $SOURCES_REPOSITORY
456 if [ "$SOURCE" ]; then
457 alt_url="http://mirror.slitaz.org/sources/packages/${SOURCE:0:1}/$SOURCE-$VERSION.tar.lzma"
458 alt_url2="http://mirror.slitaz.org/sources/packages/${SOURCE:0:1}/$TARBALL"
459 else
460 alt_url="http://mirror.slitaz.org/sources/packages/${PACKAGE:0:1}/$PACKAGE-$VERSION.tar.lzma"
461 alt_url2="http://mirror.slitaz.org/sources/packages/${PACKAGE:0:1}/$TARBALL"
462 fi
463 download $WGET_URL $alt_url $alt_url2 http://mirror.slitaz.org/sources/packages/${file:0:1}/$file
464 unset alt_url
465 unset alt_url2
466 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
467 [ ! -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && \
468 [ ! -d $tmp_src ]; then
469 echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n" >&2
470 report end-step
471 return 1
472 fi
473 fi
474 report end-step
475 if { [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && [ "$nounpack" ] ; } || \
476 { [ -f "$SOURCES_REPOSITORY/$TARBALL" ] && [ "$repack_src" != yes ] && [ "$nounpack" ] ; }; then
477 [ -d "$tmp_src" ] && rm -r $tmp_src
478 return 0
479 fi
481 # Untaring source if necessary. We don't need to extract source if
482 # the package is built with a wanted source package.
483 if [ "$WANTED" ]; then
484 [ -d "$tmp_src" ] && rm -r $tmp_src
485 return
486 fi
488 report step "Untaring source tarball"
490 # Log process.
491 echo "untaring source tarball" >> $LOG
493 # If $tmp_src exists, there's already the unpacked tarball into it.
494 if ! [ -d $tmp_src ]; then
495 mkdir $tmp_src
496 if [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && [ "$repack_src" = yes ]; then
497 lzma d $SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma -so | \
498 tar xf - -C $tmp_src
499 repack_src=no
500 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
501 elif [ -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
502 case "$TARBALL" in
503 *zip|*xpi) cd $tmp_src && unzip -o $SOURCES_REPOSITORY/$TARBALL ;;
504 *bz2|*tbz|*gem) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
505 *tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
506 *lzma|*lz) unlzma -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
507 *xz) unxz -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
508 *Z|*taz) uncompress -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
509 *gz) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
510 *rpm) cd $tmp_src && rpm2cpio $SOURCES_REPOSITORY/$TARBALL | cpio -idm --quiet;;
512 # It's a plain file or something receipt unpack itself.
513 *)
514 mkdir $tmp_src/${SOURCE:-$PACKAGE}-$VERSION
515 cp $SOURCES_REPOSITORY/$TARBALL $tmp_src/${src##*/}
516 ;;
518 esac || { report end-step
519 rm -f $SOURCES_REPOSITORY/$TARBALL
520 rm -r $tmp_src
521 return 1
522 }
523 fi
525 # Check if uncompressed tarball is in a root dir or not.
526 if [ "$(ls -A $tmp_src | wc -l)" -gt 1 ] || [ -f $(echo $tmp_src/*) ]; then
527 if check_for_var_modification src _pkg; then
528 mv $tmp_src $tmp_src-1
529 mkdir $tmp_src
530 mv $tmp_src-1 $tmp_src/${SOURCE:-$PACKAGE}-$VERSION
531 else
532 mv $tmp_src/* $WOK/$PACKAGE
533 repack_src=no
534 rm -r $tmp_src
535 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."
536 fi
537 fi
538 fi
540 if [ "$repack_src" = yes ]; then
541 report step "Repacking sources in .tar.lzma format"
542 [ "$TARBALL" ] && rm -f $SOURCES_REPOSITORY/$TARBALL
543 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
544 cd $tmp_src
545 tar -c * | lzma e $SOURCES_REPOSITORY/$TARBALL -si
546 fi
548 # Remove previous tarball if no other package needs it. We take care to
549 # keep tarball if the same package use it into main repository.
550 if [ "$TARBALL" ]; then
551 previous_tarball=$(grep ^$PACKAGE:incoming $SOURCES_REPOSITORY/sources.list | cut -f2)
552 if [ "$previous_tarball" ]; then
553 sed "/^$PACKAGE:incoming/ s/.*/$PACKAGE:incoming\t$TARBALL/" \
554 -i $SOURCES_REPOSITORY/sources.list
555 grep -q $'\t'$previous_tarball$ $SOURCES_REPOSITORY/sources.list || \
556 rm -f $SOURCES_REPOSITORY/$previous_tarball
557 else
558 echo -e "$PACKAGE:incoming\t$TARBALL" >> $SOURCES_REPOSITORY/sources.list
559 fi
560 fi
562 if [ "$nounpack" ]; then
563 [ -d "$tmp_src" ] && rm -r $tmp_src
564 report end-step
565 return
566 fi
567 if [ ! -d "$src" ]|| [ "$target" ]; then
568 # Permissions settings.
569 chown -R root.root "$tmp_src"
570 if [ -d "$src" ]; then
571 mkdir -p $src
572 for f in $tmp_src/*/*; do
573 cp -a $f $src || { report end-step; rm -r $tmp_src; return 1; }
574 done
575 else
576 if ! check_for_var_modification src _pkg && ! [ "$target" ]; then
577 src="${src%/*}/$(ls $tmp_src)"
578 fi
579 mv $(echo $tmp_src/*) "$src" || { report end-step; rm -r $tmp_src; return 1; }
580 fi
581 rm -r $tmp_src
582 else
583 [ -d "$tmp_src" ] && rm -r $tmp_src
584 echo "There's already something at $src. Abort." >&2
585 fi
586 report end-step
587 }
589 # Log and execute compile_rules function if it exists, to configure and
590 # make the package if it exists.
591 check_for_compile_rules()
592 {
593 if grep -q ^compile_rules $RECEIPT; then
594 echo "executing compile_rules" >> $LOG
595 report step "Executing compile_rules"
596 cd $WOK/$PACKAGE
597 rm -f /tmp/config.site
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 subversion\|*)
700 file=${file#subversion|}
701 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/subversion/receipt ] && tazpkg get-install subversion --forced
702 if [ -f $INSTALLED/subversion/receipt ]; then
703 mkdir $tmp_src
704 cd $tmp_src
705 if [ "$BRANCH" ]; then
706 echo t | svn co $file -r $BRANCH ${src##*/} && rm -rf ${src##*/}/.svn* && break
707 else
708 echo t | svn co $file ${src##*/} && rm -rf ${src##*/}/.svn* && break
709 fi
710 revert_vcs_failure
711 else
712 tazwok_warning "Needs subversion to download the source tarball from $file, please add it as build-depend."
713 continue
714 fi
715 ;;
716 mercurial\|*)
717 file=${file#mercurial|}
718 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/mercurial/receipt ] && tazpkg get-install mercurial --forced
719 if [ -f $INSTALLED/mercurial/receipt ]; then
720 mkdir $tmp_src
721 cd $tmp_src
722 if [ "$BRANCH" ]; then
723 hg clone $file --rev $BRANCH ${src##*/} && rm -rf ${src##*/}/.hg* && break
724 else
725 hg clone $file ${src##*/} && rm -rf ${src##*/}/.hg* && break
726 fi
727 revert_vcs_failure
728 else
729 tazwok_warning "Needs mercurial to download the source tarball from $file, please add it as build-depend."
730 continue
731 fi
732 ;;
733 https*)
734 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/wget/receipt ] && tazpkg get-install wget --forced
735 if [ -d $INSTALLED/wget ]; then
736 if [ "${WGET_URL%$TARBALL}" = "$WGET_URL" ] && [ "$file" = "$WGET_URL" ]; then
737 wget -q --no-check-certificate -O $TARBALL $file && break
738 else
739 wget -q --no-check-certificate $file && break
740 fi
741 else
742 tazwok_warning "Needs wget to download the source tarball from $file, please add it as build-depend."
743 continue
744 fi
745 ;;
746 http*|ftp*)
747 # Handle crappy URL.
748 if [ "$COMMAND" = get-src ]; then
749 if [ "${DEPENDS/wget}" != "$DEPENDS" ] || [ "${BUILD_DEPENDS/wget}" != "$BUILD_DEPENDS" ]; then
750 [ -f $INSALLED/wget/receipt ] || tazpkg get-install wget --forced
751 fi
752 fi
753 if [ "${WGET_URL%$TARBALL}" = "$WGET_URL" ] && [ "$file" = "$WGET_URL" ]; then
754 wget -q -O $TARBALL $file && break
755 else
756 wget -q $file && break
757 fi
758 ;;
759 esac
760 done
761 }
763 # Regenerate every package that wants a PACKAGE compiled
764 refresh_packages_from_compile()
765 {
766 # make tazwok genpkg happy
767 mkdir $WOK/$PACKAGE/taz
769 # Cook rwanted in default or specied order
770 genlist=" $(look_for_rwanted | tr '\n' ' ') "
771 for i in $(look_for_cookopt genpkg | tac); do
772 [ "${genlist/ $i }" = "$genlist" ] && continue
773 genlist=" $i${genlist/ $i / }"
774 done
775 if [ "$genlist" ]; then
776 local PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
777 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
778 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
779 src _pkg DESTDIR CONFIG_SITE RECEIPT LOG stuff wanted_stuff
780 for PACKAGE in $genlist; do
781 set_common_path
782 gen_package
783 done
784 fi
785 }
787 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
788 # so some packages need to copy these files with the receipt and genpkg_rules.
789 # This function is executed by gen_package when 'tazwok genpkg'.
790 copy_generic_files()
791 {
792 # In most cases, locales are in $_pkg/usr/share/locale so we copy files
793 # using generic variables and $LOCALE from Tazwok config file.
794 if [ "$LOCALE" ]; then
795 if [ -d "$_pkg/usr/share/locale" ]; then
796 for i in $LOCALE
797 do
798 if [ -d "$_pkg/usr/share/locale/$i" ]; then
799 mkdir -p $fs/usr/share/locale
800 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
801 fi
802 done
803 fi
804 fi
806 # Pixmaps (PNG or/and XPM only). Some icons/images can be added through
807 # genpkg_rules and generic copy can be disabled with GENERIC_PIXMAPS="no"
808 # in pkg receipt.
809 if [ "$GENERIC_PIXMAPS" != "no" ]; then
810 if [ -d "$_pkg/usr/share/pixmaps" ]; then
811 mkdir -p $fs/usr/share/pixmaps
812 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
813 $fs/usr/share/pixmaps 2>/dev/null
814 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
815 $fs/usr/share/pixmaps 2>/dev/null
816 fi
818 # Custom or homemade PNG pixmap can be in stuff.
819 if [ -f "stuff/$PACKAGE.png" ]; then
820 mkdir -p $fs/usr/share/pixmaps
821 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
822 fi
823 fi
825 # Desktop entry (.desktop).
826 if [ -d "$_pkg/usr/share/applications" ]; then
827 cp -a $_pkg/usr/share/applications $fs/usr/share
828 fi
830 # Homemade desktop file(s) can be in stuff.
831 if [ -d "stuff/applications" ]; then
832 mkdir -p $fs/usr/share
833 cp -a stuff/applications $fs/usr/share
834 fi
835 if [ -f "stuff/$PACKAGE.desktop" ]; then
836 mkdir -p $fs/usr/share/applications
837 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
838 fi
839 }
841 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
842 strip_package()
843 {
844 report step "Executing strip on all files"
846 # Binaries.
847 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
848 do
849 if [ -d "$dir" ]; then
850 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
851 fi
852 done
854 # Libraries.
855 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
856 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
857 report end-step
858 }
860 # Remove .pyc and .pyo files from packages
861 py_compiled_files_remove()
862 {
863 report step "Removing all .pyc and .pyo files from package ..."
864 find $fs -type f -name "*.pyc" -delete 2>/dev/null
865 find $fs -type f -name "*.pyo" -delete 2>/dev/null
866 report end-step
867 }
869 # Check FSH in a slitaz package (Path: /:/usr)
870 check_fsh()
871 {
872 cd $WOK/$PACKAGE/taz/*/fs
873 [ -n "$FSH" ] || FSH="bin boot dev etc home init lib media mnt proc \
874 root sbin share sys tmp usr var vz usr/bin usr/games usr/include usr/lib \
875 usr/local usr/sbin usr/share usr/src"
876 for i in `ls -d * usr/* 2>/dev/null`
877 do
878 if ! echo $FSH | fgrep -q $i; then
879 echo "Wrong path: /$i" >&2
880 error=1
881 fi
882 done
883 if [ "$error" = "1" ]; then
884 cat << _EOT_
886 Package will install files in a non standard directory and won't be generated.
887 You may have a wrong copy path in genpkg_rules or need to add some options to
888 configure in compile_rules. Some valid options for SliTaz (Linux FSH):
890 --prefix=/usr
891 --sysconfdir=/etc
892 --libexecdir=/usr/lib/(pkgname)
893 --localstatedir=/var
894 --mandir=/usr/share/man
895 --infodir=/usr/share/info
897 For more information please read SliTaz docs and run: ./configure --help
898 ================================================================================
899 $PACKAGE package generation aborted.
901 _EOT_
903 # Dont generate a corrupted package.
904 cd $WOK/$PACKAGE && rm -rf taz
905 report exit
906 fi
907 }
909 gen_cookmd5()
910 {
911 # md5sum of cooking stuff make tazwok able to check for changes
912 # without hg.
913 cd $WOK/$PACKAGE
914 md5sum receipt > md5
915 [ -f description.txt ] && md5sum description.txt >> md5
916 if [ -d stuff ]; then
917 find stuff | while read file; do
918 md5sum $file >> md5
919 done
920 fi
921 }
923 # Create a package tree and build the gziped cpio archive
924 # to make a SliTaz (.tazpkg) package.
925 gen_package()
926 {
927 check_root
928 check_for_package_on_cmdline
929 check_for_receipt
930 EXTRAVERSION=""
931 . $RECEIPT
933 # May compute VERSION
934 if grep -q ^get_version $RECEIPT; then
935 get_version
936 fi
937 check_for_wanted
938 cd $WOK/$PACKAGE
940 # Remove old Tazwok package files.
941 [ -d "taz" ] && rm -rf taz
943 # Create the package tree and set useful variables.
944 mkdir -p $WOK/$PACKAGE/taz/$PACKAGE-$VERSION/fs
945 fs=$WOK/$PACKAGE/taz/$PACKAGE-$VERSION/fs
947 # Set $src for standard package and $_pkg variables.
948 set_src_path
949 set_pkg_path
951 # Execute genpkg_rules, check package and copy generic files to build
952 # the package.
953 report step "Building $PACKAGE with the receipt"
954 report open-bloc
955 if grep -q ^genpkg_rules $RECEIPT; then
957 # Log process.
958 echo "executing genpkg_rules" >> $LOG
959 report step "Executing genpkg_rules"
960 genpkg_rules
961 report end-step
962 check_fsh
963 cd $WOK/$PACKAGE
965 # Skip generic files for packages with a WANTED variable
966 # (dev and splited pkgs).
967 if [ ! "$WANTED" ]; then
968 copy_generic_files
969 fi
970 look_for_cookopt !strip || strip_package
971 py_compiled_files_remove
972 else
973 echo "No package rules to gen $PACKAGE..." >&2
974 report exit
975 fi
977 # Copy the receipt and description (if exists) into the binary package tree.
978 cd $WOK/$PACKAGE
979 report step "Copying the receipt"
980 cp receipt taz/$PACKAGE-$VERSION
981 report end-step
982 if grep -q ^get_version $RECEIPT; then
983 report step "Updating version in receipt"
984 sed -i "s/^VERSION=.*/VERSION=\"$VERSION\"/" \
985 taz/$PACKAGE-$VERSION/receipt
986 report end-step
987 fi
988 if [ -f "description.txt" ]; then
989 report step "Copying the description file"
990 cp description.txt taz/$PACKAGE-$VERSION
991 report end-step
992 fi
994 # Generate md5 of cooking stuff to look for commit later.
995 gen_cookmd5
996 echo -e "\n# md5sum of cooking stuff :" >> taz/$PACKAGE-$VERSION/receipt
997 cat md5 | sed 's/^/# /' >> taz/$PACKAGE-$VERSION/receipt
999 # Create the files.list by redirecting find output.
1000 report step "Creating the list of files"
1001 cd taz/$PACKAGE-$VERSION
1002 LAST_FILE=""
1003 { find fs -print; echo; } | while read file; do
1004 if [ "$LAST_FILE" ]; then
1005 case "$file" in
1006 $LAST_FILE/*)
1007 case "$(ls -ld "$LAST_FILE")" in
1008 drwxr-xr-x\ *\ root\ *\ root\ *);;
1009 *) echo ${LAST_FILE#fs};;
1010 esac;;
1011 *) echo ${LAST_FILE#fs};;
1012 esac
1013 fi
1014 LAST_FILE="$file"
1015 done > files.list
1017 # Next, check if something has changed in lib files.
1018 if fgrep -q '.so' files.list; then
1019 for rep in $INCOMING_REPOSITORY $PACKAGES_REPOSITORY \
1020 $([ "$undigest" ] && echo $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming && \
1021 echo $SLITAZ_DIR/$SLITAZ_VERSION/packages); do
1022 prev_VERSION=$(get_pkg_version $rep)
1023 [ "$prev_VERSION" ] && pkg_file=$rep/$PACKAGE-$prev_VERSION.tazpkg && break
1024 done
1025 if [ "$pkg_file" ]; then
1026 report step "Look for major/minor update in libraries"
1027 get_pkg_files $pkg_file
1028 cd $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
1029 fgrep ".so" files.list | egrep -v "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*" | \
1030 while read lib; do
1031 fgrep -q "$lib" $pkg_files_dir/files.list && continue
1032 echo "A minor/major update in libraries is detected, planning re-cook of reverse-depends of $PACKAGE."
1033 for rdep in $(scan $PACKAGE --look_for=rdep | use_wanted); do
1034 [ "$rdep" = "${WANTED:-$PACKAGE}" ] && continue
1035 grep -q ^$rdep$ $PACKAGES_REPOSITORY/blocked \
1036 $PACKAGES_REPOSITORY/cooklist && continue
1037 echo $rdep >> $PACKAGES_REPOSITORY/cooklist
1038 done
1039 regen_cooklist=yes
1040 break
1041 done
1042 rm -r $pkg_files_dir
1043 unset pkg_file
1044 report end-step
1045 fi
1046 fi
1047 if [ ! "$EXTRAVERSION" ]; then
1048 case "$PACKAGE" in
1049 linux*);;
1050 *) EXTRAVERSION="$(grep '/lib/modules/.*-slitaz/' files.list |\
1051 head -1 | sed 's|/lib/modules/\(.*\)-slitaz/.*|_\1|')";;
1052 esac
1053 fi
1054 rm -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
1055 report step "Creating md5sum of files"
1056 while read file; do
1057 [ -L "fs$file" ] && continue
1058 [ -f "fs$file" ] || continue
1059 md5sum "fs$file" | sed 's/ fs/ /'
1060 done < files.list > md5sum
1061 report end-step
1062 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
1063 2> /dev/null | awk '{ sz=$1 } END { print sz }')
1065 # Build cpio archives. Find, cpio and gzip the fs, finish by
1066 # removing the fs tree.
1067 # Don't log this because compression always output error messages.
1068 find fs -print | cpio -o -H newc | case "$PACKAGE-$COMPRESSION" in
1069 tazpkg-lzma) gzip > fs.cpio.gz;;
1070 *-lzma) lzma e fs.cpio.lzma -si;;
1071 *) gzip > fs.cpio.gz;;
1072 esac && rm -rf fs
1073 PACKED_SIZE=$(du -chs fs.cpio.* receipt files.list md5sum \
1074 description.txt 2> /dev/null | awk '{ sz=$1 } END { print sz }')
1075 report step "Updating receipt sizes"
1076 sed -i '/^PACKED_SIZE/d' receipt
1077 sed -i '/^UNPACKED_SIZE/d' receipt
1078 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
1079 sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
1080 report end-step
1081 if [ "$EXTRAVERSION" ]; then
1082 report step "Updating receipt EXTRAVERSION"
1083 sed -i s/^EXTRAVERSION.*$// receipt
1084 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
1085 fi
1086 prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
1087 remove_previous_package $INCOMING_REPOSITORY
1088 report step "Creating full cpio archive"
1089 find . -print | cpio -o -H newc > $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
1091 # Restore package tree in case we want to browse it.
1092 report step "Restoring original package tree"
1093 { zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma; } | cpio --quiet -id
1094 rm fs.cpio.* && cd ..
1096 # Log process.
1097 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
1098 report close-bloc
1099 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
1100 echo "Size : `du -sh $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
1101 echo ""
1103 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/broken
1104 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/commit
1105 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/cooklist
1108 ########################################################################
1109 # This section contains functions used by several other functions
1110 # bellow.
1111 ########################
1113 # Look for receipt/files.list in wok. If they can't be found, get them
1114 # from package. Accept one argument : absolute path to package.
1115 get_pkg_files()
1117 pkg_files_dir=$tmp/$(basename ${1%.tazpkg})
1118 mkdir -p $pkg_files_dir && \
1119 cd $pkg_files_dir && \
1120 cpio --quiet -idm receipt < $1 && \
1121 cpio --quiet -idm files.list < $1
1124 ########################################################################
1125 # This section contains functions to generate packages databases.
1126 ########################
1129 gen_packages_db()
1131 # pkg_repository can be $PACKAGES_REPOSITORY or $INCOMING_REPOSITORY.
1132 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
1133 cd $pkg_repository
1134 report step "Generating packages lists: $pkg_repository"
1135 report open-bloc
1136 report step "Removing old files"
1137 for file in files.list.lzma packages.list packages.txt \
1138 packages.desc packages.equiv packages.md5; do
1139 [ -f $file ] && rm $file
1140 done
1141 touch files.list
1143 packages_db_start
1144 unset RECEIPT
1145 report step "Reading datas from all packages"
1146 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1147 get_packages_info
1148 done
1149 report end-step
1150 packages_db_end
1151 report close-bloc
1154 update_packages_db()
1156 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
1157 cd $pkg_repository
1158 for file in packages.list packages.equiv packages.md5 packages.desc \
1159 packages.txt; do
1160 if [ ! -f "$file" ]; then
1161 gen_packages_db
1162 return
1163 fi
1164 done
1165 if [ -f files.list.lzma ]; then
1166 lzma d files.list.lzma files.list
1167 else
1168 gen_packages_db
1169 fi
1170 report step "Updating packages lists: $pkg_repository"
1171 packages_db_start
1173 # Look for removed/update packages.
1174 for PACKAGE in $(grep ^[0-9,a-z,A-Z] packages.txt); do
1175 pkg="$pkg_repository/$(grep -m1 ^$PACKAGE- packages.list).tazpkg"
1176 if ! [ -f "$pkg" ]; then
1177 erase_package_info
1178 else
1179 if [ "$pkg" -nt "packages.list" ]; then
1180 updated_pkg="$updated_pkg
1181 $PACKAGE $pkg"
1182 elif [ ! -f $WOK/$PACKAGE/receipt ] && \
1183 [ "$COMMAND" = check-incoming -o "$pkg_repository" = "$INCOMING_REPOSITORY" ]; then
1184 erase_package_info
1185 echo "Removing $PACKAGE from $pkg_repository."
1186 rm $pkg
1187 [ -d $WOK/$PACKAGE ] && rm -r $WOK/$PACKAGE
1188 sed "/^$PACKAGE\t/d" -i $wan_db $dep_db
1189 for i in cookorder.txt cooklist commit blocked broken; do
1190 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/$i
1191 done
1192 rm -f $LOCAL_REPOSITORY/log/$PACKAGE.html
1193 if [ "$pkg_repository" = "$INCOMING_REPOSITORY" ] && \
1194 [ "$(sed 1!d $PACKAGES_REPOSITORY/cookorder.txt)" != "#PlanSort" ] ; then
1195 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
1196 regen_cooklist=yes
1197 else
1198 echo "$PACKAGE" >> $PACKAGES_REPOSITORY/removed
1199 sed -n '1,10p' -i $PACKAGES_REPOSITORY/removed
1200 fi
1201 fi
1202 fi
1203 done
1204 echo "$updated_pkg" | sed 1d | while read PACKAGE pkg; do
1205 erase_package_info
1206 get_packages_info
1207 done
1208 unset updated_pkg
1210 # Look for new packages.
1211 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1212 if ! fgrep -q " ${pkg##*/}" $pkg_repository/packages.md5; then
1213 get_packages_info
1214 fi
1215 done
1216 report end-step
1217 packages_db_end
1220 packages_db_start()
1222 if [ ! -s packages.txt ]; then
1223 echo "# SliTaz GNU/Linux - Packages list
1225 # Packages : unknow
1226 # Date : $(date +%Y-%m-%d\ \%H:%M:%S)
1228 " > packages.txt
1229 else
1230 sed -e 's/^# Packages :.*/# Packages : unknow/' \
1231 -e "s/# Date :.*/# Date : $(date +%Y-%m-%d\ \%H:%M:%S)/" \
1232 -i packages.txt
1233 fi
1235 # Needed in some case as tazwok define RECEIPT at configuration time
1236 # in this particular case it can broke the script.
1237 unset RECEIPT
1240 erase_package_info()
1242 cd $pkg_repository
1243 sed "/^$PACKAGE$/,/^$/d" -i packages.txt
1244 sed "/^$PACKAGE /d" -i packages.desc
1245 sed -e "s/=$PACKAGE /= /" -e "s/ $PACKAGE / /" -e "s/ $PACKAGE$//" \
1246 -e "/=$PACKAGE$/d" -e "s/=[0-9,a-z,A-Z]:$PACKAGE /= /" \
1247 -e "s/ [0-9,a-z,A-Z]:$PACKAGE / /" -e "s/ [0-9,a-z,A-Z]:$PACKAGE$/ /" \
1248 -e "/=[0-9,a-z,A-Z]:$PACKAGE$/d" \
1249 -i packages.equiv
1250 sed "/^$PACKAGE:/d" -i files.list
1251 sed "/^$(basename ${pkg%.tazpkg})$/d" -i packages.list
1252 sed "/ $(basename $pkg)$/d" -i packages.md5
1255 get_packages_info()
1257 # If there's no taz folder in the wok, extract infos from the
1258 # package.
1259 get_pkg_files $pkg
1260 source_receipt
1261 echo "Getting datas from $PACKAGE"
1263 cat >> $pkg_repository/packages.txt << _EOT_
1264 $PACKAGE
1265 $VERSION$EXTRAVERSION
1266 $SHORT_DESC
1267 _EOT_
1268 if [ "$PACKED_SIZE" ]; then
1269 cat >> $pkg_repository/packages.txt << _EOT_
1270 $PACKED_SIZE ($UNPACKED_SIZE installed)
1272 _EOT_
1273 else
1274 echo "" >> $pkg_repository/packages.txt
1275 fi
1277 # Packages.desc is used by Tazpkgbox <tree>.
1278 echo "$PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> $pkg_repository/packages.desc
1280 # Packages.equiv is used by tazpkg install to check depends
1281 for i in $PROVIDE; do
1282 DEST=""
1283 echo $i | fgrep -q : && DEST="${i#*:}:"
1284 if grep -qs ^${i%:*}= $pkg_repository/packages.equiv; then
1285 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" $pkg_repository/packages.equiv
1286 else
1287 echo "${i%:*}=$DEST$PACKAGE" >> $pkg_repository/packages.equiv
1288 fi
1289 done
1291 if [ -f files.list ]; then
1292 { echo "$PACKAGE"; cat files.list; } | awk '
1293 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }' >> $pkg_repository/files.list
1294 fi
1296 cd .. && rm -r "$pkg_files_dir"
1298 cd $pkg_repository
1299 echo $(basename ${pkg%.tazpkg}) >> packages.list
1300 [ ! "$package_md5" ] && package_md5=$(md5sum $(basename $pkg))
1301 echo "$package_md5" >> packages.md5
1302 unset package_md5
1305 source_receipt()
1307 unset PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
1308 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
1309 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
1310 src _pkg DESTDIR CONFIG_SITE BRANCH TARBALL stuff wanted_stuff
1311 . ${RECEIPT:-$PWD/receipt}
1314 packages_db_end()
1316 cd $pkg_repository
1317 pkgs=$(wc -l packages.list | sed 's/ .*//')
1318 sed "s/# Packages : .*/# Packages : $pkgs/" -i packages.txt
1320 # If lists was updated it's generally needed to sort them well.
1321 if ! sort -c packages.list 2> /dev/null; then
1322 report step "Sorting packages lists"
1323 for file in packages.list packages.desc packages.equiv; do
1324 [ -f $file ] || continue
1325 sort -o $file $file
1326 done
1327 report end-step
1328 fi
1330 # Dont log this because lzma always output error.
1331 lzma e files.list files.list.lzma
1332 rm -f files.list
1333 [ -f packages.equiv ] || touch packages.equiv
1336 ########################################################################
1337 # This section contains functions to generate wok database.
1338 ########################
1340 gen_wok_db()
1342 report step "Generating wok database"
1343 report open-bloc
1344 report step "Removing old files"
1345 for file in $wan_db $dep_db $PACKAGES_REPOSITORY/cookorder.txt; do
1346 [ -f $file ] && rm $file
1347 done
1348 report step "Generating wok-wanted.txt"
1349 gen_wan_db
1350 report step "Generating wok-depends.txt"
1351 for PACKAGE in $(cut -f1 -d '|' $PACKAGES_REPOSITORY/packages.desc \
1352 $INCOMING_REPOSITORY/packages.desc | sort -u); do
1353 RECEIPT=$WOK/$PACKAGE/receipt
1354 if [ -s $RECEIPT ]; then
1355 source_receipt
1356 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
1357 fi
1358 done
1359 sort_db
1360 report close-bloc
1363 gen_wan_db()
1365 for RECEIPT in $(fgrep -l WANTED $WOK/*/receipt); do
1366 WANTED=
1367 source $RECEIPT
1368 [ "$WANTED" ] || continue
1369 echo -e $PACKAGE"\t"$WANTED >> $tmp/wan_db
1370 done
1371 if ! [ -f $wan_db ] || [ "$(diff -q $tmp/wan_db $wan_db)" ]; then
1372 mv -f $tmp/wan_db $wan_db
1373 plan_regen_cookorder=yes
1374 else
1375 rm $tmp/wan_db
1376 fi
1379 update_wan_db()
1381 local PACKAGE=$PACKAGE
1382 for RECEIPT in $(fgrep WANTED $WOK/*/receipt | \
1383 fgrep $PACKAGE | cut -f1 -d ':'); do
1384 WANTED=
1385 source $RECEIPT
1386 [ "$WANTED" ] || continue
1387 wan_info=$(echo -e $PACKAGE"\t"$WANTED)
1388 [ "$wan_info" = "$(grep -m1 ^$PACKAGE$'\t' $wan_db 2>/dev/null)" ] && return
1389 sed "/^$PACKAGE\t/d" -i $wan_db
1390 echo "$wan_info" >> $wan_db
1391 plan_regen_cookorder=yes
1392 plan_sort_wandb=yes
1393 done
1396 update_dep_db()
1398 dep_info=$(echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ')
1399 [ "$dep_info" = "$(grep -m1 ^$PACKAGE$'\t' $dep_db 2>/dev/null)" ] && return
1400 sed "/^$PACKAGE\t/d" -i $dep_db
1401 echo "$dep_info" >> $dep_db
1402 plan_regen_cookorder=yes
1403 plan_sort_depdb=yes
1406 sort_db()
1408 report step "Generating cookorder.txt"
1409 cat $dep_db | sed 's/ \t / /' | while read PACKAGE BUILD_DEPENDS; do
1410 grep -q ^$PACKAGE$'\t' $wan_db && continue
1412 # Replace each BUILD_DEPENDS with a WANTED package by it's
1413 # WANTED package.
1414 replace_by_wanted()
1416 for p in $BUILD_DEPENDS; do
1417 if grep -q ^$p$'\t' $wan_db; then
1418 echo -n $(grep ^$p$'\t' $wan_db | cut -f 2)' '
1419 else
1420 echo -n $p' '
1421 fi
1422 done | tr ' ' '\n' | sort -u | sed "/^$PACKAGE$/d" | tr '\n' ' '
1424 echo -e $PACKAGE"\t $(replace_by_wanted) "
1425 done > $tmp/db
1426 while [ -s "$tmp/db" ]; do
1427 status=start
1428 for pkg in $(cut -f 1 $tmp/db); do
1429 if ! fgrep -q ' '$pkg' ' $tmp/db; then
1430 echo $pkg >> $tmp/cookorder
1431 sed -e "/^$pkg\t/d" -e "s/ $pkg / /g" -i $tmp/db
1432 status=proceed
1433 fi
1434 done
1435 if [ "$status" = start ]; then
1436 cp -f $tmp/db /tmp/remain-depends.txt
1437 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
1438 for blocked in $(cut -f 1 $tmp/db); do
1439 echo "$blocked" >> $PACKAGES_REPOSITORY/blocked
1440 done
1441 break
1442 fi
1443 done
1444 [ -s $tmp/cookorder ] || touch $tmp/cookorder
1446 # The toolchain packages are moved in first position.
1447 grep $(for pkg in `scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1448 --look_for=all --with_args`; do echo " -e ^$pkg$"; done) \
1449 $tmp/cookorder | tac > $PACKAGES_REPOSITORY/cookorder.txt
1450 for pkg in $(cat $PACKAGES_REPOSITORY/cookorder.txt); do
1451 sed "/^$pkg$/d" -i $tmp/cookorder
1452 done
1454 tac $tmp/cookorder >> $PACKAGES_REPOSITORY/cookorder.txt
1455 unset plan_regen_cookorder
1456 report end-step
1459 ########################################################################
1460 # SCAN CORE
1461 ########################
1462 # Include various scan core-functions. It's not intended to be used
1463 # directly : prefer scan wrappers in next section.
1465 look_for_dep()
1467 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1468 grep -m1 ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt \
1469 | cut -f 2
1470 else
1471 grep -m1 ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1472 cut -f 2
1473 fi
1476 look_for_bdep()
1478 look_for_all
1481 look_for_all()
1483 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1484 grep -m1 ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt \
1485 | cut -f 2,3 | sed 's/ / /'
1486 else
1487 grep -m1 ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1488 cut -f 2,3 | sed 's/ / /'
1489 fi
1492 look_for_rdep()
1494 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | cut -f 1
1495 if [ "$undigest" ]; then
1496 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt | cut -f 1); do
1497 if [ ! -f "WOK$/$rdep/receipt" ]; then
1498 echo "$rdep"
1499 fi
1500 done
1501 fi
1504 look_for_rbdep()
1506 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | \
1507 cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
1508 if [ "$undigest" ]; then
1509 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt \
1510 | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1); do
1511 if [ ! -f "WOK$/$rdep/receipt" ]; then
1512 echo "$rdep"
1513 fi
1514 done
1515 fi
1518 # Return WANTED if it exists.
1519 look_for_wanted()
1521 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1522 grep -m1 ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-wanted.txt | cut -f 2
1523 else
1524 grep -m1 ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 2
1525 fi
1528 # Return packages which wants PACKAGE.
1529 look_for_rwanted()
1531 grep $'\t'$PACKAGE$ $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 1
1532 if [ "$undigest" ]; then
1533 for rwanted in $(grep $'\t'$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-wanted.txt | cut -f 1); do
1534 if [ ! -f "$WOK/$rwanted/receipt" ]; then
1535 echo "$rwanted"
1536 fi
1537 done
1538 fi
1541 look_for_dev()
1543 WANTED=$(look_for_wanted)
1544 if [ "$WANTED" ]; then
1545 if [ "$undigest" ] && [ ! -f "$WOK/$WANTED/receipt" ]; then
1546 [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$WANTED-dev/receipt" ] && echo $WANTED-dev
1547 else
1548 [ -f "$WOK/$WANTED-dev/receipt" ] && echo $WANTED-dev
1549 fi
1550 fi
1551 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1552 [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
1553 else
1554 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
1555 fi
1558 with_dev()
1560 for PACKAGE in $(cat); do
1561 echo $PACKAGE
1562 look_for_dev
1563 done
1566 with_wanted()
1568 for PACKAGE in $(cat); do
1569 echo $PACKAGE
1570 look_for_wanted
1571 done
1574 use_wanted()
1576 for input in $(cat); do
1577 { grep ^$input$'\t' $wan_db || echo $input
1578 } | sed 's/.*\t//'
1579 done
1582 ########################################################################
1583 # SCAN
1584 ########################
1585 # Use wok-wanted.txt and wok-depeds.txt to scan depends.
1586 # Option in command line (must be first arg) :
1587 # --look_for=bdep/rbdep - Look for depends or reverse depends.
1588 # --with_dev - Add development packages (*-dev) in the result.
1589 # --with_wanted - Add package+reverse wanted in the result.
1590 # --with_args - Include packages in argument in the result.
1592 scan()
1594 # Get packages in argument.
1595 local PACKAGE=$PACKAGE WANTED=$WANTED pkg_list=
1596 for arg in $@; do
1597 [ "$arg" = "${arg#--}" ] || continue
1598 pkg_list="$pkg_list $arg"
1599 done
1601 # Get options.
1602 [ "$pkg_list" ] || return
1603 local cooklist= look_for= with_dev= with_wanted= with_args= log_command="$0 $@" \
1604 get_options_list="look_for with_dev with_wanted with_args cooklist use_wanted"
1605 get_options
1607 # Cooklist is a special case where we need to modify a little
1608 # scan behavior
1609 if [ "$cooklist" ]; then
1610 gen_wan_db
1611 look_for=all && with_args=yes && with_dev= && with_wanted=
1612 filter=use_wanted
1613 if [ "$COMMAND" = gen-cooklist ]; then
1614 for PACKAGE in $pkg_list; do
1615 grep -q ^$PACKAGE$'\t' $dep_db && continue
1616 [ -d "$WOK/$p" ] || continue
1617 check_for_missing
1618 done
1619 append_to_dep()
1621 if ! grep -q ^$PACKAGE$'\t' $dep_db; then
1622 check_for_missing && echo $PACKAGE >> $tmp/dep
1623 else
1624 echo $PACKAGE >> $tmp/dep
1625 fi
1627 else
1628 append_to_dep()
1630 check_for_commit && echo $PACKAGE >> $tmp/dep
1632 fi
1633 else
1634 append_to_dep()
1636 echo $PACKAGE >> $tmp/dep
1638 # If requested packages are not in dep_db, partial generation of this db is needed.
1639 for PACKAGE in $pkg_list; do
1640 grep -q ^$PACKAGE$'\t' $dep_db && continue
1641 [ -d "$WOK/$p" ] || continue
1642 plan_check_for_missing=yes
1643 check_for_missing
1644 done
1645 if [ "$plan_check_for_missing" ]; then
1646 append_to_dep()
1648 if ! grep -q ^$PACKAGE$'\t' $dep_db; then
1649 check_for_missing && echo $PACKAGE >> $tmp/dep
1650 else
1651 echo $PACKAGE >> $tmp/dep
1652 fi
1654 check_db_status=yes
1655 unset plan_check_for_missing
1656 fi
1657 fi
1659 [ "$with_dev" ] && filter=with_dev
1660 [ "$with_wanted" ] && filter=with_wanted
1661 if [ "$filter" ]; then
1662 pkg_list=$(echo $pkg_list | $filter | sort -u)
1663 scan_pkg()
1665 look_for_$look_for | $filter
1667 else
1668 scan_pkg()
1670 look_for_$look_for
1672 fi
1673 touch $tmp/dep
1674 for PACKAGE in $pkg_list; do
1675 [ "$with_args" ] && append_to_dep
1676 scan_pkg
1677 done | tr ' ' '\n' | sort -u > $tmp/list
1678 [ "$look_for" = bdep ] && look_for=dep
1679 while [ -s $tmp/list ]; do
1680 PACKAGE=$(sed 1!d $tmp/list)
1681 sed 1d -i $tmp/list
1682 append_to_dep
1683 for pkg in $(scan_pkg); do
1684 if ! grep -q ^$pkg$ $tmp/list $tmp/dep; then
1685 echo $pkg >> $tmp/list
1686 fi
1687 done
1688 done
1689 if [ "$cooklist" ]; then
1690 mv $tmp/dep $tmp/cooklist
1691 else
1692 cat $tmp/dep | sort -u
1693 fi
1694 rm -f $tmp/dep $tmp/list
1695 if [ "$check_db_status" ]; then
1696 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
1697 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
1698 if [ "$plan_regen_cookorder" ] && \
1699 [ "$(sed 1!d $PACKAGES_REPOSITORY/cookorder.txt)" != "#PlanSort" ]; then
1700 grep -q "^#" $PACKAGES_REPOSITORY/cookorder.txt || \
1701 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
1702 fi
1703 fi
1706 ########################################################################
1707 # This section contains functions to check package repository and
1708 # find which packages to cook.
1709 ########################
1711 check_for_missing()
1713 local PACKAGE=$PACKAGE
1714 if ! check_for_pkg_in_wok; then
1715 [ "$?" = 2 ] && return 1
1716 return
1717 fi
1718 RECEIPT=$WOK/$PACKAGE/receipt
1719 source_receipt
1720 PACKAGE=${WANTED:-$PACKAGE}
1721 update_wan_db
1722 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
1723 RECEIPT=$WOK/$PACKAGE/receipt
1724 source_receipt
1725 update_dep_db
1726 done
1729 check_for_commit()
1731 if ! check_for_pkg_in_wok; then
1732 [ "$?" = 2 ] && return 1
1733 return
1734 fi
1735 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
1736 RECEIPT=$WOK/$PACKAGE/receipt
1737 source_receipt
1739 # We use md5 of cooking stuff in the packaged receipt to check
1740 # commit. We look consecutively in 3 different locations :
1741 # - in the wok/PACKAGE/taz/* folder
1742 # - in the receipt in the package in incoming repository
1743 # - in the receipt in the package in packages repository
1744 # If md5sum match, there's no commit.
1745 check_for_commit_using_md5sum()
1747 if [ ! -f $WOK/$PACKAGE/md5 ]; then
1748 sed -n '/# md5sum of cooking stuff :/,$p' receipt | \
1749 sed -e 1d -e 's/^# //' > $WOK/$PACKAGE/md5
1750 cd $WOK/$PACKAGE
1751 fi
1753 if [ -s md5 ]; then
1754 if md5sum -cs md5; then
1756 # If md5sum check if ok, check for new/missing files in
1757 # cooking stuff.
1758 for file in $([ -f receipt ] && echo receipt; \
1759 [ -f description.txt ] && echo description.txt; \
1760 [ -d stuff ] && find stuff); do
1761 if ! fgrep -q " $file" md5; then
1762 set_commited
1763 fi
1764 done
1765 else
1766 set_commited
1767 fi
1768 else
1769 set_commited
1770 fi
1772 set_commited()
1774 ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/commit &&
1775 echo $PACKAGE >> $PACKAGES_REPOSITORY/commit
1776 gen_cookmd5
1777 update_dep_db
1779 taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | fgrep -v '*')
1780 if [ -f $WOK/$PACKAGE/md5 ]; then
1781 cd $WOK/$PACKAGE
1782 check_for_commit_using_md5sum
1783 elif [ "$taz_dir" ]; then
1784 cd $taz_dir
1785 check_for_commit_using_md5sum
1786 else
1787 pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1788 [ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1789 if [ "$pkg" ]; then
1790 get_pkg_files $pkg
1791 check_for_commit_using_md5sum
1792 rm -r $pkg_files_dir
1793 else
1794 set_commited
1795 fi
1796 fi
1797 [ "$forced" ] || echo $PACKAGE >> $tmp/checked
1798 done
1799 return
1802 gen_cook_list()
1804 report step "Scanning wok"
1805 if [ "$pkg" ]; then
1806 scan $pkg --cooklist
1807 else
1808 scan `cat $cooklist` --cooklist
1809 fi
1810 report end-step
1812 [ -s $tmp/checked ] || [ -s $tmp/cooklist ] || return
1814 # Core toolchain should not be cooked unless cook-toolchain is used.
1815 if ! [ -f /etc/config.site.tmptoolchain ] ; then
1816 for PACKAGE in $(scan gcc --look_for=all --with_args --with_wanted); do
1817 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/blocked || \
1818 echo $PACKAGE >> $PACKAGES_REPOSITORY/blocked
1819 done
1820 fi
1822 if [ -s $PACKAGES_REPOSITORY/commit ] && [ "$COMMAND" != gen-cooklist ]; then
1823 cd $PACKAGES_REPOSITORY
1824 for PACKAGE in $(cat commit); do
1825 WANTED="$(look_for_wanted)"
1826 if [ "$WANTED" ]; then
1827 grep -q ^$WANTED$ broken cooklist blocked commit && continue
1828 fi
1829 grep -q ^$PACKAGE$ blocked cooklist && continue
1830 echo $PACKAGE >> cooklist
1831 done
1832 fi
1833 sort_cooklist
1836 sort_cooklist()
1838 if [ "$(sed 1!d $PACKAGES_REPOSITORY/cookorder.txt)" = "#PlanSort" ]; then
1839 sed 1d -i $PACKAGES_REPOSITORY/cookorder.txt
1840 plan_regen_cookorder=yes
1841 fi
1842 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
1843 [ "$plan_regen_cookorder" ] && sort_db
1844 report step "Generating cooklist"
1845 if [ -f "$tmp/checked" ]; then
1846 rm -f $tmp/cooklist
1847 cat $tmp/checked | while read PACKAGE; do
1848 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/cooklist && \
1849 echo $PACKAGE >> $tmp/cooklist
1850 done
1851 elif ! [ "$COMMAND" = gen-cooklist ]; then
1852 cat $PACKAGES_REPOSITORY/blocked | while read PACKAGE; do
1853 sed "/^$PACKAGE/d" -i $tmp/cooklist
1854 done
1855 fi
1856 report end-step
1857 [ -s $tmp/cooklist ] || return
1859 report step "Sorting cooklist"
1860 for PACKAGE in $(cat $tmp/cooklist); do
1861 WANTED="$(look_for_wanted)"
1862 [ "$WANTED" ] || continue
1863 if grep -q ^$WANTED$ $PACKAGES_REPOSITORY/broken $tmp/cooklist; then
1864 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1865 elif [ ! -d $WOK/$WANTED/install ]; then
1866 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1867 echo $WANTED >> $tmp/cooklist
1868 fi
1869 done
1871 # Use cookorder.txt to sort cooklist.
1872 if [ -s $tmp/cooklist ]; then
1873 cat $PACKAGES_REPOSITORY/cookorder.txt | while read PACKAGE; do
1874 if grep -q ^$PACKAGE$ $tmp/cooklist; then
1875 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1876 echo $PACKAGE >> $tmp/cooklist.tmp
1877 fi
1878 done
1880 # Remaining packages in cooklist are thoses without compile_rules.
1881 # They can be cooked first in any order.
1882 if [ -f $tmp/cooklist.tmp ]; then
1883 cat $tmp/cooklist.tmp >> $tmp/cooklist
1884 rm $tmp/cooklist.tmp
1885 fi
1887 cat $tmp/cooklist
1888 [ "$cooklist" = "$PACKAGES_REPOSITORY/cooklist" ] && \
1889 cat $tmp/cooklist > $cooklist
1890 fi
1892 report end-step
1895 look_for_missing_pkg()
1897 for pkg in $(cat $PACKAGES_REPOSITORY/$1); do
1898 grep -q ^$pkg$ $INCOMING_REPOSITORY/packages.txt \
1899 $PACKAGES_REPOSITORY/packages.txt || \
1900 continue
1901 echo $pkg
1902 done
1905 check_for_incoming()
1907 report step "Check that all packages were cooked fine"
1908 [ -s $INCOMING_REPOSITORY/packages.desc ] || {
1909 echo "No packages in $INCOMING_REPOSITORY."
1910 report end-step; return; }
1911 if [ -s $PACKAGES_REPOSITORY/broken ]; then
1912 missingpkg=$(look_for_missing_pkg broken)
1913 if [ "$missingpkg" ]; then
1914 echo "Don't move incoming packages to main repository because theses ones are broken:" >&2
1915 echo "$missingpkg"
1916 report end-step
1917 return 1
1918 fi
1919 fi
1920 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
1921 missingpkg=$(look_for_missing_pkg cooklist)
1922 if [ "$missingpkg" ]; then
1923 echo "Don't move incoming packages to main repository because theses ones needs to be cooked:" >&2
1924 echo "$missingpkg"
1925 report end-step
1926 return 1
1927 fi
1928 fi
1929 incoming_pkgs="$(cut -f 1 -d '|' $INCOMING_REPOSITORY/packages.desc)"
1930 if ! [ "$forced" ]; then
1931 cooklist=$PACKAGES_REPOSITORY/cooklist
1932 pkg="$incoming_pkgs"
1933 gen_cook_list
1934 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
1935 missingpkg=$(look_for_missing_pkg cooklist)
1936 if [ "$missingpkg" ]; then
1937 echo "Don't move incoming packages to main repository because theses ones needs to be cooked:" >&2
1938 echo "$missingpkg"
1939 report end-step
1940 return 1
1941 fi
1942 fi
1943 fi
1945 report step "Moving incoming packages to main repository"
1946 unset EXTRAVERSION
1947 for PACKAGE in $incoming_pkgs; do
1948 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
1949 VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
1950 remove_previous_package $PACKAGES_REPOSITORY
1951 echo "Moving $PACKAGE..."
1952 mv -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION.tazpkg $PACKAGES_REPOSITORY
1953 touch $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
1954 previous_tarball=$(grep ^$PACKAGE:main $SOURCES_REPOSITORY/sources.list | cut -f2)
1955 sed -e "/^$PACKAGE:main/d" \
1956 -e "s/^$PACKAGE:incoming/$PACKAGE:main/" \
1957 -i $SOURCES_REPOSITORY/sources.list
1958 if [ "$previous_tarball" ]; then
1959 grep -q $'\t'$previous_tarball$ $SOURCES_REPOSITORY/sources.list || \
1960 rm -f $SOURCES_REPOSITORY/$previous_tarball
1961 fi
1962 done
1963 for file in packages.list packages.equiv packages.md5 packages.desc \
1964 packages.txt; do
1965 echo -n "" > $INCOMING_REPOSITORY/$file
1966 done
1967 rm -r $INCOMING_REPOSITORY/files.list.lzma
1968 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
1970 report step "Updating flavors"
1971 if [ -x /usr/bin/tazlito ] || [ -x /usr/bin/clean-chroot ]; then
1972 if ! [ -x /usr/bin/tazlito ]; then
1973 tazpkg get-install tazlito
1974 fi
1976 # Handle cases where tazwok is used into main system;
1977 # Handle cases where SLITAZ_DIR is not /home/slitaz.
1978 [ -L /home/slitaz/flavors ] && rm /home/slitaz/flavors
1979 mkdir -p /home/slitaz
1980 ln -s $LOCAL_REPOSITORY/flavors /home/slitaz/flavors
1982 cd $LOCAL_REPOSITORY/packages
1983 for i in $LOCAL_REPOSITORY/flavors/*; do
1984 [ -d "$i" ] || continue
1985 tazlito pack-flavor ${i##*/}
1986 done
1988 noheader=""
1989 for i in *.flavor; do
1990 tazlito show-flavor $i --brief $noheader
1991 noheader="--noheader"
1992 done > flavors.list
1993 [ -x /usr/bin/clean-chroot ] && clean-chroot
1994 else
1995 echo "Can't create up-to-date flavors because tazlito package is missing." >&2
1996 fi
1997 report end-step
2000 ########################################################################
2001 # TAZWOK MAIN FUNCTIONS
2002 ########################
2004 clean()
2006 cd $WOK/$PACKAGE
2007 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
2008 -e ^stuff$ || return
2010 [ "$COMMAND" = clean-wok ] || report step "Cleaning $PACKAGE"
2011 # Check for clean_wok function.
2012 if grep -q ^clean_wok $RECEIPT; then
2013 clean_wok
2014 fi
2015 # Clean should only have a receipt, stuff and optional desc.
2016 for f in `ls .`
2017 do
2018 case $f in
2019 receipt|stuff|description.txt|md5)
2020 continue ;;
2021 *)
2022 rm -rf $f ;;
2023 esac
2024 done
2025 [ "$COMMAND" != clean-wok ] && report end-step
2028 # Configure and make a package with the receipt.
2029 compile_package()
2031 check_for_package_on_cmdline
2033 # Include the receipt to get all needed variables and functions
2034 # and cd into the work directory to start the work.
2035 check_for_receipt
2036 source_receipt
2038 # Log the package name and date.
2039 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
2040 echo "package $PACKAGE (compile)" >> $LOG
2042 # Set wanted $src variable to help compiling.
2043 [ ! "$src" ] && set_src_path
2044 check_for_build_depends || return 1
2045 check_for_wanted
2046 unset target
2047 check_for_tarball && check_for_compile_rules
2050 # Cook command also include all features to manage lists which keep
2051 # track of wok/packages state.
2052 cook()
2054 cook_code=
2055 set_common_path
2056 check_for_receipt
2057 source_receipt
2059 # Define log path and start report.
2060 [ -f $LOCAL_REPOSITORY/log/$PACKAGE.html ] && rm $LOCAL_REPOSITORY/log/$PACKAGE.html
2061 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
2062 echo "$PACKAGE" > $LOCAL_REPOSITORY/log/package
2063 report step "Cooking $PACKAGE"
2064 report open-bloc
2066 clean $PACKAGE
2067 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
2069 if compile_package; then
2070 remove_src
2071 refresh_packages_from_compile
2072 gen_package
2074 # Update packages-incoming repository.
2075 store_pkgname=$PACKAGE
2076 pkg_repository=$INCOMING_REPOSITORY
2077 update_packages_db
2079 PACKAGE=$store_pkgname
2080 unset store_pkgname
2082 # Upgrade to cooked packages if it was previously installed.
2083 report step "Look for package(s) to upgrade"
2084 for pkg in $(look_for_rwanted) $PACKAGE; do
2085 if [ -d $INSTALLED/$pkg ]; then
2086 tazpkg get-install $pkg --forced
2087 fi
2088 done
2089 report end-step
2090 else
2092 # Set package as broken.
2093 if ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then
2094 echo $PACKAGE >> $PACKAGES_REPOSITORY/broken
2095 fi
2096 gen_cookmd5
2097 cook_code=1
2098 fi
2100 # Remove build_depends in cook mode (if in cooklist, it's done when
2101 # checking build_depends of next package and we remove only unneeded
2102 # packages to keep chroot minimal and gain some time).
2103 if [ "$COMMAND" = cook ]; then
2104 remove_build_depends $MISSING_PACKAGE
2105 [ -x /usr/bin/clean-chroot ] && clean-chroot
2106 fi
2108 # Regen the cooklist if it was planned and command is not cook.
2109 [ "$regen_cooklist" ] && unset regen_cooklist && \
2110 [ "$COMMAND" != cook ] && sort_cooklist
2112 # Some hacks to set the bloc & function status as failed if cook was
2113 # failed.
2114 report_return_code=$cook_code
2115 report close-bloc
2116 report end-sublog
2117 rm -f $LOCAL_REPOSITORY/log/package
2118 return $cook_code
2121 cook_list()
2123 if [ -s $tmp/cooklist ]; then
2124 if [ -f /usr/bin/tazchroot ]; then
2125 # Note : options -main variables- are automatically keeped by
2126 # the sub-applications tazchroot/tazwok; as well as report data.
2127 cd $LOCAL_REPOSITORY
2128 [ ! -f tazchroot.conf ] && configure_tazchroot
2129 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
2130 return
2131 fi
2132 while [ -s $tmp/cooklist ]; do
2133 PACKAGE=$(sed 1!d $tmp/cooklist)
2134 cook
2135 done
2136 remove_build_depends $MISSING_PACKAGE $remove_later
2137 [ -x /usr/bin/clean-chroot ] && clean-chroot
2138 else
2139 echo "Nothing to cook."
2140 return
2141 fi
2144 configure_tazchroot()
2146 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
2147 # Tazchroot configuration file - created by tazwok.
2149 # Default chroot path
2150 SLITAZ_DIR=$SLITAZ_DIR
2151 SLITAZ_VERSION=$SLITAZ_VERSION
2152 $( [ "$undigest" ] && echo "undigest=$undigest" )
2153 LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
2154 chroot_dir=\$LOCAL_REPOSITORY/chroot
2156 # Default scripts path (theses scripts are added in the
2157 # $chroot_dir/usr/bin and can be called with tazchroot script)
2158 script_dir=/usr/lib/slitaz/chroot-scripts/tazwok
2160 # List of directories to mount.
2161 list_dir="$(for dir in packages wok src packages-incoming log flavors iso clean-wok; do echo $LOCAL_REPOSITORY/$dir; done)
2162 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
2164 create_chroot()
2166 mkdir -p \$chroot_dir
2167 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
2168 tazpkg get-install \$pkg --root="\$chroot_dir"
2169 done
2171 # Store list of installed packages needed by cleanchroot.
2172 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
2174 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
2175 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
2176 -i \$chroot_dir/etc/slitaz/slitaz.conf
2177 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
2178 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
2181 mount_chroot()
2183 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
2184 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCALSTATE/mirror
2185 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
2186 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
2187 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION
2188 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror' )
2189 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
2190 mount -t proc proc \$chroot_dir/proc
2191 mount -t sysfs sysfs \$chroot_dir/sys
2192 mount -t devpts devpts \$chroot_dir/dev/pts
2193 mount -t tmpfs shm \$chroot_dir/dev/shm
2194 for dir in \$list_dir; do
2195 mkdir -p \$dir \$chroot_dir\$dir
2196 mount \$dir \$chroot_dir\$dir
2197 done
2200 umount_chroot()
2202 for dir in \$list_dir; do
2203 umount \$chroot_dir\$dir
2204 done
2205 umount \$chroot_dir/dev/shm
2206 umount \$chroot_dir/dev/pts
2207 umount \$chroot_dir/sys
2208 umount \$chroot_dir/proc
2210 EOF
2213 ########################################################################
2214 ######################### END OF NEW FUNCTIONS #########################
2215 ########################################################################
2217 # List packages providing a virtual package
2218 whoprovide()
2220 local i;
2221 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
2222 . $i
2223 case " $PROVIDE " in
2224 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
2225 esac
2226 done
2229 ########################################################################
2230 # TAZWOK COMMANDS
2231 ########################
2233 case "$COMMAND" in
2234 stats)
2235 # Tazwok general statistics from the wok config file.
2237 get_tazwok_config
2238 echo -e "\n\033[1mTazwok configuration statistics\033[0m
2239 ================================================================================
2240 Wok directory : $WOK
2241 Packages repository : $PACKAGES_REPOSITORY
2242 Incoming repository : $INCOMING_REPOSITORY
2243 Sources repository : $SOURCES_REPOSITORY
2244 Log directory : $LOCAL_REPOSITORY/log
2245 Packages in the wok : `ls -1 $WOK | wc -l`
2246 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2247 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2248 ================================================================================\n"
2249 ;;
2250 edit)
2251 get_tazwok_config
2252 check_for_package_on_cmdline
2253 check_for_receipt
2254 $EDITOR $WOK/$PACKAGE/receipt
2255 ;;
2256 build-depends)
2257 # List dependencies to rebuild wok, or only a package
2258 get_tazwok_config
2259 report(){ : ; }
2260 if [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
2261 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
2262 --look_for=dep --with_dev --with_args
2263 else
2264 check_for_package_on_cmdline
2265 scan $PACKAGE --look_for=bdep --with_dev
2266 fi
2267 ;;
2268 gen-cooklist)
2269 check_root
2270 get_options_list="pkg"
2271 get_tazwok_config
2272 report(){ : ; }
2273 if ! [ "$pkg" ]; then
2274 if [ ! "$LIST" ] || [ "$LIST" = toolchain ]; then
2275 pkg="$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA"
2276 else
2277 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2278 fi
2279 fi
2280 gen_cook_list
2281 ;;
2282 check-depends)
2283 # Check package depends /!\
2284 get_tazwok_config
2285 echo ""
2286 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
2287 ================================================================================"
2288 TMPDIR=/tmp/tazwok$$
2289 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
2291 # Build ALL_DEPENDS variable
2292 scan_dep()
2294 local i
2295 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
2296 for i in $DEPENDS $SUGGESTED ; do
2297 case " $ALL_DEPENDS " in
2298 *\ $i\ *) continue;;
2299 esac
2300 [ -d $WOK/$i ] || {
2301 ALL_DEPENDS="$ALL_DEPENDS$i "
2302 continue
2304 DEPENDS=""
2305 SUGGESTED=""
2306 . $WOK/$i/receipt
2307 scan_dep
2308 done
2311 # Check for ELF file
2312 is_elf()
2314 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ]
2317 # Print shared library dependencies
2318 ldd()
2320 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
2323 mkdir $TMPDIR
2324 cd $TMPDIR
2325 for i in $LOCALSTATE/files.list.lzma \
2326 $LOCALSTATE/undigest/*/files.list.lzma ; do
2327 [ -f $i ] && lzma d $i -so >> files.list
2328 done
2329 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
2330 tazpkg extract $pkg > /dev/null 2>&1
2331 . */receipt
2332 ALL_DEPENDS="$DEFAULT_DEPENDS "
2333 scan_dep
2334 find */fs -type f | while read file ; do
2335 is_elf $file || continue
2336 case "$file" in
2337 *.o|*.ko|*.ko.gz) continue;;
2338 esac
2339 ldd $file | while read lib rem; do
2340 case "$lib" in
2341 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
2342 continue;;
2343 esac
2344 for dep in $(fgrep $lib files.list | cut -d: -f1); do
2345 case " $ALL_DEPENDS " in
2346 *\ $dep\ *) continue 2;;
2347 esac
2348 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
2349 case " $ALL_DEPENDS " in
2350 *\ $vdep\ *) continue 3;;
2351 esac
2352 done
2353 done
2354 [ -n "$dep" ] || dep="UNKNOWN"
2355 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
2356 done
2357 done
2358 rm -rf */
2359 done
2360 cd /tmp
2361 rm -rf $TMPDIR
2362 ;;
2363 check)
2364 # Check wok consistency
2365 get_tazwok_config
2366 echo ""
2367 echo -e "\033[1mWok and packages checking\033[0m
2368 ================================================================================"
2369 cd $WOK
2370 for pkg in $(ls)
2371 do
2372 [ -f $pkg/receipt ] || continue
2373 RECEIPT= $pkg/receipt
2374 source_receipt
2375 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
2376 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
2377 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
2378 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
2379 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
2380 if [ -n "$WANTED" ]; then
2381 if [ ! -f $WANTED/receipt ]; then
2382 echo "Package $PACKAGE wants unknown $WANTED package" >&2
2383 else
2384 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
2385 if [ "$VERSION" = "$WANTED" ]; then
2386 # BASEVERSION is computed in receipt
2387 fgrep -q '_pkg=' $pkg/receipt &&
2388 BASEVERSION=$VERSION
2389 fi
2390 if [ "$VERSION" != "$BASEVERSION" ]; then
2391 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
2392 fi
2393 fi
2394 fi
2396 if [ -n "$CATEGORY" ]; then
2397 case " $(echo $CATEGORIES) " in
2398 *\ $CATEGORY\ *);;
2399 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
2400 esac
2401 else
2402 echo"Package $PACKAGE has no CATEGORY" >&2
2403 fi
2404 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
2405 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
2406 case "$WGET_URL" in
2407 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
2408 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
2409 '') ;;
2410 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
2411 esac
2412 case "$WEB_SITE" in
2413 ftp*|http*);;
2414 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
2415 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
2416 esac
2417 case "$MAINTAINER" in
2418 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
2419 esac
2420 case "$MAINTAINER" in
2421 *@*);;
2422 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
2423 esac
2424 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2425 for i in $DEPENDS; do
2426 [ -d $i ] && continue
2427 [ -n "$(whoprovide $i)" ] && continue
2428 echo -e "$MSG $i"
2429 MSG=""
2430 done
2431 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2432 for i in $BUILD_DEPENDS; do
2433 [ -d $i ] && continue
2434 [ -n "$(whoprovide $i)" ] && continue
2435 echo -e "$MSG $i"
2436 MSG=""
2437 done
2438 MSG="Dependencies loop between $PACKAGE and :\n"
2439 ALL_DEPS=""
2440 check_for_deps_loop $PACKAGE $DEPENDS
2441 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
2442 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
2443 echo "$pkg should be rebuilt after $i installation"
2444 done
2445 done
2446 ;;
2447 list)
2448 # List packages in wok directory. User can specify a category.
2450 get_tazwok_config
2451 if [ "$2" = "category" ]; then
2452 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
2453 exit 0
2454 fi
2455 # Check for an asked category.
2456 if [ -n "$2" ]; then
2457 ASKED_CATEGORY=$2
2458 echo ""
2459 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
2460 echo "================================================================================"
2461 for pkg in $WOK/*
2462 do
2463 [ ! -f $pkg/receipt ] && continue
2464 . $pkg/receipt
2465 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
2466 echo -n "$PACKAGE"
2467 echo -e "\033[28G $VERSION"
2468 packages=$(($packages+1))
2469 fi
2470 done
2471 echo "================================================================================"
2472 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
2473 else
2474 # By default list all packages and version.
2475 echo ""
2476 echo -e "\033[1mList of packages in the wok\033[0m"
2477 echo "================================================================================"
2478 for pkg in $WOK/*
2479 do
2480 [ ! -f $pkg/receipt ] && continue
2481 . $pkg/receipt
2482 echo -n "$PACKAGE"
2483 echo -en "\033[28G $VERSION"
2484 echo -e "\033[42G $CATEGORY"
2485 packages=$(($packages+1))
2486 done
2487 echo "================================================================================"
2488 echo -e "$packages packages available in the wok.\n"
2489 fi
2490 ;;
2491 info)
2492 # Information about a package.
2494 get_tazwok_config
2495 check_for_package_on_cmdline
2496 check_for_receipt
2497 . $WOK/$PACKAGE/receipt
2498 echo ""
2499 echo -e "\033[1mTazwok package information\033[0m
2500 ================================================================================
2501 Package : $PACKAGE
2502 Version : $VERSION
2503 Category : $CATEGORY
2504 Short desc : $SHORT_DESC
2505 Maintainer : $MAINTAINER"
2506 if [ ! "$WEB_SITE" = "" ]; then
2507 echo "Web site : $WEB_SITE"
2508 fi
2509 if [ ! "$DEPENDS" = "" ]; then
2510 echo "Depends : $DEPENDS"
2511 fi
2512 if [ ! "$WANTED" = "" ]; then
2513 echo "Wanted src : $WANTED"
2514 fi
2515 echo "================================================================================"
2516 echo ""
2517 ;;
2518 check-log)
2519 # We just cat the file log to view process info.
2521 get_tazwok_config
2522 if [ ! -f "$LOG" ]; then
2523 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
2524 exit 1
2525 else
2526 echo ""
2527 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
2528 echo "================================================================================"
2529 cat $LOG
2530 echo "================================================================================"
2531 echo ""
2532 if [ -s "$WOK/$PACKAGE/warning.txt" ]; then
2533 echo -e "\033[1mCook warning(s) for :\033[0m $PACKAGE"
2534 echo "================================================================================"
2535 cat "$WOK/$PACKAGE/warning.txt"
2536 echo "================================================================================"
2537 echo ""
2538 fi
2539 fi
2540 ;;
2541 search)
2542 # Search for a package by pattern or name.
2544 get_tazwok_config
2545 if [ -z "$2" ]; then
2546 echo -e "\nPlease specify a pattern or a package name to search." >&2
2547 echo -e "Example : 'tazwok search gcc'.\n" >&2
2548 exit 1
2549 fi
2550 echo ""
2551 echo -e "\033[1mSearch result for :\033[0m $2"
2552 echo "================================================================================"
2553 list=`ls -1 $WOK | fgrep $2`
2554 for pkg in $list
2555 do
2556 . $WOK/$pkg/receipt
2557 echo -n "$PACKAGE "
2558 echo -en "\033[24G $VERSION"
2559 echo -e "\033[42G $CATEGORY"
2560 packages=$(($PACKAGEs+1))
2561 done
2562 echo "================================================================================"
2563 echo "$packages packages found for : $2"
2564 echo ""
2565 ;;
2566 compile)
2567 # Configure and make a package with the receipt.
2569 get_tazwok_config
2570 source_lib report
2571 report start
2572 compile_package
2573 ;;
2574 genpkg)
2575 # Generate a package.
2577 get_tazwok_config
2578 source_lib report
2579 report start
2580 gen_package
2581 ;;
2582 cook)
2583 # Compile and generate a package. Just execute tazwok with
2584 # the good commands.
2586 check_root
2587 get_tazwok_config
2588 source_lib report
2589 report start
2590 update_wan_db
2591 check_for_commit
2592 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
2593 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
2594 if [ "$plan_regen_cookorder" ]; then
2595 [ "$(sed 1!d $PACKAGES_REPOSITORY/cookorder.txt)" = "#PlanSort" ] || \
2596 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
2597 fi
2598 cook
2599 ;;
2600 sort-cooklist)
2601 if [ ! -f "$LIST" ]; then
2602 echo "Usage : tazwok sort-cooklist cooklist" >&2
2603 exit 1
2604 fi
2605 check_root
2606 get_tazwok_config
2607 report(){ : ; }
2608 # When using sort-cooklist, the script should behave as for gen-cooklist
2609 # The only difference between theses two is where the output is sended.
2610 COMMAND=gen-cooklist
2611 cooklist=$LIST
2612 gen_cook_list
2613 cp -af $tmp/cooklist $cooklist
2614 ;;
2615 cook-list)
2616 # Cook all packages listed in a file or in default cooklist.
2617 check_root
2618 get_options_list="pkg forced"
2619 get_tazwok_config
2620 source_lib report
2621 report start
2622 if ! [ "$pkg" ]; then
2623 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2624 fi
2625 gen_cook_list
2626 cook_list
2627 ;;
2628 clean)
2629 # Clean up a package work directory + thoses which want it.
2631 get_tazwok_config
2632 check_for_package_on_cmdline
2633 check_for_receipt
2634 source_lib report
2635 report start
2636 . $RECEIPT
2637 clean
2638 ;;
2639 gen-clean-wok)
2640 # Generate a clean wok from the current wok by copying all receipts
2641 # and stuff directory.
2643 get_tazwok_config
2644 source_lib report
2645 report start
2646 if [ -z "$ARG" ]; then
2647 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
2648 exit 1
2649 else
2650 dest=$ARG
2651 mkdir -p $dest
2652 fi
2653 report step "Creating clean wok in : $dest"
2654 for pkg in `ls -1 $WOK`
2655 do
2656 mkdir -p $dest/$pkg
2657 cp -a $WOK/$pkg/receipt $dest/$pkg
2658 [ -f $WOK/$pkg/description.txt ] && \
2659 cp -a $WOK/$pkg/description.txt $dest/$pkg
2660 if [ -d "$WOK/$pkg/stuff" ]; then
2661 cp -a $WOK/$pkg/stuff $dest/$pkg
2662 fi
2663 done
2664 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
2665 report end-step
2666 echo "Packages cleaned : `ls -1 $dest | wc -l`"
2667 echo ""
2668 ;;
2669 clean-wok)
2670 # Clean all packages in the work directory
2672 get_tazwok_config
2673 source_lib report
2674 report start
2675 report step "Cleaning wok"
2676 for PACKAGE in `ls -1 $WOK`
2677 do
2678 set_common_path
2679 source_receipt
2680 clean
2681 done
2682 echo "`ls -1 $WOK | wc -l` packages cleaned."
2683 ;;
2684 clean-src)
2685 # Remove tarball unrelated to wok receipts from src repo.
2686 check_root
2687 get_options_list="forced"
2688 get_tazwok_config
2689 cd $SOURCES_REPOSITORY
2690 echo -n "Checking $SOURCES_REPOSITORY..."
2691 for TARBALL in *; do
2692 [ "$TARBALL" = sources.list ] && continue
2693 grep -q $'\t'$TARBALL$ $SOURCES_REPOSITORY/sources.list || \
2694 echo $TARBALL >> $tmp/obsolete
2695 done
2696 status
2697 if ! [ -f $tmp/obsolete ]; then
2698 echo "No sources need to be removed."
2699 exit 1
2700 fi
2701 echo ""
2702 echo -e "\033[1mObsolete/unrelated-to-wok sourcess :\033[0m"
2703 horizontal_line
2704 cat $tmp/obsolete
2705 horizontal_line
2706 echo "$(wc -l $tmp/obsolete | cut -f1 -d' ') tarballs to remove."
2707 echo ""
2708 echo -n "Please confirm removing (type uppercase YES): "
2709 read answer
2710 if [ "$answer" = YES ]; then
2711 echo -n "Removing old sources..."
2712 cat $tmp/obsolete | while read i; do
2713 rm -f $SOURCES_REPOSITORY/$i
2714 done
2715 status
2716 fi
2717 ;;
2718 gen-list)
2719 get_tazwok_config
2720 if [ "$2" ]; then
2721 if [ -d "$2" ]; then
2722 pkg_repository=$2
2723 else
2724 echo -e "\nUnable to find directory : $2\n" >&2
2725 exit 1
2726 fi
2727 fi
2729 source_lib report
2730 report start
2731 if [ "$pkg_repository" ]; then
2732 gen_packages_db
2733 else
2734 pkg_repository=$PACKAGES_REPOSITORY && gen_packages_db
2735 pkg_repository=$INCOMING_REPOSITORY && gen_packages_db
2736 fi
2737 ;;
2738 check-list)
2739 # The directory to move into by default is the repository,
2740 # if $2 is not empty cd into $2.
2742 get_tazwok_config
2743 if [ "$2" ]; then
2744 if [ -d "$2" ]; then
2745 pkg_repository=$2
2746 else
2747 echo -e "\nUnable to find directory : $2\n" >&2
2748 exit 1
2749 fi
2750 fi
2752 source_lib report
2753 report start
2754 if [ "$pkg_repository" ]; then
2755 update_packages_db
2756 else
2757 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
2758 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
2759 fi
2760 ;;
2761 new-tree)
2762 # Just create a few directories and generate an empty receipt to prepare
2763 # the creation of a new package.
2765 get_tazwok_config
2766 check_for_package_on_cmdline
2767 clean_wok=$LOCAL_REPOSITORY/clean-wok
2768 if [ -d $clean_wok/$PACKAGE ]; then
2769 echo -e "\n$PACKAGE package tree already exists.\n" >&2
2770 exit 1
2771 fi
2772 echo "Creating : $WOK/$PACKAGE"
2773 mkdir $clean_wok/$PACKAGE
2774 cd $clean_wok/$PACKAGE
2775 echo -n "Preparing the receipt..."
2777 # Default receipt begin.
2779 echo "# SliTaz package receipt." > receipt
2780 echo "" >> receipt
2781 echo "PACKAGE=\"$PACKAGE\"" >> receipt
2782 # Finish the empty receipt.
2783 cat >> receipt << "EOF"
2784 VERSION=""
2785 CATEGORY=""
2786 SHORT_DESC=""
2787 MAINTAINER=""
2788 DEPENDS=""
2789 TARBALL="$PACKAGE-$VERSION.tar.gz"
2790 WEB_SITE=""
2791 WGET_URL=""
2793 # Rules to configure and make the package.
2794 compile_rules()
2796 cd $src
2797 ./configure && make && make install
2800 # Rules to gen a SliTaz package suitable for Tazpkg.
2801 genpkg_rules()
2803 mkdir -p $fs/usr
2804 cp -a $_pkg/usr/bin $fs/usr
2807 EOF
2809 # Default receipt end.
2811 status
2812 # Interactive mode, asking and seding.
2813 if [ "$3" = "--interactive" ]; then
2814 echo "Entering into interactive mode..."
2815 echo "================================================================================"
2816 echo "Package : $PACKAGE"
2817 # Version.
2818 echo -n "Version : " ; read anser
2819 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
2820 # Category.
2821 echo -n "Category : " ; read anser
2822 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
2823 # Short description.
2824 echo -n "Short desc : " ; read anser
2825 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
2826 # Maintainer.
2827 echo -n "Maintainer : " ; read anser
2828 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
2829 # Web site.
2830 echo -n "Web site : " ; read anser
2831 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
2832 echo ""
2833 # Wget URL.
2834 echo "Wget URL to download source tarball."
2835 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
2836 echo -n "Wget url : " ; read anser
2837 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
2838 # Ask for a stuff dir.
2839 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
2840 if [ "$anser" = "y" ]; then
2841 echo -n "Creating the stuff directory..."
2842 mkdir stuff && status
2843 fi
2844 # Ask for a description file.
2845 echo -n "Are you going to write a description ? (y/N) : " ; read anser
2846 if [ "$anser" = "y" ]; then
2847 echo -n "Creating the description.txt file..."
2848 echo "" > description.txt && status
2849 fi
2850 echo "================================================================================"
2851 echo ""
2852 fi
2853 ;;
2854 remove)
2855 # Remove a package from the wok.
2857 get_tazwok_config
2858 check_for_package_on_cmdline
2859 echo ""
2860 echo -n "Please confirm deletion (y/N) : "; read anser
2861 if [ "$anser" = "y" ]; then
2862 echo -n "Removing $PACKAGE..."
2863 rm -rf $WOK/$PACKAGE && status
2864 echo ""
2865 fi
2866 ;;
2867 update-wok)
2868 # Pull and update a Hg wok.
2869 get_options_list="local"
2870 get_tazwok_config
2871 source_lib report
2872 report start
2873 clean_wok=$LOCAL_REPOSITORY/clean-wok
2874 cd $clean_wok
2875 if ! [ "$local" ]; then
2876 if [ "$WOK_UPDATE_METHOD" = hg ]; then
2877 if ! [ -f "$INSTALLED/mercurial/receipt" ]; then
2879 # Auto-install only if we are in a cook chroot.
2880 if [ -x /usr/bin/clean-chroot ]; then
2881 echo "" >&2
2882 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
2883 echo "">&2
2884 exit 1
2885 else
2886 tazpkg get-install mercurial
2887 fi
2888 fi
2890 report step "Getting wok changes using hg"
2891 if [ -d .hg ]; then
2892 hg pull -u || exit 1
2893 else
2894 hg clone $HG_WOK . || exit 1
2895 fi
2896 report end-step
2897 [ -x /usr/bin/clean-chroot ] && clean-chroot
2898 else
2899 report step "Getting wok changes using tarball"
2900 { mkdir .tmp && cd .tmp
2901 wget "$TARBALL_WOK" &&
2902 case $TARBALL_WOK in
2903 *bz2) tar xjf *.bz2 -C wok; rm *.bz2;;
2904 *lzma) unlzma -c *.lzma | tar xf - -C wok; rm *.lzma ;;
2905 *gz) tar xzf *.gz -C wok; rm*.gz ;;
2906 esac &&
2907 rm -r $(ls -d $clean_wok/*) &&
2908 cp -a wok/* $clean_wok &&
2909 cd .. &&
2910 rm -r .tmp
2911 } || { echo "That's not cool: it fails!" >&2
2912 report end-step
2913 exit 1; }
2914 report end-step
2915 fi
2916 fi
2917 report step "Appending changes to wok"
2919 # Handle removed files/dir.
2920 cd $WOK
2921 for dir in *; do
2922 [ -d "$clean_wok/$dir" ] || rm -rf $dir
2923 done
2924 for file in */receipt */description.txt; do
2925 [ -f "$clean_wok/$file" ] || rm -rf $file
2926 done
2927 for i in $(find */stuff 2>/dev/null); do
2928 [ -e "$clean_wok/$i" ] || rm -rf $i
2929 done
2931 cp -a $clean_wok/* $WOK
2932 report end-step
2933 ;;
2934 maintainers)
2935 get_tazwok_config
2936 echo ""
2937 echo "List of maintainers for: $WOK"
2938 echo "================================================================================"
2939 touch /tmp/slitaz-maintainers
2940 for pkg in $WOK/*
2941 do
2942 . $pkg/receipt
2943 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
2944 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
2945 echo "$MAINTAINER"
2946 fi
2947 done
2948 echo "================================================================================"
2949 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
2950 echo ""
2951 # Remove tmp files
2952 rm -f /tmp/slitaz-maintainers
2953 ;;
2954 maintained-by)
2955 # Search for packages maintained by a contributor.
2956 get_tazwok_config
2957 if [ ! -n "$2" ]; then
2958 echo "Specify a name or email of a maintainer." >&2
2959 exit 1
2960 fi
2961 echo "Maintainer packages"
2962 echo "================================================================================"
2963 for pkg in $WOK/*
2964 do
2965 . $pkg/receipt
2966 if echo "$MAINTAINER" | fgrep -q "$2"; then
2967 echo "$PACKAGE"
2968 packages=$(($PACKAGEs+1))
2969 fi
2970 done
2971 echo "================================================================================"
2972 echo "Packages maintained by $2: $PACKAGEs"
2973 echo ""
2974 ;;
2975 tags)
2976 get_tazwok_config
2977 echo -e "\n\033[1mTags list :\033[0m"
2978 horizontal_line
2979 cd $WOK
2980 for i in */receipt; do
2981 unset TAGS
2982 source $i
2983 for t in $TAGS; do
2984 grep -q ^$t$ $tmp/tags && continue
2985 echo $t | tee -a $tmp/tags
2986 done
2987 done
2988 horizontal_line
2989 echo "$(wc -l $tmp/tags | cut -f1 -d ' ') tags listed."
2990 ;;
2991 check-src)
2992 # Verify if upstream package is still available
2994 get_tazwok_config
2995 check_for_package_on_cmdline
2996 check_for_receipt
2997 source_receipt
2998 check_src()
3000 for url in $@; do
3001 busybox wget -s $url 2>/dev/null && break
3002 done
3004 if [ "$WGET_URL" ];then
3005 echo -n "$PACKAGE : "
3006 check_src $WGET_URL
3007 status
3008 else
3009 echo "No tarball to check for $PACKAGE"
3010 fi
3011 ;;
3012 get-src)
3013 check_root
3014 get_options_list="target nounpack"
3015 get_tazwok_config
3016 check_for_package_on_cmdline
3017 check_for_receipt
3018 source_receipt
3019 if [ "$WGET_URL" ];then
3020 source_lib report
3021 report start
3022 check_for_tarball
3023 else
3024 echo "No tarball to download for $PACKAGE"
3025 fi
3026 ;;
3027 check-commit)
3028 check_root
3029 get_options_list="missing forced"
3030 get_tazwok_config
3031 source_lib report
3032 report start
3033 if [ "$forced" ]; then
3034 rm -f $WOK/*/md5
3035 unset forced
3036 fi
3037 if [ "$missing" ]; then
3038 pkg=$(ls -1 $WOK)
3039 else
3040 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3041 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3042 } | sort -u)"
3043 fi
3044 cooklist=$PACKAGES_REPOSITORY/cooklist
3045 gen_cook_list
3046 ;;
3047 cook-commit)
3048 check_root
3049 get_options_list="missing forced"
3050 get_tazwok_config
3051 source_lib report
3052 report start
3053 if [ "$forced" ]; then
3054 rm -f $WOK/*/md5
3055 unset forced
3056 fi
3057 if [ "$missing" ]; then
3058 pkg=$(ls -1 $WOK)
3059 else
3060 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3061 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3062 } | sort -u)"
3063 fi
3064 cooklist=$PACKAGES_REPOSITORY/cooklist
3065 gen_cook_list
3066 cook_list
3067 ;;
3068 cook-all)
3069 check_root
3070 get_options_list="forced missing"
3071 get_tazwok_config
3072 source_lib report
3073 report start
3074 if [ "$missing" ]; then
3075 pkg=$(ls -1 $WOK)
3076 else
3077 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3078 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3079 } | sort -u)"
3080 fi
3081 cooklist=$PACKAGES_REPOSITORY/cooklist
3082 gen_cook_list
3083 cook_list
3084 ;;
3085 gen-wok-db)
3086 check_root
3087 get_tazwok_config
3088 source_lib report
3089 report start
3090 gen_wok_db
3091 ;;
3092 report)
3093 get_tazwok_config
3094 cd $PACKAGES_REPOSITORY
3095 if [ "$2" ]; then
3096 case $2 in
3097 commit|cooklist|incoming|broken|blocked)
3098 show="$2"
3099 ;;
3100 *)
3101 echo "usage : tazwok report [commit|cooklist|incoming|broken|blocked]" >&2
3102 exit 1
3103 ;;
3104 esac
3105 else
3106 show="commit cooklist incoming broken blocked"
3107 fi
3108 for i in $show; do
3109 if [ -s $i ]; then
3110 echo ""
3111 echo -e "\033[1m$i\033[0m"
3112 echo "================================================================================"
3113 cat $i
3114 echo "================================================================================"
3115 echo ""
3116 fi
3117 done
3118 ;;
3119 check-incoming)
3120 check_root
3121 get_options_list="forced"
3122 get_tazwok_config
3123 source_lib report
3124 report start
3125 [ -f $LOCAL_RESOSITORY/incoming ] && rm [ -f $LOCAL_REPOSITORY/incoming ]
3126 report step "Checking $INCOMING_REPOSITORY"
3127 report open-bloc
3128 [ -f $LOCAL_REPOSITORY/log/incoming.html ] && rm $LOCAL_REPOSITORY/log/incoming.html
3129 report sublog $LOCAL_REPOSITORY/log/incoming.html
3130 echo "incoming" > $LOCAL_REPOSITORY/log/package
3131 check_for_incoming
3132 report end-sublog
3133 report close-bloc
3134 ;;
3135 configure-chroot)
3136 check_root
3137 get_tazwok_config
3138 if [ -f /usr/bin/tazchroot ]; then
3139 cd $LOCAL_REPOSITORY
3140 configure_tazchroot
3141 else
3142 echo "The packages tazchroot need to be installed" >&2
3143 exit 1
3144 fi
3145 ;;
3146 chroot)
3147 check_root
3148 get_tazwok_config
3149 # Merge this and the other chroot function ?.
3150 if [ -f /usr/bin/tazchroot ]; then
3151 cd $LOCAL_REPOSITORY
3152 [ ! -f tazchroot.conf ] && configure_tazchroot
3153 tazchroot
3154 else
3155 echo "The packages tazchroot need to be installed" >&2
3156 exit 1
3157 fi
3158 ;;
3159 cook-toolchain)
3160 check_root
3161 get_tazwok_config
3162 echo -n "" > $PACKAGES_REPOSITORY/broken
3163 if [ -f /usr/bin/tazchroot ]; then
3164 cd $LOCAL_REPOSITORY
3165 [ ! -f tazchroot.conf ] && configure_tazchroot
3166 tazchroot cook-toolchain
3167 # Buggy : chroot can be elsewhere.
3168 rm -r $LOCAL_REPOSITORY/chroot
3169 # /!\ to be writed :
3170 # next rm chroot and plan cook-all by pushing all packages
3171 # in cooklist.
3172 else
3173 echo "The packages tazchroot need to be installed" >&2
3174 exit 1
3175 fi
3176 ;;
3177 webserver)
3178 check_root
3179 get_tazwok_config
3180 if [ "$ARG" = on ]; then
3181 if [ "$WEBSERVER" ] && [ -f "$WEBSERVER/repositories.list" ] && \
3182 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3183 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3184 exit 1
3185 fi
3186 if ! [ -f $LOCAL_REPOSITORY/tazchroot.conf ]; then
3187 tazwok configure-chroot ${undigest:+--undigest=$undigest} --SLITAZ_VERSION=$SLITAZ_VERSION --SLITAZ_DIR=$SLITAZ_DIR
3188 fi
3189 for pkg in php lighttpd; do
3190 [ -d $INSTALLED/$pkg ] || missing="$missing $pkg"
3191 done
3192 if [ "$missing" ]; then
3193 echo "You need to install those packages to start webserver: $missing." >&2
3194 exit 1
3195 fi
3196 if [ ! -f "$LOCAL_REPOSITORY/tazwok.conf" ]; then
3197 echo "Copying /etc/slitaz/tazwok.conf to $LOCAL_REPOSITORY/tazwok.conf: webserver is configured repository-by-repository."
3198 cp /etc/slitaz/tazwok.conf $LOCAL_REPOSITORY
3199 fi
3200 if ! [ "$WEBSERVER" ]; then
3201 echo -n "Where to store php pages (default: /var/www/vhosts/bb)? "
3202 read WEBSERVER
3203 [ "$WEBSERVER" ] || WEBSERVER="/var/www/vhosts/bb"
3204 fi
3205 if [ -f "$WEBSERVER/repositories.list" ] && \
3206 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3207 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3208 exit 1
3209 fi
3210 mkdir -p $WEBSERVER
3211 echo "${undigest:-$SLITAZ_VERSION}" >> $WEBSERVER/repositories.list
3212 for file in index.php log.php download.php; do
3213 [ -f "$WEBSERVER/$file" ] || ln -s /usr/share/slitaz/web-bb/$file $WEBSERVER
3214 done
3215 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3216 ln -s $dir $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3217 done
3218 source $LOCAL_REPOSITORY/tazchroot.conf
3219 echo "<?php
3221 // Web interface configuration
3223 \$version=\"${undigest:-$SLITAZ_VERSION}\";
3224 \$chroot=\"$chroot_dir\";
3225 \$lockfile=\"\$chroot/proc/1/status\";
3226 \$db_dir=\"$PACKAGES_REPOSITORY\";
3227 \$log_dir=\"$LOCAL_REPOSITORY/log\";
3228 \$packages=\"$PACKAGES_REPOSITORY\";
3229 \$incoming=\"$INCOMING_REPOSITORY\";
3230 \$wok=\"$WOK\";
3232 ?>" > $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3233 [ -L "$WEBSERVER/web" ] || ln -s /usr/share/slitaz/web $WEBSERVER
3234 echo "WEBSERVER=\"$WEBSERVER\"" >> $LOCAL_REPOSITORY/tazwok.conf
3235 if [ -L "$WEBSERVER/conf.php" ]; then
3236 echo "Do yo want to make ${undigest:-$SLITAZ_VERSION} the default page (y/N) ? "
3237 read answer
3238 if [ "$answer" = y ]; then
3239 rm $WEBSERVER/conf.php
3240 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3241 fi
3242 else
3243 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3244 fi
3245 elif [ "$ARG" = off ]; then
3246 if ! [ "$WEBSERVER" ]; then
3247 echo "No webserver running for ${undigest:-$SLITAZ_VERSION}" >&2
3248 exit 1
3249 fi
3250 sed '/^WEBSERVER/d' -i $LOCAL_REPOSITORY/tazwok.conf
3251 sed "/^${undigest:-$SLITAZ_VERSION}$/d" -i $WEBSERVER/repositories.list
3252 rm $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3253 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3254 rm $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3255 done
3256 if ! [ -s "$WEBSERVER/repositories.list" ]; then
3257 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"
3258 rm $WEBSERVER/conf.php
3259 elif [ "$(readlink $WEBSERVER/conf.php)" = "$WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php" ]; then
3260 echo "${undigest:-$SLITAZ_VERSION} was the default version to use; switched to : $(sed 1!d $WEBSERVER/repositories.list)"
3261 rm $WEBSERVER/conf.php
3262 ln -s $WEBSERVER/conf-$(sed 1!d $WEBSERVER/repositories.list).php $WEBSERVER/conf.php
3263 fi
3264 else
3265 echo "Usage: tazwok webserver on/off" >&2
3266 exit 1
3267 fi
3268 ;;
3269 block)
3270 # Add a pkg name to the list of blocked packages.
3271 echo ""
3272 if grep -qs "^$2$" $PACKAGES_REPOSITORY/blocked; then
3273 echo -e "$2 is already in the blocked packages list."
3274 else
3275 echo -n "Adding $2 to : $PACKAGES_REPOSITORY/blocked... "
3276 echo "$2" >> $PACKAGES_REPOSITORY/blocked && echo "Done"
3277 if grep -q "^$2$" $PACKAGES_REPOSITORY/cooklist; then
3278 echo -n "Removing $2 from : $DB_DIR/cooklist... "
3279 sed -i /"^$2$"/d $PACKAGES_REPOSITORY/cooklist && echo "Done"
3280 fi
3281 fi
3282 echo "" ;;
3283 unblock)
3284 # Remove a pkg name from the list of blocked packages.
3285 echo ""
3286 if grep -qs "^$2$" $PACKAGES_REPOSITORY/blocked; then
3287 echo -n "Removing $2 from : $PACKAGES_REPOSITORY/blocked... "
3288 sed -i /"^$2$"/d $PACKAGES_REPOSITORY/blocked
3289 sed -i '/^$/d' $PACKAGES_REPOSITORY/blocked && echo "Done"
3290 echo -n "Adding $2 to : $DB_DIR/cooklist... "
3291 echo "$2" >> $DB_DIR/cooklist && echo "Done"
3292 sort_cooklist
3293 else
3294 echo -e "$2 is not in the blocked packages list."
3295 fi
3296 echo "" ;;
3297 usage|*)
3298 # Print usage also for all unknown commands.
3300 usage
3301 ;;
3302 esac
3304 report stop 2>/dev/null
3305 exit 0