tazwok view tazwok @ rev 214

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