tazwok view tazwok @ rev 209

Fix: block core toolchain packages efficiently and support block-list correctly
author Antoine Bodin <gokhlayeh@slitaz.org>
date Mon Jan 31 03:08:09 2011 +0100 (2011-01-31)
parents f9c33585ac83
children ee704af5304a
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 [ "$COMMAND" = cook ] && remove_build_depends $MISSING_PACKAGE
1802 # Regen the cooklist if it was planned and command is not cook.
1803 [ "$regen_cooklist" ] && unset regen_cooklist && \
1804 [ "$COMMAND" != cook ] && sort_cooklist
1806 # Some hacks to set the bloc & function status as failed if cook was
1807 # failed.
1808 report_return_code=$cook_code
1809 report close-bloc
1810 report end-sublog
1811 return $cook_code
1814 cook_list()
1816 if [ -s $tmp/cooklist ]; then
1817 if [ -f /usr/bin/tazchroot ]; then
1818 # Note : options -main variables- are automatically keeped by
1819 # the sub-applications tazchroot/tazwok; as well as report data.
1820 cd $LOCAL_REPOSITORY
1821 [ ! -f tazchroot.conf ] && configure_tazchroot
1822 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
1823 return
1824 fi
1825 while [ -s $tmp/cooklist ]; do
1826 PACKAGE=$(sed 1!d $tmp/cooklist)
1827 cook
1828 done
1829 remove_build_depends $MISSING_PACKAGE $remove_later
1830 else
1831 echo "Nothing to cook."
1832 return
1833 fi
1836 configure_tazchroot()
1838 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
1839 # Tazchroot configuration file - created by tazwok.
1841 # Default chroot path
1842 SLITAZ_DIR=$SLITAZ_DIR
1843 SLITAZ_VERSION=$SLITAZ_VERSION
1844 $( [ "$undigest" ] && echo "undigest=$undigest" )
1845 LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
1846 chroot_dir=\$LOCAL_REPOSITORY/chroot
1848 # Default scripts path (theses scripts are added in the
1849 # $chroot_dir/usr/bin and can be called with tazchroot script)
1850 script_dir=/var/lib/tazchroot
1852 # List of directories to mount.
1853 list_dir="$(for dir in packages wok src packages-incoming log flavors iso; do echo $LOCAL_REPOSITORY/$dir; done)
1854 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
1856 create_chroot()
1858 mkdir -p \$chroot_dir
1859 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
1860 tazpkg get-install \$pkg --root="\$chroot_dir"
1861 done
1863 # Store list of installed packages needed by cleanchroot.
1864 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
1866 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
1867 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
1868 -i \$chroot_dir/etc/slitaz/slitaz.conf
1869 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
1870 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
1873 mount_chroot()
1875 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
1876 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCALSTATE/mirror
1877 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
1878 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
1879 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION
1880 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror' )
1881 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
1882 mount -t proc proc \$chroot_dir/proc
1883 mount -t sysfs sysfs \$chroot_dir/sys
1884 mount -t devpts devpts \$chroot_dir/dev/pts
1885 mount -t tmpfs shm \$chroot_dir/dev/shm
1886 for dir in \$list_dir; do
1887 mkdir -p \$dir \$chroot_dir\$dir
1888 mount \$dir \$chroot_dir\$dir
1889 done
1892 umount_chroot()
1894 for dir in \$list_dir; do
1895 umount \$chroot_dir\$dir
1896 done
1897 umount \$chroot_dir/dev/shm
1898 umount \$chroot_dir/dev/pts
1899 umount \$chroot_dir/sys
1900 umount \$chroot_dir/proc
1902 EOF
1905 ########################################################################
1906 ######################### END OF NEW FUNCTIONS #########################
1907 ########################################################################
1909 # List packages providing a virtual package
1910 whoprovide()
1912 local i;
1913 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
1914 . $i
1915 case " $PROVIDE " in
1916 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
1917 esac
1918 done
1921 ########################################################################
1922 # TAZWOK COMMANDS
1923 ########################
1925 case "$COMMAND" in
1926 stats)
1927 # Tazwok general statistics from the wok config file.
1929 get_tazwok_config
1930 echo -e "\n\033[1mTazwok configuration statistics\033[0m
1931 ================================================================================
1932 Wok directory : $WOK
1933 Packages repository : $PACKAGES_REPOSITORY
1934 Incoming repository : $INCOMING_REPOSITORY
1935 Sources repository : $SOURCES_REPOSITORY
1936 Log directory : $LOCAL_REPOSITORY/log
1937 Packages in the wok : `ls -1 $WOK | wc -l`
1938 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
1939 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
1940 ================================================================================\n"
1941 ;;
1942 edit)
1943 get_tazwok_config
1944 check_for_package_on_cmdline
1945 check_for_receipt
1946 $EDITOR $WOK/$PACKAGE/receipt
1947 ;;
1948 build-depends)
1949 # List dependencies to rebuild wok, or only a package
1950 get_tazwok_config
1951 if [ "$PACKAGE" = toolchain-cooklist ]; then
1952 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1953 --cooklist
1954 elif [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
1955 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1956 --look_for=dep --with_dev --with_args
1957 else
1958 check_for_package_on_cmdline
1959 scan $PACKAGE --look_for=bdep --with_dev
1960 fi
1961 ;;
1962 gen-cooklist)
1963 get_options_list="pkg"
1964 get_tazwok_config
1965 check_root
1966 if ! [ "$pkg" ]; then
1967 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
1968 fi
1969 forced=yes
1970 gen_cook_list
1971 ;;
1972 check-depends)
1973 # Check package depends /!\
1974 get_tazwok_config
1975 echo ""
1976 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
1977 ================================================================================"
1978 TMPDIR=/tmp/tazwok$$
1979 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
1981 # Build ALL_DEPENDS variable
1982 scan_dep()
1984 local i
1985 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
1986 for i in $DEPENDS $SUGGESTED ; do
1987 case " $ALL_DEPENDS " in
1988 *\ $i\ *) continue;;
1989 esac
1990 [ -d $WOK/$i ] || {
1991 ALL_DEPENDS="$ALL_DEPENDS$i "
1992 continue
1994 DEPENDS=""
1995 SUGGESTED=""
1996 . $WOK/$i/receipt
1997 scan_dep
1998 done
2001 # Check for ELF file
2002 is_elf()
2004 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" \
2005 = "ELF" ]
2008 # Print shared library dependencies
2009 ldd()
2011 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
2014 mkdir $TMPDIR
2015 cd $TMPDIR
2016 for i in $LOCALSTATE/files.list.lzma \
2017 $LOCALSTATE/undigest/*/files.list.lzma ; do
2018 [ -f $i ] && lzma d $i -so >> files.list
2019 done
2020 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
2021 tazpkg extract $pkg > /dev/null 2>&1
2022 . */receipt
2023 ALL_DEPENDS="$DEFAULT_DEPENDS "
2024 scan_dep
2025 find */fs -type f | while read file ; do
2026 is_elf $file || continue
2027 case "$file" in
2028 *.o|*.ko|*.ko.gz) continue;;
2029 esac
2030 ldd $file | while read lib rem; do
2031 case "$lib" in
2032 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
2033 continue;;
2034 esac
2035 for dep in $(fgrep $lib files.list | cut -d: -f1); do
2036 case " $ALL_DEPENDS " in
2037 *\ $dep\ *) continue 2;;
2038 esac
2039 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
2040 case " $ALL_DEPENDS " in
2041 *\ $vdep\ *) continue 3;;
2042 esac
2043 done
2044 done
2045 [ -n "$dep" ] || dep="UNKNOWN"
2046 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
2047 done
2048 done
2049 rm -rf */
2050 done
2051 cd /tmp
2052 rm -rf $TMPDIR
2053 ;;
2054 check)
2055 # Check wok consistency
2056 get_tazwok_config
2057 echo ""
2058 echo -e "\033[1mWok and packages checking\033[0m
2059 ================================================================================"
2060 cd $WOK
2061 for pkg in $(ls)
2062 do
2063 [ -f $pkg/receipt ] || continue
2064 RECEIPT= $pkg/receipt
2065 source_receipt
2066 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
2067 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
2068 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
2069 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
2070 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
2071 if [ -n "$WANTED" ]; then
2072 if [ ! -f $WANTED/receipt ]; then
2073 echo "Package $PACKAGE wants unknown $WANTED package" >&2
2074 else
2075 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
2076 if [ "$VERSION" = "$WANTED" ]; then
2077 # BASEVERSION is computed in receipt
2078 fgrep -q '_pkg=' $pkg/receipt &&
2079 BASEVERSION=$VERSION
2080 fi
2081 if [ "$VERSION" != "$BASEVERSION" ]; then
2082 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
2083 fi
2084 fi
2085 fi
2087 if [ -n "$CATEGORY" ]; then
2088 case " $(echo $CATEGORIES) " in
2089 *\ $CATEGORY\ *);;
2090 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
2091 esac
2092 else
2093 echo"Package $PACKAGE has no CATEGORY" >&2
2094 fi
2095 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
2096 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
2097 case "$WGET_URL" in
2098 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
2099 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
2100 '') ;;
2101 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
2102 esac
2103 case "$WEB_SITE" in
2104 ftp*|http*);;
2105 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
2106 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
2107 esac
2108 case "$MAINTAINER" in
2109 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
2110 esac
2111 case "$MAINTAINER" in
2112 *@*);;
2113 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
2114 esac
2115 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2116 for i in $DEPENDS; do
2117 [ -d $i ] && continue
2118 [ -n "$(whoprovide $i)" ] && continue
2119 echo -e "$MSG $i"
2120 MSG=""
2121 done
2122 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2123 for i in $BUILD_DEPENDS; do
2124 [ -d $i ] && continue
2125 [ -n "$(whoprovide $i)" ] && continue
2126 echo -e "$MSG $i"
2127 MSG=""
2128 done
2129 MSG="Dependencies loop between $PACKAGE and :\n"
2130 ALL_DEPS=""
2131 check_for_deps_loop $PACKAGE $DEPENDS
2132 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
2133 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
2134 echo "$pkg should be rebuilt after $i installation"
2135 done
2136 done
2137 ;;
2138 list)
2139 # List packages in wok directory. User can specify a category.
2141 get_tazwok_config
2142 if [ "$2" = "category" ]; then
2143 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
2144 exit 0
2145 fi
2146 # Check for an asked category.
2147 if [ -n "$2" ]; then
2148 ASKED_CATEGORY=$2
2149 echo ""
2150 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
2151 echo "================================================================================"
2152 for pkg in $WOK/*
2153 do
2154 [ ! -f $pkg/receipt ] && continue
2155 . $pkg/receipt
2156 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
2157 echo -n "$PACKAGE"
2158 echo -e "\033[28G $VERSION"
2159 packages=$(($packages+1))
2160 fi
2161 done
2162 echo "================================================================================"
2163 echo -e "$PACKAGEs packages in category $ASKED_CATEGORY.\n"
2164 else
2165 # By default list all packages and version.
2166 echo ""
2167 echo -e "\033[1mList of packages in the wok\033[0m"
2168 echo "================================================================================"
2169 for pkg in $WOK/*
2170 do
2171 [ ! -f $pkg/receipt ] && continue
2172 . $pkg/receipt
2173 echo -n "$PACKAGE"
2174 echo -en "\033[28G $VERSION"
2175 echo -e "\033[42G $CATEGORY"
2176 packages=$(($packages+1))
2177 done
2178 echo "================================================================================"
2179 echo -e "$PACKAGEs packages available in the wok.\n"
2180 fi
2181 ;;
2182 info)
2183 # Information about a package.
2185 get_tazwok_config
2186 check_for_package_on_cmdline
2187 check_for_receipt
2188 . $WOK/$PACKAGE/receipt
2189 echo ""
2190 echo -e "\033[1mTazwok package information\033[0m
2191 ================================================================================
2192 Package : $PACKAGE
2193 Version : $VERSION
2194 Category : $CATEGORY
2195 Short desc : $SHORT_DESC
2196 Maintainer : $MAINTAINER"
2197 if [ ! "$WEB_SITE" = "" ]; then
2198 echo "Web site : $WEB_SITE"
2199 fi
2200 if [ ! "$DEPENDS" = "" ]; then
2201 echo "Depends : $DEPENDS"
2202 fi
2203 if [ ! "$WANTED" = "" ]; then
2204 echo "Wanted src : $WANTED"
2205 fi
2206 echo "================================================================================"
2207 echo ""
2208 ;;
2209 check-log)
2210 # We just cat the file log to view process info.
2212 get_tazwok_config
2213 if [ ! -f "$LOG" ]; then
2214 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
2215 exit 1
2216 else
2217 echo ""
2218 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
2219 echo "================================================================================"
2220 cat $LOG
2221 echo "================================================================================"
2222 echo ""
2223 fi
2224 ;;
2225 search)
2226 # Search for a package by pattern or name.
2228 get_tazwok_config
2229 if [ -z "$2" ]; then
2230 echo -e "\nPlease specify a pattern or a package name to search." >&2
2231 echo -e "Example : 'tazwok search gcc'.\n" >&2
2232 exit 1
2233 fi
2234 echo ""
2235 echo -e "\033[1mSearch result for :\033[0m $2"
2236 echo "================================================================================"
2237 list=`ls -1 $WOK | fgrep $2`
2238 for pkg in $list
2239 do
2240 . $WOK/$pkg/receipt
2241 echo -n "$PACKAGE "
2242 echo -en "\033[24G $VERSION"
2243 echo -e "\033[42G $CATEGORY"
2244 packages=$(($PACKAGEs+1))
2245 done
2246 echo "================================================================================"
2247 echo "$PACKAGEs packages found for : $2"
2248 echo ""
2249 ;;
2250 compile)
2251 # Configure and make a package with the receipt.
2253 get_tazwok_config
2254 source_lib report
2255 report start
2256 compile_package
2257 ;;
2258 genpkg)
2259 # Generate a package.
2261 get_tazwok_config
2262 source_lib report
2263 report start
2264 gen_package
2265 ;;
2266 cook)
2267 # Compile and generate a package. Just execute tazwok with
2268 # the good commands.
2270 check_root
2271 get_tazwok_config
2272 source_lib report
2273 report start
2274 cook
2275 ;;
2276 sort-cooklist)
2277 if [ ! "$LIST" ]; then
2278 echo "Usage : tazwok sort-cooklist cooklist" >&2\
2279 exit 1
2280 fi
2281 get_tazwok_config
2282 source_lib report
2283 report start
2284 cooklist=$LIST
2285 sort_cooklist
2286 cp -af $tmp/cooklist $cooklist
2287 ;;
2288 cook-list)
2289 # Cook all packages listed in a file or in default cooklist.
2290 check_root
2291 get_options_list="pkg forced"
2292 get_tazwok_config
2293 source_lib report
2294 report start
2295 if ! [ "$pkg" ]; then
2296 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2297 fi
2298 gen_cook_list
2299 cook_list
2300 ;;
2301 clean)
2302 # Clean up a package work directory + thoses which want it.
2304 get_tazwok_config
2305 check_for_package_on_cmdline
2306 check_for_receipt
2307 source_lib report
2308 report start
2309 . $RECEIPT
2310 clean
2311 ;;
2312 gen-clean-wok)
2313 # Generate a clean wok from the current wok by copying all receipts
2314 # and stuff directory.
2316 get_tazwok_config
2317 source_lib report
2318 report start
2319 if [ -z "$ARG" ]; then
2320 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
2321 exit 1
2322 else
2323 dest=$ARG
2324 mkdir -p $dest
2325 fi
2326 report step "Creating clean wok in : $dest"
2327 for pkg in `ls -1 $WOK`
2328 do
2329 mkdir -p $dest/$pkg
2330 cp -a $WOK/$pkg/receipt $dest/$pkg
2331 [ -f $WOK/$pkg/description.txt ] && \
2332 cp -a $WOK/$pkg/description.txt $dest/$pkg
2333 if [ -d "$WOK/$pkg/stuff" ]; then
2334 cp -a $WOK/$pkg/stuff $dest/$pkg
2335 fi
2336 done
2337 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
2338 report end-step
2339 echo "Packages cleaned : `ls -1 $dest | wc -l`"
2340 echo ""
2341 ;;
2342 clean-wok)
2343 # Clean all packages in the work directory
2345 get_tazwok_config
2346 source_lib report
2347 report start
2348 report step "Cleaning wok"
2349 report open-bloc
2350 for PACKAGE in `ls -1 $WOK`
2351 do
2352 set_common_path
2353 source_receipt
2354 clean
2355 done
2356 report close-bloc
2357 echo "`ls -1 $WOK | wc -l` packages cleaned."
2358 ;;
2359 gen-list)
2360 get_tazwok_config
2361 if [ "$2" ]; then
2362 if [ -d "$2" ]; then
2363 pkg_repository=$2
2364 else
2365 echo -e "\nUnable to find directory : $2\n" >&2
2366 exit 1
2367 fi
2368 fi
2370 source_lib report
2371 report start
2372 if [ "$pkg_repository" ]; then
2373 gen_packages_db
2374 else
2375 pkg_repository=$PACKAGES_REPOSITORY && gen_packages_db
2376 pkg_repository=$INCOMING_REPOSITORY && gen_packages_db
2377 fi
2378 ;;
2379 check-list)
2380 # The directory to move into by default is the repository,
2381 # if $2 is not empty cd into $2.
2383 get_tazwok_config
2384 if [ "$2" ]; then
2385 if [ -d "$2" ]; then
2386 pkg_repository=$2
2387 else
2388 echo -e "\nUnable to find directory : $2\n" >&2
2389 exit 1
2390 fi
2391 fi
2393 source_lib report
2394 report start
2395 if [ "$pkg_repository" ]; then
2396 update_packages_db
2397 else
2398 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
2399 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
2400 fi
2401 ;;
2402 new-tree)
2403 # Just create a few directories and generate an empty receipt to prepare
2404 # the creation of a new package.
2406 get_tazwok_config
2407 check_for_package_on_cmdline
2408 if [ -d $WOK/$PACKAGE ]; then
2409 echo -e "\n$PACKAGE package tree already exists.\n" >&2
2410 exit 1
2411 fi
2412 echo "Creating : $WOK/$PACKAGE"
2413 mkdir $WOK/$PACKAGE
2414 cd $WOK/$PACKAGE
2415 echo -n "Preparing the receipt..."
2417 # Default receipt begin.
2419 echo "# SliTaz package receipt." > receipt
2420 echo "" >> receipt
2421 echo "PACKAGE=\"$PACKAGE\"" >> receipt
2422 # Finish the empty receipt.
2423 cat >> receipt << "EOF"
2424 VERSION=""
2425 CATEGORY=""
2426 SHORT_DESC=""
2427 MAINTAINER=""
2428 DEPENDS=""
2429 TARBALL="$PACKAGE-$VERSION.tar.gz"
2430 WEB_SITE=""
2431 WGET_URL=""
2433 # Rules to configure and make the package.
2434 compile_rules()
2436 cd $src
2437 ./configure && make && make install
2440 # Rules to gen a SliTaz package suitable for Tazpkg.
2441 genpkg_rules()
2443 mkdir -p $fs/usr
2444 cp -a $_pkg/usr/bin $fs/usr
2447 EOF
2449 # Default receipt end.
2451 status
2452 # Interactive mode, asking and seding.
2453 if [ "$3" = "--interactive" ]; then
2454 echo "Entering into interactive mode..."
2455 echo "================================================================================"
2456 echo "Package : $PACKAGE"
2457 # Version.
2458 echo -n "Version : " ; read anser
2459 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
2460 # Category.
2461 echo -n "Category : " ; read anser
2462 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
2463 # Short description.
2464 echo -n "Short desc : " ; read anser
2465 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
2466 # Maintainer.
2467 echo -n "Maintainer : " ; read anser
2468 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
2469 # Web site.
2470 echo -n "Web site : " ; read anser
2471 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
2472 echo ""
2473 # Wget URL.
2474 echo "Wget URL to download source tarball."
2475 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
2476 echo -n "Wget url : " ; read anser
2477 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
2478 # Ask for a stuff dir.
2479 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
2480 if [ "$anser" = "y" ]; then
2481 echo -n "Creating the stuff directory..."
2482 mkdir stuff && status
2483 fi
2484 # Ask for a description file.
2485 echo -n "Are you going to write a description ? (y/N) : " ; read anser
2486 if [ "$anser" = "y" ]; then
2487 echo -n "Creating the description.txt file..."
2488 echo "" > description.txt && status
2489 fi
2490 echo "================================================================================"
2491 echo ""
2492 fi
2493 ;;
2494 remove)
2495 # Remove a package from the wok.
2497 get_tazwok_config
2498 check_for_package_on_cmdline
2499 echo ""
2500 echo -n "Please confirm deletion (y/N) : "; read anser
2501 if [ "$anser" = "y" ]; then
2502 echo -n "Removing $PACKAGE..."
2503 rm -rf $WOK/$PACKAGE && status
2504 echo ""
2505 fi
2506 ;;
2507 hgup)
2508 # Pull and update a Hg wok.
2509 get_tazwok_config
2510 if ls -l $WOK/.hg/hgrc | fgrep -q "root"; then
2511 check_root
2512 fi
2513 cd $WOK
2514 hg pull && hg update
2515 ;;
2516 maintainers)
2517 get_tazwok_config
2518 echo ""
2519 echo "List of maintainers for: $WOK"
2520 echo "================================================================================"
2521 touch /tmp/slitaz-maintainers
2522 for pkg in $WOK/*
2523 do
2524 . $pkg/receipt
2525 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
2526 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
2527 echo "$MAINTAINER"
2528 fi
2529 done
2530 echo "================================================================================"
2531 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
2532 echo ""
2533 # Remove tmp files
2534 rm -f /tmp/slitaz-maintainers
2535 ;;
2536 maintained-by)
2537 # Search for packages maintained by a contributor.
2538 get_tazwok_config
2539 if [ ! -n "$2" ]; then
2540 echo "Specify a name or email of a maintainer." >&2
2541 exit 1
2542 fi
2543 echo "Maintainer packages"
2544 echo "================================================================================"
2545 for pkg in $WOK/*
2546 do
2547 . $pkg/receipt
2548 if echo "$MAINTAINER" | fgrep -q "$2"; then
2549 echo "$PACKAGE"
2550 packages=$(($PACKAGEs+1))
2551 fi
2552 done
2553 echo "================================================================================"
2554 echo "Packages maintained by $2: $PACKAGEs"
2555 echo ""
2556 ;;
2557 check-src)
2558 # Verify if upstream package is still available
2560 get_tazwok_config
2561 check_for_package_on_cmdline
2562 check_for_receipt
2563 source_receipt
2564 check_src()
2566 for url in $@; do
2567 busybox wget -s $url 2>/dev/null && break
2568 done
2570 if [ "$WGET_URL" ];then
2571 echo -n "$PACKAGE : "
2572 check_src $WGET_URL
2573 status
2574 else
2575 echo "No tarball to check for $PACKAGE"
2576 fi
2577 ;;
2578 get-src)
2579 check_root
2580 get_options_list="target"
2581 get_tazwok_config
2582 check_for_package_on_cmdline
2583 check_for_receipt
2584 source_receipt
2585 if [ "$WGET_URL" ];then
2586 source_lib report
2587 report start
2588 check_for_tarball
2589 else
2590 echo "No tarball to download for $PACKAGE"
2591 fi
2592 ;;
2593 check-commit)
2594 check_root
2595 get_options_list="missing forced"
2596 get_tazwok_config
2597 source_lib report
2598 report start
2599 if [ "$forced" ]; then
2600 rm -f $WOK/*/md5
2601 unset forced
2602 fi
2603 if [ "$missing" ]; then
2604 pkg=$(ls -1 $WOK)
2605 else
2606 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2607 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2608 } | sort -u)"
2609 fi
2610 cooklist=$PACKAGES_REPOSITORY/cooklist
2611 gen_cook_list
2612 ;;
2613 cook-commit)
2614 check_root
2615 get_options_list="missing forced"
2616 get_tazwok_config
2617 source_lib report
2618 report start
2619 if [ "$forced" ]; then
2620 rm -f $WOK/*/md5
2621 unset forced
2622 fi
2623 if [ "$missing" ]; then
2624 pkg=$(ls -1 $WOK)
2625 else
2626 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2627 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2628 } | sort -u)"
2629 fi
2630 cooklist=$PACKAGES_REPOSITORY/cooklist
2631 gen_cook_list
2632 cook_list
2633 ;;
2634 cook-all)
2635 check_root
2636 get_options_list="forced missing"
2637 get_tazwok_config
2638 source_lib report
2639 report start
2640 if [ "$missing" ]; then
2641 pkg=$(ls -1 $WOK)
2642 else
2643 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2644 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2645 } | sort -u)"
2646 fi
2647 cooklist=$PACKAGES_REPOSITORY/cooklist
2648 gen_cook_list
2649 cook_list
2650 ;;
2651 gen-wok-db)
2652 check_root
2653 get_tazwok_config
2654 source_lib report
2655 report start
2656 gen_wok_db
2657 ;;
2658 report)
2659 check_root
2660 get_tazwok_config
2661 cd $PACKAGES_REPOSITORY
2662 for i in commit cooklist incoming broken blocked; do
2663 if [ -s $i ]; then
2664 echo -e "\n********************* $i *********************\n$(cat $i)\n*********************"
2665 fi
2666 done
2667 ;;
2668 check-incoming)
2669 check_root
2670 get_tazwok_config
2671 source_lib report
2672 report start
2673 check_for_incoming
2674 ;;
2675 configure-chroot)
2676 check_root
2677 get_tazwok_config
2678 if [ -f /usr/bin/tazchroot ]; then
2679 cd $LOCAL_REPOSITORY
2680 configure_tazchroot
2681 else
2682 echo "The packages tazchroot need to be installed" >&2
2683 exit 1
2684 fi
2685 ;;
2686 chroot)
2687 check_root
2688 get_tazwok_config
2689 # Merge this and the other chroot function ?.
2690 if [ -f /usr/bin/tazchroot ]; then
2691 cd $LOCAL_REPOSITORY
2692 [ ! -f tazchroot.conf ] && configure_tazchroot
2693 tazchroot
2694 else
2695 echo "The packages tazchroot need to be installed" >&2
2696 exit 1
2697 fi
2698 ;;
2699 cook-toolchain)
2700 check_root
2701 get_tazwok_config
2702 echo -n "" > $PACKAGES_REPOSITORY/broken
2703 if [ -f /usr/bin/tazchroot ]; then
2704 cd $LOCAL_REPOSITORY
2705 [ ! -f tazchroot.conf ] && configure_tazchroot
2706 tazchroot cook-toolchain
2707 # Buggy : chroot can be elsewhere.
2708 rm -r $LOCAL_REPOSITORY/chroot
2709 # /!\ to be writed :
2710 # next rm chroot and plan cook-all by pushing all packages
2711 # in cooklist.
2712 else
2713 echo "The packages tazchroot need to be installed" >&2
2714 exit 1
2715 fi
2716 ;;
2717 usage|*)
2718 # Print usage also for all unknown commands.
2720 usage
2721 ;;
2722 esac
2724 report stop 2>/dev/null || exit 0