tazwok view tazwok @ rev 215

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