tazwok view tazwok @ rev 204

Rework commits/cooklist handling and fixed various minor issues
author Antoine Bodin <gokhlayeh@slitaz.org>
date Mon Jan 31 02:51:00 2011 +0100 (2011-01-31)
parents dbf006430b6e
children 0215ceb46bce
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
1559 [ -s $tmp/checked ] || return
1560 if [ -s $PACKAGES_REPOSITORY/commit ]; then
1561 cd $PACKAGES_REPOSITORY
1562 for PACKAGE in $(cat commit); do
1563 WANTED="$(look_for_wanted)"
1564 if [ "$WANTED" ]; then
1565 grep -q ^$WANTED$ broken cooklist blocked commit && continue
1566 fi
1567 grep -q ^$PACKAGE$ blocked cooklist && continue
1568 echo $PACKAGE >> cooklist
1569 done
1570 fi
1571 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
1572 [ "$plan_regen_cookorder" ] && sort_db
1573 [ -s $PACKAGES_REPOSITORY/cooklist ] || return
1575 # Core toolchain should not be cooked unless cook-toolchain is used.
1576 if ! [ -f /etc/config.site.tmptoolchain ] ; then
1577 for PACKAGE in $(scan gcc --look_for=all --with_args --with_wanted); do
1578 [ -f $tmp/cooklist ] && sed "/^$PACKAGE/d" -i $tmp/cooklist
1579 [ -f $tmp/checked ] && sed "/^$PACKAGE/d" -i $tmp/checked
1580 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/blocked || \
1581 echo $PACKAGE >> $PACKAGES_REPOSITORY/blocked
1582 done
1583 fi
1584 sort_cooklist
1587 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 fi
1598 [ -s $tmp/cooklist ] || return
1599 report step "Sorting cooklist"
1600 for PACKAGE in $(cat $tmp/cooklist); do
1601 WANTED="$(look_for_wanted)"
1602 [ "$WANTED" ] || continue
1603 if grep -q ^$WANTED$ $PACKAGES_REPOSITORY/broken $tmp/cooklist.tmp; then
1604 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1605 elif [ ! -d $WOK/$WANTED/install ]; then
1606 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1607 echo $WANTED >> $tmp/cooklist
1608 fi
1609 done
1611 # Use cookorder.txt to sort cooklist.
1612 if [ -s $tmp/cooklist ]; then
1613 cat $PACKAGES_REPOSITORY/cookorder.txt | while read PACKAGE; do
1614 if grep -q ^$PACKAGE$ $tmp/cooklist; then
1615 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1616 echo $PACKAGE >> $tmp/cooklist.tmp
1617 fi
1618 done
1620 # Remaining packages in cooklist are thoses without compile_rules.
1621 # They can be cooked first in any order.
1622 if [ -f $tmp/cooklist.tmp ]; then
1623 cat $tmp/cooklist.tmp >> $tmp/cooklist
1624 rm $tmp/cooklist.tmp
1625 fi
1627 cat $tmp/cooklist
1628 [ "$cooklist" = "$PACKAGES_REPOSITORY/cooklist" ] && \
1629 cat $tmp/cooklist > $cooklist
1630 fi
1632 report end-step
1635 check_for_incoming()
1637 [ -s $INCOMING_REPOSITORY/packages.desc ] || {
1638 echo "No packages in $INCOMING_REPOSITORY."
1639 return; }
1640 if [ -s $PACKAGES_REPOSITORY/broken ]; then
1641 echo "Don't move incoming packages to main repository because theses ones are broken:
1642 $(cat $PACKAGES_REPOSITORY/broken)" >&2
1643 return
1644 fi
1645 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
1646 echo "Don't move incoming packages to main repository because some of them need to be cooked:
1647 $(cat $PACKAGES_REPOSITORY/cooklist)" >&2
1648 return
1649 fi
1650 rm -f $WOK/*/md5
1651 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
1652 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
1653 } | sort -u)"
1654 cooklist=$PACKAGES_REPOSITORY/cooklist
1655 gen_cook_list
1656 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
1657 echo "Don't move incoming packages to main repository because some of them need to be cooked." >&2
1658 return
1659 fi
1660 report step "Moving incoming packages to main repository"
1661 unset EXTRAVERSION
1662 for PACKAGE in $(cut -f 1 -d '|' $INCOMING_REPOSITORY/packages.desc); do
1663 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
1664 VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
1665 remove_previous_package $PACKAGES_REPOSITORY
1666 remove_previous_tarball
1667 echo "Moving $PACKAGE..."
1668 mv -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION.tazpkg $PACKAGES_REPOSITORY
1669 touch $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
1670 done
1671 report end-step
1672 for file in packages.list packages.equiv packages.md5 packages.desc \
1673 packages.txt; do
1674 echo -n "" > $INCOMING_REPOSITORY/$file
1675 done
1676 rm -r $INCOMING_REPOSITORY/files.list.lzma
1677 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
1680 ########################################################################
1681 # TAZWOK MAIN FUNCTIONS
1682 ########################
1684 clean()
1686 cd $WOK/$PACKAGE
1687 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
1688 -e ^stuff$ || return
1690 report step "Cleaning $PACKAGE"
1691 # Check for clean_wok function.
1692 if grep -q ^clean_wok $RECEIPT; then
1693 clean_wok
1694 fi
1695 # Clean should only have a receipt, stuff and optional desc.
1696 for f in `ls .`
1697 do
1698 case $f in
1699 receipt|stuff|description.txt)
1700 continue ;;
1701 *)
1702 echo "Removing: $f"
1703 rm -rf $f
1704 esac
1705 done
1706 report end-step
1709 # Configure and make a package with the receipt.
1710 compile_package()
1712 check_for_package_on_cmdline
1714 # Include the receipt to get all needed variables and functions
1715 # and cd into the work directory to start the work.
1716 check_for_receipt
1717 source_receipt
1719 # Log the package name and date.
1720 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
1721 echo "package $PACKAGE (compile)" >> $LOG
1723 # Set wanted $src variable to help compiling.
1724 [ ! "$src" ] && set_src_path
1725 check_for_build_depends || return 1
1726 check_for_wanted
1727 unset target
1728 check_for_tarball && check_for_compile_rules
1731 # Cook command also include all features to manage lists which keep
1732 # track of wok/packages state.
1733 cook()
1735 cook_code=
1736 set_common_path
1737 check_for_receipt
1738 source_receipt
1740 # Define log path and start report.
1741 [ -f $LOCAL_REPOSITORY/log/$PACKAGE.html ] && rm $LOCAL_REPOSITORY/log/$PACKAGE.html
1742 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
1743 report step "Cooking $PACKAGE"
1744 report open-bloc
1746 clean $PACKAGE
1747 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
1749 if compile_package; then
1750 refresh_packages_from_compile
1751 gen_package
1752 remove_src
1754 # Plan recook of reverse build depends if gen_package has detect
1755 # a change in libraries.
1756 if [ "$cook_rdep" ]; then
1757 report step "Look for packages which need a refresh"
1758 for rdep in $(scan $PACKAGE --look_for=rdep); do
1759 sed "/^$rdep$/d" -i $PACKAGES_REPOSITORY/broken
1760 if [ -f $WOK/$rdep/receipt ] && ! grep -q ^$rdep$ $tmp/cooklist; then
1761 echo "Add $rdep in cooklist to avoid broke caused by library update in $PACKAGE"
1762 echo $rdep >> $tmp/cooklist
1763 regen_cooklist=yes
1764 fi
1765 done
1766 report end-step
1767 fi
1769 # Update packages-incoming repository.
1770 store_pkgname=$PACKAGE
1771 pkg_repository=$INCOMING_REPOSITORY
1772 update_packages_db
1774 PACKAGE=$store_pkgname
1775 unset store_pkgname
1777 # Upgrade to cooked packages if it was previously installed.
1778 report step "Look for package(s) to upgrade"
1779 for pkg in $(look_for_rwanted) $PACKAGE; do
1780 if [ -d $INSTALLED/$pkg ]; then
1781 tazpkg get-install $pkg --forced
1782 fi
1783 done
1784 report end-step
1785 else
1787 # Set package as broken.
1788 if ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then
1789 echo $PACKAGE >> $PACKAGES_REPOSITORY/broken
1790 fi
1791 gen_cookmd5
1792 cook_code=1
1793 fi
1795 # Remove build_depends in cook mode (if in cooklist, it's done when
1796 # checking build_depends of next package and we remove only unneeded
1797 # packages to keep chroot minimal and gain some time).
1798 [ "$COMMAND" = cook ] && remove_build_depends $MISSING_PACKAGE
1800 # Regen the cooklist if it was planned and command is not cook.
1801 [ "$regen_cooklist" ] && unset regen_cooklist && \
1802 [ "$COMMAND" != cook ] && sort_cooklist
1804 # Some hacks to set the bloc & function status as failed if cook was
1805 # failed.
1806 report_return_code=$cook_code
1807 report close-bloc
1808 report end-sublog
1809 return $cook_code
1812 cook_list()
1814 if [ -s $tmp/cooklist ]; then
1815 if [ -f /usr/bin/tazchroot ]; then
1816 # Note : options -main variables- are automatically keeped by
1817 # the sub-applications tazchroot/tazwok; as well as report data.
1818 cd $LOCAL_REPOSITORY
1819 [ ! -f tazchroot.conf ] && configure_tazchroot
1820 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
1821 return
1822 fi
1823 while [ -s $tmp/cooklist ]; do
1824 PACKAGE=$(sed 1!d $tmp/cooklist)
1825 cook
1826 done
1827 remove_build_depends $MISSING_PACKAGE $remove_later
1828 else
1829 echo "Nothing to cook."
1830 return
1831 fi
1834 configure_tazchroot()
1836 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
1837 # Tazchroot configuration file - created by tazwok.
1839 # Default chroot path
1840 SLITAZ_DIR=$SLITAZ_DIR
1841 SLITAZ_VERSION=$SLITAZ_VERSION
1842 $( [ "$undigest" ] && echo "undigest=$undigest" )
1843 LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
1844 chroot_dir=\$LOCAL_REPOSITORY/chroot
1846 # Default scripts path (theses scripts are added in the
1847 # $chroot_dir/usr/bin and can be called with tazchroot script)
1848 script_dir=/var/lib/tazchroot
1850 # List of directories to mount.
1851 list_dir="$(for dir in packages wok src packages-incoming log flavors iso; do echo $LOCAL_REPOSITORY/$dir; done)
1852 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
1854 create_chroot()
1856 mkdir -p \$chroot_dir
1857 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
1858 tazpkg get-install \$pkg --root="\$chroot_dir"
1859 done
1861 # Store list of installed packages needed by cleanchroot.
1862 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
1864 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
1865 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
1866 -i \$chroot_dir/etc/slitaz/slitaz.conf
1867 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
1868 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
1871 mount_chroot()
1873 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
1874 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCALSTATE/mirror
1875 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
1876 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
1877 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION
1878 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror' )
1879 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
1880 mount -t proc proc \$chroot_dir/proc
1881 mount -t sysfs sysfs \$chroot_dir/sys
1882 mount -t devpts devpts \$chroot_dir/dev/pts
1883 mount -t tmpfs shm \$chroot_dir/dev/shm
1884 for dir in \$list_dir; do
1885 mkdir -p \$dir \$chroot_dir\$dir
1886 mount \$dir \$chroot_dir\$dir
1887 done
1890 umount_chroot()
1892 for dir in \$list_dir; do
1893 umount \$chroot_dir\$dir
1894 done
1895 umount \$chroot_dir/dev/shm
1896 umount \$chroot_dir/dev/pts
1897 umount \$chroot_dir/sys
1898 umount \$chroot_dir/proc
1900 EOF
1903 ########################################################################
1904 ######################### END OF NEW FUNCTIONS #########################
1905 ########################################################################
1907 # List packages providing a virtual package
1908 whoprovide()
1910 local i;
1911 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
1912 . $i
1913 case " $PROVIDE " in
1914 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
1915 esac
1916 done
1919 ########################################################################
1920 # TAZWOK COMMANDS
1921 ########################
1923 case "$COMMAND" in
1924 stats)
1925 # Tazwok general statistics from the wok config file.
1927 get_tazwok_config
1928 echo -e "\n\033[1mTazwok configuration statistics\033[0m
1929 ================================================================================
1930 Wok directory : $WOK
1931 Packages repository : $PACKAGES_REPOSITORY
1932 Incoming repository : $INCOMING_REPOSITORY
1933 Sources repository : $SOURCES_REPOSITORY
1934 Log directory : $LOCAL_REPOSITORY/log
1935 Packages in the wok : `ls -1 $WOK | wc -l`
1936 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
1937 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
1938 ================================================================================\n"
1939 ;;
1940 edit)
1941 get_tazwok_config
1942 check_for_package_on_cmdline
1943 check_for_receipt
1944 $EDITOR $WOK/$PACKAGE/receipt
1945 ;;
1946 build-depends)
1947 # List dependencies to rebuild wok, or only a package
1948 get_tazwok_config
1949 if [ "$PACKAGE" = toolchain-cooklist ]; then
1950 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1951 --cooklist
1952 elif [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
1953 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1954 --look_for=dep --with_dev --with_args
1955 else
1956 check_for_package_on_cmdline
1957 scan $PACKAGE --look_for=bdep --with_dev
1958 fi
1959 ;;
1960 gen-cooklist)
1961 get_options_list="pkg"
1962 get_tazwok_config
1963 check_root
1964 if ! [ "$pkg" ]; then
1965 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
1966 fi
1967 forced=yes
1968 gen_cook_list
1969 ;;
1970 check-depends)
1971 # Check package depends /!\
1972 get_tazwok_config
1973 echo ""
1974 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
1975 ================================================================================"
1976 TMPDIR=/tmp/tazwok$$
1977 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
1979 # Build ALL_DEPENDS variable
1980 scan_dep()
1982 local i
1983 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
1984 for i in $DEPENDS $SUGGESTED ; do
1985 case " $ALL_DEPENDS " in
1986 *\ $i\ *) continue;;
1987 esac
1988 [ -d $WOK/$i ] || {
1989 ALL_DEPENDS="$ALL_DEPENDS$i "
1990 continue
1992 DEPENDS=""
1993 SUGGESTED=""
1994 . $WOK/$i/receipt
1995 scan_dep
1996 done
1999 # Check for ELF file
2000 is_elf()
2002 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" \
2003 = "ELF" ]
2006 # Print shared library dependencies
2007 ldd()
2009 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
2012 mkdir $TMPDIR
2013 cd $TMPDIR
2014 for i in $LOCALSTATE/files.list.lzma \
2015 $LOCALSTATE/undigest/*/files.list.lzma ; do
2016 [ -f $i ] && lzma d $i -so >> files.list
2017 done
2018 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
2019 tazpkg extract $pkg > /dev/null 2>&1
2020 . */receipt
2021 ALL_DEPENDS="$DEFAULT_DEPENDS "
2022 scan_dep
2023 find */fs -type f | while read file ; do
2024 is_elf $file || continue
2025 case "$file" in
2026 *.o|*.ko|*.ko.gz) continue;;
2027 esac
2028 ldd $file | while read lib rem; do
2029 case "$lib" in
2030 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
2031 continue;;
2032 esac
2033 for dep in $(fgrep $lib files.list | cut -d: -f1); do
2034 case " $ALL_DEPENDS " in
2035 *\ $dep\ *) continue 2;;
2036 esac
2037 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
2038 case " $ALL_DEPENDS " in
2039 *\ $vdep\ *) continue 3;;
2040 esac
2041 done
2042 done
2043 [ -n "$dep" ] || dep="UNKNOWN"
2044 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
2045 done
2046 done
2047 rm -rf */
2048 done
2049 cd /tmp
2050 rm -rf $TMPDIR
2051 ;;
2052 check)
2053 # Check wok consistency
2054 get_tazwok_config
2055 echo ""
2056 echo -e "\033[1mWok and packages checking\033[0m
2057 ================================================================================"
2058 cd $WOK
2059 for pkg in $(ls)
2060 do
2061 [ -f $pkg/receipt ] || continue
2062 RECEIPT= $pkg/receipt
2063 source_receipt
2064 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
2065 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
2066 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
2067 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
2068 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
2069 if [ -n "$WANTED" ]; then
2070 if [ ! -f $WANTED/receipt ]; then
2071 echo "Package $PACKAGE wants unknown $WANTED package" >&2
2072 else
2073 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
2074 if [ "$VERSION" = "$WANTED" ]; then
2075 # BASEVERSION is computed in receipt
2076 fgrep -q '_pkg=' $pkg/receipt &&
2077 BASEVERSION=$VERSION
2078 fi
2079 if [ "$VERSION" != "$BASEVERSION" ]; then
2080 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
2081 fi
2082 fi
2083 fi
2085 if [ -n "$CATEGORY" ]; then
2086 case " $(echo $CATEGORIES) " in
2087 *\ $CATEGORY\ *);;
2088 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
2089 esac
2090 else
2091 echo"Package $PACKAGE has no CATEGORY" >&2
2092 fi
2093 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
2094 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
2095 case "$WGET_URL" in
2096 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
2097 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
2098 '') ;;
2099 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
2100 esac
2101 case "$WEB_SITE" in
2102 ftp*|http*);;
2103 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
2104 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
2105 esac
2106 case "$MAINTAINER" in
2107 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
2108 esac
2109 case "$MAINTAINER" in
2110 *@*);;
2111 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
2112 esac
2113 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2114 for i in $DEPENDS; do
2115 [ -d $i ] && continue
2116 [ -n "$(whoprovide $i)" ] && continue
2117 echo -e "$MSG $i"
2118 MSG=""
2119 done
2120 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2121 for i in $BUILD_DEPENDS; do
2122 [ -d $i ] && continue
2123 [ -n "$(whoprovide $i)" ] && continue
2124 echo -e "$MSG $i"
2125 MSG=""
2126 done
2127 MSG="Dependencies loop between $PACKAGE and :\n"
2128 ALL_DEPS=""
2129 check_for_deps_loop $PACKAGE $DEPENDS
2130 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
2131 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
2132 echo "$pkg should be rebuilt after $i installation"
2133 done
2134 done
2135 ;;
2136 list)
2137 # List packages in wok directory. User can specify a category.
2139 get_tazwok_config
2140 if [ "$2" = "category" ]; then
2141 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
2142 exit 0
2143 fi
2144 # Check for an asked category.
2145 if [ -n "$2" ]; then
2146 ASKED_CATEGORY=$2
2147 echo ""
2148 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
2149 echo "================================================================================"
2150 for pkg in $WOK/*
2151 do
2152 [ ! -f $pkg/receipt ] && continue
2153 . $pkg/receipt
2154 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
2155 echo -n "$PACKAGE"
2156 echo -e "\033[28G $VERSION"
2157 packages=$(($packages+1))
2158 fi
2159 done
2160 echo "================================================================================"
2161 echo -e "$PACKAGEs packages in category $ASKED_CATEGORY.\n"
2162 else
2163 # By default list all packages and version.
2164 echo ""
2165 echo -e "\033[1mList of packages in the wok\033[0m"
2166 echo "================================================================================"
2167 for pkg in $WOK/*
2168 do
2169 [ ! -f $pkg/receipt ] && continue
2170 . $pkg/receipt
2171 echo -n "$PACKAGE"
2172 echo -en "\033[28G $VERSION"
2173 echo -e "\033[42G $CATEGORY"
2174 packages=$(($packages+1))
2175 done
2176 echo "================================================================================"
2177 echo -e "$PACKAGEs packages available in the wok.\n"
2178 fi
2179 ;;
2180 info)
2181 # Information about a package.
2183 get_tazwok_config
2184 check_for_package_on_cmdline
2185 check_for_receipt
2186 . $WOK/$PACKAGE/receipt
2187 echo ""
2188 echo -e "\033[1mTazwok package information\033[0m
2189 ================================================================================
2190 Package : $PACKAGE
2191 Version : $VERSION
2192 Category : $CATEGORY
2193 Short desc : $SHORT_DESC
2194 Maintainer : $MAINTAINER"
2195 if [ ! "$WEB_SITE" = "" ]; then
2196 echo "Web site : $WEB_SITE"
2197 fi
2198 if [ ! "$DEPENDS" = "" ]; then
2199 echo "Depends : $DEPENDS"
2200 fi
2201 if [ ! "$WANTED" = "" ]; then
2202 echo "Wanted src : $WANTED"
2203 fi
2204 echo "================================================================================"
2205 echo ""
2206 ;;
2207 check-log)
2208 # We just cat the file log to view process info.
2210 get_tazwok_config
2211 if [ ! -f "$LOG" ]; then
2212 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
2213 exit 1
2214 else
2215 echo ""
2216 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
2217 echo "================================================================================"
2218 cat $LOG
2219 echo "================================================================================"
2220 echo ""
2221 fi
2222 ;;
2223 search)
2224 # Search for a package by pattern or name.
2226 get_tazwok_config
2227 if [ -z "$2" ]; then
2228 echo -e "\nPlease specify a pattern or a package name to search." >&2
2229 echo -e "Example : 'tazwok search gcc'.\n" >&2
2230 exit 1
2231 fi
2232 echo ""
2233 echo -e "\033[1mSearch result for :\033[0m $2"
2234 echo "================================================================================"
2235 list=`ls -1 $WOK | fgrep $2`
2236 for pkg in $list
2237 do
2238 . $WOK/$pkg/receipt
2239 echo -n "$PACKAGE "
2240 echo -en "\033[24G $VERSION"
2241 echo -e "\033[42G $CATEGORY"
2242 packages=$(($PACKAGEs+1))
2243 done
2244 echo "================================================================================"
2245 echo "$PACKAGEs packages found for : $2"
2246 echo ""
2247 ;;
2248 compile)
2249 # Configure and make a package with the receipt.
2251 get_tazwok_config
2252 source_lib report
2253 report start
2254 compile_package
2255 ;;
2256 genpkg)
2257 # Generate a package.
2259 get_tazwok_config
2260 source_lib report
2261 report start
2262 gen_package
2263 ;;
2264 cook)
2265 # Compile and generate a package. Just execute tazwok with
2266 # the good commands.
2268 check_root
2269 get_tazwok_config
2270 source_lib report
2271 report start
2272 cook
2273 ;;
2274 sort-cooklist)
2275 if [ ! "$LIST" ]; then
2276 echo "Usage : tazwok sort-cooklist cooklist" >&2\
2277 exit 1
2278 fi
2279 get_tazwok_config
2280 source_lib report
2281 report start
2282 cooklist=$LIST
2283 sort_cooklist
2284 cp -af $tmp/cooklist $cooklist
2285 ;;
2286 cook-list)
2287 # Cook all packages listed in a file or in default cooklist.
2288 check_root
2289 get_options_list="pkg forced"
2290 get_tazwok_config
2291 source_lib report
2292 report start
2293 if ! [ "$pkg" ]; then
2294 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2295 fi
2296 gen_cook_list
2297 cook_list
2298 ;;
2299 clean)
2300 # Clean up a package work directory + thoses which want it.
2302 get_tazwok_config
2303 check_for_package_on_cmdline
2304 check_for_receipt
2305 source_lib report
2306 report start
2307 . $RECEIPT
2308 clean
2309 ;;
2310 gen-clean-wok)
2311 # Generate a clean wok from the current wok by copying all receipts
2312 # and stuff directory.
2314 get_tazwok_config
2315 source_lib report
2316 report start
2317 if [ -z "$ARG" ]; then
2318 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
2319 exit 1
2320 else
2321 dest=$ARG
2322 mkdir -p $dest
2323 fi
2324 report step "Creating clean wok in : $dest"
2325 for pkg in `ls -1 $WOK`
2326 do
2327 mkdir -p $dest/$pkg
2328 cp -a $WOK/$pkg/receipt $dest/$pkg
2329 [ -f $WOK/$pkg/description.txt ] && \
2330 cp -a $WOK/$pkg/description.txt $dest/$pkg
2331 if [ -d "$WOK/$pkg/stuff" ]; then
2332 cp -a $WOK/$pkg/stuff $dest/$pkg
2333 fi
2334 done
2335 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
2336 report end-step
2337 echo "Packages cleaned : `ls -1 $dest | wc -l`"
2338 echo ""
2339 ;;
2340 clean-wok)
2341 # Clean all packages in the work directory
2343 get_tazwok_config
2344 source_lib report
2345 report start
2346 report step "Cleaning wok"
2347 report open-bloc
2348 for PACKAGE in `ls -1 $WOK`
2349 do
2350 set_common_path
2351 source_receipt
2352 clean
2353 done
2354 report close-bloc
2355 echo "`ls -1 $WOK | wc -l` packages cleaned."
2356 ;;
2357 gen-list)
2358 get_tazwok_config
2359 if [ "$2" ]; then
2360 if [ -d "$2" ]; then
2361 pkg_repository=$2
2362 else
2363 echo -e "\nUnable to find directory : $2\n" >&2
2364 exit 1
2365 fi
2366 fi
2368 source_lib report
2369 report start
2370 if [ "$pkg_repository" ]; then
2371 gen_packages_db
2372 else
2373 pkg_repository=$PACKAGES_REPOSITORY && gen_packages_db
2374 pkg_repository=$INCOMING_REPOSITORY && gen_packages_db
2375 fi
2376 ;;
2377 check-list)
2378 # The directory to move into by default is the repository,
2379 # if $2 is not empty cd into $2.
2381 get_tazwok_config
2382 if [ "$2" ]; then
2383 if [ -d "$2" ]; then
2384 pkg_repository=$2
2385 else
2386 echo -e "\nUnable to find directory : $2\n" >&2
2387 exit 1
2388 fi
2389 fi
2391 source_lib report
2392 report start
2393 if [ "$pkg_repository" ]; then
2394 update_packages_db
2395 else
2396 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
2397 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
2398 fi
2399 ;;
2400 new-tree)
2401 # Just create a few directories and generate an empty receipt to prepare
2402 # the creation of a new package.
2404 get_tazwok_config
2405 check_for_package_on_cmdline
2406 if [ -d $WOK/$PACKAGE ]; then
2407 echo -e "\n$PACKAGE package tree already exists.\n" >&2
2408 exit 1
2409 fi
2410 echo "Creating : $WOK/$PACKAGE"
2411 mkdir $WOK/$PACKAGE
2412 cd $WOK/$PACKAGE
2413 echo -n "Preparing the receipt..."
2415 # Default receipt begin.
2417 echo "# SliTaz package receipt." > receipt
2418 echo "" >> receipt
2419 echo "PACKAGE=\"$PACKAGE\"" >> receipt
2420 # Finish the empty receipt.
2421 cat >> receipt << "EOF"
2422 VERSION=""
2423 CATEGORY=""
2424 SHORT_DESC=""
2425 MAINTAINER=""
2426 DEPENDS=""
2427 TARBALL="$PACKAGE-$VERSION.tar.gz"
2428 WEB_SITE=""
2429 WGET_URL=""
2431 # Rules to configure and make the package.
2432 compile_rules()
2434 cd $src
2435 ./configure && make && make install
2438 # Rules to gen a SliTaz package suitable for Tazpkg.
2439 genpkg_rules()
2441 mkdir -p $fs/usr
2442 cp -a $_pkg/usr/bin $fs/usr
2445 EOF
2447 # Default receipt end.
2449 status
2450 # Interactive mode, asking and seding.
2451 if [ "$3" = "--interactive" ]; then
2452 echo "Entering into interactive mode..."
2453 echo "================================================================================"
2454 echo "Package : $PACKAGE"
2455 # Version.
2456 echo -n "Version : " ; read anser
2457 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
2458 # Category.
2459 echo -n "Category : " ; read anser
2460 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
2461 # Short description.
2462 echo -n "Short desc : " ; read anser
2463 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
2464 # Maintainer.
2465 echo -n "Maintainer : " ; read anser
2466 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
2467 # Web site.
2468 echo -n "Web site : " ; read anser
2469 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
2470 echo ""
2471 # Wget URL.
2472 echo "Wget URL to download source tarball."
2473 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
2474 echo -n "Wget url : " ; read anser
2475 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
2476 # Ask for a stuff dir.
2477 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
2478 if [ "$anser" = "y" ]; then
2479 echo -n "Creating the stuff directory..."
2480 mkdir stuff && status
2481 fi
2482 # Ask for a description file.
2483 echo -n "Are you going to write a description ? (y/N) : " ; read anser
2484 if [ "$anser" = "y" ]; then
2485 echo -n "Creating the description.txt file..."
2486 echo "" > description.txt && status
2487 fi
2488 echo "================================================================================"
2489 echo ""
2490 fi
2491 ;;
2492 remove)
2493 # Remove a package from the wok.
2495 get_tazwok_config
2496 check_for_package_on_cmdline
2497 echo ""
2498 echo -n "Please confirm deletion (y/N) : "; read anser
2499 if [ "$anser" = "y" ]; then
2500 echo -n "Removing $PACKAGE..."
2501 rm -rf $WOK/$PACKAGE && status
2502 echo ""
2503 fi
2504 ;;
2505 hgup)
2506 # Pull and update a Hg wok.
2507 get_tazwok_config
2508 if ls -l $WOK/.hg/hgrc | fgrep -q "root"; then
2509 check_root
2510 fi
2511 cd $WOK
2512 hg pull && hg update
2513 ;;
2514 maintainers)
2515 get_tazwok_config
2516 echo ""
2517 echo "List of maintainers for: $WOK"
2518 echo "================================================================================"
2519 touch /tmp/slitaz-maintainers
2520 for pkg in $WOK/*
2521 do
2522 . $pkg/receipt
2523 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
2524 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
2525 echo "$MAINTAINER"
2526 fi
2527 done
2528 echo "================================================================================"
2529 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
2530 echo ""
2531 # Remove tmp files
2532 rm -f /tmp/slitaz-maintainers
2533 ;;
2534 maintained-by)
2535 # Search for packages maintained by a contributor.
2536 get_tazwok_config
2537 if [ ! -n "$2" ]; then
2538 echo "Specify a name or email of a maintainer." >&2
2539 exit 1
2540 fi
2541 echo "Maintainer packages"
2542 echo "================================================================================"
2543 for pkg in $WOK/*
2544 do
2545 . $pkg/receipt
2546 if echo "$MAINTAINER" | fgrep -q "$2"; then
2547 echo "$PACKAGE"
2548 packages=$(($PACKAGEs+1))
2549 fi
2550 done
2551 echo "================================================================================"
2552 echo "Packages maintained by $2: $PACKAGEs"
2553 echo ""
2554 ;;
2555 check-src)
2556 # Verify if upstream package is still available
2558 get_tazwok_config
2559 check_for_package_on_cmdline
2560 check_for_receipt
2561 source_receipt
2562 check_src()
2564 for url in $@; do
2565 busybox wget -s $url 2>/dev/null && break
2566 done
2568 if [ "$WGET_URL" ];then
2569 echo -n "$PACKAGE : "
2570 check_src $WGET_URL
2571 status
2572 else
2573 echo "No tarball to check for $PACKAGE"
2574 fi
2575 ;;
2576 get-src)
2577 check_root
2578 get_options_list="target"
2579 get_tazwok_config
2580 check_for_package_on_cmdline
2581 check_for_receipt
2582 source_receipt
2583 if [ "$WGET_URL" ];then
2584 source_lib report
2585 report start
2586 check_for_tarball
2587 else
2588 echo "No tarball to download for $PACKAGE"
2589 fi
2590 ;;
2591 check-commit)
2592 check_root
2593 get_options_list="missing forced"
2594 get_tazwok_config
2595 source_lib report
2596 report start
2597 if [ "$forced" ]; then
2598 rm -f $WOK/*/md5
2599 unset forced
2600 fi
2601 if [ "$missing" ]; then
2602 pkg=$(ls -1 $WOK)
2603 else
2604 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2605 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2606 } | sort -u)"
2607 fi
2608 cooklist=$PACKAGES_REPOSITORY/cooklist
2609 gen_cook_list
2610 ;;
2611 cook-commit)
2612 check_root
2613 get_options_list="missing forced"
2614 get_tazwok_config
2615 source_lib report
2616 report start
2617 if [ "$forced" ]; then
2618 rm -f $WOK/*/md5
2619 unset forced
2620 fi
2621 if [ "$missing" ]; then
2622 pkg=$(ls -1 $WOK)
2623 else
2624 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2625 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2626 } | sort -u)"
2627 fi
2628 cooklist=$PACKAGES_REPOSITORY/cooklist
2629 gen_cook_list
2630 cook_list
2631 ;;
2632 cook-all)
2633 check_root
2634 get_options_list="forced missing"
2635 get_tazwok_config
2636 source_lib report
2637 report start
2638 if [ "$missing" ]; then
2639 pkg=$(ls -1 $WOK)
2640 else
2641 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2642 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2643 } | sort -u)"
2644 fi
2645 cooklist=$PACKAGES_REPOSITORY/cooklist
2646 gen_cook_list
2647 cook_list
2648 ;;
2649 gen-wok-db)
2650 check_root
2651 get_tazwok_config
2652 source_lib report
2653 report start
2654 gen_wok_db
2655 ;;
2656 report)
2657 check_root
2658 get_tazwok_config
2659 cd $PACKAGES_REPOSITORY
2660 for i in commit cooklist incoming broken blocked; do
2661 if [ -s $i ]; then
2662 echo -e "\n********************* $i *********************\n$(cat $i)\n*********************"
2663 fi
2664 done
2665 ;;
2666 check-incoming)
2667 check_root
2668 get_tazwok_config
2669 source_lib report
2670 report start
2671 check_for_incoming
2672 ;;
2673 configure-chroot)
2674 check_root
2675 get_tazwok_config
2676 if [ -f /usr/bin/tazchroot ]; then
2677 cd $LOCAL_REPOSITORY
2678 configure_tazchroot
2679 else
2680 echo "The packages tazchroot need to be installed" >&2
2681 exit 1
2682 fi
2683 ;;
2684 chroot)
2685 check_root
2686 get_tazwok_config
2687 # Merge this and the other chroot function ?.
2688 if [ -f /usr/bin/tazchroot ]; then
2689 cd $LOCAL_REPOSITORY
2690 [ ! -f tazchroot.conf ] && configure_tazchroot
2691 tazchroot
2692 else
2693 echo "The packages tazchroot need to be installed" >&2
2694 exit 1
2695 fi
2696 ;;
2697 cook-toolchain)
2698 check_root
2699 get_tazwok_config
2700 echo -n "" > $PACKAGES_REPOSITORY/broken
2701 if [ -f /usr/bin/tazchroot ]; then
2702 cd $LOCAL_REPOSITORY
2703 [ ! -f tazchroot.conf ] && configure_tazchroot
2704 tazchroot cook-toolchain
2705 # Buggy : chroot can be elsewhere.
2706 rm -r $LOCAL_REPOSITORY/chroot
2707 # /!\ to be writed :
2708 # next rm chroot and plan cook-all by pushing all packages
2709 # in cooklist.
2710 else
2711 echo "The packages tazchroot need to be installed" >&2
2712 exit 1
2713 fi
2714 ;;
2715 usage|*)
2716 # Print usage also for all unknown commands.
2718 usage
2719 ;;
2720 esac
2722 report stop 2>/dev/null || exit 0