tazwok view tazwok @ rev 236

fix function: list
author Antoine Bodin <gokhlayeh@slitaz.org>
date Thu Feb 10 17:10:22 2011 +0100 (2011-02-10)
parents d30774579470
children 3dac6b64424e
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=3.9.0
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 cmp|compare* Compare the wok and the cooked pkgs (--remove old pkgs).
35 list List all packages in the wok tree or by category.
36 info Get information about a package in the wok.
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 (--list) in argument.
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 gen-wok-db (Re-)Generate wok lists with depends and wanted datas.
56 gen-clean-wok Gen a clean wok in a dir ('clean-wok' cleans current wok).
57 clean-wok Clean entirely the wok.
58 remove Remove a package from the wok.
59 hgup Pull and update a wok under Hg.
60 maintainers List all maintainers in the wok.
61 maintained-by List packages maintained by a contributor.\n
63 You can use `basename $0` command --help to list avaible options.
64 \033[1mImportant - *: \033[0m Commands which need a rewrite."
65 }
67 # This function display an error message without returning any error code.
68 # It also log the message in source package's warnings.txt; this file can be
69 # used on an eventual package page on website to display cooking warnings.
70 tazwok_warning()
71 {
72 echo -e "tazwok: $1" >&2
73 echo -e "$1" >> $WOK/${WANTED:-$PACKAGE}/warning.txt
74 return
75 }
77 ########################################################################
78 # TAZWOK VARIABLES & INITIAL CONFIGURATION
79 ########################
81 get_tazwok_config()
82 {
83 # Get configuration file.
84 get_config
86 # Define & get options.
87 get_options_list="$get_options_list SLITAZ_DIR SLITAZ_VERSION undigest"
88 get_options
90 if [ "$undigest" ]; then
91 LOCAL_REPOSITORY=$SLITAZ_DIR/$undigest
92 else
93 LOCAL_REPOSITORY=$SLITAZ_DIR/$SLITAZ_VERSION
94 fi
96 if ! [ "$save_dir" ]; then
97 if [ -f $LOCAL_REPOSITORY/tazwok.conf ] || [ -f $LOCAL_REPOSITORY/slitaz.conf ]; then
98 save_dir=$LOCAL_REPOSITORY
99 [ -f $LOCAL_REPOSITORY/slitaz.conf ] && source $LOCAL_REPOSITORY/slitaz.conf
100 cd $save_dir
101 get_tazwok_config
102 unset save_dir
103 return
104 fi
105 fi
107 # The path to the most important files/dir used by Tazwok.
108 PACKAGES_REPOSITORY=$LOCAL_REPOSITORY/packages
109 WOK=$LOCAL_REPOSITORY/wok
110 INCOMING_REPOSITORY=$LOCAL_REPOSITORY/packages-incoming
111 SOURCES_REPOSITORY=$LOCAL_REPOSITORY/src
112 set_common_path
114 # /!\ This part needs some changes.
115 # Basically, get theses files from the net if they are missing.
116 dep_db=$INCOMING_REPOSITORY/wok-depends.txt
117 wan_db=$INCOMING_REPOSITORY/wok-wanted.txt
118 [ -f $dep_db ] || touch $dep_db
119 [ -f $wan_db ] || touch $wan_db
120 [ -f $PACKAGES_REPOSITORY/cookorder.txt ] || touch $PACKAGES_REPOSITORY/cookorder.txt
122 # Check commons directories, create them if user is root.
123 if test $(id -u) = 0 ; then
124 check_dir $WOK || chmod 777 $WOK
125 check_dir $PACKAGES_REPOSITORY
126 check_dir $SOURCES_REPOSITORY
127 check_dir $INCOMING_REPOSITORY
128 check_dir $LOCAL_REPOSITORY/log
129 fi
131 # Some files are needed by tazwok in PACKAGES_REPOSITORY. Create
132 # them if they are missing.
133 for file in broken blocked commit incoming cooklist; do
134 [ ! -f $PACKAGES_REPOSITORY/$file ] && touch $PACKAGES_REPOSITORY/$file
135 done
137 # Limit memory usage.
138 ulimit -v $(awk '/MemTotal/ { print int(($2*80)/100) }' < /proc/meminfo)
139 }
141 # Used in several functions.
142 set_common_path()
143 {
144 # The receipt is used to compile the source code and
145 # generate suitable packages for Tazpkg.
146 RECEIPT="$WOK/$PACKAGE/receipt"
148 # The path to the process log file.
149 LOG="$WOK/$PACKAGE/process.log"
150 }
152 ########################################################################
153 # TAZWOK CHECK FUNCTIONS
154 ########################
156 # Check for a package name on cmdline.
157 check_for_package_on_cmdline()
158 {
159 if [ ! "$PACKAGE" ]; then
160 echo -e "\nYou must specify a package name on the command line." >&2
161 echo -e "Example : tazwok $COMMAND package\n" >&2
162 exit 1
163 fi
164 }
166 # Check for the receipt of a package used to cook.
167 check_for_receipt()
168 {
169 if [ ! -f "$RECEIPT" ]; then
170 echo -e "\nUnable to find the receipt : $RECEIPT\n" >&2
171 exit 1
172 fi
173 }
175 # Check for a specified file list on cmdline.
176 check_for_list()
177 {
178 if [ ! "$LIST" ]; then
179 echo -e "\nPlease specify the path to the list of packages to cook.\n" >&2
180 exit 1
181 fi
183 # Check if the list of packages exists.
184 if [ -f "$LIST" ]; then
185 LIST=`cat $LIST`
186 else
187 echo -e "\nUnable to find $LIST packages list.\n" >&2
188 exit 1
189 fi
191 if [ ! "$LIST" ]; then
192 echo -e "\nList is empty.\n" >&2
193 exit 1
194 fi
195 }
197 check_for_pkg_in_wok()
198 {
199 [ -f $WOK/$PACKAGE/receipt ] && return
200 if [ "$undigest" ]; then
201 [ -f "$SLITAZ_VERSION/wok/$PACKAGE/receipt" ] && return 1
202 grep -q ^$PACKAGE$ $SLITAZ_VERSION/packages/packages.txt && return 1
203 fi
204 echo "Can't find $PACKAGE in wok or mirror" >&2
205 return 2
206 }
208 ########################################################################
209 # TAZWOK CORE FUNCTIONS
210 ########################
212 remove_src()
213 {
214 [ "$WANTED" ] && return
215 look_for_cookopt !remove_src && return
216 if [ ! -d $WOK/$PACKAGE/install ] && [ "$src" ] && [ -d "$src/_pkg" ]; then
217 check_for_var_modification _pkg src || return
218 mv "$src/_pkg" $WOK/$PACKAGE/install
219 fi
221 # Don't remove sources if a package use src variable in his
222 # genpkg_rules: it maybe need something inside.
223 for i in $PACKAGE $(look_for_rwanted); do
224 sed -n '/^genpkg_rules\(\)/','/}/'p $WOK/$i/receipt | \
225 fgrep -q '$src' && tazwok_warning "Sources will not be removed \
226 because $i use \$src in his receipt." && return
227 done
229 report step "Removing sources directory"
230 rm -fr "$src"
231 report end-step
232 }
234 # Check $COOK_OPT; usage : get_cookopt particular_opt
235 # Return error if not founded
236 # Return args if the opt is in the format opt=arg1:arg2:etc
237 look_for_cookopt()
238 {
239 for arg in $COOK_OPT; do
240 case $arg in
241 $1=*)
242 arg=${arg#$1=}
243 while [ "$arg" ]; do
244 echo "${arg%%:*}"
245 [ "${arg/:}" = "$arg" ] && return
246 arg=${arg#*:}
247 done
248 ;;
249 $1)
250 return
251 ;;
252 esac
253 done
254 return 1
255 }
257 # Check for the wanted package if specified in WANTED
258 # receipt variable. Set the $src/$_pkg variable to help compile
259 # and generate packages.
260 check_for_wanted()
261 {
262 if [ "$WANTED" ]; then
263 report "Checking for the wanted package"
264 if [ ! -d "$WOK/$WANTED" ]; then
265 report exit "\nWanted package is missing in the work directory.\n"
266 fi
268 # Checking for buildtree of Wanted package
269 if [ ! -d "$WOK/$WANTED/taz" ]; then
270 echo -e "\n\nSource files of wanted package is missing in the work directory."
271 echo -n "Would you like to build the missing package (y/N) ? " ; read anser
272 if [ "$anser" == "y" ]; then
273 tazwok cook $WANTED
274 else
275 report exit "\nWanted package source tree is missing in the work directory.\n"
276 fi
277 fi
278 report end-step
280 # Set wanted src path.
281 set_src_path && set_pkg_path
283 fi
284 }
286 # Check for build dependencies, notify user and install if specified.
287 check_for_build_depends()
288 {
289 [ "$WANTED" ] && return
290 [ "$CATEGORY" = meta ] && ! fgrep -q compile_rules $RECEIPT && return
291 report step "Looking for build dependencies"
293 # Keep the list of previously installed build_depends then compare
294 # it with new build_depends to know what to install and what to
295 # what to remove.
296 plan_remove=" $MISSING_PACKAGE $remove_later "
297 [ ! "${plan_remove// }" ] && unset plan_remove
298 unset MISSING_PACKAGE remove_later
299 rwanted=$(look_for_rwanted)
301 for pkg in $(scan $PACKAGE --look_for=bdep --with_dev | \
302 fgrep -v $(for i in $(look_for_rwanted) $PACKAGE; do echo " -e $i"; done))
303 do
305 # Delay the removing of previous cook depends if they are needed
306 # for next cook too.
307 if [ ! -d "$INSTALLED/$pkg" ] ; then
308 MISSING_PACKAGE="$MISSING_PACKAGE $pkg"
309 fi
310 if [ "$plan_remove" != "${plan_remove/ $pkg }" ]; then
311 plan_remove="${plan_remove/ $pkg / }"
312 remove_later="$remove_later $pkg"
313 fi
314 if grep -q ^$pkg$ $PACKAGES_REPOSITORY/broken; then
315 broken="$broken$pkg "
316 fi
317 done
319 # Don't cook if a depend is broken.
320 if [ "$broken" ]; then
321 MISSING_PACKAGE=$plan_remove
322 echo "Can't cook $PACKAGE because broken depend(s) : $broken" >&2
323 unset plan_remove broken
325 # Set report step to failed.
326 report_return_code=1
327 report end-step
328 return 1
329 fi
330 if [ "$MISSING_PACKAGE" ]; then
331 install_missing()
332 {
333 echo "Installing missing packages : $MISSING_PACKAGE"
334 for pkg in $MISSING_PACKAGE; do
335 [ -d "$INSTALLED/$pkg" ] || tazpkg get-install $pkg
336 done
337 }
338 if [ "$auto_install" = yes ]; then
339 install_missing
340 else
341 echo "================================================================================"
342 for pkg in $MISSING_PACKAGE
343 do
344 echo "Missing : $pkg"
345 done
346 echo "================================================================================"
347 echo "You can continue, exit or install missing dependencies."
348 echo -n "Install, continue or exit (install/y/N) ? "; read answer
349 case $answer in
350 install)
351 install_missing ;;
352 y|yes)
353 unset MISSING_PACKAGE;;
354 *)
355 report stop
356 exit 0 ;;
357 esac
358 fi
359 fi
360 report end-step
361 remove_build_depends $plan_remove
362 unset plan_remove
363 }
365 remove_build_depends()
366 {
367 [ "$1" ] || return
368 report step "Removing previous build dependencies"
369 echo "Removing theses packages : $@"
370 for pkg in $@; do
371 [ -d "$INSTALLED/$pkg" ] && tazpkg remove $pkg --auto
372 done
373 report end-step
374 }
376 # Check if we can use the new way to handle tarball
377 # or if we keep the previous method by check for
378 # _pkg=/src= in receipt and reverse-wanted.
379 check_for_var_modification()
380 {
381 for var in $@; do
382 for pkg in $PACKAGE $(look_for_wanted) $(look_for_rwanted); do
383 [ -f $WOK/$pkg/receipt ] || continue
384 fgrep -q "$var=" $WOK/$pkg/receipt && return 1
385 done
386 done
388 # Tweak to make if; then...; fi function working with this one.
389 echo -n ""
390 }
392 set_src_path()
393 {
394 if check_for_var_modification src _pkg; then
395 src=$WOK/${WANTED:-$PACKAGE}/${WANTED:-$PACKAGE}-$VERSION
396 else
397 src=$WOK/${WANTED:-$PACKAGE}/${SOURCE:-${WANTED:-$PACKAGE}}-$VERSION
398 fi
399 }
401 set_pkg_path()
402 {
403 if [ -d $WOK/${WANTED:-$PACKAGE}/install ] ; then
404 _pkg=$WOK/${WANTED:-$PACKAGE}/install
405 else
406 _pkg=$src/_pkg
407 fi
408 }
410 # Output $VERSION-$EXTRAVERSION using packages.txt
411 get_pkg_version()
412 {
413 [ "$PACKAGE" ] || return
414 grep -m1 -A1 -sh ^$PACKAGE$ $1/packages.txt | tail -1 | sed 's/ *//'
415 }
417 remove_previous_tarball()
418 {
419 [ "$prev_VERSION" ] || return
420 if [ "$VERSION" != "$prev_VERSION" ]; then
421 rm -f $SOURCES_REPOSITORY/$PACKAGE-$prev_VERSION.tar.lzma
422 fi
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 if [ "$WGET_URL" ]; then
438 report step "Checking for source tarball"
440 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
441 [ ! -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] ; then
442 cd $SOURCES_REPOSITORY
443 download $WGET_URL
445 # If source tarball is unreachable, try to find it on SliTaz
446 # mirror.
447 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
448 report step "Download failed, try with mirror copy... "
449 if [ "$SOURCE" ]; then
450 download http://mirror.slitaz.org/sources/packages/${SOURCE:0:1}/$SOURCE-$VERSION.tar.lzma
451 else
452 download http://mirror.slitaz.org/sources/packages/${PACKAGE:0:1}/$PACKAGE-$VERSION.tar.lzma
453 fi
454 fi
455 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
456 [ ! -f "$SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma" ]; then
457 report step "Download failed, try with mirror copy (again)... "
458 file=$(basename $WGET_URL)
459 download http://mirror.slitaz.org/sources/packages/${file:0:1}/$file
460 fi
462 # Exit if download failed to avoid errors.
463 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
464 echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n" >&2
465 report end-step
466 return 1
467 fi
468 fi
469 fi
470 report end-step
472 if [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && [ "$nounpack" ]; then
473 return
474 fi
476 # Untaring source if necessary. We don't need to extract source if
477 # the package is built with a wanted source package.
478 if [ "$WANTED" ]; then
479 return
480 fi
482 report step "Untaring source tarball"
483 if [ "$target" ]; then
484 src="$target"
485 else
486 set_src_path
487 fi
489 # Log process.
490 echo "untaring source tarball" >> $LOG
492 tmp_src=$WOK/$PACKAGE/tmp-src-$$
493 mkdir $tmp_src
494 if [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
495 lzma d $SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma -so | \
496 tar xf - -C $tmp_src
497 elif [ -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
498 case "$TARBALL" in
499 *zip|*xpi) { cd $tmp_src; unzip -o $SOURCES_REPOSITORY/$TARBALL; };;
500 *bz2) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
501 *tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
502 *lzma) unlzma -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
503 *xz) unxz -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
504 *Z) uncompress -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
505 *) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
506 esac || return 1
508 # Check if uncompressed tarball is in a root dir or not.
509 if [ "$(ls -A $tmp_src | wc -l)" -gt 1 ]; then
510 if check_for_var_modification src _pkg; then
511 mv $tmp_src $tmp_src-1
512 mkdir $tmp_src
513 mv $tmp_src-1 $tmp_src/${SOURCE:-$PACKAGE}-$VERSION
514 else
515 mv $tmp_src/* $WOK/$PACKAGE
516 repack_src=no
517 rm -r $tmp_src
518 fi
519 fi
521 if [ "$repack_src" = yes ]; then
522 report step "Repacking sources in .tar.lzma format"
523 cd $tmp_src
524 tar -c * | lzma e $SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma -si
525 rm $SOURCES_REPOSITORY/$TARBALL
526 prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
528 # Remove previous tarball if it's not used either by
529 # incoming and legacy packages.
530 [ "$prev_VERSION" != "$(get_pkg_version $PACKAGES_REPOSITORY)" ] && \
531 remove_previous_tarball
532 fi
533 fi
534 if [ "$nounpack" ]; then
535 [ -d "$tmp_src" ] && rm -r $tmp_src
536 return
537 fi
539 if [ ! -d "$src" ]; then
540 if [ -d "$tmp_src" ]; then
541 if ! check_for_var_modification src _pkg; then
542 src="${src%/*}/$(ls $tmp_src)"
543 fi
544 mv $(echo $tmp_src/*) "$src"
545 rm -r $tmp_src
547 # Permissions settings.
548 chown -R root.root "$src"
549 fi
550 report end-step
551 else
552 echo "There's already something at $src. Abord." >&2
553 fi
554 }
556 # Log and execute compile_rules function if it exists, to configure and
557 # make the package if it exists.
558 check_for_compile_rules()
559 {
560 if grep -q ^compile_rules $RECEIPT; then
561 echo "executing compile_rules" >> $LOG
562 report step "Executing compile_rules"
563 cd $WOK/$PACKAGE
564 rm -f /tmp/config.site
566 # Free some RAM by cleaning cache if option is enabled.
567 freeram=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
569 # Disable -pipe in CFLAGS/CXXFLAGS if less than 512Mb of free
570 # RAM are available.
571 if [ "$freeram" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" -o \
572 "$CXXFLAGS" != "${CXXFLAGS/-pipe}" ]; then
573 tazwok_warning "Disabling -pipe compile flag because only ${freeram}b of RAM are available."
574 CFLAGS="${CFLAGS/-pipe}"
575 CXXFLAGS="${CXXFLAGS/-pipe}"
576 fi
577 unset freeram
579 # Set cook environnement variables.
580 [ "$src" ] || set_src_path
581 [ "$DESTDIR" ] || DESTDIR="$WOK/$PACKAGE/install"
582 [ "$CONFIG_SITE" ] || CONFIG_SITE=/etc/config.site
583 export CFLAGS CXXFLAGS MAKEFLAGS DESTDIR BUILD_HOST \
584 CONFIG_SITE default_prefix \
585 default_datarootdir default_datadir default_localedir \
586 default_infodir default_mandir default_build default_host
587 local LC_ALL=POSIX LANG=POSIX
588 compile_rules
590 # Check if config.site has been used.
591 # /!\ disabled since it screw the return_code of the step.
592 #if [ -f /tmp/config.site ]; then
593 # rm /tmp/config.site
594 #else
595 # tazwok_warning "config.site hasn't been used during \
596 #configuration process."
597 #fi
599 report end-step
600 fi
601 }
603 # Check for loop in deps tree. /!\ can be removed
604 check_for_deps_loop()
605 {
606 local list
607 local pkg
608 local deps
609 pkg=$1
610 shift
611 [ -n "$1" ] || return
612 list=""
614 # Filter out already processed deps
615 for i in $@; do
616 case " $ALL_DEPS" in
617 *\ $i\ *);;
618 *) list="$list $i";;
619 esac
620 done
621 ALL_DEPS="$ALL_DEPS$list "
622 for i in $list; do
623 [ -f $i/receipt ] || continue
624 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
625 case " $deps " in
626 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
627 *) check_for_deps_loop $pkg $deps;;
628 esac
629 done
630 }
632 download()
633 {
634 for file in $@; do
635 wget -q $file && break
636 done
637 }
639 # Regenerate every package that wants a PACKAGE compiled
640 refresh_packages_from_compile()
641 {
642 # make tazwok genpkg happy
643 mkdir $WOK/$PACKAGE/taz
645 # Cook rwanted in default or specied order
646 genlist=" $(look_for_rwanted | tr '\n' ' ') "
647 for i in $(look_for_cookopt genpkg | tac); do
648 [ "${genlist/ $i }" = "$genlist" ] && continue
649 genlist=" $i${genlist/ $i / }"
650 done
651 if [ "$genlist" ]; then
652 local PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
653 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
654 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
655 src _pkg DESTDIR CONFIG_SITE RECEIPT LOG
656 for PACKAGE in $genlist; do
657 set_common_path
658 gen_package
659 done
660 fi
661 }
663 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
664 # so some packages need to copy these files with the receipt and genpkg_rules.
665 # This function is executed by gen_package when 'tazwok genpkg'.
666 copy_generic_files()
667 {
668 # In most cases, locales are in $_pkg/usr/share/locale so we copy files
669 # using generic variables and $LOCALE from Tazwok config file.
670 if [ "$LOCALE" ]; then
671 if [ -d "$_pkg/usr/share/locale" ]; then
672 for i in $LOCALE
673 do
674 if [ -d "$_pkg/usr/share/locale/$i" ]; then
675 mkdir -p $fs/usr/share/locale
676 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
677 fi
678 done
679 fi
680 fi
682 # Pixmaps (PNG or/and XPM only). Some icons/images can be added through
683 # genpkg_rules and generic copy can be disabled with GENERIC_PIXMAPS="no"
684 # in pkg receipt.
685 if [ "$GENERIC_PIXMAPS" != "no" ]; then
686 if [ -d "$_pkg/usr/share/pixmaps" ]; then
687 mkdir -p $fs/usr/share/pixmaps
688 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
689 $fs/usr/share/pixmaps 2>/dev/null
690 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
691 $fs/usr/share/pixmaps 2>/dev/null
692 fi
694 # Custom or homemade PNG pixmap can be in stuff.
695 if [ -f "stuff/$PACKAGE.png" ]; then
696 mkdir -p $fs/usr/share/pixmaps
697 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
698 fi
699 fi
701 # Desktop entry (.desktop).
702 if [ -d "$_pkg/usr/share/applications" ]; then
703 cp -a $_pkg/usr/share/applications $fs/usr/share
704 fi
706 # Homemade desktop file(s) can be in stuff.
707 if [ -d "stuff/applications" ]; then
708 mkdir -p $fs/usr/share
709 cp -a stuff/applications $fs/usr/share
710 fi
711 if [ -f "stuff/$PACKAGE.desktop" ]; then
712 mkdir -p $fs/usr/share/applications
713 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
714 fi
715 }
717 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
718 strip_package()
719 {
720 report step "Executing strip on all files"
722 # Binaries.
723 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
724 do
725 if [ -d "$dir" ]; then
726 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
727 fi
728 done
730 # Libraries.
731 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
732 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
733 report end-step
734 }
736 # Remove .pyc and .pyo files from packages
737 py_compiled_files_remove()
738 {
739 report step "Removing all .pyc and .pyo files from package ..."
740 find $fs -type f -name "*.pyc" -delete 2>/dev/null
741 find $fs -type f -name "*.pyo" -delete 2>/dev/null
742 report end-step
743 }
745 # Check FSH in a slitaz package (Path: /:/usr)
746 check_fsh()
747 {
748 cd $WOK/$PACKAGE/taz/*/fs
749 [ -n "$FSH" ] || FSH="bin boot dev etc home init lib media mnt proc \
750 root sbin share sys tmp usr var vz usr/bin usr/games usr/include usr/lib \
751 usr/local usr/sbin usr/share usr/src"
752 for i in `ls -d * usr/* 2>/dev/null`
753 do
754 if ! echo $FSH | fgrep -q $i; then
755 echo "Wrong path: /$i" >&2
756 error=1
757 fi
758 done
759 if [ "$error" = "1" ]; then
760 cat << _EOT_
762 Package will install files in a non standard directory and won't be generated.
763 You may have a wrong copy path in genpkg_rules or need to add some options to
764 configure in compile_rules. Some valid options for SliTaz (Linux FSH):
766 --prefix=/usr
767 --sysconfdir=/etc
768 --libexecdir=/usr/lib/(pkgname)
769 --localstatedir=/var
770 --mandir=/usr/share/man
771 --infodir=/usr/share/info
773 For more information please read SliTaz docs and run: ./configure --help
774 ================================================================================
775 $PACKAGE package generation aborted.
777 _EOT_
779 # Dont generate a corrupted package.
780 cd $WOK/$PACKAGE && rm -rf taz
781 report exit
782 fi
783 }
785 gen_cookmd5()
786 {
787 # md5sum of cooking stuff make tazwok able to check for changes
788 # without hg.
789 cd $WOK/$PACKAGE
790 md5sum receipt > md5
791 [ -f description.txt ] && md5sum description.txt >> md5
792 if [ -d stuff ]; then
793 find stuff | while read file; do
794 md5sum $file >> md5
795 done
796 fi
797 }
799 # Create a package tree and build the gziped cpio archive
800 # to make a SliTaz (.tazpkg) package.
801 gen_package()
802 {
803 check_root
804 check_for_package_on_cmdline
805 check_for_receipt
806 EXTRAVERSION=""
807 . $RECEIPT
809 # May compute VERSION
810 if grep -q ^get_version $RECEIPT; then
811 get_version
812 fi
813 check_for_wanted
814 cd $WOK/$PACKAGE
816 # Remove old Tazwok package files.
817 [ -d "taz" ] && rm -rf taz
819 # Create the package tree and set useful variables.
820 mkdir -p taz/$PACKAGE-$VERSION/fs
821 fs=taz/$PACKAGE-$VERSION/fs
823 # Set $src for standard package and $_pkg variables.
824 set_src_path && set_pkg_path
826 # Execute genpkg_rules, check package and copy generic files to build
827 # the package.
828 report step "Building $PACKAGE with the receipt"
829 report open-bloc
830 if grep -q ^genpkg_rules $RECEIPT; then
832 # Log process.
833 echo "executing genpkg_rules" >> $LOG
834 report step "Executing genpkg_rules"
835 genpkg_rules
836 report end-step
837 check_fsh
838 cd $WOK/$PACKAGE
840 # Skip generic files for packages with a WANTED variable
841 # (dev and splited pkgs).
842 if [ ! "$WANTED" ]; then
843 copy_generic_files
844 fi
845 look_for_cookopt !strip || strip_package
846 py_compiled_files_remove
847 else
848 echo "No package rules to gen $PACKAGE..." >&2
849 report exit
850 fi
852 # Copy the receipt and description (if exists) into the binary package tree.
853 cd $WOK/$PACKAGE
854 report step "Copying the receipt"
855 cp receipt taz/$PACKAGE-$VERSION
856 report end-step
857 if grep -q ^get_version $RECEIPT; then
858 report step "Updating version in receipt"
859 sed -i "s/^VERSION=.*/VERSION=\"$VERSION\"/" \
860 taz/$PACKAGE-$VERSION/receipt
861 report end-step
862 fi
863 if [ -f "description.txt" ]; then
864 report step "Copying the description file"
865 cp description.txt taz/$PACKAGE-$VERSION
866 report end-step
867 fi
869 # Generate md5 of cooking stuff to look for commit later.
870 gen_cookmd5
871 echo -e "\n# md5sum of cooking stuff :" >> taz/$PACKAGE-$VERSION/receipt
872 cat md5 | sed 's/^/# /' >> taz/$PACKAGE-$VERSION/receipt
874 # Create the files.list by redirecting find output.
875 report step "Creating the list of files"
876 cd taz/$PACKAGE-$VERSION
877 LAST_FILE=""
878 { find fs -print; echo; } | while read file; do
879 if [ "$LAST_FILE" ]; then
880 case "$file" in
881 $LAST_FILE/*)
882 case "$(ls -ld "$LAST_FILE")" in
883 drwxr-xr-x\ *\ root\ *\ root\ *);;
884 *) echo ${LAST_FILE#fs};;
885 esac;;
886 *) echo ${LAST_FILE#fs};;
887 esac
888 fi
889 LAST_FILE="$file"
890 done > files.list
892 # Next, check if something has changed in lib files.
893 if fgrep -q '.so' files.list; then
894 report step "Look for major/minor update in libraries"
895 for rep in $INCOMING_REPOSITORY $PACKAGES_REPOSITORY \
896 $([ "$undigest" ] && echo SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming && \
897 echo $SLITAZ_DIR/$SLITAZ_VERSION/packages); do
898 prev_VERSION=$(get_pkg_version $rep)
899 [ "$prev_VERSION" ] && pkg_file=$rep/$PACKAGE-$prev_VERSION.tazpkg && break
900 done
901 if [ "$pkg_file" ]; then
902 get_pkg_files $pkg_file
903 cd $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
904 fgrep ".so" files.list | egrep -v "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*" | \
905 while read lib; do
906 fgrep -q "$lib" $pkg_files_dir/files.list && continue
907 echo "A minor/major update in libraries is detected, planning re-cook of reverse-depends of $PACKAGE."
908 for rdep in $(scan $PACKAGE --look_for=rdep | use_wanted); do
909 [ "$rdep" = "${WANTED:-$PACKAGE}" ] && continue
910 grep -q ^$rdep$ $PACKAGES_REPOSITORY/blocked \
911 $PACKAGES_REPOSITORY/cooklist && continue
912 echo $rdep >> $PACKAGES_REPOSITORY/cooklist
913 done
914 regen_cooklist=yes
915 break
916 done
917 rm -r $pkg_files_dir
918 fi
919 report end-step
920 fi
921 if [ ! "$EXTRAVERSION" ]; then
922 case "$PACKAGE" in
923 linux*);;
924 *) EXTRAVERSION="$(grep '/lib/modules/.*-slitaz/' files.list |\
925 head -1 | sed 's|/lib/modules/\(.*\)-slitaz/.*|_\1|')";;
926 esac
927 fi
928 rm -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
929 report step "Creating md5sum of files"
930 while read file; do
931 [ -L "fs$file" ] && continue
932 [ -f "fs$file" ] || continue
933 md5sum "fs$file" | sed 's/ fs/ /'
934 done < files.list > md5sum
935 report end-step
936 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
937 2> /dev/null | awk '{ sz=$1 } END { print sz }')
939 # Build cpio archives. Find, cpio and gzip the fs, finish by
940 # removing the fs tree.
941 # Don't log this because compression always output error messages.
942 find fs -print | cpio -o -H newc | case "$PACKAGE-$COMPRESSION" in
943 tazpkg-lzma) gzip > fs.cpio.gz;;
944 *-lzma) lzma e fs.cpio.lzma -si;;
945 *) gzip > fs.cpio.gz;;
946 esac && rm -rf fs
947 PACKED_SIZE=$(du -chs fs.cpio.* receipt files.list md5sum \
948 description.txt 2> /dev/null | awk '{ sz=$1 } END { print sz }')
949 report step "Updating receipt sizes"
950 sed -i '/^PACKED_SIZE/d' receipt
951 sed -i '/^UNPACKED_SIZE/d' receipt
952 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
953 sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
954 report end-step
955 if [ "$EXTRAVERSION" ]; then
956 report step "Updating receipt EXTRAVERSION"
957 sed -i s/^EXTRAVERSION.*$// receipt
958 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
959 fi
960 prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
961 remove_previous_package $INCOMING_REPOSITORY
962 report step "Creating full cpio archive"
963 find . -print | cpio -o -H newc > $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
965 # Restore package tree in case we want to browse it.
966 report step "Restoring original package tree"
967 { zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma; } | cpio --quiet -id
968 rm fs.cpio.* && cd ..
970 # Log process.
971 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
972 report close-bloc
973 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
974 echo "Size : `du -sh $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
975 echo ""
977 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/broken
978 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/commit
979 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/cooklist
980 }
982 ########################################################################
983 # This section contains functions used by several other functions
984 # bellow.
985 ########################
987 # Look for receipt/files.list in wok. If they can't be found, get them
988 # from package. Accept one argument : absolute path to package.
989 get_pkg_files()
990 {
991 pkg_files_dir=$tmp/$(basename ${1%.tazpkg})
992 mkdir -p $pkg_files_dir && \
993 cd $pkg_files_dir && \
994 cpio --quiet -idm receipt < $1 && \
995 cpio --quiet -idm files.list < $1
996 }
998 ########################################################################
999 # This section contains functions to generate packages databases.
1000 ########################
1003 gen_packages_db()
1005 # pkg_repository can be $PACKAGES_REPOSITORY or $INCOMING_REPOSITORY.
1006 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
1007 cd $pkg_repository
1008 report step "Generating packages lists: $pkg_repository"
1009 report open-bloc
1010 report step "Removing old files"
1011 for file in files.list.lzma packages.list packages.txt \
1012 packages.desc packages.equiv packages.md5; do
1013 [ -f $file ] && rm $file
1014 done
1015 touch files.list
1017 packages_db_start
1018 unset RECEIPT
1019 report step "Reading datas from all packages"
1020 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1021 get_packages_info
1022 done
1023 report end-step
1024 packages_db_end
1025 report close-bloc
1028 update_packages_db()
1030 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
1031 cd $pkg_repository
1032 for file in packages.list packages.equiv packages.md5 packages.desc \
1033 packages.txt; do
1034 if [ ! -f "$file" ]; then
1035 gen_packages_db
1036 return
1037 fi
1038 done
1039 if [ -f files.list.lzma ]; then
1040 lzma d files.list.lzma files.list
1041 else
1042 gen_packages_db
1043 fi
1044 report step "Updating packages lists: $pkg_repository"
1045 packages_db_start
1047 # Look for removed/update packages.
1048 for PACKAGE in $(grep ^[0-9,a-z,A-Z] packages.txt); do
1049 pkg="$pkg_repository/$(grep -m1 ^$PACKAGE- packages.list).tazpkg"
1050 if ! [ -f "$pkg" ]; then
1051 erase_package_info
1052 else
1053 if [ "$pkg" -nt "packages.list" ]; then
1054 updated_pkg="$updated_pkg
1055 $PACKAGE $pkg"
1056 fi
1057 fi
1058 done
1059 echo "$updated_pkg" | sed 1d | while read PACKAGE pkg; do
1060 erase_package_info
1061 get_packages_info
1062 done
1063 unset updated_pkg
1065 # Look for new packages.
1066 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1067 if ! fgrep -q " ${pkg##*/}" $pkg_repository/packages.md5; then
1068 get_packages_info
1069 fi
1070 done
1071 report end-step
1072 packages_db_end
1075 packages_db_start()
1077 if [ ! -s packages.txt ]; then
1078 echo "# SliTaz GNU/Linux - Packages list
1080 # Packages : unknow
1081 # Date : $(date +%Y-%m-%d\ \%H:%M:%S)
1083 " > packages.txt
1084 else
1085 sed -e 's/^# Packages :.*/# Packages : unknow/' \
1086 -e "s/# Date :.*/# Date : $(date +%Y-%m-%d\ \%H:%M:%S)/" \
1087 -i packages.txt
1088 fi
1090 # Needed in some case as tazwok define RECEIPT at configuration time
1091 # in this particular case it can broke the script.
1092 unset RECEIPT
1095 erase_package_info()
1097 cd $pkg_repository
1098 sed "/^$PACKAGE$/,/^$/d" -i packages.txt
1099 sed "/^$PACKAGE /d" -i packages.desc
1100 sed -e "s/=$PACKAGE /= /" -e "s/ $PACKAGE / /" -e "s/ $PACKAGE$//" \
1101 -e "/=$PACKAGE$/d" -e "s/=[0-9,a-z,A-Z]:$PACKAGE /= /" \
1102 -e "s/ [0-9,a-z,A-Z]:$PACKAGE / /" -e "s/ [0-9,a-z,A-Z]:$PACKAGE$/ /" \
1103 -e "/=[0-9,a-z,A-Z]:$PACKAGE$/d" \
1104 -i packages.equiv
1105 sed "/^$PACKAGE:/d" -i files.list
1106 sed "/^$(basename ${pkg%.tazpkg})$/d" -i packages.list
1107 sed "/ $(basename $pkg)$/d" -i packages.md5
1110 get_packages_info()
1112 # If there's no taz folder in the wok, extract infos from the
1113 # package.
1114 get_pkg_files $pkg
1115 source_receipt
1116 echo "Getting datas from $PACKAGE"
1118 cat >> $pkg_repository/packages.txt << _EOT_
1119 $PACKAGE
1120 $VERSION$EXTRAVERSION
1121 $SHORT_DESC
1122 _EOT_
1123 if [ "$PACKED_SIZE" ]; then
1124 cat >> $pkg_repository/packages.txt << _EOT_
1125 $PACKED_SIZE ($UNPACKED_SIZE installed)
1127 _EOT_
1128 else
1129 echo "" >> $pkg_repository/packages.txt
1130 fi
1132 # Packages.desc is used by Tazpkgbox <tree>.
1133 echo "$PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> $pkg_repository/packages.desc
1135 # Packages.equiv is used by tazpkg install to check depends
1136 for i in $PROVIDE; do
1137 DEST=""
1138 echo $i | fgrep -q : && DEST="${i#*:}:"
1139 if grep -qs ^${i%:*}= $pkg_repository/packages.equiv; then
1140 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" $pkg_repository/packages.equiv
1141 else
1142 echo "${i%:*}=$DEST$PACKAGE" >> $pkg_repository/packages.equiv
1143 fi
1144 done
1146 if [ -f files.list ]; then
1147 { echo "$PACKAGE"; cat files.list; } | awk '
1148 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }' >> $pkg_repository/files.list
1149 fi
1151 cd .. && rm -r "$pkg_files_dir"
1153 cd $pkg_repository
1154 echo $(basename ${pkg%.tazpkg}) >> packages.list
1155 [ ! "$package_md5" ] && package_md5=$(md5sum $(basename $pkg))
1156 echo "$package_md5" >> packages.md5
1157 unset package_md5
1160 source_receipt()
1162 unset PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
1163 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
1164 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
1165 src _pkg DESTDIR CONFIG_SITE
1166 . ${RECEIPT:-$PWD/receipt}
1169 packages_db_end()
1171 cd $pkg_repository
1172 pkgs=$(wc -l packages.list | sed 's/ .*//')
1173 sed "s/# Packages : .*/# Packages : $pkgs/" -i packages.txt
1175 # If lists was updated it's generally needed to sort them well.
1176 if ! sort -c packages.list 2> /dev/null; then
1177 report step "Sorting packages lists"
1178 for file in packages.list packages.desc packages.equiv; do
1179 [ -f $file ] || continue
1180 sort -o $file $file
1181 done
1182 report end-step
1183 fi
1185 # Dont log this because lzma always output error.
1186 lzma e files.list files.list.lzma
1187 rm -f files.list
1188 [ -f packages.equiv ] || touch packages.equiv
1191 ########################################################################
1192 # This section contains functions to generate wok database.
1193 ########################
1195 gen_wok_db()
1197 report step "Generating wok database"
1198 report open-bloc
1199 report step "Removing old files"
1200 for file in $wan_db $dep_db $PACKAGES_REPOSITORY/cookorder.txt; do
1201 [ -f $file ] && rm $file
1202 done
1203 report step "Generating wok-wanted.txt"
1204 gen_wan_db
1205 report step "Generating wok-depends.txt"
1206 for PACKAGE in $(cut -f1 -d '|' $PACKAGES_REPOSITORY/packages.desc \
1207 $INCOMING_REPOSITORY/packages.desc | sort -u); do
1208 RECEIPT=$WOK/$PACKAGE/receipt
1209 if [ -s $RECEIPT ]; then
1210 source_receipt
1211 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
1212 fi
1213 done
1214 sort_db
1215 report close-bloc
1218 gen_wan_db()
1220 for RECEIPT in $(fgrep -l WANTED $WOK/*/receipt); do
1221 WANTED=
1222 source $RECEIPT
1223 [ "$WANTED" ] || continue
1224 echo -e $PACKAGE"\t"$WANTED >> $tmp/wan_db
1225 done
1226 if ! [ -f $wan_db ] || [ "$(diff -q $tmp/wan_db $wan_db)" ]; then
1227 mv -f $tmp/wan_db $wan_db
1228 plan_regen_cookorder=yes
1229 else
1230 rm $tmp/wan_db
1231 fi
1234 update_wan_db()
1236 local PACKAGE
1237 for RECEIPT in $(fgrep WANTED $WOK/*/receipt | \
1238 fgrep $PACKAGE | cut -f1 -d ':'); do
1239 WANTED=
1240 source $RECEIPT
1241 [ "$WANTED" ] || continue
1242 wan_info=$(echo -e $PACKAGE"\t"$WANTED)
1243 [ "$wan_info" = "$(grep -m1 ^$PACKAGE$'\t' $wan_db 2>/dev/null)" ] && return
1244 sed "/^$PACKAGE\t/d" -i $wan_db
1245 echo "$wan_info" >> $wan_db
1246 plan_regen_cookorder=yes
1247 plan_sort_wandb=yes
1248 done
1251 update_dep_db()
1253 dep_info=$(echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ')
1254 [ "$dep_info" = "$(grep -m1 ^$PACKAGE$'\t' $dep_db 2>/dev/null)" ] && return
1255 sed "/^$PACKAGE\t/d" -i $dep_db
1256 echo "$dep_info" >> $dep_db
1257 plan_regen_cookorder=yes
1258 plan_sort_depdb=yes
1261 sort_db()
1263 report step "Generating cookorder.txt"
1264 cat $dep_db | sed 's/ \t / /' | while read PACKAGE BUILD_DEPENDS; do
1265 grep -q ^$PACKAGE$'\t' $wan_db && continue
1267 # Replace each BUILD_DEPENDS with a WANTED package by it's
1268 # WANTED package.
1269 replace_by_wanted()
1271 for p in $BUILD_DEPENDS; do
1272 if grep -q ^$p$'\t' $wan_db; then
1273 echo -n $(grep ^$p$'\t' $wan_db | cut -f 2)' '
1274 else
1275 echo -n $p' '
1276 fi
1277 done | tr ' ' '\n' | sort -u | sed "/^$PACKAGE$/d" | tr '\n' ' '
1279 echo -e $PACKAGE"\t $(replace_by_wanted) "
1280 done > $tmp/db
1281 while [ -s "$tmp/db" ]; do
1282 status=start
1283 for pkg in $(cut -f 1 $tmp/db); do
1284 if ! fgrep -q ' '$pkg' ' $tmp/db; then
1285 echo $pkg >> $tmp/cookorder
1286 sed -e "/^$pkg\t/d" -e "s/ $pkg / /g" -i $tmp/db
1287 status=proceed
1288 fi
1289 done
1290 if [ "$status" = start ]; then
1291 cp -f $tmp/db /tmp/remain-depends.txt
1292 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
1293 for blocked in $(cut -f 1 $tmp/db); do
1294 echo "$blocked" >> $PACKAGES_REPOSITORY/blocked
1295 done
1296 break
1297 fi
1298 done
1299 [ -s $tmp/cookorder ] || touch $tmp/cookorder
1301 # The toolchain packages are moved in first position.
1302 grep $(for pkg in `scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1303 --look_for=all --with_args`; do echo " -e ^$pkg$"; done) \
1304 $tmp/cookorder | tac > $PACKAGES_REPOSITORY/cookorder.txt
1305 for pkg in $(cat $PACKAGES_REPOSITORY/cookorder.txt); do
1306 sed "/^$pkg$/d" -i $tmp/cookorder
1307 done
1309 tac $tmp/cookorder >> $PACKAGES_REPOSITORY/cookorder.txt
1310 unset plan_regen_cookorder
1311 report end-step
1314 ########################################################################
1315 # SCAN CORE
1316 ########################
1317 # Include various scan core-functions. It's not intended to be used
1318 # directly : prefer scan wrappers in next section.
1320 look_for_dep()
1322 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1323 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
1324 | cut -f 2
1325 else
1326 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1327 cut -f 2
1328 fi
1331 look_for_bdep()
1333 look_for_all
1336 look_for_all()
1338 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1339 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
1340 | cut -f 2,3 | sed 's/ / /'
1341 else
1342 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1343 cut -f 2,3 | sed 's/ / /'
1344 fi
1347 look_for_rdep()
1349 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | cut -f 1
1350 if [ "$undigest" ]; then
1351 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt | cut -f 1); do
1352 if [ ! -f "WOK$/$rdep/receipt" ]; then
1353 echo "$rdep"
1354 fi
1355 done
1356 fi
1359 look_for_rbdep()
1361 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | \
1362 cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
1363 if [ "$undigest" ]; then
1364 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
1365 | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1); do
1366 if [ ! -f "WOK$/$rdep/receipt" ]; then
1367 echo "$rdep"
1368 fi
1369 done
1370 fi
1373 # Return WANTED if it exists.
1374 look_for_wanted()
1376 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1377 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-wanted.txt | cut -f 2
1378 else
1379 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 2
1380 fi
1383 # Return packages which wants PACKAGE.
1384 look_for_rwanted()
1386 grep $'\t'$PACKAGE$ $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 1
1387 if [ "$undigest" ]; then
1388 for rwanted in $(grep $'\t'$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-wanted.txt | cut -f 1); do
1389 if [ ! -f "$WOK/$rwanted/receipt" ]; then
1390 echo "$rwanted"
1391 fi
1392 done
1393 fi
1396 look_for_dev()
1398 WANTED=$(look_for_wanted)
1399 if [ "$WANTED" ]; then
1400 if [ "$undigest" ] && [ ! -f "$WOK/$WANTED/receipt" ]; then
1401 [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$WANTED-dev/receipt" ] && echo $WANTED-dev
1402 else
1403 [ -f "$WOK/$WANTED-dev/receipt" ] && echo $WANTED-dev
1404 fi
1405 fi
1406 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1407 [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
1408 else
1409 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
1410 fi
1413 with_dev()
1415 for PACKAGE in $(cat); do
1416 echo $PACKAGE
1417 look_for_dev
1418 done
1421 with_wanted()
1423 for PACKAGE in $(cat); do
1424 echo $PACKAGE
1425 look_for_wanted
1426 done
1429 use_wanted()
1431 for input in $(cat); do
1432 { grep ^$input$'\t' $wan_db || echo $input
1433 } | sed 's/.*\t//'
1434 done
1437 ########################################################################
1438 # SCAN
1439 ########################
1440 # Use wok-wanted.txt and wok-depeds.txt to scan depends.
1441 # Option in command line (must be first arg) :
1442 # --look_for=bdep/rbdep - Look for depends or reverse depends.
1443 # --with_dev - Add development packages (*-dev) in the result.
1444 # --with_wanted - Add package+reverse wanted in the result.
1445 # --with_args - Include packages in argument in the result.
1447 scan()
1449 # Get packages in argument.
1450 local PACKAGE WANTED pkg_list=
1451 for arg in $@; do
1452 [ "$arg" = "${arg#--}" ] || continue
1453 pkg_list="$pkg_list $arg"
1454 done
1456 # Get options.
1457 [ "$pkg_list" ] || return
1458 local cooklist= look_for= with_dev= with_wanted= with_args= log_command="$0 $@" \
1459 get_options_list="look_for with_dev with_wanted with_args cooklist use_wanted"
1460 get_options
1462 # Cooklist is a special case where we need to modify a little
1463 # scan behavior
1464 if [ "$cooklist" ]; then
1465 gen_wan_db
1466 look_for=all && with_args=yes && with_dev= && with_wanted=
1467 filter=use_wanted
1468 append_to_dep()
1470 check_for_commit && echo $PACKAGE >> $tmp/dep
1472 else
1473 append_to_dep()
1475 echo $PACKAGE >> $tmp/dep
1477 fi
1479 [ "$with_dev" ] && filter=with_dev
1480 [ "$with_wanted" ] && filter=with_wanted
1481 if [ "$filter" ]; then
1482 pkg_list=$(echo $pkg_list | $filter)
1483 scan_pkg()
1485 look_for_$look_for | $filter
1487 else
1488 scan_pkg()
1490 look_for_$look_for
1492 fi
1493 touch $tmp/dep
1494 for PACKAGE in $pkg_list; do
1495 [ "$with_args" ] && append_to_dep
1496 scan_pkg
1497 done | tr ' ' '\n' | sort -u > $tmp/list
1498 [ "$look_for" = bdep ] && look_for=dep
1499 while [ -s $tmp/list ]; do
1500 PACKAGE=$(sed 1!d $tmp/list)
1501 sed 1d -i $tmp/list
1502 append_to_dep
1503 for pkg in $(scan_pkg); do
1504 if ! grep -q ^$pkg$ $tmp/list $tmp/dep; then
1505 echo $pkg >> $tmp/list
1506 fi
1507 done
1508 done
1509 if [ "$cooklist" ]; then
1510 mv $tmp/dep $tmp/cooklist
1511 else
1512 cat $tmp/dep | sort -u
1513 fi
1514 rm -f $tmp/dep $tmp/list
1517 ########################################################################
1518 # This section contains functions to check package repository and
1519 # find which packages to cook.
1520 ########################
1522 check_for_commit()
1524 if ! check_for_pkg_in_wok; then
1525 [ "$?" = 2 ] && return 1
1526 return
1527 fi
1528 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
1529 RECEIPT=$WOK/$PACKAGE/receipt
1530 source_receipt
1532 # We use md5 of cooking stuff in the packaged receipt to check
1533 # commit. We look consecutively in 3 different locations :
1534 # - in the wok/PACKAGE/taz/* folder
1535 # - in the receipt in the package in incoming repository
1536 # - in the receipt in the package in packages repository
1537 # If md5sum match, there's no commit.
1538 check_for_commit_using_md5sum()
1540 if [ ! -f $WOK/$PACKAGE/md5 ]; then
1541 sed -n '/# md5sum of cooking stuff :/,$p' receipt | \
1542 sed -e 1d -e 's/^# //' > $WOK/$PACKAGE/md5
1543 cd $WOK/$PACKAGE
1544 fi
1546 if [ -s md5 ]; then
1547 if md5sum -cs md5; then
1549 # If md5sum check if ok, check for new/missing files in
1550 # cooking stuff.
1551 for file in $([ -f receipt ] && echo receipt; \
1552 [ -f description.txt ] && echo description.txt; \
1553 [ -d stuff ] && find stuff); do
1554 if ! fgrep -q " $file" md5; then
1555 set_commited
1556 fi
1557 done
1558 else
1559 set_commited
1560 fi
1561 else
1562 set_commited
1563 fi
1565 set_commited()
1567 ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/commit &&
1568 echo $PACKAGE >> $PACKAGES_REPOSITORY/commit
1569 gen_cookmd5
1570 update_dep_db
1572 taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | fgrep -v '*')
1573 if [ -f $WOK/$PACKAGE/md5 ]; then
1574 cd $WOK/$PACKAGE
1575 check_for_commit_using_md5sum
1576 elif [ "$taz_dir" ]; then
1577 cd $taz_dir
1578 check_for_commit_using_md5sum
1579 else
1580 pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1581 [ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1582 if [ "$pkg" ]; then
1583 get_pkg_files $pkg
1584 check_for_commit_using_md5sum
1585 rm -r $pkg_files_dir
1586 else
1587 set_commited
1588 fi
1589 fi
1590 [ "$forced" ] || echo $PACKAGE >> $tmp/checked
1591 done
1592 return
1595 gen_cook_list()
1597 report step "Scanning wok"
1598 if [ "$pkg" ]; then
1599 scan $pkg --cooklist
1600 else
1601 scan `cat $cooklist` --cooklist
1602 fi
1603 report end-step
1605 [ -s $tmp/checked ] || [ -s $tmp/cooklist ] || return
1606 if [ "$(sed 1!d $PACKAGES_REPOSITORY/cookorder.txt)" = "#PlanSort" ]; then
1607 sed 1d -i $PACKAGES_REPOSITORY/cookorder.txt
1608 plan_regen_cookorder=yes
1609 fi
1611 # Core toolchain should not be cooked unless cook-toolchain is used.
1612 if ! [ -f /etc/config.site.tmptoolchain ] ; then
1613 for PACKAGE in $(scan gcc --look_for=all --with_args --with_wanted); do
1614 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/blocked || \
1615 echo $PACKAGE >> $PACKAGES_REPOSITORY/blocked
1616 done
1617 fi
1619 if [ -s $PACKAGES_REPOSITORY/commit ]; then
1620 cd $PACKAGES_REPOSITORY
1621 for PACKAGE in $(cat commit); do
1622 WANTED="$(look_for_wanted)"
1623 if [ "$WANTED" ]; then
1624 grep -q ^$WANTED$ broken cooklist blocked commit && continue
1625 fi
1626 grep -q ^$PACKAGE$ blocked cooklist && continue
1627 echo $PACKAGE >> cooklist
1628 done
1629 fi
1630 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
1631 [ "$plan_regen_cookorder" ] && sort_db
1632 sort_cooklist
1635 sort_cooklist()
1637 report step "Sorting cooklist"
1638 if [ -f "$tmp/checked" ]; then
1639 rm -f $tmp/cooklist
1640 cat $tmp/checked | while read PACKAGE; do
1641 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/cooklist && \
1642 echo $PACKAGE >> $tmp/cooklist
1643 done
1644 elif ! [ "$COMMAND" = gen-cooklist ]; then
1645 cat $PACKAGES_REPOSITORY/blocked | while read PACKAGE; do
1646 sed "/^$PACKAGE/d" -i $tmp/cooklist
1647 done
1648 fi
1650 for PACKAGE in $(cat $tmp/cooklist); do
1651 WANTED="$(look_for_wanted)"
1652 [ "$WANTED" ] || continue
1653 if grep -q ^$WANTED$ $PACKAGES_REPOSITORY/broken $tmp/cooklist; then
1654 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1655 elif [ ! -d $WOK/$WANTED/install ]; then
1656 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1657 echo $WANTED >> $tmp/cooklist
1658 fi
1659 done
1661 # Use cookorder.txt to sort cooklist.
1662 if [ -s $tmp/cooklist ]; then
1663 cat $PACKAGES_REPOSITORY/cookorder.txt | while read PACKAGE; do
1664 if grep -q ^$PACKAGE$ $tmp/cooklist; then
1665 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1666 echo $PACKAGE >> $tmp/cooklist.tmp
1667 fi
1668 done
1670 # Remaining packages in cooklist are thoses without compile_rules.
1671 # They can be cooked first in any order.
1672 if [ -f $tmp/cooklist.tmp ]; then
1673 cat $tmp/cooklist.tmp >> $tmp/cooklist
1674 rm $tmp/cooklist.tmp
1675 fi
1677 cat $tmp/cooklist
1678 [ "$cooklist" = "$PACKAGES_REPOSITORY/cooklist" ] && \
1679 cat $tmp/cooklist > $cooklist
1680 fi
1682 report end-step
1685 check_for_incoming()
1687 [ -s $INCOMING_REPOSITORY/packages.desc ] || {
1688 echo "No packages in $INCOMING_REPOSITORY."
1689 return; }
1690 if [ -s $PACKAGES_REPOSITORY/broken ]; then
1691 echo "Don't move incoming packages to main repository because theses ones are broken:
1692 $(cat $PACKAGES_REPOSITORY/broken)" >&2
1693 return
1694 fi
1695 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
1696 echo "Don't move incoming packages to main repository because some of them need to be cooked:
1697 $(cat $PACKAGES_REPOSITORY/cooklist)" >&2
1698 return
1699 fi
1700 pkg="$(cut -f 1 -d '|' $INCOMING_REPOSITORY/packages.desc)"
1701 if ! [ "$forced" ]; then
1702 cooklist=$PACKAGES_REPOSITORY/cooklist
1703 gen_cook_list
1704 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
1705 echo "Don't move incoming packages to main repository because some of them need to be cooked." >&2
1706 return
1707 fi
1708 fi
1709 report step "Moving incoming packages to main repository"
1710 unset EXTRAVERSION
1711 for PACKAGE in $pkg; do
1712 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
1713 VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
1714 remove_previous_package $PACKAGES_REPOSITORY
1715 remove_previous_tarball
1716 echo "Moving $PACKAGE..."
1717 mv -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION.tazpkg $PACKAGES_REPOSITORY
1718 touch $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
1719 done
1720 report end-step
1721 for file in packages.list packages.equiv packages.md5 packages.desc \
1722 packages.txt; do
1723 echo -n "" > $INCOMING_REPOSITORY/$file
1724 done
1725 rm -r $INCOMING_REPOSITORY/files.list.lzma
1726 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
1729 ########################################################################
1730 # TAZWOK MAIN FUNCTIONS
1731 ########################
1733 clean()
1735 cd $WOK/$PACKAGE
1736 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
1737 -e ^stuff$ || return
1739 report step "Cleaning $PACKAGE"
1740 # Check for clean_wok function.
1741 if grep -q ^clean_wok $RECEIPT; then
1742 clean_wok
1743 fi
1744 # Clean should only have a receipt, stuff and optional desc.
1745 for f in `ls .`
1746 do
1747 case $f in
1748 receipt|stuff|description.txt)
1749 continue ;;
1750 *)
1751 echo "Removing: $f"
1752 rm -rf $f
1753 esac
1754 done
1755 report end-step
1758 # Configure and make a package with the receipt.
1759 compile_package()
1761 check_for_package_on_cmdline
1763 # Include the receipt to get all needed variables and functions
1764 # and cd into the work directory to start the work.
1765 check_for_receipt
1766 source_receipt
1768 # Log the package name and date.
1769 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
1770 echo "package $PACKAGE (compile)" >> $LOG
1772 # Set wanted $src variable to help compiling.
1773 [ ! "$src" ] && set_src_path
1774 check_for_build_depends || return 1
1775 check_for_wanted
1776 unset target
1777 check_for_tarball && check_for_compile_rules
1780 # Cook command also include all features to manage lists which keep
1781 # track of wok/packages state.
1782 cook()
1784 cook_code=
1785 set_common_path
1786 check_for_receipt
1787 source_receipt
1789 # Define log path and start report.
1790 [ -f $LOCAL_REPOSITORY/log/$PACKAGE.html ] && rm $LOCAL_REPOSITORY/log/$PACKAGE.html
1791 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
1792 report step "Cooking $PACKAGE"
1793 report open-bloc
1795 clean $PACKAGE
1796 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
1798 if compile_package; then
1799 remove_src
1800 refresh_packages_from_compile
1801 gen_package
1803 # Update packages-incoming repository.
1804 store_pkgname=$PACKAGE
1805 pkg_repository=$INCOMING_REPOSITORY
1806 update_packages_db
1808 PACKAGE=$store_pkgname
1809 unset store_pkgname
1811 # Upgrade to cooked packages if it was previously installed.
1812 report step "Look for package(s) to upgrade"
1813 for pkg in $(look_for_rwanted) $PACKAGE; do
1814 if [ -d $INSTALLED/$pkg ]; then
1815 tazpkg get-install $pkg --forced
1816 fi
1817 done
1818 report end-step
1819 else
1821 # Set package as broken.
1822 if ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then
1823 echo $PACKAGE >> $PACKAGES_REPOSITORY/broken
1824 fi
1825 gen_cookmd5
1826 cook_code=1
1827 fi
1829 # Remove build_depends in cook mode (if in cooklist, it's done when
1830 # checking build_depends of next package and we remove only unneeded
1831 # packages to keep chroot minimal and gain some time).
1832 if [ "$COMMAND" = cook ]; then
1833 remove_build_depends $MISSING_PACKAGE
1834 [ -x /usr/bin/clean-chroot ] && clean-chroot
1835 fi
1837 # Regen the cooklist if it was planned and command is not cook.
1838 [ "$regen_cooklist" ] && unset regen_cooklist && \
1839 [ "$COMMAND" != cook ] && sort_cooklist
1841 # Some hacks to set the bloc & function status as failed if cook was
1842 # failed.
1843 report_return_code=$cook_code
1844 report close-bloc
1845 report end-sublog
1846 return $cook_code
1849 cook_list()
1851 if [ -s $tmp/cooklist ]; then
1852 if [ -f /usr/bin/tazchroot ]; then
1853 # Note : options -main variables- are automatically keeped by
1854 # the sub-applications tazchroot/tazwok; as well as report data.
1855 cd $LOCAL_REPOSITORY
1856 [ ! -f tazchroot.conf ] && configure_tazchroot
1857 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
1858 return
1859 fi
1860 while [ -s $tmp/cooklist ]; do
1861 PACKAGE=$(sed 1!d $tmp/cooklist)
1862 cook
1863 done
1864 remove_build_depends $MISSING_PACKAGE $remove_later
1865 [ -x /usr/bin/clean-chroot ] && clean-chroot
1866 else
1867 echo "Nothing to cook."
1868 return
1869 fi
1872 configure_tazchroot()
1874 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
1875 # Tazchroot configuration file - created by tazwok.
1877 # Default chroot path
1878 SLITAZ_DIR=$SLITAZ_DIR
1879 SLITAZ_VERSION=$SLITAZ_VERSION
1880 $( [ "$undigest" ] && echo "undigest=$undigest" )
1881 LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
1882 chroot_dir=\$LOCAL_REPOSITORY/chroot
1884 # Default scripts path (theses scripts are added in the
1885 # $chroot_dir/usr/bin and can be called with tazchroot script)
1886 script_dir=/var/lib/tazchroot
1888 # List of directories to mount.
1889 list_dir="$(for dir in packages wok src packages-incoming log flavors iso; do echo $LOCAL_REPOSITORY/$dir; done)
1890 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
1892 create_chroot()
1894 mkdir -p \$chroot_dir
1895 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
1896 tazpkg get-install \$pkg --root="\$chroot_dir"
1897 done
1899 # Store list of installed packages needed by cleanchroot.
1900 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
1902 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
1903 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
1904 -i \$chroot_dir/etc/slitaz/slitaz.conf
1905 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
1906 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
1909 mount_chroot()
1911 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
1912 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCALSTATE/mirror
1913 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
1914 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
1915 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION
1916 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror' )
1917 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
1918 mount -t proc proc \$chroot_dir/proc
1919 mount -t sysfs sysfs \$chroot_dir/sys
1920 mount -t devpts devpts \$chroot_dir/dev/pts
1921 mount -t tmpfs shm \$chroot_dir/dev/shm
1922 for dir in \$list_dir; do
1923 mkdir -p \$dir \$chroot_dir\$dir
1924 mount \$dir \$chroot_dir\$dir
1925 done
1928 umount_chroot()
1930 for dir in \$list_dir; do
1931 umount \$chroot_dir\$dir
1932 done
1933 umount \$chroot_dir/dev/shm
1934 umount \$chroot_dir/dev/pts
1935 umount \$chroot_dir/sys
1936 umount \$chroot_dir/proc
1938 EOF
1941 ########################################################################
1942 ######################### END OF NEW FUNCTIONS #########################
1943 ########################################################################
1945 # List packages providing a virtual package
1946 whoprovide()
1948 local i;
1949 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
1950 . $i
1951 case " $PROVIDE " in
1952 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
1953 esac
1954 done
1957 ########################################################################
1958 # TAZWOK COMMANDS
1959 ########################
1961 case "$COMMAND" in
1962 stats)
1963 # Tazwok general statistics from the wok config file.
1965 get_tazwok_config
1966 echo -e "\n\033[1mTazwok configuration statistics\033[0m
1967 ================================================================================
1968 Wok directory : $WOK
1969 Packages repository : $PACKAGES_REPOSITORY
1970 Incoming repository : $INCOMING_REPOSITORY
1971 Sources repository : $SOURCES_REPOSITORY
1972 Log directory : $LOCAL_REPOSITORY/log
1973 Packages in the wok : `ls -1 $WOK | wc -l`
1974 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
1975 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
1976 ================================================================================\n"
1977 ;;
1978 edit)
1979 get_tazwok_config
1980 check_for_package_on_cmdline
1981 check_for_receipt
1982 $EDITOR $WOK/$PACKAGE/receipt
1983 ;;
1984 build-depends)
1985 # List dependencies to rebuild wok, or only a package
1986 get_tazwok_config
1987 report(){ : ; }
1988 if [ "$PACKAGE" = toolchain-cooklist ]; then
1989 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1990 --cooklist
1991 elif [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
1992 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1993 --look_for=dep --with_dev --with_args
1994 else
1995 check_for_package_on_cmdline
1996 scan $PACKAGE --look_for=bdep --with_dev
1997 fi
1998 ;;
1999 gen-cooklist)
2000 check_root
2001 get_options_list="pkg"
2002 get_tazwok_config
2003 report(){ : ; }
2004 if ! [ "$pkg" ]; then
2005 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2006 fi
2007 forced=yes
2008 gen_cook_list
2009 ;;
2010 check-depends)
2011 # Check package depends /!\
2012 get_tazwok_config
2013 echo ""
2014 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
2015 ================================================================================"
2016 TMPDIR=/tmp/tazwok$$
2017 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
2019 # Build ALL_DEPENDS variable
2020 scan_dep()
2022 local i
2023 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
2024 for i in $DEPENDS $SUGGESTED ; do
2025 case " $ALL_DEPENDS " in
2026 *\ $i\ *) continue;;
2027 esac
2028 [ -d $WOK/$i ] || {
2029 ALL_DEPENDS="$ALL_DEPENDS$i "
2030 continue
2032 DEPENDS=""
2033 SUGGESTED=""
2034 . $WOK/$i/receipt
2035 scan_dep
2036 done
2039 # Check for ELF file
2040 is_elf()
2042 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" \
2043 = "ELF" ]
2046 # Print shared library dependencies
2047 ldd()
2049 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
2052 mkdir $TMPDIR
2053 cd $TMPDIR
2054 for i in $LOCALSTATE/files.list.lzma \
2055 $LOCALSTATE/undigest/*/files.list.lzma ; do
2056 [ -f $i ] && lzma d $i -so >> files.list
2057 done
2058 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
2059 tazpkg extract $pkg > /dev/null 2>&1
2060 . */receipt
2061 ALL_DEPENDS="$DEFAULT_DEPENDS "
2062 scan_dep
2063 find */fs -type f | while read file ; do
2064 is_elf $file || continue
2065 case "$file" in
2066 *.o|*.ko|*.ko.gz) continue;;
2067 esac
2068 ldd $file | while read lib rem; do
2069 case "$lib" in
2070 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
2071 continue;;
2072 esac
2073 for dep in $(fgrep $lib files.list | cut -d: -f1); do
2074 case " $ALL_DEPENDS " in
2075 *\ $dep\ *) continue 2;;
2076 esac
2077 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
2078 case " $ALL_DEPENDS " in
2079 *\ $vdep\ *) continue 3;;
2080 esac
2081 done
2082 done
2083 [ -n "$dep" ] || dep="UNKNOWN"
2084 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
2085 done
2086 done
2087 rm -rf */
2088 done
2089 cd /tmp
2090 rm -rf $TMPDIR
2091 ;;
2092 check)
2093 # Check wok consistency
2094 get_tazwok_config
2095 echo ""
2096 echo -e "\033[1mWok and packages checking\033[0m
2097 ================================================================================"
2098 cd $WOK
2099 for pkg in $(ls)
2100 do
2101 [ -f $pkg/receipt ] || continue
2102 RECEIPT= $pkg/receipt
2103 source_receipt
2104 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
2105 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
2106 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
2107 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
2108 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
2109 if [ -n "$WANTED" ]; then
2110 if [ ! -f $WANTED/receipt ]; then
2111 echo "Package $PACKAGE wants unknown $WANTED package" >&2
2112 else
2113 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
2114 if [ "$VERSION" = "$WANTED" ]; then
2115 # BASEVERSION is computed in receipt
2116 fgrep -q '_pkg=' $pkg/receipt &&
2117 BASEVERSION=$VERSION
2118 fi
2119 if [ "$VERSION" != "$BASEVERSION" ]; then
2120 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
2121 fi
2122 fi
2123 fi
2125 if [ -n "$CATEGORY" ]; then
2126 case " $(echo $CATEGORIES) " in
2127 *\ $CATEGORY\ *);;
2128 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
2129 esac
2130 else
2131 echo"Package $PACKAGE has no CATEGORY" >&2
2132 fi
2133 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
2134 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
2135 case "$WGET_URL" in
2136 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
2137 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
2138 '') ;;
2139 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
2140 esac
2141 case "$WEB_SITE" in
2142 ftp*|http*);;
2143 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
2144 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
2145 esac
2146 case "$MAINTAINER" in
2147 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
2148 esac
2149 case "$MAINTAINER" in
2150 *@*);;
2151 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
2152 esac
2153 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2154 for i in $DEPENDS; do
2155 [ -d $i ] && continue
2156 [ -n "$(whoprovide $i)" ] && continue
2157 echo -e "$MSG $i"
2158 MSG=""
2159 done
2160 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2161 for i in $BUILD_DEPENDS; do
2162 [ -d $i ] && continue
2163 [ -n "$(whoprovide $i)" ] && continue
2164 echo -e "$MSG $i"
2165 MSG=""
2166 done
2167 MSG="Dependencies loop between $PACKAGE and :\n"
2168 ALL_DEPS=""
2169 check_for_deps_loop $PACKAGE $DEPENDS
2170 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
2171 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
2172 echo "$pkg should be rebuilt after $i installation"
2173 done
2174 done
2175 ;;
2176 list)
2177 # List packages in wok directory. User can specify a category.
2179 get_tazwok_config
2180 if [ "$2" = "category" ]; then
2181 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
2182 exit 0
2183 fi
2184 # Check for an asked category.
2185 if [ -n "$2" ]; then
2186 ASKED_CATEGORY=$2
2187 echo ""
2188 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
2189 echo "================================================================================"
2190 for pkg in $WOK/*
2191 do
2192 [ ! -f $pkg/receipt ] && continue
2193 . $pkg/receipt
2194 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
2195 echo -n "$PACKAGE"
2196 echo -e "\033[28G $VERSION"
2197 packages=$(($packages+1))
2198 fi
2199 done
2200 echo "================================================================================"
2201 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
2202 else
2203 # By default list all packages and version.
2204 echo ""
2205 echo -e "\033[1mList of packages in the wok\033[0m"
2206 echo "================================================================================"
2207 for pkg in $WOK/*
2208 do
2209 [ ! -f $pkg/receipt ] && continue
2210 . $pkg/receipt
2211 echo -n "$PACKAGE"
2212 echo -en "\033[28G $VERSION"
2213 echo -e "\033[42G $CATEGORY"
2214 packages=$(($packages+1))
2215 done
2216 echo "================================================================================"
2217 echo -e "$packages packages available in the wok.\n"
2218 fi
2219 ;;
2220 info)
2221 # Information about a package.
2223 get_tazwok_config
2224 check_for_package_on_cmdline
2225 check_for_receipt
2226 . $WOK/$PACKAGE/receipt
2227 echo ""
2228 echo -e "\033[1mTazwok package information\033[0m
2229 ================================================================================
2230 Package : $PACKAGE
2231 Version : $VERSION
2232 Category : $CATEGORY
2233 Short desc : $SHORT_DESC
2234 Maintainer : $MAINTAINER"
2235 if [ ! "$WEB_SITE" = "" ]; then
2236 echo "Web site : $WEB_SITE"
2237 fi
2238 if [ ! "$DEPENDS" = "" ]; then
2239 echo "Depends : $DEPENDS"
2240 fi
2241 if [ ! "$WANTED" = "" ]; then
2242 echo "Wanted src : $WANTED"
2243 fi
2244 echo "================================================================================"
2245 echo ""
2246 ;;
2247 check-log)
2248 # We just cat the file log to view process info.
2250 get_tazwok_config
2251 if [ ! -f "$LOG" ]; then
2252 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
2253 exit 1
2254 else
2255 echo ""
2256 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
2257 echo "================================================================================"
2258 cat $LOG
2259 echo "================================================================================"
2260 echo ""
2261 fi
2262 ;;
2263 search)
2264 # Search for a package by pattern or name.
2266 get_tazwok_config
2267 if [ -z "$2" ]; then
2268 echo -e "\nPlease specify a pattern or a package name to search." >&2
2269 echo -e "Example : 'tazwok search gcc'.\n" >&2
2270 exit 1
2271 fi
2272 echo ""
2273 echo -e "\033[1mSearch result for :\033[0m $2"
2274 echo "================================================================================"
2275 list=`ls -1 $WOK | fgrep $2`
2276 for pkg in $list
2277 do
2278 . $WOK/$pkg/receipt
2279 echo -n "$PACKAGE "
2280 echo -en "\033[24G $VERSION"
2281 echo -e "\033[42G $CATEGORY"
2282 packages=$(($PACKAGEs+1))
2283 done
2284 echo "================================================================================"
2285 echo "$PACKAGEs packages found for : $2"
2286 echo ""
2287 ;;
2288 compile)
2289 # Configure and make a package with the receipt.
2291 get_tazwok_config
2292 source_lib report
2293 report start
2294 compile_package
2295 ;;
2296 genpkg)
2297 # Generate a package.
2299 get_tazwok_config
2300 source_lib report
2301 report start
2302 gen_package
2303 ;;
2304 cook)
2305 # Compile and generate a package. Just execute tazwok with
2306 # the good commands.
2308 check_root
2309 get_tazwok_config
2310 source_lib report
2311 report start
2312 update_wan_db
2313 check_for_commit
2314 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
2315 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
2316 if [ "$plan_regen_cookorder" ]; then
2317 grep -q "^#" $PACKAGES_REPOSITORY/cookorder.txt || \
2318 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
2319 fi
2320 cook
2321 ;;
2322 sort-cooklist)
2323 if [ ! "$LIST" ]; then
2324 echo "Usage : tazwok sort-cooklist cooklist" >&2\
2325 exit 1
2326 fi
2327 get_tazwok_config
2328 source_lib report
2329 report start
2330 cooklist=$LIST
2331 sort_cooklist
2332 cp -af $tmp/cooklist $cooklist
2333 ;;
2334 cook-list)
2335 # Cook all packages listed in a file or in default cooklist.
2336 check_root
2337 get_options_list="pkg forced"
2338 get_tazwok_config
2339 source_lib report
2340 report start
2341 if ! [ "$pkg" ]; then
2342 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2343 fi
2344 gen_cook_list
2345 cook_list
2346 ;;
2347 clean)
2348 # Clean up a package work directory + thoses which want it.
2350 get_tazwok_config
2351 check_for_package_on_cmdline
2352 check_for_receipt
2353 source_lib report
2354 report start
2355 . $RECEIPT
2356 clean
2357 ;;
2358 gen-clean-wok)
2359 # Generate a clean wok from the current wok by copying all receipts
2360 # and stuff directory.
2362 get_tazwok_config
2363 source_lib report
2364 report start
2365 if [ -z "$ARG" ]; then
2366 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
2367 exit 1
2368 else
2369 dest=$ARG
2370 mkdir -p $dest
2371 fi
2372 report step "Creating clean wok in : $dest"
2373 for pkg in `ls -1 $WOK`
2374 do
2375 mkdir -p $dest/$pkg
2376 cp -a $WOK/$pkg/receipt $dest/$pkg
2377 [ -f $WOK/$pkg/description.txt ] && \
2378 cp -a $WOK/$pkg/description.txt $dest/$pkg
2379 if [ -d "$WOK/$pkg/stuff" ]; then
2380 cp -a $WOK/$pkg/stuff $dest/$pkg
2381 fi
2382 done
2383 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
2384 report end-step
2385 echo "Packages cleaned : `ls -1 $dest | wc -l`"
2386 echo ""
2387 ;;
2388 clean-wok)
2389 # Clean all packages in the work directory
2391 get_tazwok_config
2392 source_lib report
2393 report start
2394 report step "Cleaning wok"
2395 report open-bloc
2396 for PACKAGE in `ls -1 $WOK`
2397 do
2398 set_common_path
2399 source_receipt
2400 clean
2401 done
2402 report close-bloc
2403 echo "`ls -1 $WOK | wc -l` packages cleaned."
2404 ;;
2405 gen-list)
2406 get_tazwok_config
2407 if [ "$2" ]; then
2408 if [ -d "$2" ]; then
2409 pkg_repository=$2
2410 else
2411 echo -e "\nUnable to find directory : $2\n" >&2
2412 exit 1
2413 fi
2414 fi
2416 source_lib report
2417 report start
2418 if [ "$pkg_repository" ]; then
2419 gen_packages_db
2420 else
2421 pkg_repository=$PACKAGES_REPOSITORY && gen_packages_db
2422 pkg_repository=$INCOMING_REPOSITORY && gen_packages_db
2423 fi
2424 ;;
2425 check-list)
2426 # The directory to move into by default is the repository,
2427 # if $2 is not empty cd into $2.
2429 get_tazwok_config
2430 if [ "$2" ]; then
2431 if [ -d "$2" ]; then
2432 pkg_repository=$2
2433 else
2434 echo -e "\nUnable to find directory : $2\n" >&2
2435 exit 1
2436 fi
2437 fi
2439 source_lib report
2440 report start
2441 if [ "$pkg_repository" ]; then
2442 update_packages_db
2443 else
2444 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
2445 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
2446 fi
2447 ;;
2448 new-tree)
2449 # Just create a few directories and generate an empty receipt to prepare
2450 # the creation of a new package.
2452 get_tazwok_config
2453 check_for_package_on_cmdline
2454 if [ -d $WOK/$PACKAGE ]; then
2455 echo -e "\n$PACKAGE package tree already exists.\n" >&2
2456 exit 1
2457 fi
2458 echo "Creating : $WOK/$PACKAGE"
2459 mkdir $WOK/$PACKAGE
2460 cd $WOK/$PACKAGE
2461 echo -n "Preparing the receipt..."
2463 # Default receipt begin.
2465 echo "# SliTaz package receipt." > receipt
2466 echo "" >> receipt
2467 echo "PACKAGE=\"$PACKAGE\"" >> receipt
2468 # Finish the empty receipt.
2469 cat >> receipt << "EOF"
2470 VERSION=""
2471 CATEGORY=""
2472 SHORT_DESC=""
2473 MAINTAINER=""
2474 DEPENDS=""
2475 TARBALL="$PACKAGE-$VERSION.tar.gz"
2476 WEB_SITE=""
2477 WGET_URL=""
2479 # Rules to configure and make the package.
2480 compile_rules()
2482 cd $src
2483 ./configure && make && make install
2486 # Rules to gen a SliTaz package suitable for Tazpkg.
2487 genpkg_rules()
2489 mkdir -p $fs/usr
2490 cp -a $_pkg/usr/bin $fs/usr
2493 EOF
2495 # Default receipt end.
2497 status
2498 # Interactive mode, asking and seding.
2499 if [ "$3" = "--interactive" ]; then
2500 echo "Entering into interactive mode..."
2501 echo "================================================================================"
2502 echo "Package : $PACKAGE"
2503 # Version.
2504 echo -n "Version : " ; read anser
2505 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
2506 # Category.
2507 echo -n "Category : " ; read anser
2508 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
2509 # Short description.
2510 echo -n "Short desc : " ; read anser
2511 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
2512 # Maintainer.
2513 echo -n "Maintainer : " ; read anser
2514 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
2515 # Web site.
2516 echo -n "Web site : " ; read anser
2517 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
2518 echo ""
2519 # Wget URL.
2520 echo "Wget URL to download source tarball."
2521 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
2522 echo -n "Wget url : " ; read anser
2523 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
2524 # Ask for a stuff dir.
2525 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
2526 if [ "$anser" = "y" ]; then
2527 echo -n "Creating the stuff directory..."
2528 mkdir stuff && status
2529 fi
2530 # Ask for a description file.
2531 echo -n "Are you going to write a description ? (y/N) : " ; read anser
2532 if [ "$anser" = "y" ]; then
2533 echo -n "Creating the description.txt file..."
2534 echo "" > description.txt && status
2535 fi
2536 echo "================================================================================"
2537 echo ""
2538 fi
2539 ;;
2540 remove)
2541 # Remove a package from the wok.
2543 get_tazwok_config
2544 check_for_package_on_cmdline
2545 echo ""
2546 echo -n "Please confirm deletion (y/N) : "; read anser
2547 if [ "$anser" = "y" ]; then
2548 echo -n "Removing $PACKAGE..."
2549 rm -rf $WOK/$PACKAGE && status
2550 echo ""
2551 fi
2552 ;;
2553 hgup)
2554 # Pull and update a Hg wok.
2555 get_tazwok_config
2556 if ls -l $WOK/.hg/hgrc | fgrep -q "root"; then
2557 check_root
2558 fi
2559 cd $WOK
2560 hg pull && hg update
2561 ;;
2562 maintainers)
2563 get_tazwok_config
2564 echo ""
2565 echo "List of maintainers for: $WOK"
2566 echo "================================================================================"
2567 touch /tmp/slitaz-maintainers
2568 for pkg in $WOK/*
2569 do
2570 . $pkg/receipt
2571 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
2572 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
2573 echo "$MAINTAINER"
2574 fi
2575 done
2576 echo "================================================================================"
2577 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
2578 echo ""
2579 # Remove tmp files
2580 rm -f /tmp/slitaz-maintainers
2581 ;;
2582 maintained-by)
2583 # Search for packages maintained by a contributor.
2584 get_tazwok_config
2585 if [ ! -n "$2" ]; then
2586 echo "Specify a name or email of a maintainer." >&2
2587 exit 1
2588 fi
2589 echo "Maintainer packages"
2590 echo "================================================================================"
2591 for pkg in $WOK/*
2592 do
2593 . $pkg/receipt
2594 if echo "$MAINTAINER" | fgrep -q "$2"; then
2595 echo "$PACKAGE"
2596 packages=$(($PACKAGEs+1))
2597 fi
2598 done
2599 echo "================================================================================"
2600 echo "Packages maintained by $2: $PACKAGEs"
2601 echo ""
2602 ;;
2603 check-src)
2604 # Verify if upstream package is still available
2606 get_tazwok_config
2607 check_for_package_on_cmdline
2608 check_for_receipt
2609 source_receipt
2610 check_src()
2612 for url in $@; do
2613 busybox wget -s $url 2>/dev/null && break
2614 done
2616 if [ "$WGET_URL" ];then
2617 echo -n "$PACKAGE : "
2618 check_src $WGET_URL
2619 status
2620 else
2621 echo "No tarball to check for $PACKAGE"
2622 fi
2623 ;;
2624 get-src)
2625 check_root
2626 get_options_list="target nounpack"
2627 get_tazwok_config
2628 check_for_package_on_cmdline
2629 check_for_receipt
2630 source_receipt
2631 if [ "$WGET_URL" ];then
2632 source_lib report
2633 report start
2634 check_for_tarball
2635 else
2636 echo "No tarball to download for $PACKAGE"
2637 fi
2638 ;;
2639 check-commit)
2640 check_root
2641 get_options_list="missing forced"
2642 get_tazwok_config
2643 source_lib report
2644 report start
2645 if [ "$forced" ]; then
2646 rm -f $WOK/*/md5
2647 unset forced
2648 fi
2649 if [ "$missing" ]; then
2650 pkg=$(ls -1 $WOK)
2651 else
2652 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2653 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2654 } | sort -u)"
2655 fi
2656 cooklist=$PACKAGES_REPOSITORY/cooklist
2657 gen_cook_list
2658 ;;
2659 cook-commit)
2660 check_root
2661 get_options_list="missing forced"
2662 get_tazwok_config
2663 source_lib report
2664 report start
2665 if [ "$forced" ]; then
2666 rm -f $WOK/*/md5
2667 unset forced
2668 fi
2669 if [ "$missing" ]; then
2670 pkg=$(ls -1 $WOK)
2671 else
2672 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2673 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2674 } | sort -u)"
2675 fi
2676 cooklist=$PACKAGES_REPOSITORY/cooklist
2677 gen_cook_list
2678 cook_list
2679 ;;
2680 cook-all)
2681 check_root
2682 get_options_list="forced missing"
2683 get_tazwok_config
2684 source_lib report
2685 report start
2686 if [ "$missing" ]; then
2687 pkg=$(ls -1 $WOK)
2688 else
2689 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2690 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2691 } | sort -u)"
2692 fi
2693 cooklist=$PACKAGES_REPOSITORY/cooklist
2694 gen_cook_list
2695 cook_list
2696 ;;
2697 gen-wok-db)
2698 check_root
2699 get_tazwok_config
2700 source_lib report
2701 report start
2702 gen_wok_db
2703 ;;
2704 report)
2705 check_root
2706 get_tazwok_config
2707 cd $PACKAGES_REPOSITORY
2708 for i in commit cooklist incoming broken blocked; do
2709 if [ -s $i ]; then
2710 echo -e "\n********************* $i *********************\n$(cat $i)\n*********************"
2711 fi
2712 done
2713 ;;
2714 check-incoming)
2715 check_root
2716 get_options_list="forced"
2717 get_tazwok_config
2718 source_lib report
2719 report start
2720 check_for_incoming
2721 ;;
2722 configure-chroot)
2723 check_root
2724 get_tazwok_config
2725 if [ -f /usr/bin/tazchroot ]; then
2726 cd $LOCAL_REPOSITORY
2727 configure_tazchroot
2728 else
2729 echo "The packages tazchroot need to be installed" >&2
2730 exit 1
2731 fi
2732 ;;
2733 chroot)
2734 check_root
2735 get_tazwok_config
2736 # Merge this and the other chroot function ?.
2737 if [ -f /usr/bin/tazchroot ]; then
2738 cd $LOCAL_REPOSITORY
2739 [ ! -f tazchroot.conf ] && configure_tazchroot
2740 tazchroot
2741 else
2742 echo "The packages tazchroot need to be installed" >&2
2743 exit 1
2744 fi
2745 ;;
2746 cook-toolchain)
2747 check_root
2748 get_tazwok_config
2749 echo -n "" > $PACKAGES_REPOSITORY/broken
2750 if [ -f /usr/bin/tazchroot ]; then
2751 cd $LOCAL_REPOSITORY
2752 [ ! -f tazchroot.conf ] && configure_tazchroot
2753 tazchroot cook-toolchain
2754 # Buggy : chroot can be elsewhere.
2755 rm -r $LOCAL_REPOSITORY/chroot
2756 # /!\ to be writed :
2757 # next rm chroot and plan cook-all by pushing all packages
2758 # in cooklist.
2759 else
2760 echo "The packages tazchroot need to be installed" >&2
2761 exit 1
2762 fi
2763 ;;
2764 webserver)
2765 check_root
2766 get_tazwok_config
2767 if [ "$ARG" = on ]; then
2768 if [ "$WEBSERVER" ] && [ -f "$WEBSERVER/repositories.list" ] && \
2769 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
2770 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
2771 exit 1
2772 fi
2773 if ! [ -f $LOCAL_REPOSITORY/tazchroot.conf ]; then
2774 tazwok configure-chroot ${undigest:+--undigest=$undigest} --SLITAZ_VERSION=$SLITAZ_VERSION --SLITAZ_DIR=$SLITAZ_DIR
2775 fi
2776 for pkg in php lighttpd; do
2777 [ -d $INSTALLED/$pkg ] || missing="$missing $pkg"
2778 done
2779 if [ "$missing" ]; then
2780 echo "You need to install those packages to start webserver: $missing." >&2
2781 exit 1
2782 fi
2783 if [ ! -f "$LOCAL_REPOSITORY/tazwok.conf" ]; then
2784 echo "Copying /etc/slitaz/tazwok.conf to $LOCAL_REPOSITORY/tazwok.conf: webserver is configured repository-by-repository."
2785 cp /etc/slitaz/tazwok.conf $LOCAL_REPOSITORY
2786 fi
2787 if ! [ "$WEBSERVER" ]; then
2788 echo -n "Where to store php pages (default: /var/www/vhosts/bb)? "
2789 read WEBSERVER
2790 [ "$WEBSERVER" ] || WEBSERVER="/var/www/vhosts/bb"
2791 fi
2792 if [ -f "$WEBSERVER/repositories.list" ] && \
2793 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
2794 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
2795 exit 1
2796 fi
2797 mkdir -p $WEBSERVER
2798 echo "${undigest:-$SLITAZ_VERSION}" >> $WEBSERVER/repositories.list
2799 for file in index.php log.php; do
2800 [ -f "$WEBSERVER/$file" ] || ln -s /usr/share/slitaz/web-bb/$file $WEBSERVER
2801 done
2802 source $LOCAL_REPOSITORY/tazchroot.conf
2803 echo "<?php
2805 // Web interface configuration
2807 \$version=\"${undigest:-$SLITAZ_VERSION}\";
2808 \$chroot=\"$chroot_dir\";
2809 \$lockfile=\"\$chroot/proc/1\";
2810 \$db_dir=\"$PACKAGES_REPOSITORY\";
2811 \$log_dir=\"$LOCAL_REPOSITORY/log\";
2812 \$packages=\"$PACKAGES_REPOSITORY\";
2813 \$incoming=\"$INCOMING_REPOSITORY\";
2815 ?>" > $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
2816 [ -L "$WEBSERVER/web" ] || ln -s /usr/share/slitaz/web $WEBSERVER
2817 echo "WEBSERVER=\"$WEBSERVER\"" >> $LOCAL_REPOSITORY/tazwok.conf
2818 if [ -L "$WEBSERVER/conf.php" ]; then
2819 echo "Do yo want to make ${undigest:-$SLITAZ_VERSION} the default page (y/N) ? "
2820 read answer
2821 if [ "$answer" = y ]; then
2822 rm $WEBSERVER/conf.php
2823 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
2824 fi
2825 else
2826 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
2827 fi
2828 elif [ "$ARG" = off ]; then
2829 if ! [ "$WEBSERVER" ]; then
2830 echo "No webserver running for ${undigest:-$SLITAZ_VERSION}" >&2
2831 exit 1
2832 fi
2833 sed '/^WEBSERVER/d' -i $LOCAL_REPOSITORY/tazwok.conf
2834 sed "/^${undigest:-$SLITAZ_VERSION}$/d" -i $WEBSERVER/repositories.list
2835 rm $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
2836 if ! [ -s "$WEBSERVER/repositories.list" ]; then
2837 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"
2838 rm $WEBSERVER/conf.php
2839 elif [ "$(readlink $WEBSERVER/conf.php)" = "$WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php" ]; then
2840 echo "${undigest:-$SLITAZ_VERSION} was the default version to use; switched to : $(sed 1!d $WEBSERVER/repositories.list)"
2841 rm $WEBSERVER/conf.php
2842 ln -s $WEBSERVER/conf-$(sed 1!d $WEBSERVER/repositories.list).php $WEBSERVER/conf.php
2843 fi
2844 else
2845 echo "Usage: tazwok webserver on/off" >&2
2846 exit 1
2847 fi
2848 ;;
2849 usage|*)
2850 # Print usage also for all unknown commands.
2852 usage
2853 ;;
2854 esac
2856 report stop 2>/dev/null || exit 0