tazwok view tazwok @ rev 351

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