tazwok view tazwok @ rev 218

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