tazwok view tazwok @ rev 210

Fix: use clean-chroot to ensure no more depends are left in cooking environnment
author Antoine Bodin <gokhlayeh@slitaz.org>
date Mon Jan 31 03:10:19 2011 +0100 (2011-01-31)
parents 0215ceb46bce
children 50409f2b7ad6
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 if [ -n "$EXTRAVERSION" ]; then
929 report step "Updating receipt EXTRAVERSION"
930 sed -i s/^EXTRAVERSION.*$// receipt
931 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
932 fi
933 prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
934 remove_previous_package $INCOMING_REPOSITORY
935 report step "Creating full cpio archive"
936 find . -print | cpio -o -H newc > $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
938 # Restore package tree in case we want to browse it.
939 report step "Restoring original package tree"
940 { zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma; } | cpio --quiet -id
941 rm fs.cpio.* && cd ..
943 # Log process.
944 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
945 report close-bloc
946 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
947 echo "Size : `du -sh $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
948 echo ""
950 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/broken
951 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/commit
952 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/cooklist
953 }
955 ########################################################################
956 ######################## START OF NEW FUNCTIONS ########################
957 ########################################################################
959 ########################################################################
960 # This section contains functions used by several other functions
961 # bellow.
962 ########################
964 # Look for receipt/files.list in wok. If they can't be found, get them
965 # from package. Accept one argument : absolute path to package.
966 get_pkg_files()
967 {
968 pkg_files_dir=$tmp/$(basename ${1%.tazpkg})
969 mkdir -p $pkg_files_dir && \
970 cd $pkg_files_dir && \
971 cpio --quiet -idm receipt < $1 && \
972 cpio --quiet -idm files.list < $1
973 }
975 ########################################################################
976 # This section contains functions to generate packages databases.
977 ########################
980 gen_packages_db()
981 {
982 # pkg_repository can be $PACKAGES_REPOSITORY or $INCOMING_REPOSITORY.
983 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
984 cd $pkg_repository
985 report step "Generating packages lists: $pkg_repository"
986 report open-bloc
987 report step "Removing old files"
988 for file in files.list.lzma packages.list packages.txt \
989 packages.desc packages.equiv packages.md5; do
990 [ -f $file ] && rm $file
991 done
992 touch files.list
994 packages_db_start
995 unset RECEIPT
996 report step "Reading datas from all packages"
997 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
998 get_packages_info
999 done
1000 report end-step
1001 packages_db_end
1002 report close-bloc
1005 update_packages_db()
1007 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
1008 cd $pkg_repository
1009 for file in packages.list packages.equiv packages.md5 packages.desc \
1010 packages.txt; do
1011 if [ ! -f "$file" ]; then
1012 gen_packages_db
1013 return
1014 fi
1015 done
1016 if [ -f files.list.lzma ]; then
1017 lzma d files.list.lzma files.list
1018 else
1019 gen_packages_db
1020 fi
1021 report step "Updating packages lists: $pkg_repository"
1022 packages_db_start
1024 # Look for removed/update packages.
1025 for PACKAGE in $(grep ^[0-9,a-z,A-Z] packages.txt); do
1026 pkg="$pkg_repository/$(grep -m1 ^$PACKAGE- packages.list).tazpkg"
1027 if ! [ -f "$pkg" ]; then
1028 erase_package_info
1029 else
1030 if [ "$pkg" -nt "packages.list" ]; then
1031 updated_pkg="$updated_pkg $pkg"
1032 fi
1033 fi
1034 done
1036 for pkg in $updated_pkg; do
1037 erase_package_info
1038 get_packages_info
1039 done
1040 unset updated_pkg
1042 # Look for new packages.
1043 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1044 if ! fgrep -q " ${pkg##*/}" $pkg_repository/packages.md5; then
1045 get_packages_info
1046 fi
1047 done
1048 report end-step
1049 packages_db_end
1052 packages_db_start()
1054 if [ ! -s packages.txt ]; then
1055 echo "# SliTaz GNU/Linux - Packages list
1057 # Packages : unknow
1058 # Date : $(date +%Y-%m-%d\ \%H:%M:%S)
1059 #" > packages.txt
1060 else
1061 sed -e 's/^# Packages :.*/# Packages : unknow/' \
1062 -e "s/# Date :.*/# Date : $(date +%Y-%m-%d\ \%H:%M:%S)/" \
1063 -i packages.txt
1064 fi
1066 # Needed in some case as tazwok define RECEIPT at configuration time
1067 # in this particular case it can broke the script.
1068 unset RECEIPT
1071 erase_package_info()
1073 cd $pkg_repository
1074 sed "/^$PACKAGE$/,/^$/d" -i packages.txt
1075 sed "/^$PACKAGE /d" -i packages.desc
1076 sed -e "s/=$PACKAGE /= /" -e "s/ $PACKAGE / /" -e "s/ $PACKAGE$//" \
1077 -e "/=$PACKAGE$/d" -e "s/=[0-9,a-z,A-Z]:$PACKAGE /= /" \
1078 -e "s/ [0-9,a-z,A-Z]:$PACKAGE / /" -e "s/ [0-9,a-z,A-Z]:$PACKAGE$/ /" \
1079 -e "/=[0-9,a-z,A-Z]:$PACKAGE$/d" \
1080 -i packages.equiv
1081 sed "/^$PACKAGE:/d" -i files.list
1082 sed "/^$(basename ${pkg%.tazpkg})$/d" -i packages.list
1083 sed "/ $(basename $pkg)$/d" -i packages.md5
1086 get_packages_info()
1088 # If there's no taz folder in the wok, extract infos from the
1089 # package.
1090 get_pkg_files $pkg
1091 source_receipt
1092 echo "Getting datas from $PACKAGE"
1094 cat >> $pkg_repository/packages.txt << _EOT_
1096 $PACKAGE
1097 $VERSION$EXTRAVERSION
1098 $SHORT_DESC
1099 _EOT_
1100 [ "$PACKED_SIZE" ] && cat >> $pkg_repository/packages.txt << _EOT_
1101 $PACKED_SIZE ($UNPACKED_SIZE installed)
1102 _EOT_
1104 # Packages.desc is used by Tazpkgbox <tree>.
1105 echo "$PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> $pkg_repository/packages.desc
1107 # Packages.equiv is used by tazpkg install to check depends
1108 for i in $PROVIDE; do
1109 DEST=""
1110 echo $i | fgrep -q : && DEST="${i#*:}:"
1111 if grep -qs ^${i%:*}= $pkg_repository/packages.equiv; then
1112 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" $pkg_repository/packages.equiv
1113 else
1114 echo "${i%:*}=$DEST$PACKAGE" >> $pkg_repository/packages.equiv
1115 fi
1116 done
1118 if [ -f files.list ]; then
1119 { echo "$PACKAGE"; cat files.list; } | awk '
1120 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }' >> $pkg_repository/files.list
1121 fi
1123 cd .. && rm -r "$pkg_files_dir"
1125 cd $pkg_repository
1126 echo $(basename ${pkg%.tazpkg}) >> packages.list
1127 [ ! "$package_md5" ] && package_md5=$(md5sum $(basename $pkg))
1128 echo "$package_md5" >> packages.md5
1129 unset package_md5
1132 source_receipt()
1134 unset PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
1135 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
1136 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
1137 src _pkg DESTDIR CONFIG_SITE
1138 . ${RECEIPT:-$PWD/receipt}
1141 packages_db_end()
1143 cd $pkg_repository
1144 pkgs=$(wc -l packages.list | sed 's/ .*//')
1145 sed "s/# Packages : .*/# Packages : $pkgs/" -i packages.txt
1147 # If lists was updated it's generally needed to sort them well.
1148 if ! sort -c packages.list 2> /dev/null; then
1149 report step "Sorting packages lists"
1150 for file in packages.list packages.desc packages.equiv; do
1151 [ -f $file ] || continue
1152 sort -o $file $file
1153 done
1154 report end-step
1155 fi
1157 # Dont log this because lzma always output error.
1158 lzma e files.list files.list.lzma
1159 rm -f files.list
1160 [ -f packages.equiv ] || touch packages.equiv
1163 ########################################################################
1164 # This section contains functions to generate wok database.
1165 ########################
1167 gen_wok_db()
1169 report step "Generating wok database"
1170 report open-bloc
1171 report step "Removing old files"
1172 for file in $wan_db $dep_db $PACKAGES_REPOSITORY/cookorder.txt; do
1173 [ -f $file ] && rm $file
1174 done
1175 report step "Generating wok-wanted.txt"
1176 gen_wan_db
1177 report step "Generating wok-depends.txt"
1178 for PACKAGE in $(cut -f1 -d '|' $PACKAGES_REPOSITORY/packages.desc \
1179 $INCOMING_REPOSITORY/packages.desc | sort -u); do
1180 RECEIPT=$WOK/$PACKAGE/receipt
1181 if [ -s $RECEIPT ]; then
1182 source_receipt
1183 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
1184 fi
1185 done
1186 report close-bloc
1189 gen_wan_db()
1191 for RECEIPT in $(fgrep -l WANTED $WOK/*/receipt); do
1192 WANTED=
1193 source $RECEIPT
1194 [ "$WANTED" ] || continue
1195 echo -e $PACKAGE"\t"$WANTED >> $tmp/wan_db
1196 done
1197 if [ "$(diff -q $tmp/wan_db $wan_db)" ]; then
1198 mv -f $tmp/wan_db $wan_db
1199 plan_regen_cookorder=yes
1200 else
1201 rm $tmp/wan_db
1202 fi
1205 update_dep_db()
1207 dep_info=$(echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ')
1208 [ "$dep_info" = "$(grep -m1 ^$PACKAGE$'\t' $dep_db)" ] && return
1209 sed "/^$PACKAGE\t/d" -i $dep_db
1210 echo "$dep_info" >> $dep_db
1211 plan_regen_cookorder=yes
1212 plan_sort_depdb=yes
1215 sort_db()
1217 report step "Generating cookorder.txt"
1218 rm $PACKAGES_REPOSITORY/blocked && touch $PACKAGES_REPOSITORY/blocked
1219 cat $dep_db | sed 's/ \t / /' | while read PACKAGE BUILD_DEPENDS; do
1220 grep -q ^$PACKAGE$'\t' $wan_db && continue
1222 # Replace each BUILD_DEPENDS with a WANTED package by it's
1223 # WANTED package.
1224 replace_by_wanted()
1226 for p in $BUILD_DEPENDS; do
1227 if grep -q ^$p$'\t' $wan_db; then
1228 echo -n $(grep ^$p$'\t' $wan_db | cut -f 2)' '
1229 else
1230 echo -n $p' '
1231 fi
1232 done | tr ' ' '\n' | sort -u | sed "/^$PACKAGE$/d" | tr '\n' ' '
1234 echo -e $PACKAGE"\t $(replace_by_wanted) "
1235 done > $tmp/db
1236 while [ -s "$tmp/db" ]; do
1237 status=start
1238 for pkg in $(cut -f 1 $tmp/db); do
1239 if ! fgrep -q ' '$pkg' ' $tmp/db; then
1240 echo $pkg >> $tmp/cookorder
1241 sed -e "/^$pkg\t/d" -e "s/ $pkg / /g" -i $tmp/db
1242 status=proceed
1243 fi
1244 done
1245 if [ "$status" = start ]; then
1246 cp -f $tmp/db /tmp/remain-depends.txt
1247 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
1248 for blocked in $(cut -f 1 $tmp/db); do
1249 echo "$blocked" >> $PACKAGES_REPOSITORY/blocked
1250 done
1251 break
1252 fi
1253 done
1254 [ -s $tmp/cookorder ] || touch $tmp/cookorder
1256 # The toolchain packages are moved in first position.
1257 grep $(for pkg in `scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1258 --look_for=all --with_args`; do echo " -e ^$pkg$"; done) \
1259 $tmp/cookorder | tac > $PACKAGES_REPOSITORY/cookorder.txt
1260 for pkg in $(cat $PACKAGES_REPOSITORY/cookorder.txt); do
1261 sed "/^$pkg$/d" -i $tmp/cookorder
1262 done
1264 tac $tmp/cookorder >> $PACKAGES_REPOSITORY/cookorder.txt
1265 unset plan_regen_cookorder
1266 report end-step
1269 ########################################################################
1270 # SCAN CORE
1271 ########################
1272 # Include various scan core-functions. It's not intended to be used
1273 # directly : prefer scan wrappers in next section.
1275 look_for_dep()
1277 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1278 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
1279 | cut -f 2
1280 else
1281 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1282 cut -f 2
1283 fi
1286 look_for_bdep()
1288 look_for_all
1291 look_for_all()
1293 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1294 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
1295 | cut -f 2,3 | sed 's/ / /'
1296 else
1297 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1298 cut -f 2,3 | sed 's/ / /'
1299 fi
1302 look_for_rdep()
1304 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | cut -f 1
1305 if [ "$undigest" ]; then
1306 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt | cut -f 1); do
1307 if [ ! -f "WOK$/$rdep/receipt" ]; then
1308 echo "$rdep"
1309 fi
1310 done
1311 fi
1314 look_for_rbdep()
1316 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | \
1317 cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
1318 if [ "$undigest" ]; then
1319 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
1320 | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1); do
1321 if [ ! -f "WOK$/$rdep/receipt" ]; then
1322 echo "$rdep"
1323 fi
1324 done
1325 fi
1328 # Return WANTED if it exists.
1329 look_for_wanted()
1331 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1332 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-wanted.txt | cut -f 2
1333 else
1334 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 2
1335 fi
1338 # Return packages which wants PACKAGE.
1339 look_for_rwanted()
1341 grep $'\t'$PACKAGE$ $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 1
1342 if [ "$undigest" ]; then
1343 for rwanted in $(grep $'\t'$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-wanted.txt | cut -f 1); do
1344 if [ ! -f "$WOK/$rwanted/receipt" ]; then
1345 echo "$rwanted"
1346 fi
1347 done
1348 fi
1351 look_for_dev()
1353 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev && return
1354 [ "$undigest" ] && [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$PACKAGE-dev/receipt" ] && \
1355 echo $PACKAGE-dev
1358 ########################################################################
1359 # SCAN
1360 ########################
1361 # Use wok-wanted.txt and wok-depeds.txt to scan depends.
1362 # Option in command line (must be first arg) :
1363 # --look_for=bdep/rbdep - Look for depends or reverse depends.
1364 # --with_dev - Add development packages (*-dev) in the result.
1365 # --with_wanted - Add package+reverse wanted in the result.
1366 # --with_args - Include packages in argument in the result.
1368 scan()
1370 # With some commands we don't want report (list output).
1371 if [ "$COMMAND" = gen-cooklist ] || [ "$COMMAND" = build-depends ]; then
1372 report(){ : ; }
1373 fi
1375 # Get packages in argument.
1376 local PACKAGE pkg_list=
1377 for arg in $@; do
1378 [ "$arg" = "${arg#--}" ] || continue
1379 pkg_list="$pkg_list $arg"
1380 done
1382 # Get options.
1383 [ "$pkg_list" ] || return
1384 local cooklist= look_for= with_dev= with_wanted= with_args= log_command="$0 $@" \
1385 get_options_list="look_for with_dev with_wanted with_args cooklist"
1386 get_options
1388 # Cooklist is a special case where we need to modify a little
1389 # scan behavior
1390 if [ "$cooklist" ]; then
1391 gen_wan_db
1392 look_for=all && with_args=yes && with_dev= && with_wanted=
1393 filter=use_wanted
1394 append_to_dep()
1396 check_for_commit && echo $PACKAGE >> $tmp/dep
1398 else
1399 append_to_dep()
1401 echo $PACKAGE >> $tmp/dep
1403 fi
1405 [ "$with_dev" ] && filter=with_dev
1406 [ "$with_wanted" ] && filter=with_wanted
1408 ##############################################################
1409 # ADD TO LISTS PROPOSAL ######################################
1410 ##############################################################
1412 with_dev()
1414 for PACKAGE in $(cat); do
1415 echo $PACKAGE
1416 look_for_dev
1417 done
1420 with_wanted()
1422 for PACKAGE in $(cat); do
1423 echo $PACKAGE
1424 look_for_wanted
1425 done
1428 use_wanted()
1430 for PACKAGE in $(cat); do
1431 { grep ^$PACKAGE$'\t' $wan_db || echo $PACKAGE
1432 } | sed 's/.*\t//'
1433 done
1436 if [ "$filter" ]; then
1437 pkg_list=$(echo $pkg_list | $filter)
1438 scan_pkg()
1440 look_for_$look_for | $filter
1442 else
1443 scan_pkg()
1445 look_for_$look_for
1447 fi
1449 for PACKAGE in $pkg_list; do
1450 [ "$with_args" ] && append_to_dep
1451 scan_pkg
1452 done | tr ' ' '\n' | sort -u > $tmp/list
1453 [ "$look_for" = bdep ] && look_for=dep
1454 while [ -s $tmp/list ]; do
1455 PACKAGE=$(sed 1!d $tmp/list)
1456 sed 1d -i $tmp/list
1457 append_to_dep
1458 for pkg in $(scan_pkg); do
1459 if ! grep -q ^$pkg$ $tmp/list $tmp/dep; then
1460 echo $pkg >> $tmp/list
1461 fi
1462 done
1463 done
1464 if [ "$cooklist" ]; then
1465 mv $tmp/dep $tmp/cooklist
1466 else
1467 cat $tmp/dep | sort -u
1468 fi
1469 rm -f $tmp/dep $tmp/list
1472 ########################################################################
1473 # This section contains functions to check package repository and
1474 # find which packages to cook.
1475 ########################
1477 check_for_commit()
1479 if ! check_for_pkg_in_wok; then
1480 [ "$?" = 2 ] && return 1
1481 return
1482 fi
1483 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
1484 RECEIPT=$WOK/$PACKAGE/receipt
1485 source_receipt
1487 # We use md5 of cooking stuff in the packaged receipt to check
1488 # commit. We look consecutively in 3 different locations :
1489 # - in the wok/PACKAGE/taz/* folder
1490 # - in the receipt in the package in incoming repository
1491 # - in the receipt in the package in packages repository
1492 # If md5sum match, there's no commit.
1493 check_for_commit_using_md5sum()
1495 if [ ! -f $WOK/$PACKAGE/md5 ]; then
1496 sed -n '/# md5sum of cooking stuff :/,$p' receipt | \
1497 sed -e 1d -e 's/^# //' > $WOK/$PACKAGE/md5
1498 cd $WOK/$PACKAGE
1499 fi
1501 if [ -s md5 ]; then
1502 if md5sum -cs md5; then
1504 # If md5sum check if ok, check for new/missing files in
1505 # cooking stuff.
1506 for file in $([ -f receipt ] && echo receipt; \
1507 [ -f description.txt ] && echo description.txt; \
1508 [ -d stuff ] && find stuff); do
1509 if ! fgrep -q " $file" md5; then
1510 set_commited
1511 fi
1512 done
1513 else
1514 set_commited
1515 fi
1516 else
1517 set_commited
1518 fi
1520 set_commited()
1522 ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/commit &&
1523 echo $PACKAGE >> $PACKAGES_REPOSITORY/commit
1524 gen_cookmd5
1525 update_dep_db
1527 taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | fgrep -v '*')
1528 if [ -f $WOK/$PACKAGE/md5 ]; then
1529 cd $WOK/$PACKAGE
1530 check_for_commit_using_md5sum
1531 elif [ "$taz_dir" ]; then
1532 cd $taz_dir
1533 check_for_commit_using_md5sum
1534 else
1535 pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1536 [ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1537 if [ "$pkg" ]; then
1538 get_pkg_files $pkg
1539 check_for_commit_using_md5sum
1540 rm -r $pkg_files_dir
1541 else
1542 set_commited
1543 fi
1544 fi
1545 [ "$forced" ] || echo $PACKAGE >> $tmp/checked
1546 done
1547 return
1550 gen_cook_list()
1552 report step "Scanning wok"
1553 if [ "$pkg" ]; then
1554 scan $pkg --cooklist
1555 else
1556 scan `cat $cooklist` --cooklist
1557 fi
1558 report end-step
1560 [ -s $tmp/checked ] || [ -s $tmp/cooklist ] || return
1562 # Core toolchain should not be cooked unless cook-toolchain is used.
1563 if ! [ -f /etc/config.site.tmptoolchain ] ; then
1564 for PACKAGE in $(scan gcc --look_for=all --with_args --with_wanted); do
1565 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/blocked || \
1566 echo $PACKAGE >> $PACKAGES_REPOSITORY/blocked
1567 done
1568 fi
1570 if [ -s $PACKAGES_REPOSITORY/commit ]; then
1571 cd $PACKAGES_REPOSITORY
1572 for PACKAGE in $(cat commit); do
1573 WANTED="$(look_for_wanted)"
1574 if [ "$WANTED" ]; then
1575 grep -q ^$WANTED$ broken cooklist blocked commit && continue
1576 fi
1577 grep -q ^$PACKAGE$ blocked cooklist && continue
1578 echo $PACKAGE >> cooklist
1579 done
1580 fi
1581 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
1582 [ "$plan_regen_cookorder" ] && sort_db
1583 sort_cooklist
1586 sort_cooklist()
1588 if [ -f "$tmp/checked" ]; then
1589 rm -f $tmp/cooklist
1590 cat $tmp/checked | while read PACKAGE; do
1591 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/cooklist && \
1592 echo $PACKAGE >> $tmp/cooklist
1593 done
1594 elif ! [ "$COMMAND" = gen-cooklist ]; then
1595 cat $PACKAGES_REPOSITORY/blocked | while read PACKAGE; do
1596 sed "/^$PACKAGE/d" -i $tmp/cooklist
1597 done
1598 fi
1600 [ -s $tmp/cooklist ] || return
1601 report step "Sorting cooklist"
1602 for PACKAGE in $(cat $tmp/cooklist); do
1603 WANTED="$(look_for_wanted)"
1604 [ "$WANTED" ] || continue
1605 if grep -q ^$WANTED$ $PACKAGES_REPOSITORY/broken $tmp/cooklist.tmp; then
1606 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1607 elif [ ! -d $WOK/$WANTED/install ]; then
1608 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1609 echo $WANTED >> $tmp/cooklist
1610 fi
1611 done
1613 # Use cookorder.txt to sort cooklist.
1614 if [ -s $tmp/cooklist ]; then
1615 cat $PACKAGES_REPOSITORY/cookorder.txt | while read PACKAGE; do
1616 if grep -q ^$PACKAGE$ $tmp/cooklist; then
1617 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1618 echo $PACKAGE >> $tmp/cooklist.tmp
1619 fi
1620 done
1622 # Remaining packages in cooklist are thoses without compile_rules.
1623 # They can be cooked first in any order.
1624 if [ -f $tmp/cooklist.tmp ]; then
1625 cat $tmp/cooklist.tmp >> $tmp/cooklist
1626 rm $tmp/cooklist.tmp
1627 fi
1629 cat $tmp/cooklist
1630 [ "$cooklist" = "$PACKAGES_REPOSITORY/cooklist" ] && \
1631 cat $tmp/cooklist > $cooklist
1632 fi
1634 report end-step
1637 check_for_incoming()
1639 [ -s $INCOMING_REPOSITORY/packages.desc ] || {
1640 echo "No packages in $INCOMING_REPOSITORY."
1641 return; }
1642 if [ -s $PACKAGES_REPOSITORY/broken ]; then
1643 echo "Don't move incoming packages to main repository because theses ones are broken:
1644 $(cat $PACKAGES_REPOSITORY/broken)" >&2
1645 return
1646 fi
1647 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
1648 echo "Don't move incoming packages to main repository because some of them need to be cooked:
1649 $(cat $PACKAGES_REPOSITORY/cooklist)" >&2
1650 return
1651 fi
1652 rm -f $WOK/*/md5
1653 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
1654 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
1655 } | sort -u)"
1656 cooklist=$PACKAGES_REPOSITORY/cooklist
1657 gen_cook_list
1658 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
1659 echo "Don't move incoming packages to main repository because some of them need to be cooked." >&2
1660 return
1661 fi
1662 report step "Moving incoming packages to main repository"
1663 unset EXTRAVERSION
1664 for PACKAGE in $(cut -f 1 -d '|' $INCOMING_REPOSITORY/packages.desc); do
1665 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
1666 VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
1667 remove_previous_package $PACKAGES_REPOSITORY
1668 remove_previous_tarball
1669 echo "Moving $PACKAGE..."
1670 mv -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION.tazpkg $PACKAGES_REPOSITORY
1671 touch $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
1672 done
1673 report end-step
1674 for file in packages.list packages.equiv packages.md5 packages.desc \
1675 packages.txt; do
1676 echo -n "" > $INCOMING_REPOSITORY/$file
1677 done
1678 rm -r $INCOMING_REPOSITORY/files.list.lzma
1679 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
1682 ########################################################################
1683 # TAZWOK MAIN FUNCTIONS
1684 ########################
1686 clean()
1688 cd $WOK/$PACKAGE
1689 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
1690 -e ^stuff$ || return
1692 report step "Cleaning $PACKAGE"
1693 # Check for clean_wok function.
1694 if grep -q ^clean_wok $RECEIPT; then
1695 clean_wok
1696 fi
1697 # Clean should only have a receipt, stuff and optional desc.
1698 for f in `ls .`
1699 do
1700 case $f in
1701 receipt|stuff|description.txt)
1702 continue ;;
1703 *)
1704 echo "Removing: $f"
1705 rm -rf $f
1706 esac
1707 done
1708 report end-step
1711 # Configure and make a package with the receipt.
1712 compile_package()
1714 check_for_package_on_cmdline
1716 # Include the receipt to get all needed variables and functions
1717 # and cd into the work directory to start the work.
1718 check_for_receipt
1719 source_receipt
1721 # Log the package name and date.
1722 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
1723 echo "package $PACKAGE (compile)" >> $LOG
1725 # Set wanted $src variable to help compiling.
1726 [ ! "$src" ] && set_src_path
1727 check_for_build_depends || return 1
1728 check_for_wanted
1729 unset target
1730 check_for_tarball && check_for_compile_rules
1733 # Cook command also include all features to manage lists which keep
1734 # track of wok/packages state.
1735 cook()
1737 cook_code=
1738 set_common_path
1739 check_for_receipt
1740 source_receipt
1742 # Define log path and start report.
1743 [ -f $LOCAL_REPOSITORY/log/$PACKAGE.html ] && rm $LOCAL_REPOSITORY/log/$PACKAGE.html
1744 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
1745 report step "Cooking $PACKAGE"
1746 report open-bloc
1748 clean $PACKAGE
1749 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
1751 if compile_package; then
1752 refresh_packages_from_compile
1753 gen_package
1754 remove_src
1756 # Plan recook of reverse build depends if gen_package has detect
1757 # a change in libraries.
1758 if [ "$cook_rdep" ]; then
1759 report step "Look for packages which need a refresh"
1760 for rdep in $(scan $PACKAGE --look_for=rdep); do
1761 sed "/^$rdep$/d" -i $PACKAGES_REPOSITORY/broken
1762 if [ -f $WOK/$rdep/receipt ] && ! grep -q ^$rdep$ $tmp/cooklist; then
1763 echo "Add $rdep in cooklist to avoid broke caused by library update in $PACKAGE"
1764 echo $rdep >> $tmp/cooklist
1765 regen_cooklist=yes
1766 fi
1767 done
1768 report end-step
1769 fi
1771 # Update packages-incoming repository.
1772 store_pkgname=$PACKAGE
1773 pkg_repository=$INCOMING_REPOSITORY
1774 update_packages_db
1776 PACKAGE=$store_pkgname
1777 unset store_pkgname
1779 # Upgrade to cooked packages if it was previously installed.
1780 report step "Look for package(s) to upgrade"
1781 for pkg in $(look_for_rwanted) $PACKAGE; do
1782 if [ -d $INSTALLED/$pkg ]; then
1783 tazpkg get-install $pkg --forced
1784 fi
1785 done
1786 report end-step
1787 else
1789 # Set package as broken.
1790 if ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then
1791 echo $PACKAGE >> $PACKAGES_REPOSITORY/broken
1792 fi
1793 gen_cookmd5
1794 cook_code=1
1795 fi
1797 # Remove build_depends in cook mode (if in cooklist, it's done when
1798 # checking build_depends of next package and we remove only unneeded
1799 # packages to keep chroot minimal and gain some time).
1800 if [ "$COMMAND" = cook ]; then
1801 remove_build_depends $MISSING_PACKAGE
1802 [ -x /usr/bin/clean-chroot ] && clean-chroot
1803 fi
1805 # Regen the cooklist if it was planned and command is not cook.
1806 [ "$regen_cooklist" ] && unset regen_cooklist && \
1807 [ "$COMMAND" != cook ] && sort_cooklist
1809 # Some hacks to set the bloc & function status as failed if cook was
1810 # failed.
1811 report_return_code=$cook_code
1812 report close-bloc
1813 report end-sublog
1814 return $cook_code
1817 cook_list()
1819 if [ -s $tmp/cooklist ]; then
1820 if [ -f /usr/bin/tazchroot ]; then
1821 # Note : options -main variables- are automatically keeped by
1822 # the sub-applications tazchroot/tazwok; as well as report data.
1823 cd $LOCAL_REPOSITORY
1824 [ ! -f tazchroot.conf ] && configure_tazchroot
1825 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
1826 return
1827 fi
1828 while [ -s $tmp/cooklist ]; do
1829 PACKAGE=$(sed 1!d $tmp/cooklist)
1830 cook
1831 done
1832 remove_build_depends $MISSING_PACKAGE $remove_later
1833 [ -x /usr/bin/clean-chroot ] && clean-chroot
1834 else
1835 echo "Nothing to cook."
1836 return
1837 fi
1840 configure_tazchroot()
1842 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
1843 # Tazchroot configuration file - created by tazwok.
1845 # Default chroot path
1846 SLITAZ_DIR=$SLITAZ_DIR
1847 SLITAZ_VERSION=$SLITAZ_VERSION
1848 $( [ "$undigest" ] && echo "undigest=$undigest" )
1849 LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
1850 chroot_dir=\$LOCAL_REPOSITORY/chroot
1852 # Default scripts path (theses scripts are added in the
1853 # $chroot_dir/usr/bin and can be called with tazchroot script)
1854 script_dir=/var/lib/tazchroot
1856 # List of directories to mount.
1857 list_dir="$(for dir in packages wok src packages-incoming log flavors iso; do echo $LOCAL_REPOSITORY/$dir; done)
1858 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
1860 create_chroot()
1862 mkdir -p \$chroot_dir
1863 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
1864 tazpkg get-install \$pkg --root="\$chroot_dir"
1865 done
1867 # Store list of installed packages needed by cleanchroot.
1868 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
1870 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
1871 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
1872 -i \$chroot_dir/etc/slitaz/slitaz.conf
1873 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
1874 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
1877 mount_chroot()
1879 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
1880 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCALSTATE/mirror
1881 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
1882 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
1883 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION
1884 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror' )
1885 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
1886 mount -t proc proc \$chroot_dir/proc
1887 mount -t sysfs sysfs \$chroot_dir/sys
1888 mount -t devpts devpts \$chroot_dir/dev/pts
1889 mount -t tmpfs shm \$chroot_dir/dev/shm
1890 for dir in \$list_dir; do
1891 mkdir -p \$dir \$chroot_dir\$dir
1892 mount \$dir \$chroot_dir\$dir
1893 done
1896 umount_chroot()
1898 for dir in \$list_dir; do
1899 umount \$chroot_dir\$dir
1900 done
1901 umount \$chroot_dir/dev/shm
1902 umount \$chroot_dir/dev/pts
1903 umount \$chroot_dir/sys
1904 umount \$chroot_dir/proc
1906 EOF
1909 ########################################################################
1910 ######################### END OF NEW FUNCTIONS #########################
1911 ########################################################################
1913 # List packages providing a virtual package
1914 whoprovide()
1916 local i;
1917 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
1918 . $i
1919 case " $PROVIDE " in
1920 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
1921 esac
1922 done
1925 ########################################################################
1926 # TAZWOK COMMANDS
1927 ########################
1929 case "$COMMAND" in
1930 stats)
1931 # Tazwok general statistics from the wok config file.
1933 get_tazwok_config
1934 echo -e "\n\033[1mTazwok configuration statistics\033[0m
1935 ================================================================================
1936 Wok directory : $WOK
1937 Packages repository : $PACKAGES_REPOSITORY
1938 Incoming repository : $INCOMING_REPOSITORY
1939 Sources repository : $SOURCES_REPOSITORY
1940 Log directory : $LOCAL_REPOSITORY/log
1941 Packages in the wok : `ls -1 $WOK | wc -l`
1942 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
1943 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
1944 ================================================================================\n"
1945 ;;
1946 edit)
1947 get_tazwok_config
1948 check_for_package_on_cmdline
1949 check_for_receipt
1950 $EDITOR $WOK/$PACKAGE/receipt
1951 ;;
1952 build-depends)
1953 # List dependencies to rebuild wok, or only a package
1954 get_tazwok_config
1955 if [ "$PACKAGE" = toolchain-cooklist ]; then
1956 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1957 --cooklist
1958 elif [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
1959 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1960 --look_for=dep --with_dev --with_args
1961 else
1962 check_for_package_on_cmdline
1963 scan $PACKAGE --look_for=bdep --with_dev
1964 fi
1965 ;;
1966 gen-cooklist)
1967 get_options_list="pkg"
1968 get_tazwok_config
1969 check_root
1970 if ! [ "$pkg" ]; then
1971 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
1972 fi
1973 forced=yes
1974 gen_cook_list
1975 ;;
1976 check-depends)
1977 # Check package depends /!\
1978 get_tazwok_config
1979 echo ""
1980 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
1981 ================================================================================"
1982 TMPDIR=/tmp/tazwok$$
1983 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
1985 # Build ALL_DEPENDS variable
1986 scan_dep()
1988 local i
1989 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
1990 for i in $DEPENDS $SUGGESTED ; do
1991 case " $ALL_DEPENDS " in
1992 *\ $i\ *) continue;;
1993 esac
1994 [ -d $WOK/$i ] || {
1995 ALL_DEPENDS="$ALL_DEPENDS$i "
1996 continue
1998 DEPENDS=""
1999 SUGGESTED=""
2000 . $WOK/$i/receipt
2001 scan_dep
2002 done
2005 # Check for ELF file
2006 is_elf()
2008 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" \
2009 = "ELF" ]
2012 # Print shared library dependencies
2013 ldd()
2015 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
2018 mkdir $TMPDIR
2019 cd $TMPDIR
2020 for i in $LOCALSTATE/files.list.lzma \
2021 $LOCALSTATE/undigest/*/files.list.lzma ; do
2022 [ -f $i ] && lzma d $i -so >> files.list
2023 done
2024 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
2025 tazpkg extract $pkg > /dev/null 2>&1
2026 . */receipt
2027 ALL_DEPENDS="$DEFAULT_DEPENDS "
2028 scan_dep
2029 find */fs -type f | while read file ; do
2030 is_elf $file || continue
2031 case "$file" in
2032 *.o|*.ko|*.ko.gz) continue;;
2033 esac
2034 ldd $file | while read lib rem; do
2035 case "$lib" in
2036 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
2037 continue;;
2038 esac
2039 for dep in $(fgrep $lib files.list | cut -d: -f1); do
2040 case " $ALL_DEPENDS " in
2041 *\ $dep\ *) continue 2;;
2042 esac
2043 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
2044 case " $ALL_DEPENDS " in
2045 *\ $vdep\ *) continue 3;;
2046 esac
2047 done
2048 done
2049 [ -n "$dep" ] || dep="UNKNOWN"
2050 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
2051 done
2052 done
2053 rm -rf */
2054 done
2055 cd /tmp
2056 rm -rf $TMPDIR
2057 ;;
2058 check)
2059 # Check wok consistency
2060 get_tazwok_config
2061 echo ""
2062 echo -e "\033[1mWok and packages checking\033[0m
2063 ================================================================================"
2064 cd $WOK
2065 for pkg in $(ls)
2066 do
2067 [ -f $pkg/receipt ] || continue
2068 RECEIPT= $pkg/receipt
2069 source_receipt
2070 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
2071 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
2072 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
2073 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
2074 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
2075 if [ -n "$WANTED" ]; then
2076 if [ ! -f $WANTED/receipt ]; then
2077 echo "Package $PACKAGE wants unknown $WANTED package" >&2
2078 else
2079 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
2080 if [ "$VERSION" = "$WANTED" ]; then
2081 # BASEVERSION is computed in receipt
2082 fgrep -q '_pkg=' $pkg/receipt &&
2083 BASEVERSION=$VERSION
2084 fi
2085 if [ "$VERSION" != "$BASEVERSION" ]; then
2086 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
2087 fi
2088 fi
2089 fi
2091 if [ -n "$CATEGORY" ]; then
2092 case " $(echo $CATEGORIES) " in
2093 *\ $CATEGORY\ *);;
2094 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
2095 esac
2096 else
2097 echo"Package $PACKAGE has no CATEGORY" >&2
2098 fi
2099 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
2100 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
2101 case "$WGET_URL" in
2102 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
2103 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
2104 '') ;;
2105 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
2106 esac
2107 case "$WEB_SITE" in
2108 ftp*|http*);;
2109 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
2110 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
2111 esac
2112 case "$MAINTAINER" in
2113 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
2114 esac
2115 case "$MAINTAINER" in
2116 *@*);;
2117 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
2118 esac
2119 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2120 for i in $DEPENDS; do
2121 [ -d $i ] && continue
2122 [ -n "$(whoprovide $i)" ] && continue
2123 echo -e "$MSG $i"
2124 MSG=""
2125 done
2126 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2127 for i in $BUILD_DEPENDS; do
2128 [ -d $i ] && continue
2129 [ -n "$(whoprovide $i)" ] && continue
2130 echo -e "$MSG $i"
2131 MSG=""
2132 done
2133 MSG="Dependencies loop between $PACKAGE and :\n"
2134 ALL_DEPS=""
2135 check_for_deps_loop $PACKAGE $DEPENDS
2136 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
2137 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
2138 echo "$pkg should be rebuilt after $i installation"
2139 done
2140 done
2141 ;;
2142 list)
2143 # List packages in wok directory. User can specify a category.
2145 get_tazwok_config
2146 if [ "$2" = "category" ]; then
2147 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
2148 exit 0
2149 fi
2150 # Check for an asked category.
2151 if [ -n "$2" ]; then
2152 ASKED_CATEGORY=$2
2153 echo ""
2154 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
2155 echo "================================================================================"
2156 for pkg in $WOK/*
2157 do
2158 [ ! -f $pkg/receipt ] && continue
2159 . $pkg/receipt
2160 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
2161 echo -n "$PACKAGE"
2162 echo -e "\033[28G $VERSION"
2163 packages=$(($packages+1))
2164 fi
2165 done
2166 echo "================================================================================"
2167 echo -e "$PACKAGEs packages in category $ASKED_CATEGORY.\n"
2168 else
2169 # By default list all packages and version.
2170 echo ""
2171 echo -e "\033[1mList of packages in the wok\033[0m"
2172 echo "================================================================================"
2173 for pkg in $WOK/*
2174 do
2175 [ ! -f $pkg/receipt ] && continue
2176 . $pkg/receipt
2177 echo -n "$PACKAGE"
2178 echo -en "\033[28G $VERSION"
2179 echo -e "\033[42G $CATEGORY"
2180 packages=$(($packages+1))
2181 done
2182 echo "================================================================================"
2183 echo -e "$PACKAGEs packages available in the wok.\n"
2184 fi
2185 ;;
2186 info)
2187 # Information about a package.
2189 get_tazwok_config
2190 check_for_package_on_cmdline
2191 check_for_receipt
2192 . $WOK/$PACKAGE/receipt
2193 echo ""
2194 echo -e "\033[1mTazwok package information\033[0m
2195 ================================================================================
2196 Package : $PACKAGE
2197 Version : $VERSION
2198 Category : $CATEGORY
2199 Short desc : $SHORT_DESC
2200 Maintainer : $MAINTAINER"
2201 if [ ! "$WEB_SITE" = "" ]; then
2202 echo "Web site : $WEB_SITE"
2203 fi
2204 if [ ! "$DEPENDS" = "" ]; then
2205 echo "Depends : $DEPENDS"
2206 fi
2207 if [ ! "$WANTED" = "" ]; then
2208 echo "Wanted src : $WANTED"
2209 fi
2210 echo "================================================================================"
2211 echo ""
2212 ;;
2213 check-log)
2214 # We just cat the file log to view process info.
2216 get_tazwok_config
2217 if [ ! -f "$LOG" ]; then
2218 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
2219 exit 1
2220 else
2221 echo ""
2222 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
2223 echo "================================================================================"
2224 cat $LOG
2225 echo "================================================================================"
2226 echo ""
2227 fi
2228 ;;
2229 search)
2230 # Search for a package by pattern or name.
2232 get_tazwok_config
2233 if [ -z "$2" ]; then
2234 echo -e "\nPlease specify a pattern or a package name to search." >&2
2235 echo -e "Example : 'tazwok search gcc'.\n" >&2
2236 exit 1
2237 fi
2238 echo ""
2239 echo -e "\033[1mSearch result for :\033[0m $2"
2240 echo "================================================================================"
2241 list=`ls -1 $WOK | fgrep $2`
2242 for pkg in $list
2243 do
2244 . $WOK/$pkg/receipt
2245 echo -n "$PACKAGE "
2246 echo -en "\033[24G $VERSION"
2247 echo -e "\033[42G $CATEGORY"
2248 packages=$(($PACKAGEs+1))
2249 done
2250 echo "================================================================================"
2251 echo "$PACKAGEs packages found for : $2"
2252 echo ""
2253 ;;
2254 compile)
2255 # Configure and make a package with the receipt.
2257 get_tazwok_config
2258 source_lib report
2259 report start
2260 compile_package
2261 ;;
2262 genpkg)
2263 # Generate a package.
2265 get_tazwok_config
2266 source_lib report
2267 report start
2268 gen_package
2269 ;;
2270 cook)
2271 # Compile and generate a package. Just execute tazwok with
2272 # the good commands.
2274 check_root
2275 get_tazwok_config
2276 source_lib report
2277 report start
2278 cook
2279 ;;
2280 sort-cooklist)
2281 if [ ! "$LIST" ]; then
2282 echo "Usage : tazwok sort-cooklist cooklist" >&2\
2283 exit 1
2284 fi
2285 get_tazwok_config
2286 source_lib report
2287 report start
2288 cooklist=$LIST
2289 sort_cooklist
2290 cp -af $tmp/cooklist $cooklist
2291 ;;
2292 cook-list)
2293 # Cook all packages listed in a file or in default cooklist.
2294 check_root
2295 get_options_list="pkg forced"
2296 get_tazwok_config
2297 source_lib report
2298 report start
2299 if ! [ "$pkg" ]; then
2300 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2301 fi
2302 gen_cook_list
2303 cook_list
2304 ;;
2305 clean)
2306 # Clean up a package work directory + thoses which want it.
2308 get_tazwok_config
2309 check_for_package_on_cmdline
2310 check_for_receipt
2311 source_lib report
2312 report start
2313 . $RECEIPT
2314 clean
2315 ;;
2316 gen-clean-wok)
2317 # Generate a clean wok from the current wok by copying all receipts
2318 # and stuff directory.
2320 get_tazwok_config
2321 source_lib report
2322 report start
2323 if [ -z "$ARG" ]; then
2324 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
2325 exit 1
2326 else
2327 dest=$ARG
2328 mkdir -p $dest
2329 fi
2330 report step "Creating clean wok in : $dest"
2331 for pkg in `ls -1 $WOK`
2332 do
2333 mkdir -p $dest/$pkg
2334 cp -a $WOK/$pkg/receipt $dest/$pkg
2335 [ -f $WOK/$pkg/description.txt ] && \
2336 cp -a $WOK/$pkg/description.txt $dest/$pkg
2337 if [ -d "$WOK/$pkg/stuff" ]; then
2338 cp -a $WOK/$pkg/stuff $dest/$pkg
2339 fi
2340 done
2341 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
2342 report end-step
2343 echo "Packages cleaned : `ls -1 $dest | wc -l`"
2344 echo ""
2345 ;;
2346 clean-wok)
2347 # Clean all packages in the work directory
2349 get_tazwok_config
2350 source_lib report
2351 report start
2352 report step "Cleaning wok"
2353 report open-bloc
2354 for PACKAGE in `ls -1 $WOK`
2355 do
2356 set_common_path
2357 source_receipt
2358 clean
2359 done
2360 report close-bloc
2361 echo "`ls -1 $WOK | wc -l` packages cleaned."
2362 ;;
2363 gen-list)
2364 get_tazwok_config
2365 if [ "$2" ]; then
2366 if [ -d "$2" ]; then
2367 pkg_repository=$2
2368 else
2369 echo -e "\nUnable to find directory : $2\n" >&2
2370 exit 1
2371 fi
2372 fi
2374 source_lib report
2375 report start
2376 if [ "$pkg_repository" ]; then
2377 gen_packages_db
2378 else
2379 pkg_repository=$PACKAGES_REPOSITORY && gen_packages_db
2380 pkg_repository=$INCOMING_REPOSITORY && gen_packages_db
2381 fi
2382 ;;
2383 check-list)
2384 # The directory to move into by default is the repository,
2385 # if $2 is not empty cd into $2.
2387 get_tazwok_config
2388 if [ "$2" ]; then
2389 if [ -d "$2" ]; then
2390 pkg_repository=$2
2391 else
2392 echo -e "\nUnable to find directory : $2\n" >&2
2393 exit 1
2394 fi
2395 fi
2397 source_lib report
2398 report start
2399 if [ "$pkg_repository" ]; then
2400 update_packages_db
2401 else
2402 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
2403 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
2404 fi
2405 ;;
2406 new-tree)
2407 # Just create a few directories and generate an empty receipt to prepare
2408 # the creation of a new package.
2410 get_tazwok_config
2411 check_for_package_on_cmdline
2412 if [ -d $WOK/$PACKAGE ]; then
2413 echo -e "\n$PACKAGE package tree already exists.\n" >&2
2414 exit 1
2415 fi
2416 echo "Creating : $WOK/$PACKAGE"
2417 mkdir $WOK/$PACKAGE
2418 cd $WOK/$PACKAGE
2419 echo -n "Preparing the receipt..."
2421 # Default receipt begin.
2423 echo "# SliTaz package receipt." > receipt
2424 echo "" >> receipt
2425 echo "PACKAGE=\"$PACKAGE\"" >> receipt
2426 # Finish the empty receipt.
2427 cat >> receipt << "EOF"
2428 VERSION=""
2429 CATEGORY=""
2430 SHORT_DESC=""
2431 MAINTAINER=""
2432 DEPENDS=""
2433 TARBALL="$PACKAGE-$VERSION.tar.gz"
2434 WEB_SITE=""
2435 WGET_URL=""
2437 # Rules to configure and make the package.
2438 compile_rules()
2440 cd $src
2441 ./configure && make && make install
2444 # Rules to gen a SliTaz package suitable for Tazpkg.
2445 genpkg_rules()
2447 mkdir -p $fs/usr
2448 cp -a $_pkg/usr/bin $fs/usr
2451 EOF
2453 # Default receipt end.
2455 status
2456 # Interactive mode, asking and seding.
2457 if [ "$3" = "--interactive" ]; then
2458 echo "Entering into interactive mode..."
2459 echo "================================================================================"
2460 echo "Package : $PACKAGE"
2461 # Version.
2462 echo -n "Version : " ; read anser
2463 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
2464 # Category.
2465 echo -n "Category : " ; read anser
2466 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
2467 # Short description.
2468 echo -n "Short desc : " ; read anser
2469 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
2470 # Maintainer.
2471 echo -n "Maintainer : " ; read anser
2472 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
2473 # Web site.
2474 echo -n "Web site : " ; read anser
2475 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
2476 echo ""
2477 # Wget URL.
2478 echo "Wget URL to download source tarball."
2479 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
2480 echo -n "Wget url : " ; read anser
2481 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
2482 # Ask for a stuff dir.
2483 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
2484 if [ "$anser" = "y" ]; then
2485 echo -n "Creating the stuff directory..."
2486 mkdir stuff && status
2487 fi
2488 # Ask for a description file.
2489 echo -n "Are you going to write a description ? (y/N) : " ; read anser
2490 if [ "$anser" = "y" ]; then
2491 echo -n "Creating the description.txt file..."
2492 echo "" > description.txt && status
2493 fi
2494 echo "================================================================================"
2495 echo ""
2496 fi
2497 ;;
2498 remove)
2499 # Remove a package from the wok.
2501 get_tazwok_config
2502 check_for_package_on_cmdline
2503 echo ""
2504 echo -n "Please confirm deletion (y/N) : "; read anser
2505 if [ "$anser" = "y" ]; then
2506 echo -n "Removing $PACKAGE..."
2507 rm -rf $WOK/$PACKAGE && status
2508 echo ""
2509 fi
2510 ;;
2511 hgup)
2512 # Pull and update a Hg wok.
2513 get_tazwok_config
2514 if ls -l $WOK/.hg/hgrc | fgrep -q "root"; then
2515 check_root
2516 fi
2517 cd $WOK
2518 hg pull && hg update
2519 ;;
2520 maintainers)
2521 get_tazwok_config
2522 echo ""
2523 echo "List of maintainers for: $WOK"
2524 echo "================================================================================"
2525 touch /tmp/slitaz-maintainers
2526 for pkg in $WOK/*
2527 do
2528 . $pkg/receipt
2529 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
2530 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
2531 echo "$MAINTAINER"
2532 fi
2533 done
2534 echo "================================================================================"
2535 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
2536 echo ""
2537 # Remove tmp files
2538 rm -f /tmp/slitaz-maintainers
2539 ;;
2540 maintained-by)
2541 # Search for packages maintained by a contributor.
2542 get_tazwok_config
2543 if [ ! -n "$2" ]; then
2544 echo "Specify a name or email of a maintainer." >&2
2545 exit 1
2546 fi
2547 echo "Maintainer packages"
2548 echo "================================================================================"
2549 for pkg in $WOK/*
2550 do
2551 . $pkg/receipt
2552 if echo "$MAINTAINER" | fgrep -q "$2"; then
2553 echo "$PACKAGE"
2554 packages=$(($PACKAGEs+1))
2555 fi
2556 done
2557 echo "================================================================================"
2558 echo "Packages maintained by $2: $PACKAGEs"
2559 echo ""
2560 ;;
2561 check-src)
2562 # Verify if upstream package is still available
2564 get_tazwok_config
2565 check_for_package_on_cmdline
2566 check_for_receipt
2567 source_receipt
2568 check_src()
2570 for url in $@; do
2571 busybox wget -s $url 2>/dev/null && break
2572 done
2574 if [ "$WGET_URL" ];then
2575 echo -n "$PACKAGE : "
2576 check_src $WGET_URL
2577 status
2578 else
2579 echo "No tarball to check for $PACKAGE"
2580 fi
2581 ;;
2582 get-src)
2583 check_root
2584 get_options_list="target"
2585 get_tazwok_config
2586 check_for_package_on_cmdline
2587 check_for_receipt
2588 source_receipt
2589 if [ "$WGET_URL" ];then
2590 source_lib report
2591 report start
2592 check_for_tarball
2593 else
2594 echo "No tarball to download for $PACKAGE"
2595 fi
2596 ;;
2597 check-commit)
2598 check_root
2599 get_options_list="missing forced"
2600 get_tazwok_config
2601 source_lib report
2602 report start
2603 if [ "$forced" ]; then
2604 rm -f $WOK/*/md5
2605 unset forced
2606 fi
2607 if [ "$missing" ]; then
2608 pkg=$(ls -1 $WOK)
2609 else
2610 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2611 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2612 } | sort -u)"
2613 fi
2614 cooklist=$PACKAGES_REPOSITORY/cooklist
2615 gen_cook_list
2616 ;;
2617 cook-commit)
2618 check_root
2619 get_options_list="missing forced"
2620 get_tazwok_config
2621 source_lib report
2622 report start
2623 if [ "$forced" ]; then
2624 rm -f $WOK/*/md5
2625 unset forced
2626 fi
2627 if [ "$missing" ]; then
2628 pkg=$(ls -1 $WOK)
2629 else
2630 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2631 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2632 } | sort -u)"
2633 fi
2634 cooklist=$PACKAGES_REPOSITORY/cooklist
2635 gen_cook_list
2636 cook_list
2637 ;;
2638 cook-all)
2639 check_root
2640 get_options_list="forced missing"
2641 get_tazwok_config
2642 source_lib report
2643 report start
2644 if [ "$missing" ]; then
2645 pkg=$(ls -1 $WOK)
2646 else
2647 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2648 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2649 } | sort -u)"
2650 fi
2651 cooklist=$PACKAGES_REPOSITORY/cooklist
2652 gen_cook_list
2653 cook_list
2654 ;;
2655 gen-wok-db)
2656 check_root
2657 get_tazwok_config
2658 source_lib report
2659 report start
2660 gen_wok_db
2661 ;;
2662 report)
2663 check_root
2664 get_tazwok_config
2665 cd $PACKAGES_REPOSITORY
2666 for i in commit cooklist incoming broken blocked; do
2667 if [ -s $i ]; then
2668 echo -e "\n********************* $i *********************\n$(cat $i)\n*********************"
2669 fi
2670 done
2671 ;;
2672 check-incoming)
2673 check_root
2674 get_tazwok_config
2675 source_lib report
2676 report start
2677 check_for_incoming
2678 ;;
2679 configure-chroot)
2680 check_root
2681 get_tazwok_config
2682 if [ -f /usr/bin/tazchroot ]; then
2683 cd $LOCAL_REPOSITORY
2684 configure_tazchroot
2685 else
2686 echo "The packages tazchroot need to be installed" >&2
2687 exit 1
2688 fi
2689 ;;
2690 chroot)
2691 check_root
2692 get_tazwok_config
2693 # Merge this and the other chroot function ?.
2694 if [ -f /usr/bin/tazchroot ]; then
2695 cd $LOCAL_REPOSITORY
2696 [ ! -f tazchroot.conf ] && configure_tazchroot
2697 tazchroot
2698 else
2699 echo "The packages tazchroot need to be installed" >&2
2700 exit 1
2701 fi
2702 ;;
2703 cook-toolchain)
2704 check_root
2705 get_tazwok_config
2706 echo -n "" > $PACKAGES_REPOSITORY/broken
2707 if [ -f /usr/bin/tazchroot ]; then
2708 cd $LOCAL_REPOSITORY
2709 [ ! -f tazchroot.conf ] && configure_tazchroot
2710 tazchroot cook-toolchain
2711 # Buggy : chroot can be elsewhere.
2712 rm -r $LOCAL_REPOSITORY/chroot
2713 # /!\ to be writed :
2714 # next rm chroot and plan cook-all by pushing all packages
2715 # in cooklist.
2716 else
2717 echo "The packages tazchroot need to be installed" >&2
2718 exit 1
2719 fi
2720 ;;
2721 usage|*)
2722 # Print usage also for all unknown commands.
2724 usage
2725 ;;
2726 esac
2728 report stop 2>/dev/null || exit 0