tazwok view tazwok @ rev 212

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