tazwok view tazwok @ rev 223

Improve with_dev, use --auto option for tazpkg remove
author Antoine Bodin <gokhlayeh@slitaz.org>
date Wed Feb 02 03:47:22 2011 +0100 (2011-02-02)
parents 4898dcb2d606
children c1c9086a9e31
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" ] && tazpkg remove $pkg --auto
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)
1219 [ "$wan_info" = "$(grep -m1 ^$PACKAGE$'\t' $wan_db 2>/dev/null)" ] && return
1220 sed "/^$PACKAGE\t/d" -i $wan_db
1221 echo "$wan_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 WANTED=$(look_for_wanted)
1375 if [ "$WANTED" ]; then
1376 if [ "$undigest" ] && [ ! -f "$WOK/$WANTED/receipt" ]; then
1377 [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$WANTED-dev/receipt" ] && echo $WANTED-dev
1378 else
1379 [ -f "$WOK/$WANTED-dev/receipt" ] && echo $WANTED-dev
1380 fi
1381 fi
1382 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1383 [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
1384 else
1385 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
1386 fi
1389 with_dev()
1391 for PACKAGE in $(cat); do
1392 echo $PACKAGE
1393 look_for_dev
1394 done
1397 with_wanted()
1399 for PACKAGE in $(cat); do
1400 echo $PACKAGE
1401 look_for_wanted
1402 done
1405 use_wanted()
1407 for input in $(cat); do
1408 { grep ^$input$'\t' $wan_db || echo $input
1409 } | sed 's/.*\t//'
1410 done
1413 ########################################################################
1414 # SCAN
1415 ########################
1416 # Use wok-wanted.txt and wok-depeds.txt to scan depends.
1417 # Option in command line (must be first arg) :
1418 # --look_for=bdep/rbdep - Look for depends or reverse depends.
1419 # --with_dev - Add development packages (*-dev) in the result.
1420 # --with_wanted - Add package+reverse wanted in the result.
1421 # --with_args - Include packages in argument in the result.
1423 scan()
1425 # Get packages in argument.
1426 local PACKAGE WANTED pkg_list=
1427 for arg in $@; do
1428 [ "$arg" = "${arg#--}" ] || continue
1429 pkg_list="$pkg_list $arg"
1430 done
1432 # Get options.
1433 [ "$pkg_list" ] || return
1434 local cooklist= look_for= with_dev= with_wanted= with_args= log_command="$0 $@" \
1435 get_options_list="look_for with_dev with_wanted with_args cooklist use_wanted"
1436 get_options
1438 # Cooklist is a special case where we need to modify a little
1439 # scan behavior
1440 if [ "$cooklist" ]; then
1441 gen_wan_db
1442 look_for=all && with_args=yes && with_dev= && with_wanted=
1443 filter=use_wanted
1444 append_to_dep()
1446 check_for_commit && echo $PACKAGE >> $tmp/dep
1448 else
1449 append_to_dep()
1451 echo $PACKAGE >> $tmp/dep
1453 fi
1455 [ "$with_dev" ] && filter=with_dev
1456 [ "$with_wanted" ] && filter=with_wanted
1457 if [ "$filter" ]; then
1458 pkg_list=$(echo $pkg_list | $filter)
1459 scan_pkg()
1461 look_for_$look_for | $filter
1463 else
1464 scan_pkg()
1466 look_for_$look_for
1468 fi
1469 touch $tmp/dep
1470 for PACKAGE in $pkg_list; do
1471 [ "$with_args" ] && append_to_dep
1472 scan_pkg
1473 done | tr ' ' '\n' | sort -u > $tmp/list
1474 [ "$look_for" = bdep ] && look_for=dep
1475 while [ -s $tmp/list ]; do
1476 PACKAGE=$(sed 1!d $tmp/list)
1477 sed 1d -i $tmp/list
1478 append_to_dep
1479 for pkg in $(scan_pkg); do
1480 if ! grep -q ^$pkg$ $tmp/list $tmp/dep; then
1481 echo $pkg >> $tmp/list
1482 fi
1483 done
1484 done
1485 if [ "$cooklist" ]; then
1486 mv $tmp/dep $tmp/cooklist
1487 else
1488 cat $tmp/dep | sort -u
1489 fi
1490 rm -f $tmp/dep $tmp/list
1493 ########################################################################
1494 # This section contains functions to check package repository and
1495 # find which packages to cook.
1496 ########################
1498 check_for_commit()
1500 if ! check_for_pkg_in_wok; then
1501 [ "$?" = 2 ] && return 1
1502 return
1503 fi
1504 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
1505 RECEIPT=$WOK/$PACKAGE/receipt
1506 source_receipt
1508 # We use md5 of cooking stuff in the packaged receipt to check
1509 # commit. We look consecutively in 3 different locations :
1510 # - in the wok/PACKAGE/taz/* folder
1511 # - in the receipt in the package in incoming repository
1512 # - in the receipt in the package in packages repository
1513 # If md5sum match, there's no commit.
1514 check_for_commit_using_md5sum()
1516 if [ ! -f $WOK/$PACKAGE/md5 ]; then
1517 sed -n '/# md5sum of cooking stuff :/,$p' receipt | \
1518 sed -e 1d -e 's/^# //' > $WOK/$PACKAGE/md5
1519 cd $WOK/$PACKAGE
1520 fi
1522 if [ -s md5 ]; then
1523 if md5sum -cs md5; then
1525 # If md5sum check if ok, check for new/missing files in
1526 # cooking stuff.
1527 for file in $([ -f receipt ] && echo receipt; \
1528 [ -f description.txt ] && echo description.txt; \
1529 [ -d stuff ] && find stuff); do
1530 if ! fgrep -q " $file" md5; then
1531 set_commited
1532 fi
1533 done
1534 else
1535 set_commited
1536 fi
1537 else
1538 set_commited
1539 fi
1541 set_commited()
1543 ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/commit &&
1544 echo $PACKAGE >> $PACKAGES_REPOSITORY/commit
1545 gen_cookmd5
1546 update_dep_db
1548 taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | fgrep -v '*')
1549 if [ -f $WOK/$PACKAGE/md5 ]; then
1550 cd $WOK/$PACKAGE
1551 check_for_commit_using_md5sum
1552 elif [ "$taz_dir" ]; then
1553 cd $taz_dir
1554 check_for_commit_using_md5sum
1555 else
1556 pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1557 [ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1558 if [ "$pkg" ]; then
1559 get_pkg_files $pkg
1560 check_for_commit_using_md5sum
1561 rm -r $pkg_files_dir
1562 else
1563 set_commited
1564 fi
1565 fi
1566 [ "$forced" ] || echo $PACKAGE >> $tmp/checked
1567 done
1568 return
1571 gen_cook_list()
1573 report step "Scanning wok"
1574 if [ "$pkg" ]; then
1575 scan $pkg --cooklist
1576 else
1577 scan `cat $cooklist` --cooklist
1578 fi
1579 report end-step
1581 [ -s $tmp/checked ] || [ -s $tmp/cooklist ] || return
1582 if [ "$(sed 1!d $PACKAGES_REPOSITORY/cookorder.txt)" = "#PlanSort" ]; then
1583 sed 1d -i $PACKAGES_REPOSITORY/cookorder.txt
1584 plan_regen_cookorder=yes
1585 fi
1587 # Core toolchain should not be cooked unless cook-toolchain is used.
1588 if ! [ -f /etc/config.site.tmptoolchain ] ; then
1589 for PACKAGE in $(scan gcc --look_for=all --with_args --with_wanted); do
1590 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/blocked || \
1591 echo $PACKAGE >> $PACKAGES_REPOSITORY/blocked
1592 done
1593 fi
1595 if [ -s $PACKAGES_REPOSITORY/commit ]; then
1596 cd $PACKAGES_REPOSITORY
1597 for PACKAGE in $(cat commit); do
1598 WANTED="$(look_for_wanted)"
1599 if [ "$WANTED" ]; then
1600 grep -q ^$WANTED$ broken cooklist blocked commit && continue
1601 fi
1602 grep -q ^$PACKAGE$ blocked cooklist && continue
1603 echo $PACKAGE >> cooklist
1604 done
1605 fi
1606 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
1607 [ "$plan_regen_cookorder" ] && sort_db
1608 sort_cooklist
1611 sort_cooklist()
1613 report step "Sorting cooklist"
1614 if [ -f "$tmp/checked" ]; then
1615 rm -f $tmp/cooklist
1616 cat $tmp/checked | while read PACKAGE; do
1617 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/cooklist && \
1618 echo $PACKAGE >> $tmp/cooklist
1619 done
1620 elif ! [ "$COMMAND" = gen-cooklist ]; then
1621 cat $PACKAGES_REPOSITORY/blocked | while read PACKAGE; do
1622 sed "/^$PACKAGE/d" -i $tmp/cooklist
1623 done
1624 fi
1626 for PACKAGE in $(cat $tmp/cooklist); do
1627 WANTED="$(look_for_wanted)"
1628 [ "$WANTED" ] || continue
1629 if grep -q ^$WANTED$ $PACKAGES_REPOSITORY/broken $tmp/cooklist; then
1630 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1631 elif [ ! -d $WOK/$WANTED/install ]; then
1632 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1633 echo $WANTED >> $tmp/cooklist
1634 fi
1635 done
1637 # Use cookorder.txt to sort cooklist.
1638 if [ -s $tmp/cooklist ]; then
1639 cat $PACKAGES_REPOSITORY/cookorder.txt | while read PACKAGE; do
1640 if grep -q ^$PACKAGE$ $tmp/cooklist; then
1641 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1642 echo $PACKAGE >> $tmp/cooklist.tmp
1643 fi
1644 done
1646 # Remaining packages in cooklist are thoses without compile_rules.
1647 # They can be cooked first in any order.
1648 if [ -f $tmp/cooklist.tmp ]; then
1649 cat $tmp/cooklist.tmp >> $tmp/cooklist
1650 rm $tmp/cooklist.tmp
1651 fi
1653 cat $tmp/cooklist
1654 [ "$cooklist" = "$PACKAGES_REPOSITORY/cooklist" ] && \
1655 cat $tmp/cooklist > $cooklist
1656 fi
1658 report end-step
1661 check_for_incoming()
1663 [ -s $INCOMING_REPOSITORY/packages.desc ] || {
1664 echo "No packages in $INCOMING_REPOSITORY."
1665 return; }
1666 if [ -s $PACKAGES_REPOSITORY/broken ]; then
1667 echo "Don't move incoming packages to main repository because theses ones are broken:
1668 $(cat $PACKAGES_REPOSITORY/broken)" >&2
1669 return
1670 fi
1671 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
1672 echo "Don't move incoming packages to main repository because some of them need to be cooked:
1673 $(cat $PACKAGES_REPOSITORY/cooklist)" >&2
1674 return
1675 fi
1676 pkg="$(cut -f 1 -d '|' $INCOMING_REPOSITORY/packages.desc)"
1677 if ! [ "$forced" ]; then
1678 cooklist=$PACKAGES_REPOSITORY/cooklist
1679 gen_cook_list
1680 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
1681 echo "Don't move incoming packages to main repository because some of them need to be cooked." >&2
1682 return
1683 fi
1684 fi
1685 report step "Moving incoming packages to main repository"
1686 unset EXTRAVERSION
1687 for PACKAGE in $pkg; do
1688 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
1689 VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
1690 remove_previous_package $PACKAGES_REPOSITORY
1691 remove_previous_tarball
1692 echo "Moving $PACKAGE..."
1693 mv -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION.tazpkg $PACKAGES_REPOSITORY
1694 touch $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
1695 done
1696 report end-step
1697 for file in packages.list packages.equiv packages.md5 packages.desc \
1698 packages.txt; do
1699 echo -n "" > $INCOMING_REPOSITORY/$file
1700 done
1701 rm -r $INCOMING_REPOSITORY/files.list.lzma
1702 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
1705 ########################################################################
1706 # TAZWOK MAIN FUNCTIONS
1707 ########################
1709 clean()
1711 cd $WOK/$PACKAGE
1712 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
1713 -e ^stuff$ || return
1715 report step "Cleaning $PACKAGE"
1716 # Check for clean_wok function.
1717 if grep -q ^clean_wok $RECEIPT; then
1718 clean_wok
1719 fi
1720 # Clean should only have a receipt, stuff and optional desc.
1721 for f in `ls .`
1722 do
1723 case $f in
1724 receipt|stuff|description.txt)
1725 continue ;;
1726 *)
1727 echo "Removing: $f"
1728 rm -rf $f
1729 esac
1730 done
1731 report end-step
1734 # Configure and make a package with the receipt.
1735 compile_package()
1737 check_for_package_on_cmdline
1739 # Include the receipt to get all needed variables and functions
1740 # and cd into the work directory to start the work.
1741 check_for_receipt
1742 source_receipt
1744 # Log the package name and date.
1745 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
1746 echo "package $PACKAGE (compile)" >> $LOG
1748 # Set wanted $src variable to help compiling.
1749 [ ! "$src" ] && set_src_path
1750 check_for_build_depends || return 1
1751 check_for_wanted
1752 unset target
1753 check_for_tarball && check_for_compile_rules
1756 # Cook command also include all features to manage lists which keep
1757 # track of wok/packages state.
1758 cook()
1760 cook_code=
1761 set_common_path
1762 check_for_receipt
1763 source_receipt
1765 # Define log path and start report.
1766 [ -f $LOCAL_REPOSITORY/log/$PACKAGE.html ] && rm $LOCAL_REPOSITORY/log/$PACKAGE.html
1767 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
1768 report step "Cooking $PACKAGE"
1769 report open-bloc
1771 clean $PACKAGE
1772 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
1774 if compile_package; then
1775 remove_src
1776 refresh_packages_from_compile
1777 gen_package
1779 # Update packages-incoming repository.
1780 store_pkgname=$PACKAGE
1781 pkg_repository=$INCOMING_REPOSITORY
1782 update_packages_db
1784 PACKAGE=$store_pkgname
1785 unset store_pkgname
1787 # Upgrade to cooked packages if it was previously installed.
1788 report step "Look for package(s) to upgrade"
1789 for pkg in $(look_for_rwanted) $PACKAGE; do
1790 if [ -d $INSTALLED/$pkg ]; then
1791 tazpkg get-install $pkg --forced
1792 fi
1793 done
1794 report end-step
1795 else
1797 # Set package as broken.
1798 if ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then
1799 echo $PACKAGE >> $PACKAGES_REPOSITORY/broken
1800 fi
1801 gen_cookmd5
1802 cook_code=1
1803 fi
1805 # Remove build_depends in cook mode (if in cooklist, it's done when
1806 # checking build_depends of next package and we remove only unneeded
1807 # packages to keep chroot minimal and gain some time).
1808 if [ "$COMMAND" = cook ]; then
1809 remove_build_depends $MISSING_PACKAGE
1810 [ -x /usr/bin/clean-chroot ] && clean-chroot
1811 fi
1813 # Regen the cooklist if it was planned and command is not cook.
1814 [ "$regen_cooklist" ] && unset regen_cooklist && \
1815 [ "$COMMAND" != cook ] && sort_cooklist
1817 # Some hacks to set the bloc & function status as failed if cook was
1818 # failed.
1819 report_return_code=$cook_code
1820 report close-bloc
1821 report end-sublog
1822 return $cook_code
1825 cook_list()
1827 if [ -s $tmp/cooklist ]; then
1828 if [ -f /usr/bin/tazchroot ]; then
1829 # Note : options -main variables- are automatically keeped by
1830 # the sub-applications tazchroot/tazwok; as well as report data.
1831 cd $LOCAL_REPOSITORY
1832 [ ! -f tazchroot.conf ] && configure_tazchroot
1833 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
1834 return
1835 fi
1836 while [ -s $tmp/cooklist ]; do
1837 PACKAGE=$(sed 1!d $tmp/cooklist)
1838 cook
1839 done
1840 remove_build_depends $MISSING_PACKAGE $remove_later
1841 [ -x /usr/bin/clean-chroot ] && clean-chroot
1842 else
1843 echo "Nothing to cook."
1844 return
1845 fi
1848 configure_tazchroot()
1850 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
1851 # Tazchroot configuration file - created by tazwok.
1853 # Default chroot path
1854 SLITAZ_DIR=$SLITAZ_DIR
1855 SLITAZ_VERSION=$SLITAZ_VERSION
1856 $( [ "$undigest" ] && echo "undigest=$undigest" )
1857 LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
1858 chroot_dir=\$LOCAL_REPOSITORY/chroot
1860 # Default scripts path (theses scripts are added in the
1861 # $chroot_dir/usr/bin and can be called with tazchroot script)
1862 script_dir=/var/lib/tazchroot
1864 # List of directories to mount.
1865 list_dir="$(for dir in packages wok src packages-incoming log flavors iso; do echo $LOCAL_REPOSITORY/$dir; done)
1866 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
1868 create_chroot()
1870 mkdir -p \$chroot_dir
1871 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
1872 tazpkg get-install \$pkg --root="\$chroot_dir"
1873 done
1875 # Store list of installed packages needed by cleanchroot.
1876 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
1878 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
1879 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
1880 -i \$chroot_dir/etc/slitaz/slitaz.conf
1881 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
1882 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
1885 mount_chroot()
1887 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
1888 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCALSTATE/mirror
1889 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
1890 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
1891 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION
1892 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror' )
1893 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
1894 mount -t proc proc \$chroot_dir/proc
1895 mount -t sysfs sysfs \$chroot_dir/sys
1896 mount -t devpts devpts \$chroot_dir/dev/pts
1897 mount -t tmpfs shm \$chroot_dir/dev/shm
1898 for dir in \$list_dir; do
1899 mkdir -p \$dir \$chroot_dir\$dir
1900 mount \$dir \$chroot_dir\$dir
1901 done
1904 umount_chroot()
1906 for dir in \$list_dir; do
1907 umount \$chroot_dir\$dir
1908 done
1909 umount \$chroot_dir/dev/shm
1910 umount \$chroot_dir/dev/pts
1911 umount \$chroot_dir/sys
1912 umount \$chroot_dir/proc
1914 EOF
1917 ########################################################################
1918 ######################### END OF NEW FUNCTIONS #########################
1919 ########################################################################
1921 # List packages providing a virtual package
1922 whoprovide()
1924 local i;
1925 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
1926 . $i
1927 case " $PROVIDE " in
1928 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
1929 esac
1930 done
1933 ########################################################################
1934 # TAZWOK COMMANDS
1935 ########################
1937 case "$COMMAND" in
1938 stats)
1939 # Tazwok general statistics from the wok config file.
1941 get_tazwok_config
1942 echo -e "\n\033[1mTazwok configuration statistics\033[0m
1943 ================================================================================
1944 Wok directory : $WOK
1945 Packages repository : $PACKAGES_REPOSITORY
1946 Incoming repository : $INCOMING_REPOSITORY
1947 Sources repository : $SOURCES_REPOSITORY
1948 Log directory : $LOCAL_REPOSITORY/log
1949 Packages in the wok : `ls -1 $WOK | wc -l`
1950 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
1951 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
1952 ================================================================================\n"
1953 ;;
1954 edit)
1955 get_tazwok_config
1956 check_for_package_on_cmdline
1957 check_for_receipt
1958 $EDITOR $WOK/$PACKAGE/receipt
1959 ;;
1960 build-depends)
1961 # List dependencies to rebuild wok, or only a package
1962 get_tazwok_config
1963 report(){ : ; }
1964 if [ "$PACKAGE" = toolchain-cooklist ]; then
1965 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1966 --cooklist
1967 elif [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
1968 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1969 --look_for=dep --with_dev --with_args
1970 else
1971 check_for_package_on_cmdline
1972 scan $PACKAGE --look_for=bdep --with_dev
1973 fi
1974 ;;
1975 gen-cooklist)
1976 check_root
1977 get_options_list="pkg"
1978 get_tazwok_config
1979 report(){ : ; }
1980 if ! [ "$pkg" ]; then
1981 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
1982 fi
1983 forced=yes
1984 gen_cook_list
1985 ;;
1986 check-depends)
1987 # Check package depends /!\
1988 get_tazwok_config
1989 echo ""
1990 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
1991 ================================================================================"
1992 TMPDIR=/tmp/tazwok$$
1993 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
1995 # Build ALL_DEPENDS variable
1996 scan_dep()
1998 local i
1999 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
2000 for i in $DEPENDS $SUGGESTED ; do
2001 case " $ALL_DEPENDS " in
2002 *\ $i\ *) continue;;
2003 esac
2004 [ -d $WOK/$i ] || {
2005 ALL_DEPENDS="$ALL_DEPENDS$i "
2006 continue
2008 DEPENDS=""
2009 SUGGESTED=""
2010 . $WOK/$i/receipt
2011 scan_dep
2012 done
2015 # Check for ELF file
2016 is_elf()
2018 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" \
2019 = "ELF" ]
2022 # Print shared library dependencies
2023 ldd()
2025 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
2028 mkdir $TMPDIR
2029 cd $TMPDIR
2030 for i in $LOCALSTATE/files.list.lzma \
2031 $LOCALSTATE/undigest/*/files.list.lzma ; do
2032 [ -f $i ] && lzma d $i -so >> files.list
2033 done
2034 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
2035 tazpkg extract $pkg > /dev/null 2>&1
2036 . */receipt
2037 ALL_DEPENDS="$DEFAULT_DEPENDS "
2038 scan_dep
2039 find */fs -type f | while read file ; do
2040 is_elf $file || continue
2041 case "$file" in
2042 *.o|*.ko|*.ko.gz) continue;;
2043 esac
2044 ldd $file | while read lib rem; do
2045 case "$lib" in
2046 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
2047 continue;;
2048 esac
2049 for dep in $(fgrep $lib files.list | cut -d: -f1); do
2050 case " $ALL_DEPENDS " in
2051 *\ $dep\ *) continue 2;;
2052 esac
2053 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
2054 case " $ALL_DEPENDS " in
2055 *\ $vdep\ *) continue 3;;
2056 esac
2057 done
2058 done
2059 [ -n "$dep" ] || dep="UNKNOWN"
2060 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
2061 done
2062 done
2063 rm -rf */
2064 done
2065 cd /tmp
2066 rm -rf $TMPDIR
2067 ;;
2068 check)
2069 # Check wok consistency
2070 get_tazwok_config
2071 echo ""
2072 echo -e "\033[1mWok and packages checking\033[0m
2073 ================================================================================"
2074 cd $WOK
2075 for pkg in $(ls)
2076 do
2077 [ -f $pkg/receipt ] || continue
2078 RECEIPT= $pkg/receipt
2079 source_receipt
2080 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
2081 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
2082 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
2083 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
2084 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
2085 if [ -n "$WANTED" ]; then
2086 if [ ! -f $WANTED/receipt ]; then
2087 echo "Package $PACKAGE wants unknown $WANTED package" >&2
2088 else
2089 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
2090 if [ "$VERSION" = "$WANTED" ]; then
2091 # BASEVERSION is computed in receipt
2092 fgrep -q '_pkg=' $pkg/receipt &&
2093 BASEVERSION=$VERSION
2094 fi
2095 if [ "$VERSION" != "$BASEVERSION" ]; then
2096 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
2097 fi
2098 fi
2099 fi
2101 if [ -n "$CATEGORY" ]; then
2102 case " $(echo $CATEGORIES) " in
2103 *\ $CATEGORY\ *);;
2104 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
2105 esac
2106 else
2107 echo"Package $PACKAGE has no CATEGORY" >&2
2108 fi
2109 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
2110 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
2111 case "$WGET_URL" in
2112 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
2113 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
2114 '') ;;
2115 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
2116 esac
2117 case "$WEB_SITE" in
2118 ftp*|http*);;
2119 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
2120 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
2121 esac
2122 case "$MAINTAINER" in
2123 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
2124 esac
2125 case "$MAINTAINER" in
2126 *@*);;
2127 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
2128 esac
2129 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2130 for i in $DEPENDS; do
2131 [ -d $i ] && continue
2132 [ -n "$(whoprovide $i)" ] && continue
2133 echo -e "$MSG $i"
2134 MSG=""
2135 done
2136 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2137 for i in $BUILD_DEPENDS; do
2138 [ -d $i ] && continue
2139 [ -n "$(whoprovide $i)" ] && continue
2140 echo -e "$MSG $i"
2141 MSG=""
2142 done
2143 MSG="Dependencies loop between $PACKAGE and :\n"
2144 ALL_DEPS=""
2145 check_for_deps_loop $PACKAGE $DEPENDS
2146 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
2147 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
2148 echo "$pkg should be rebuilt after $i installation"
2149 done
2150 done
2151 ;;
2152 list)
2153 # List packages in wok directory. User can specify a category.
2155 get_tazwok_config
2156 if [ "$2" = "category" ]; then
2157 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
2158 exit 0
2159 fi
2160 # Check for an asked category.
2161 if [ -n "$2" ]; then
2162 ASKED_CATEGORY=$2
2163 echo ""
2164 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
2165 echo "================================================================================"
2166 for pkg in $WOK/*
2167 do
2168 [ ! -f $pkg/receipt ] && continue
2169 . $pkg/receipt
2170 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
2171 echo -n "$PACKAGE"
2172 echo -e "\033[28G $VERSION"
2173 packages=$(($packages+1))
2174 fi
2175 done
2176 echo "================================================================================"
2177 echo -e "$PACKAGEs packages in category $ASKED_CATEGORY.\n"
2178 else
2179 # By default list all packages and version.
2180 echo ""
2181 echo -e "\033[1mList of packages in the wok\033[0m"
2182 echo "================================================================================"
2183 for pkg in $WOK/*
2184 do
2185 [ ! -f $pkg/receipt ] && continue
2186 . $pkg/receipt
2187 echo -n "$PACKAGE"
2188 echo -en "\033[28G $VERSION"
2189 echo -e "\033[42G $CATEGORY"
2190 packages=$(($packages+1))
2191 done
2192 echo "================================================================================"
2193 echo -e "$PACKAGEs packages available in the wok.\n"
2194 fi
2195 ;;
2196 info)
2197 # Information about a package.
2199 get_tazwok_config
2200 check_for_package_on_cmdline
2201 check_for_receipt
2202 . $WOK/$PACKAGE/receipt
2203 echo ""
2204 echo -e "\033[1mTazwok package information\033[0m
2205 ================================================================================
2206 Package : $PACKAGE
2207 Version : $VERSION
2208 Category : $CATEGORY
2209 Short desc : $SHORT_DESC
2210 Maintainer : $MAINTAINER"
2211 if [ ! "$WEB_SITE" = "" ]; then
2212 echo "Web site : $WEB_SITE"
2213 fi
2214 if [ ! "$DEPENDS" = "" ]; then
2215 echo "Depends : $DEPENDS"
2216 fi
2217 if [ ! "$WANTED" = "" ]; then
2218 echo "Wanted src : $WANTED"
2219 fi
2220 echo "================================================================================"
2221 echo ""
2222 ;;
2223 check-log)
2224 # We just cat the file log to view process info.
2226 get_tazwok_config
2227 if [ ! -f "$LOG" ]; then
2228 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
2229 exit 1
2230 else
2231 echo ""
2232 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
2233 echo "================================================================================"
2234 cat $LOG
2235 echo "================================================================================"
2236 echo ""
2237 fi
2238 ;;
2239 search)
2240 # Search for a package by pattern or name.
2242 get_tazwok_config
2243 if [ -z "$2" ]; then
2244 echo -e "\nPlease specify a pattern or a package name to search." >&2
2245 echo -e "Example : 'tazwok search gcc'.\n" >&2
2246 exit 1
2247 fi
2248 echo ""
2249 echo -e "\033[1mSearch result for :\033[0m $2"
2250 echo "================================================================================"
2251 list=`ls -1 $WOK | fgrep $2`
2252 for pkg in $list
2253 do
2254 . $WOK/$pkg/receipt
2255 echo -n "$PACKAGE "
2256 echo -en "\033[24G $VERSION"
2257 echo -e "\033[42G $CATEGORY"
2258 packages=$(($PACKAGEs+1))
2259 done
2260 echo "================================================================================"
2261 echo "$PACKAGEs packages found for : $2"
2262 echo ""
2263 ;;
2264 compile)
2265 # Configure and make a package with the receipt.
2267 get_tazwok_config
2268 source_lib report
2269 report start
2270 compile_package
2271 ;;
2272 genpkg)
2273 # Generate a package.
2275 get_tazwok_config
2276 source_lib report
2277 report start
2278 gen_package
2279 ;;
2280 cook)
2281 # Compile and generate a package. Just execute tazwok with
2282 # the good commands.
2284 check_root
2285 get_tazwok_config
2286 source_lib report
2287 report start
2288 update_wan_db
2289 check_for_commit
2290 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
2291 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
2292 if [ "$plan_regen_cookorder" ]; then
2293 grep -q "^#" $PACKAGES_REPOSITORY/cookorder.txt || \
2294 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
2295 fi
2296 cook
2297 ;;
2298 sort-cooklist)
2299 if [ ! "$LIST" ]; then
2300 echo "Usage : tazwok sort-cooklist cooklist" >&2\
2301 exit 1
2302 fi
2303 get_tazwok_config
2304 source_lib report
2305 report start
2306 cooklist=$LIST
2307 sort_cooklist
2308 cp -af $tmp/cooklist $cooklist
2309 ;;
2310 cook-list)
2311 # Cook all packages listed in a file or in default cooklist.
2312 check_root
2313 get_options_list="pkg forced"
2314 get_tazwok_config
2315 source_lib report
2316 report start
2317 if ! [ "$pkg" ]; then
2318 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2319 fi
2320 gen_cook_list
2321 cook_list
2322 ;;
2323 clean)
2324 # Clean up a package work directory + thoses which want it.
2326 get_tazwok_config
2327 check_for_package_on_cmdline
2328 check_for_receipt
2329 source_lib report
2330 report start
2331 . $RECEIPT
2332 clean
2333 ;;
2334 gen-clean-wok)
2335 # Generate a clean wok from the current wok by copying all receipts
2336 # and stuff directory.
2338 get_tazwok_config
2339 source_lib report
2340 report start
2341 if [ -z "$ARG" ]; then
2342 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
2343 exit 1
2344 else
2345 dest=$ARG
2346 mkdir -p $dest
2347 fi
2348 report step "Creating clean wok in : $dest"
2349 for pkg in `ls -1 $WOK`
2350 do
2351 mkdir -p $dest/$pkg
2352 cp -a $WOK/$pkg/receipt $dest/$pkg
2353 [ -f $WOK/$pkg/description.txt ] && \
2354 cp -a $WOK/$pkg/description.txt $dest/$pkg
2355 if [ -d "$WOK/$pkg/stuff" ]; then
2356 cp -a $WOK/$pkg/stuff $dest/$pkg
2357 fi
2358 done
2359 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
2360 report end-step
2361 echo "Packages cleaned : `ls -1 $dest | wc -l`"
2362 echo ""
2363 ;;
2364 clean-wok)
2365 # Clean all packages in the work directory
2367 get_tazwok_config
2368 source_lib report
2369 report start
2370 report step "Cleaning wok"
2371 report open-bloc
2372 for PACKAGE in `ls -1 $WOK`
2373 do
2374 set_common_path
2375 source_receipt
2376 clean
2377 done
2378 report close-bloc
2379 echo "`ls -1 $WOK | wc -l` packages cleaned."
2380 ;;
2381 gen-list)
2382 get_tazwok_config
2383 if [ "$2" ]; then
2384 if [ -d "$2" ]; then
2385 pkg_repository=$2
2386 else
2387 echo -e "\nUnable to find directory : $2\n" >&2
2388 exit 1
2389 fi
2390 fi
2392 source_lib report
2393 report start
2394 if [ "$pkg_repository" ]; then
2395 gen_packages_db
2396 else
2397 pkg_repository=$PACKAGES_REPOSITORY && gen_packages_db
2398 pkg_repository=$INCOMING_REPOSITORY && gen_packages_db
2399 fi
2400 ;;
2401 check-list)
2402 # The directory to move into by default is the repository,
2403 # if $2 is not empty cd into $2.
2405 get_tazwok_config
2406 if [ "$2" ]; then
2407 if [ -d "$2" ]; then
2408 pkg_repository=$2
2409 else
2410 echo -e "\nUnable to find directory : $2\n" >&2
2411 exit 1
2412 fi
2413 fi
2415 source_lib report
2416 report start
2417 if [ "$pkg_repository" ]; then
2418 update_packages_db
2419 else
2420 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
2421 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
2422 fi
2423 ;;
2424 new-tree)
2425 # Just create a few directories and generate an empty receipt to prepare
2426 # the creation of a new package.
2428 get_tazwok_config
2429 check_for_package_on_cmdline
2430 if [ -d $WOK/$PACKAGE ]; then
2431 echo -e "\n$PACKAGE package tree already exists.\n" >&2
2432 exit 1
2433 fi
2434 echo "Creating : $WOK/$PACKAGE"
2435 mkdir $WOK/$PACKAGE
2436 cd $WOK/$PACKAGE
2437 echo -n "Preparing the receipt..."
2439 # Default receipt begin.
2441 echo "# SliTaz package receipt." > receipt
2442 echo "" >> receipt
2443 echo "PACKAGE=\"$PACKAGE\"" >> receipt
2444 # Finish the empty receipt.
2445 cat >> receipt << "EOF"
2446 VERSION=""
2447 CATEGORY=""
2448 SHORT_DESC=""
2449 MAINTAINER=""
2450 DEPENDS=""
2451 TARBALL="$PACKAGE-$VERSION.tar.gz"
2452 WEB_SITE=""
2453 WGET_URL=""
2455 # Rules to configure and make the package.
2456 compile_rules()
2458 cd $src
2459 ./configure && make && make install
2462 # Rules to gen a SliTaz package suitable for Tazpkg.
2463 genpkg_rules()
2465 mkdir -p $fs/usr
2466 cp -a $_pkg/usr/bin $fs/usr
2469 EOF
2471 # Default receipt end.
2473 status
2474 # Interactive mode, asking and seding.
2475 if [ "$3" = "--interactive" ]; then
2476 echo "Entering into interactive mode..."
2477 echo "================================================================================"
2478 echo "Package : $PACKAGE"
2479 # Version.
2480 echo -n "Version : " ; read anser
2481 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
2482 # Category.
2483 echo -n "Category : " ; read anser
2484 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
2485 # Short description.
2486 echo -n "Short desc : " ; read anser
2487 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
2488 # Maintainer.
2489 echo -n "Maintainer : " ; read anser
2490 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
2491 # Web site.
2492 echo -n "Web site : " ; read anser
2493 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
2494 echo ""
2495 # Wget URL.
2496 echo "Wget URL to download source tarball."
2497 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
2498 echo -n "Wget url : " ; read anser
2499 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
2500 # Ask for a stuff dir.
2501 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
2502 if [ "$anser" = "y" ]; then
2503 echo -n "Creating the stuff directory..."
2504 mkdir stuff && status
2505 fi
2506 # Ask for a description file.
2507 echo -n "Are you going to write a description ? (y/N) : " ; read anser
2508 if [ "$anser" = "y" ]; then
2509 echo -n "Creating the description.txt file..."
2510 echo "" > description.txt && status
2511 fi
2512 echo "================================================================================"
2513 echo ""
2514 fi
2515 ;;
2516 remove)
2517 # Remove a package from the wok.
2519 get_tazwok_config
2520 check_for_package_on_cmdline
2521 echo ""
2522 echo -n "Please confirm deletion (y/N) : "; read anser
2523 if [ "$anser" = "y" ]; then
2524 echo -n "Removing $PACKAGE..."
2525 rm -rf $WOK/$PACKAGE && status
2526 echo ""
2527 fi
2528 ;;
2529 hgup)
2530 # Pull and update a Hg wok.
2531 get_tazwok_config
2532 if ls -l $WOK/.hg/hgrc | fgrep -q "root"; then
2533 check_root
2534 fi
2535 cd $WOK
2536 hg pull && hg update
2537 ;;
2538 maintainers)
2539 get_tazwok_config
2540 echo ""
2541 echo "List of maintainers for: $WOK"
2542 echo "================================================================================"
2543 touch /tmp/slitaz-maintainers
2544 for pkg in $WOK/*
2545 do
2546 . $pkg/receipt
2547 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
2548 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
2549 echo "$MAINTAINER"
2550 fi
2551 done
2552 echo "================================================================================"
2553 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
2554 echo ""
2555 # Remove tmp files
2556 rm -f /tmp/slitaz-maintainers
2557 ;;
2558 maintained-by)
2559 # Search for packages maintained by a contributor.
2560 get_tazwok_config
2561 if [ ! -n "$2" ]; then
2562 echo "Specify a name or email of a maintainer." >&2
2563 exit 1
2564 fi
2565 echo "Maintainer packages"
2566 echo "================================================================================"
2567 for pkg in $WOK/*
2568 do
2569 . $pkg/receipt
2570 if echo "$MAINTAINER" | fgrep -q "$2"; then
2571 echo "$PACKAGE"
2572 packages=$(($PACKAGEs+1))
2573 fi
2574 done
2575 echo "================================================================================"
2576 echo "Packages maintained by $2: $PACKAGEs"
2577 echo ""
2578 ;;
2579 check-src)
2580 # Verify if upstream package is still available
2582 get_tazwok_config
2583 check_for_package_on_cmdline
2584 check_for_receipt
2585 source_receipt
2586 check_src()
2588 for url in $@; do
2589 busybox wget -s $url 2>/dev/null && break
2590 done
2592 if [ "$WGET_URL" ];then
2593 echo -n "$PACKAGE : "
2594 check_src $WGET_URL
2595 status
2596 else
2597 echo "No tarball to check for $PACKAGE"
2598 fi
2599 ;;
2600 get-src)
2601 check_root
2602 get_options_list="target"
2603 get_tazwok_config
2604 check_for_package_on_cmdline
2605 check_for_receipt
2606 source_receipt
2607 if [ "$WGET_URL" ];then
2608 source_lib report
2609 report start
2610 check_for_tarball
2611 else
2612 echo "No tarball to download for $PACKAGE"
2613 fi
2614 ;;
2615 check-commit)
2616 check_root
2617 get_options_list="missing forced"
2618 get_tazwok_config
2619 source_lib report
2620 report start
2621 if [ "$forced" ]; then
2622 rm -f $WOK/*/md5
2623 unset forced
2624 fi
2625 if [ "$missing" ]; then
2626 pkg=$(ls -1 $WOK)
2627 else
2628 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2629 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2630 } | sort -u)"
2631 fi
2632 cooklist=$PACKAGES_REPOSITORY/cooklist
2633 gen_cook_list
2634 ;;
2635 cook-commit)
2636 check_root
2637 get_options_list="missing forced"
2638 get_tazwok_config
2639 source_lib report
2640 report start
2641 if [ "$forced" ]; then
2642 rm -f $WOK/*/md5
2643 unset forced
2644 fi
2645 if [ "$missing" ]; then
2646 pkg=$(ls -1 $WOK)
2647 else
2648 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2649 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2650 } | sort -u)"
2651 fi
2652 cooklist=$PACKAGES_REPOSITORY/cooklist
2653 gen_cook_list
2654 cook_list
2655 ;;
2656 cook-all)
2657 check_root
2658 get_options_list="forced missing"
2659 get_tazwok_config
2660 source_lib report
2661 report start
2662 if [ "$missing" ]; then
2663 pkg=$(ls -1 $WOK)
2664 else
2665 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2666 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2667 } | sort -u)"
2668 fi
2669 cooklist=$PACKAGES_REPOSITORY/cooklist
2670 gen_cook_list
2671 cook_list
2672 ;;
2673 gen-wok-db)
2674 check_root
2675 get_tazwok_config
2676 source_lib report
2677 report start
2678 gen_wok_db
2679 ;;
2680 report)
2681 check_root
2682 get_tazwok_config
2683 cd $PACKAGES_REPOSITORY
2684 for i in commit cooklist incoming broken blocked; do
2685 if [ -s $i ]; then
2686 echo -e "\n********************* $i *********************\n$(cat $i)\n*********************"
2687 fi
2688 done
2689 ;;
2690 check-incoming)
2691 check_root
2692 get_options_list="forced"
2693 get_tazwok_config
2694 source_lib report
2695 report start
2696 check_for_incoming
2697 ;;
2698 configure-chroot)
2699 check_root
2700 get_tazwok_config
2701 if [ -f /usr/bin/tazchroot ]; then
2702 cd $LOCAL_REPOSITORY
2703 configure_tazchroot
2704 else
2705 echo "The packages tazchroot need to be installed" >&2
2706 exit 1
2707 fi
2708 ;;
2709 chroot)
2710 check_root
2711 get_tazwok_config
2712 # Merge this and the other chroot function ?.
2713 if [ -f /usr/bin/tazchroot ]; then
2714 cd $LOCAL_REPOSITORY
2715 [ ! -f tazchroot.conf ] && configure_tazchroot
2716 tazchroot
2717 else
2718 echo "The packages tazchroot need to be installed" >&2
2719 exit 1
2720 fi
2721 ;;
2722 cook-toolchain)
2723 check_root
2724 get_tazwok_config
2725 echo -n "" > $PACKAGES_REPOSITORY/broken
2726 if [ -f /usr/bin/tazchroot ]; then
2727 cd $LOCAL_REPOSITORY
2728 [ ! -f tazchroot.conf ] && configure_tazchroot
2729 tazchroot cook-toolchain
2730 # Buggy : chroot can be elsewhere.
2731 rm -r $LOCAL_REPOSITORY/chroot
2732 # /!\ to be writed :
2733 # next rm chroot and plan cook-all by pushing all packages
2734 # in cooklist.
2735 else
2736 echo "The packages tazchroot need to be installed" >&2
2737 exit 1
2738 fi
2739 ;;
2740 usage|*)
2741 # Print usage also for all unknown commands.
2743 usage
2744 ;;
2745 esac
2747 report stop 2>/dev/null || exit 0