tazwok view tazwok @ rev 195

Various code cleanup and improvement
author Antoine Bodin <gokhlayeh@slitaz.org>
date Tue Jan 25 02:29:37 2011 +0100 (2011-01-25)
parents 3736cce27b0a
children acb5f26a99ee 874d0f334cbd
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 dbtype=wok
106 dep_db=$INCOMING_REPOSITORY/wok-depends.txt
107 wan_db=$INCOMING_REPOSITORY/wok-wanted.txt
108 target_db=$INCOMING_REPOSITORY/wok-depends.txt
110 # Check commons directories, create them if user is root.
111 if test $(id -u) = 0 ; then
112 check_dir $WOK || chmod 777 $WOK
113 check_dir $PACKAGES_REPOSITORY
114 check_dir $SOURCES_REPOSITORY
115 check_dir $INCOMING_REPOSITORY
116 check_dir $LOCAL_REPOSITORY/log
117 fi
119 # Some files are needed by tazwok in PACKAGES_REPOSITORY. Create
120 # them if they are missing.
121 for file in broken blocked commit incoming genpkglist cooklist; do
122 [ ! -f $PACKAGES_REPOSITORY/$file ] && touch $PACKAGES_REPOSITORY/$file
123 done
125 # Limit memory usage.
126 ulimit -v $(awk '/MemTotal/ { print int(($2*80)/100) }' < /proc/meminfo)
127 }
129 # Used in several functions.
130 set_common_path()
131 {
132 # The receipt is used to compile the source code and
133 # generate suitable packages for Tazpkg.
134 RECEIPT="$WOK/$PACKAGE/receipt"
136 # The path to the process log file.
137 LOG="$WOK/$PACKAGE/process.log"
138 }
140 ########################################################################
141 # TAZWOK CHECK FUNCTIONS
142 ########################
144 # Check for a package name on cmdline.
145 check_for_package_on_cmdline()
146 {
147 if [ ! "$PACKAGE" ]; then
148 echo -e "\nYou must specify a package name on the command line." >&2
149 echo -e "Example : tazwok $COMMAND package\n" >&2
150 exit 1
151 fi
152 }
154 # Check for the receipt of a package used to cook.
155 check_for_receipt()
156 {
157 if [ ! -f "$RECEIPT" ]; then
158 echo -e "\nUnable to find the receipt : $RECEIPT\n" >&2
159 exit 1
160 fi
161 }
163 # Check for a specified file list on cmdline.
164 check_for_list()
165 {
166 if [ ! "$LIST" ]; then
167 echo -e "\nPlease specify the path to the list of packages to cook.\n" >&2
168 exit 1
169 fi
171 # Check if the list of packages exists.
172 if [ -f "$LIST" ]; then
173 LIST=`cat $LIST`
174 else
175 echo -e "\nUnable to find $LIST packages list.\n" >&2
176 exit 1
177 fi
179 if [ ! "$LIST" ]; then
180 echo -e "\nList is empty.\n" >&2
181 exit 1
182 fi
183 }
186 ########################################################################
187 # TAZWOK CORE FUNCTIONS
188 ########################
190 remove_src()
191 {
192 look_for_cookopt !remove_src && return
193 if [ ! -d $WOK/$PACKAGE/install ] && [ "$_pkg" ] && [ -d "$_pkg" ]; then
194 check_for_var_modification _pkg src || return
195 mv "$_pkg" $WOK/$PACKAGE/install
196 fi
198 # Don't remove sources if a package use src variable in his
199 # genpkg_rules: it maybe need something inside.
200 for i in $PACKAGE $(look_for_rwanted); do
201 sed -n '/^genpkg_rules\(\)/','/}/'p $WOK/$i/receipt | \
202 fgrep -q '$src' && tazwok_warning "Sources will not be removed \
203 because $i use \$src in his receipt." && return
204 done
206 report step "Removing sources directory"
207 rm -fr "$src"
208 report end-step
209 }
211 # Check $COOK_OPT; usage : get_cookopt particular_opt
212 # Return error if not founded
213 # Return args if the opt is in the format opt=arg1:arg2:etc
214 look_for_cookopt()
215 {
216 for arg in $COOK_OPT; do
217 case $arg in
218 $1=*)
219 arg=${arg#$1=}
220 while [ "$arg" ]; do
221 echo "${arg%%:*}"
222 [ "${arg/:}" = "$arg" ] && return
223 arg=${arg#*:}
224 done
225 ;;
226 $1)
227 return
228 ;;
229 esac
230 done
231 return 1
232 }
234 # Check for the wanted package if specified in WANTED
235 # receipt variable. Set the $src/$_pkg variable to help compile
236 # and generate packages.
237 check_for_wanted()
238 {
239 if [ "$WANTED" ]; then
240 report "Checking for the wanted package"
241 if [ ! -d "$WOK/$WANTED" ]; then
242 report exit "\nWanted package is missing in the work directory.\n"
243 fi
245 # Checking for buildtree of Wanted package
246 if [ ! -d "$WOK/$WANTED/taz" ]; then
247 echo -e "\n\nSource files of wanted package is missing in the work directory."
248 echo -n "Would you like to build the missing package (y/N) ? " ; read anser
249 if [ "$anser" == "y" ]; then
250 tazwok cook $WANTED
251 else
252 report exit "\nWanted package source tree is missing in the work directory.\n"
253 fi
254 fi
255 report end-step
257 # Set wanted src path.
258 set_src_path && set_pkg_path
260 fi
261 }
264 # Check for build dependencies, notify user and install if specified.
265 check_for_build_depends()
266 {
267 report step "Looking for build dependencies"
269 # Keep the list of previously installed build_depends then compare
270 # it with new build_depends to know what to install and what to
271 # what to remove.
272 plan_remove=" $MISSING_PACKAGE $remove_later "
273 [ ! "${plan_remove// }" ] && unset plan_remove
274 unset MISSING_PACKAGE remove_later
275 rwanted=$(look_for_rwanted)
277 for pkg in $(scan $PACKAGE --look_for=bdep --with_dev | \
278 fgrep -v -e "Don't make the command fail" $(for i in $(look_for_rwanted); do echo " -e $i"; done))
279 do
281 # Delay the removing of previous cook depends if they are needed
282 # for next cook too.
283 if [ ! -d "$INSTALLED/$pkg" ] ; then
284 MISSING_PACKAGE="$MISSING_PACKAGE $pkg"
285 fi
286 if [ "$plan_remove" != "${plan_remove/ $pkg }" ]; then
287 plan_remove="${plan_remove/ $pkg / }"
288 remove_later="$remove_later $pkg"
289 fi
290 if grep -q ^$pkg$ $PACKAGES_REPOSITORY/broken; then
291 broken="$broken$pkg "
292 fi
293 done
295 # Don't cook if a depend is broken.
296 if [ "$broken" ]; then
297 MISSING_PACKAGE=$plan_remove
298 echo "Can't cook $PACKAGE because broken depend(s) : $broken" >&2
299 unset plan_remove broken
301 # Set report step to failed.
302 report_return_code=1
303 report end-step
304 return 1
305 fi
306 if [ "$MISSING_PACKAGE" ]; then
307 install_missing()
308 {
309 echo "Installing missing packages : $MISSING_PACKAGE"
310 for pkg in $MISSING_PACKAGE; do
311 [ -d "$INSTALLED/$pkg" ] || tazpkg get-install $pkg
312 done
313 }
314 if [ "$auto_install" = yes ]; then
315 install_missing
316 else
317 echo "================================================================================"
318 for pkg in $MISSING_PACKAGE
319 do
320 echo "Missing : $pkg"
321 done
322 echo "================================================================================"
323 echo "You can continue, exit or install missing dependencies."
324 echo -n "Install, continue or exit (install/y/N) ? "; read answer
325 case $answer in
326 install)
327 install_missing ;;
328 y|yes)
329 unset MISSING_PACKAGE;;
330 *)
331 report stop
332 exit 0 ;;
333 esac
334 fi
335 fi
336 report end-step
337 remove_build_depends $plan_remove
338 unset plan_remove
339 }
341 remove_build_depends()
342 {
343 [ "$1" ] || return
344 report step "Removing previous build dependencies"
345 echo "Removing theses packages : $@"
346 for pkg in $@; do
347 [ -d "$INSTALLED/$pkg" ] && echo y | tazpkg remove $pkg
348 done
349 report end-step
350 }
352 # Check if we can use the new way to handle tarball
353 # or if we keep the previous method by check for
354 # _pkg=/src= in receipt and reverse-wanted.
355 check_for_var_modification()
356 {
357 for var in $@; do
358 for pkg in $PACKAGE $(look_for_wanted) $(look_for_rwanted); do
359 [ -f $WOK/$pkg/receipt ] || continue
360 fgrep -q "$var=" $WOK/$pkg/receipt && return 1
361 done
362 done
364 # Tweak to make if; then...; fi function working with this one.
365 echo -n ""
366 }
368 set_src_path()
369 {
370 if check_for_var_modification src _pkg; then
371 src=$WOK/${WANTED:-$PACKAGE}/${WANTED:-$PACKAGE}-$VERSION
372 else
373 src=$WOK/${WANTED:-$PACKAGE}/${SOURCE:-${WANTED:-$PACKAGE}}-$VERSION
374 fi
375 }
377 set_pkg_path()
378 {
379 if [ -d $WOK/${WANTED:-$PACKAGE}/install ] ; then
380 _pkg=$WOK/${WANTED:-$PACKAGE}/install
381 else
382 _pkg=$src/_pkg
383 fi
385 }
387 # Output $VERSION-$EXTRAVERSION using packages.txt
388 get_pkg_version()
389 {
390 [ "$PACKAGE" ] || return
391 grep -A1 -sh ^$PACKAGE$ $1/packages.txt | tail -1 | sed 's/ *//'
392 }
395 remove_previous_tarball()
396 {
397 [ "$prev_VERSION" ] || return
398 if [ "$VERSION" != "$prev_VERSION" ]; then
399 rm -f $SOURCES_REPOSITORY/$PACKAGE-$prev_VERSION.tar.lzma
400 fi
401 }
403 remove_previous_package()
404 {
405 [ "$prev_VERSION" ] || return
406 if [ "$VERSION$EXTRAVERSION" != "$prev_VERSION" ]; then
407 rm -f $1/$PACKAGE-$prev_VERSION.tazpkg
408 fi
409 }
411 # Check for src tarball and wget if needed.
412 check_for_tarball()
413 {
414 if [ "$WGET_URL" ]; then
415 report step "Checking for source tarball"
417 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
418 [ ! -f "$SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma" ] ; then
419 cd $SOURCES_REPOSITORY
420 download $WGET_URL
422 # If source tarball is unreachable, try to find it on SliTaz
423 # mirror.
424 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
425 report step "Download failed, try with mirror copy... "
426 download http://mirror.slitaz.org/sources/packages/${PACKAGE:0:1}/$PACKAGE-$VERSION.tar.lzma
427 fi
428 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
429 [ ! -f "$SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma" ]; then
430 report step "Download failed, try with mirror copy (again)... "
431 file=$(basename $WGET_URL)
432 download http://mirror.slitaz.org/sources/packages/${file:0:1}/$file
433 fi
435 # Exit if download failed to avoid errors.
436 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
437 echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n" >&2
438 report end-step
439 return 1
440 fi
442 fi
443 report end-step
445 # Untaring source if necessary. We don't need to extract source if
446 # the package is built with a wanted source package.
447 if [ ! "$WANTED" ]; then
448 report step "Untaring source tarball"
449 if [ "$target" ]; then
450 src="$target"
451 else
452 set_src_path
453 fi
454 if [ ! -d "$src" ]; then
456 # Log process.
457 echo "untaring source tarball" >> $LOG
459 tmp_src=$WOK/$PACKAGE/tmp-src-$$
460 mkdir $tmp_src
461 if [ -f "$SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma" ]; then
462 lzma d $SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma -so | \
463 tar xf - -C $tmp_src
464 else
465 case "$TARBALL" in
466 *zip|*xpi) { cd $tmp_src; unzip -o $SOURCES_REPOSITORY/$TARBALL; };;
467 *bz2) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
468 *tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
469 *lzma) unlzma -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
470 *xz) unxz -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
471 *Z) uncompress -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
472 *) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
473 esac || return 1
475 # Check if uncompressed tarbal is in a root dir or not.
476 if [ "$(ls -A $tmp_src | wc -l)" -gt 1 ]; then
477 if check_for_var_modification src _pkg; then
478 mv $tmp_src $tmp_src-1
479 mkdir $tmp_src
480 mv $tmp_src-1 $tmp_src/$PACKAGE-$VERSION
481 else
482 mv $tmp_src/* $WOK/$PACKAGE
483 repack_src=no
484 rm -r $tmp_src
485 fi
486 fi
488 if [ "$repack_src" = yes ]; then
489 report step "Repacking sources in .tar.lzma format"
490 cd $tmp_src
491 tar -c * | lzma e $SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma -si
492 rm $SOURCES_REPOSITORY/$TARBALL
493 prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
495 # Remove previous tarball if it's not used either by
496 # incoming and legacy packages.
497 [ "$prev_VERSION" != "$(get_pkg_version $PACKAGES_REPOSITORY)" ] && \
498 remove_previous_tarball
500 fi
501 fi
502 if [ -d "$tmp_src" ]; then
503 if ! check_for_var_modification src _pkg; then
504 src="${src%/*}/$(ls $tmp_src)"
505 fi
506 mv $(echo $tmp_src/*) "$src"
507 rm -r $tmp_src
509 # Permissions settings.
510 chown -R root.root "$src"
511 fi
512 else
513 echo "There's already something at $src. Abord." >&2
514 fi
515 report end-step
516 fi
517 fi
518 }
520 # Log and execute compile_rules function if it exists, to configure and
521 # make the package if it exists.
522 check_for_compile_rules()
523 {
524 if grep -q ^compile_rules $RECEIPT; then
525 echo "executing compile_rules" >> $LOG
526 report step "Executing compile_rules"
527 cd $WOK/$PACKAGE
528 rm -f /tmp/config.site
530 # Free some RAM by cleaning cache if option is enabled.
531 freeram=$(free | fgrep '-/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
533 # Disable -pipe in CFLAGS/CXXFLAGS if less than 512Mb of free
534 # RAM are available.
535 if [ "$freeram" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" -o \
536 "$CXXFLAGS" != "${CXXFLAGS/-pipe}" ]; then
537 tazwok_warning "Disabling -pipe compile flag because only ${freeram}b of RAM are available."
538 CFLAGS="${CFLAGS/-pipe}"
539 CXXFLAGS="${CXXFLAGS/-pipe}"
540 fi
541 unset freeram
543 # Set cook environnement variables.
544 [ "$src" ] || set_src_path
545 [ "$DESTDIR" ] || DESTDIR="$WOK/$PACKAGE/install"
546 [ "$CONFIG_SITE" ] || CONFIG_SITE=/etc/config.site
547 export CFLAGS CXXFLAGS MAKEFLAGS DESTDIR BUILD_HOST \
548 CONFIG_SITE default_prefix \
549 default_datarootdir default_datadir default_localedir \
550 default_infodir default_mandir default_build default_host
551 local LC_ALL=POSIX LANG=POSIX
552 compile_rules
554 # Check if config.site has been used.
555 # /!\ disabled since it screw the return_code of the step.
556 #if [ -f /tmp/config.site ]; then
557 # rm /tmp/config.site
558 #else
559 # tazwok_warning "config.site hasn't been used during \
560 #configuration process."
561 #fi
563 report end-step
564 fi
565 }
567 # Check for loop in deps tree. /!\ can be removed
568 check_for_deps_loop()
569 {
570 local list
571 local pkg
572 local deps
573 pkg=$1
574 shift
575 [ -n "$1" ] || return
576 list=""
578 # Filter out already processed deps
579 for i in $@; do
580 case " $ALL_DEPS" in
581 *\ $i\ *);;
582 *) list="$list $i";;
583 esac
584 done
585 ALL_DEPS="$ALL_DEPS$list "
586 for i in $list; do
587 [ -f $i/receipt ] || continue
588 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
589 case " $deps " in
590 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
591 *) check_for_deps_loop $pkg $deps;;
592 esac
593 done
594 }
596 download()
597 {
598 for file in $@; do
599 wget -q $file && break
600 done
601 }
603 # Regenerate every package that wants a PACKAGE compiled
604 # /!\
606 refresh_packages_from_compile()
607 {
608 # make tazwok genpkg happy
609 mkdir $WOK/$PACKAGE/taz
611 # Cook rwanted in default or specied order
612 genlist=" $(look_for_rwanted | tr '\n' ' ') "
613 for i in $(look_for_cookopt genpkg | tac); do
614 [ "${genlist/ $i }" = "$genlist" ] && continue
615 genlist=" $i${genlist/ $i / }"
616 done
617 for i in $genlist; do
618 tazwok genpkg $i --SLITAZ_VERSION=$SLITAZ_VERSION \
619 --undigest=$undigest --SLITAZ_DIR=$SLITAZ_DIR
620 done
622 # Still needs tazwok genpkg for this package
623 rm -rf $WOK/$PACKAGE/taz
624 }
626 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
627 # so some packages need to copy these files with the receipt and genpkg_rules.
628 # This function is executed by gen_package when 'tazwok genpkg'.
629 copy_generic_files()
630 {
631 # In most cases, locales are in $_pkg/usr/share/locale so we copy files
632 # using generic variables and $LOCALE from Tazwok config file.
633 if [ "$LOCALE" ]; then
634 if [ -d "$_pkg/usr/share/locale" ]; then
635 for i in $LOCALE
636 do
637 if [ -d "$_pkg/usr/share/locale/$i" ]; then
638 mkdir -p $fs/usr/share/locale
639 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
640 fi
641 done
642 fi
643 fi
645 # Pixmaps (PNG or/and XPM only). Some icons/images can be added through
646 # genpkg_rules and generic copy can be disabled with GENERIC_PIXMAPS="no"
647 # in pkg receipt.
648 if [ "$GENERIC_PIXMAPS" != "no" ]; then
649 if [ -d "$_pkg/usr/share/pixmaps" ]; then
650 mkdir -p $fs/usr/share/pixmaps
651 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
652 $fs/usr/share/pixmaps 2>/dev/null
653 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
654 $fs/usr/share/pixmaps 2>/dev/null
655 fi
657 # Custom or homemade PNG pixmap can be in stuff.
658 if [ -f "stuff/$PACKAGE.png" ]; then
659 mkdir -p $fs/usr/share/pixmaps
660 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
661 fi
662 fi
664 # Desktop entry (.desktop).
665 if [ -d "$_pkg/usr/share/applications" ]; then
666 cp -a $_pkg/usr/share/applications $fs/usr/share
667 fi
669 # Homemade desktop file(s) can be in stuff.
670 if [ -d "stuff/applications" ]; then
671 mkdir -p $fs/usr/share
672 cp -a stuff/applications $fs/usr/share
673 fi
674 if [ -f "stuff/$PACKAGE.desktop" ]; then
675 mkdir -p $fs/usr/share/applications
676 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
677 fi
678 }
680 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
681 strip_package()
682 {
683 look_for_cookopt !strip && return
684 report step "Executing strip on all files"
686 # Binaries.
687 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
688 do
689 if [ -d "$dir" ]; then
690 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
691 fi
692 done
694 # Libraries.
695 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
696 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
697 report end-step
698 }
700 # Remove .pyc and .pyo files from packages
701 py_compiled_files_remove()
702 {
703 report step "Removing all .pyc and .pyo files from package ..."
704 find $fs -type f -name "*.pyc" -delete 2>/dev/null
705 find $fs -type f -name "*.pyo" -delete 2>/dev/null
706 report end-step
707 }
709 # Check FSH in a slitaz package (Path: /:/usr)
710 check_fsh()
711 {
712 cd $WOK/$PACKAGE/taz/*/fs
713 [ -n "$FSH" ] || FSH="bin boot dev etc home init lib media mnt proc \
714 root sbin share sys tmp usr var vz usr/bin usr/games usr/include usr/lib \
715 usr/local usr/sbin usr/share usr/src"
716 for i in `ls -d * usr/* 2>/dev/null`
717 do
718 if ! echo $FSH | fgrep -q $i; then
719 echo "Wrong path: /$i" >&2
720 error=1
721 fi
722 done
723 if [ "$error" = "1" ]; then
724 cat << _EOT_
726 Package will install files in a non standard directory and won't be generated.
727 You may have a wrong copy path in genpkg_rules or need to add some options to
728 configure in compile_rules. Some valid options for SliTaz (Linux FSH):
730 --prefix=/usr
731 --sysconfdir=/etc
732 --libexecdir=/usr/lib/(pkgname)
733 --localstatedir=/var
734 --mandir=/usr/share/man
735 --infodir=/usr/share/info
737 For more information please read SliTaz docs and run: ./configure --help
738 ================================================================================
739 $PACKAGE package generation aborted.
741 _EOT_
743 # Dont generate a corrupted package.
744 cd $WOK/$PACKAGE && rm -rf taz
745 report exit
746 fi
747 }
749 gen_cookmd5()
750 {
751 # md5sum of cooking stuff make tazwok able to check for changes
752 # without hg.
753 cd $WOK/$PACKAGE
754 md5sum receipt > md5
755 [ -f description.txt ] && md5sum description.txt >> md5
756 if [ -d stuff ]; then
757 find stuff | while read file; do
758 md5sum $file >> md5
759 done
760 fi
761 }
763 # Create a package tree and build the gziped cpio archive
764 # to make a SliTaz (.tazpkg) package.
765 gen_package()
766 {
767 check_root
768 check_for_package_on_cmdline
769 check_for_receipt
770 EXTRAVERSION=""
771 . $RECEIPT
773 # May compute VERSION
774 if grep -q ^get_version $RECEIPT; then
775 get_version
776 fi
777 check_for_wanted
778 cd $WOK/$PACKAGE
780 # Remove old Tazwok package files.
781 [ -d "taz" ] && rm -rf taz
783 # Create the package tree and set useful variables.
784 mkdir -p taz/$PACKAGE-$VERSION/fs
785 fs=taz/$PACKAGE-$VERSION/fs
787 # Set $src for standard package and $_pkg variables.
788 set_src_path && set_pkg_path
790 # Execute genpkg_rules, check package and copy generic files to build
791 # the package.
792 report step "Building $PACKAGE with the receipt"
793 report open-bloc
794 if grep -q ^genpkg_rules $RECEIPT; then
796 # Log process.
797 echo "executing genpkg_rules" >> $LOG
798 report step "Executing genpkg_rules"
799 genpkg_rules
800 report end-step
801 check_fsh
802 cd $WOK/$PACKAGE
804 # Skip generic files for packages with a WANTED variable
805 # (dev and splited pkgs).
806 if [ ! "$WANTED" ]; then
807 copy_generic_files
808 fi
809 strip_package
810 py_compiled_files_remove
811 else
812 echo "No package rules to gen $PACKAGE..." >&2
813 report exit
814 fi
816 # Copy the receipt and description (if exists) into the binary package tree.
817 cd $WOK/$PACKAGE
818 report step "Copying the receipt"
819 cp receipt taz/$PACKAGE-$VERSION
820 report end-step
821 if grep -q ^get_version $RECEIPT; then
822 report step "Updating version in receipt"
823 sed -i "s/^VERSION=.*/VERSION=\"$VERSION\"/" \
824 taz/$PACKAGE-$VERSION/receipt
825 report end-step
826 fi
827 if [ -f "description.txt" ]; then
828 report step "Copying the description file"
829 cp description.txt taz/$PACKAGE-$VERSION
830 report end-step
831 fi
833 # Generate md5 of cooking stuff to look for commit later.
834 gen_cookmd5
835 echo -e "\n# md5sum of cooking stuff :" >> taz/$PACKAGE-$VERSION/receipt
836 cat md5 | sed 's/^/# /' >> taz/$PACKAGE-$VERSION/receipt
838 # Create the files.list by redirecting find output.
839 report step "Creating the list of files"
840 cd taz/$PACKAGE-$VERSION
841 LAST_FILE=""
842 { find fs -print; echo; } | while read file; do
843 if [ "$LAST_FILE" ]; then
844 case "$file" in
845 $LAST_FILE/*)
846 case "$(ls -ld "$LAST_FILE")" in
847 drwxr-xr-x\ *\ root\ *\ root\ *);;
848 *) echo ${LAST_FILE#fs};;
849 esac;;
850 *) echo ${LAST_FILE#fs};;
851 esac
852 fi
853 LAST_FILE="$file"
854 done > files.list
856 # Next, check if something has changed in lib files.
857 if [ ! "$cook_rdep" ]; then
858 report step "Look for changes in libraries"
860 # Find the most recent previous files.list.
861 # /!\ need some work to check only for minor update (not micro)
862 if grep -q ^$PACKAGE$ $INCOMING_REPOSITORY/packages.txt 2>/dev/null; then
863 files_list_dir=$PACKAGES_INCOMING
864 elif grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/packages.txt 2>/dev/null; then
865 files_list_dir=$PACKAGES_REPOSITORY
866 elif [ "$undigest" ] && grep -q ^$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/packages.txt 2>/dev/null; then
867 files_list_dir=$SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming
868 elif [ "$undigest" ] && grep -q ^$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages/packages.txt 2>/dev/null; then
869 files_list_dir=$SLITAZ_DIR/$SLITAZ_VERSION/packages
870 fi
872 # If founded, generate libs.list (new and previous)
873 if [ "$files_list_dir" ] && [ -f $files_list_dir/files.list.lzma ]; then
874 grep -e '\.so$' -e '\.so.[0-9]' files.list >> $tmp/libs.list.new
875 if [ -f $tmp/libs.list.new ]; then
876 lzma d $files_list_dir/files.list.lzma $tmp/files.list 2>/dev/null
877 grep ^$PACKAGE: $tmp/files.list >> $tmp/libs.list.previous
879 # If something as changed in libs path/names, plan recook of all
880 # reverse build depends.
881 [ "$(diff -q $tmp/libs.list.old $tmp/libs.list.previous 2>/dev/null)" ] && cook_rdep=yes
882 rm $tmp/libs.list.new $tmp/files.list $tmp/libs.list.old 2>/dev/null
883 unset files_list_dir
884 fi
885 fi
886 report end-step
887 fi
888 if [ ! "$EXTRAVERSION" ]; then
889 case "$PACKAGE" in
890 linux*);;
891 *) EXTRAVERSION="$(grep '/lib/modules/.*-slitaz/' files.list |\
892 head -1 | sed 's|/lib/modules/\(.*\)-slitaz/.*|_\1|')";;
893 esac
894 fi
895 rm -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
896 report step "Creating md5sum of files"
897 while read file; do
898 [ -L "fs$file" ] && continue
899 [ -f "fs$file" ] || continue
900 md5sum "fs$file" | sed 's/ fs/ /'
901 done < files.list > md5sum
902 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
903 2> /dev/null | awk '{ sz=$1 } END { print sz }')
905 # Build cpio archives. Find, cpio and gzip the fs, finish by
906 # removing the fs tree.
907 # Don't log this because compression always output error messages.
908 report end-step
909 find fs -print | cpio -o -H newc | case "$PACKAGE-$COMPRESSION" in
910 tazpkg-lzma) gzip > fs.cpio.gz;;
911 *-lzma) lzma e fs.cpio.lzma -si;;
912 *) gzip > fs.cpio.gz;;
913 esac && rm -rf fs
914 PACKED_SIZE=$(du -chs fs.cpio.* receipt files.list md5sum \
915 description.txt 2> /dev/null | awk '{ sz=$1 } END { print sz }')
916 report step "Updating receipt sizes"
917 sed -i '/^PACKED_SIZE/d' receipt
918 sed -i '/^UNPACKED_SIZE/d' receipt
919 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
920 sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
921 if [ -n "$EXTRAVERSION" ]; then
922 report step "Updating receipt EXTRAVERSION"
923 sed -i s/^EXTRAVERSION.*$// receipt
924 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
925 fi
926 prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
927 remove_previous_package $INCOMING_REPOSITORY
928 report step "Creating full cpio archive"
929 find . -print | cpio -o -H newc > $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
931 # Restore package tree in case we want to browse it.
932 report step "Restoring original package tree"
933 { zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma; } | cpio --quiet -id
934 rm fs.cpio.* && cd ..
936 # Log process.
937 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
938 report close-bloc
939 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
940 echo "Size : `du -sh $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
941 echo ""
943 # Remove package from broken & genpkg list if needed.
944 if grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then
945 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/broken
946 regen_cooklist=yes
947 fi
949 # Remove package from genpkglist.
950 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/genpkglist
951 }
953 ########################################################################
954 ######################## START OF NEW FUNCTIONS ########################
955 ########################################################################
957 ########################################################################
958 # This section contains functions used by several other functions
959 # bellow.
960 ########################
962 # Look for receipt/files.list in wok. If they can't be found, get them
963 # from package. Accept one argument : absolute path to package.
964 get_pkg_files()
965 {
966 pkg_files_dir=$tmp/$(basename ${1%.tazpkg})
967 mkdir -p $pkg_files_dir && \
968 cd $pkg_files_dir && \
969 cpio --quiet -idm receipt < $1 && \
970 cpio --quiet -idm files.list < $1
971 }
973 ########################################################################
974 # This section contains functions to generate packages/wok databases.
975 ########################
977 # Generic actions in both gen-packages-db/gen-wok-db
978 gen_db()
979 {
980 report step "Generating $dbtype database"
981 report open-bloc
982 report step "Removing old files"
983 for file in $files_list; do
984 [ -f $file ] && rm $file
985 [ "${file##*.}" != lzma ] && touch $file
986 done
988 # Generate wok/packages data lists.
989 gen_${dbtype}_db
990 report close-bloc
991 }
993 gen_packages_db()
994 {
995 # pkg_repository can be $PACKAGES_REPOSITORY or $INCOMING_REPOSITORY.
996 [ ! "$pkg_repository" ] && pkg_repository=$PACKAGES_REPOSITORY
997 cd $pkg_repository
998 packages_db_start
999 unset RECEIPT
1000 report step "Reading datas from all packages"
1001 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1002 get_packages_info
1003 done
1004 report end-step
1005 packages_db_end
1008 update_packages_db()
1010 [ ! "$pkg_repository" ] && pkg_repository=$PACKAGES_REPOSITORY
1011 cd $pkg_repository
1013 # If files are missing, generate the lists - not only update.
1014 dbtype=packages
1015 files_list="packages.list packages.equiv packages.md5 packages.desc packages.txt"
1016 for file in $files_list; do
1017 if [ ! -f "$file" ]; then
1018 gen_db
1019 return
1020 fi
1021 done
1022 if [ -f files.list.lzma ]; then
1023 lzma d files.list.lzma files.list
1024 else
1025 gen_db
1026 fi
1027 packages_db_start
1028 report step "Updating packages lists"
1029 touch $tmp/pkglist
1031 # Look for removed/update packages.
1032 for PACKAGE in $(grep ^[0-9,a-z,A-Z] packages.txt); do
1033 pkg="$(grep ^$PACKAGE- packages.list | sed 1!d).tazpkg"
1034 if ! [ -f "$pkg" ]; then
1035 erase_package_info
1036 else
1037 echo $pkg >> $tmp/pkglist
1038 if [ "$pkg" -nt "packages.list" ]; then
1039 erase_package_info
1040 get_packages_info
1041 fi
1042 fi
1043 done
1045 # Look for new packages.
1046 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1047 if ! fgrep " ${pkg##*/}" $pkg_repository/packages.md5; then
1048 get_packages_info
1049 fi
1050 done
1051 rm $tmp/pkglist
1052 report end-step
1053 packages_db_end
1056 packages_db_start()
1058 if [ ! -s packages.txt ]; then
1059 echo "# SliTaz GNU/Linux - Packages list
1061 # Packages : unknow
1062 # Date : $(date +%Y-%m-%d\ \%H:%M:%S)
1063 #" > packages.txt
1064 else
1065 sed -e 's/^# Packages :.*/# Packages : unknow/' \
1066 -e "s/# Date :.*/# Date : $(date +%Y-%m-%d\ \%H:%M:%S)/" \
1067 -i packages.txt
1068 fi
1070 # Needed in some case as tazwok define RECEIPT at configuration time
1071 # in this particular case it can broke the script.
1072 unset RECEIPT
1075 erase_package_info()
1077 cd $pkg_repository
1078 sed "/^$PACKAGE$/,/^$/d" -i packages.txt
1079 sed "/^$PACKAGE /d" -i packages.desc
1080 sed -e "s/=$PACKAGE /= /" -e "s/ $PACKAGE / /" -e "s/ $PACKAGE$//" \
1081 -e "/=$PACKAGE$/d" -e "s/=[0-9,a-z,A-Z]:$PACKAGE /= /" \
1082 -e "s/ [0-9,a-z,A-Z]:$PACKAGE / /" -e "s/ [0-9,a-z,A-Z]:$PACKAGE$/ /" \
1083 -e "/=[0-9,a-z,A-Z]:$PACKAGE$/d" \
1084 -i packages.equiv
1085 sed "/^$PACKAGE:/d" -i files.list
1086 sed "/^$(basename ${pkg%.tazpkg})$/d" -i packages.list
1087 sed "/ $(basename $pkg)$/d" -i packages.md5
1090 get_packages_info()
1092 # If there's no taz folder in the wok, extract infos from the
1093 # package.
1094 get_pkg_files $pkg
1095 source_receipt
1096 echo "Getting datas from $PACKAGE"
1098 cat >> $pkg_repository/packages.txt << _EOT_
1100 $PACKAGE
1101 $VERSION$EXTRAVERSION
1102 $SHORT_DESC
1103 _EOT_
1104 [ "$PACKED_SIZE" ] && cat >> $pkg_repository/packages.txt << _EOT_
1105 $PACKED_SIZE ($UNPACKED_SIZE installed)
1106 _EOT_
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 files.list 2>/dev/null
1166 ########################################################################
1167 # This section contains functions to generate wok database.
1168 ########################
1170 gen_wok_db()
1172 get_wok_info $(echo $WOK/*/receipt | sed -e "s~$WOK/~~g" -e "s~/receipt~~g")
1173 sort_db
1174 report close-bloc
1177 get_wok_info()
1179 report step "Getting datas from wok"
1180 report open-bloc
1182 report step "Generating wok-wanted.txt"
1183 for PACKAGE in $@; do
1184 RECEIPT=$WOK/$PACKAGE/receipt
1185 source_receipt
1186 [ "$WANTED" ] || continue
1187 echo -e $PACKAGE"\t"$WANTED >> $wan_db
1188 done
1190 report step "Generating wok-depends.txt"
1191 for PACKAGE in $@; do
1192 RECEIPT=$WOK/$PACKAGE/receipt
1193 if [ -s $RECEIPT ]; then
1194 source_receipt
1195 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
1196 fi
1197 done
1198 report end-step
1201 sort_db()
1203 report step "Generating cookorder.txt"
1204 rm $PACKAGES_REPOSITORY/blocked && touch $PACKAGES_REPOSITORY/blocked
1205 cat $dep_db | sed 's/ \t / /' | while read PACKAGE BUILD_DEPENDS; do
1206 grep -q ^$PACKAGE$'\t' $wan_db && continue
1208 # Replace each BUILD_DEPENDS with a WANTED package by it's
1209 # WANTED package.
1210 replace_by_wanted()
1212 for p in $BUILD_DEPENDS; do
1213 if grep -q ^$p$'\t' $wan_db; then
1214 echo -n $(grep ^$p$'\t' $wan_db | cut -f 2)' '
1215 else
1216 echo -n $p' '
1217 fi
1218 done | tr ' ' '\n' | sort -u | sed "/^$PACKAGE$/d" | tr '\n' ' '
1220 echo -e $PACKAGE"\t $(replace_by_wanted) "
1221 done > $tmp/db
1222 while [ -s "$tmp/db" ]; do
1223 status=start
1224 for pkg in $(cut -f 1 $tmp/db); do
1225 if ! fgrep -q ' '$pkg' ' $tmp/db; then
1226 echo $pkg >> $tmp/cookorder
1227 sed -e "/^$pkg\t/d" -e "s/ $pkg / /g" -i $tmp/db
1228 status=proceed
1229 fi
1230 done
1231 if [ "$status" = start ]; then
1232 cp -f $tmp/db /tmp/remain-depends.txt
1233 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
1234 for blocked in $(cut -f 1 $tmp/db); do
1235 echo "$blocked" >> $PACKAGES_REPOSITORY/blocked
1236 done
1237 break
1238 fi
1239 done
1240 [ -s $tmp/cookorder ] || touch $tmp/cookorder
1242 # The toolchain packages are moved in first position.
1243 grep $(for pkg in `scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1244 --look_for=all --with_args`; do echo " -e ^$pkg$"; done) \
1245 $tmp/cookorder | tac > $PACKAGES_REPOSITORY/cookorder.txt
1246 for pkg in $(cat $PACKAGES_REPOSITORY/cookorder.txt); do
1247 sed "/^$pkg$/d" -i $tmp/cookorder
1248 done
1250 tac $tmp/cookorder >> $PACKAGES_REPOSITORY/cookorder.txt
1251 report end-step
1254 ########################################################################
1255 # SCAN CORE
1256 ########################
1257 # Include various scan core-functions. It's not intended to be used
1258 # directly : prefer scan wrappers in next section.
1260 look_for_dep()
1262 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1263 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
1264 | cut -f 2
1265 else
1266 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1267 cut -f 2
1268 fi
1271 look_for_bdep()
1273 # if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1274 # grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
1275 # | cut -f 3
1276 # else
1277 # grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1278 # cut -f 3
1279 # fi
1280 look_for_all
1283 look_for_all()
1285 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1286 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
1287 | cut -f 2,3 | sed 's/ / /'
1288 else
1289 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1290 cut -f 2,3 | sed 's/ / /'
1291 fi
1294 filter()
1296 for pkg in $(cat); do
1297 if grep -q ^$pkg$'\t' $dep_db; then
1298 { grep ^$pkg$'\t' $wan_db || echo $pkg
1299 } | sed 's/\t/ /'
1300 else
1301 echo "Error: $pkg can't be found." >&2
1302 fi
1303 done
1306 look_for_all_filtered()
1308 look_for_all | filter
1311 look_for_rdep()
1313 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | cut -f 1
1314 if [ "$undigest" ]; then
1315 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt | cut -f 1); do
1316 if [ ! -f "WOK$/$rdep/receipt" ]; then
1317 echo "$rdep"
1318 fi
1319 done
1320 fi
1323 look_for_rbdep()
1325 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | \
1326 cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
1327 if [ "$undigest" ]; then
1328 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
1329 | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1); do
1330 if [ ! -f "WOK$/$rdep/receipt" ]; then
1331 echo "$rdep"
1332 fi
1333 done
1334 fi
1337 # Return WANTED if it exists.
1338 look_for_wanted()
1340 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1341 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-wanted.txt | cut -f 2
1342 else
1343 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 2
1344 fi
1347 # Return packages which wants PACKAGE.
1348 look_for_rwanted()
1350 grep $'\t'$PACKAGE$ $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 1
1351 if [ "$undigest" ]; then
1352 for rwanted in $(grep $'\t'$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-wanted.txt | cut -f 1); do
1353 if [ ! -f "$WOK/$rwanted/receipt" ]; then
1354 echo "$rwanted"
1355 fi
1356 done
1357 fi
1360 look_for_dev()
1362 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev && return
1363 [ "$undigest" ] && [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$PACKAGE-dev/receipt" ] && \
1364 echo $PACKAGE-dev
1367 ########################################################################
1368 # SCAN
1369 ########################
1370 # Use wok-wanted.txt and wok-depeds.txt to scan depends.
1371 # Option in command line (must be first arg) :
1372 # --look_for=bdep/rbdep - Look for depends or reverse depends.
1373 # --with_dev - Add development packages (*-dev) in the result.
1374 # --with_wanted - Add package+reverse wanted in the result.
1375 # --with_args - Include packages in argument in the result.
1377 scan()
1379 # With some commands we don't want report (list output).
1380 if [ "$COMMAND" = gen-cooklist ] || [ "$COMMAND" = build-depends ]; then
1381 report(){ : ; }
1382 fi
1384 # Generate wok data files if they're missing. Output message in
1385 # stderr as stdout output may be used as packages list.
1386 if [ ! -s "$wan_db" ] || [ ! -s "$dep_db" ]; then
1387 echo "Missing wok data files, generating them... This may take few minutes." >&2
1388 gen_wok_db
1389 fi
1391 # Get packages in argument.
1392 local PACKAGE pkg_list=
1393 for arg in $@; do
1394 [ "$arg" = "${arg#--}" ] || continue
1395 pkg_list="$pkg_list $arg"
1396 done
1398 # Get options.
1399 [ "$pkg_list" ] || return
1400 local cooklist= look_for= with_dev= with_wanted= with_args= log_command="$0 $@" \
1401 get_options_list="look_for with_dev with_wanted with_args cooklist"
1402 get_options
1404 # Cooklist is a special case where we need to modify a little
1405 # scan behavior
1406 if [ "$cooklist" ]; then
1407 look_for=all_filtered && with_args=yes && with_dev= && with_wanted= && rwan=yes
1408 pkg_list=$(echo $pkg_list | filter)
1409 fi
1411 ##############################################################
1412 # ADD TO LISTS PROPOSAL ######################################
1413 ##############################################################
1415 include_wanted()
1417 for pkg in $(cat); do
1418 { grep ^$pkg$'\t' $wan_db || echo $pkg
1419 } | sed 's/\t/ /'
1420 done
1423 no_duplication()
1425 for pkg in $(cat); do
1426 grep -q ^$pkg$ $tmp/list $tmp/dep && continue
1427 echo $pkg
1428 done
1431 append_to_list()
1433 no_duplication >> $tmp/list
1434 # OU
1435 include_wanted | no_duplication >> $tmp/list
1438 ##############################################################
1439 mkdir -p $tmp
1440 for PACKAGE in $(echo $pkg_list | filter); do
1441 look_for_$look_for
1442 done | tr ' ' '\n' | sort -u > $tmp/list
1443 [ "$look_for" = bdep ] && look_for=dep
1444 while [ -s $tmp/list ]; do
1445 PACKAGE=$(sed 1!d $tmp/list)
1446 sed 1d -i $tmp/list
1447 echo $PACKAGE >> $tmp/dep
1448 for depend in $(look_for_$look_for); do
1449 if ! grep -q ^$depend$ $tmp/list $tmp/dep; then
1450 echo $depend >> $tmp/list
1451 fi
1452 done
1453 done
1454 [ "$with_args" ] && echo $pkg_list | tr ' ' '\n' >> $tmp/dep
1455 if [ -s $tmp/dep ]; then
1456 if [ "$with_wanted" ]; then
1457 cat $tmp/dep | while read PACKAGE; do
1458 look_for_rwanted >> $tmp/dep
1459 done
1460 elif [ "$with_dev" ]; then
1461 cat $tmp/dep | while read PACKAGE; do
1462 look_for_dev >> $tmp/dep
1463 done
1464 fi
1465 if [ "$cooklist" ]; then
1466 mv $tmp/dep $tmp/cooklist
1467 sort_cooklist
1468 rm $tmp/cooklist
1469 else
1470 cat $tmp/dep | sort -u
1471 fi
1472 fi
1473 rm $tmp/dep $tmp/list 2>/dev/null
1476 ########################################################################
1477 # This section contains functions to check package repository and
1478 # find which packages to cook.
1479 ########################
1481 # Actually its becomes more than check commit... Maybe put this in report
1482 # function is a good idea.
1483 check_for_commit()
1485 report step "Checking for commits"
1487 # Clean the list... Later we will perfom a partial clean only to keep
1488 # some usefull informations
1489 rm $PACKAGES_REPOSITORY/commit 2>/dev/null
1491 # If there's a packages-incoming repository we need to check it too.
1492 for RECEIPT in $(echo $WOK/*/receipt | fgrep -v '*'); do
1493 source_receipt
1495 # We use md5 of cooking stuff in the packaged receipt to check
1496 # commit. We look consecutively in 3 different locations :
1497 # - in the wok/PACKAGE/taz folder
1498 # - in the receipt in the package in incoming repository
1499 # - in the receipt in the package in packages repository
1500 # If md5sum match, there's no commit.
1501 # If there's not md5sum datas, because the package was cooked
1502 # with a previous version of tazwok, we don't put in in commit
1503 # list (need a cook-all to refresh them)
1504 # If there's no receipt available, package is missing so we put
1505 # it in commit list.
1506 # First look for package in packages-incoming.
1507 check_for_commit_using_md5sum()
1509 if [ ! -f $WOK/$PACKAGE/md5 ]; then
1510 sed -n '/# md5sum of cooking stuff :/,$p' receipt | \
1511 sed -e 1d -e 's/^# //' > $WOK/$PACKAGE/md5
1512 cd $WOK/$PACKAGE
1513 fi
1515 # Use md5sum list in receipt to check for commit.
1516 if [ -s md5 ]; then
1517 if md5sum -cs md5; then
1518 return_code=0
1520 # If md5sum check if ok, check for new files in
1521 # cooking stuff.
1522 for file in receipt description.txt $( [ -d stuff ] && find stuff); do
1523 if [ -f $file ] && ! fgrep -q " $file" md5; then
1524 set_commited
1525 fi
1526 done
1527 else
1528 set_commited
1529 fi
1530 else
1531 gen_cookmd5
1532 fi
1534 set_commited()
1536 echo $PACKAGE >> $PACKAGES_REPOSITORY/commit
1537 echo "Commit: $PACKAGE ($VERSION)"
1538 gen_cookmd5
1540 taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | fgrep -v '*')
1541 if [ -f $WOK/$PACKAGE/md5 ]; then
1542 cd $WOK/$PACKAGE
1543 check_for_commit_using_md5sum
1544 elif [ "$taz_dir" ]; then
1545 cd $taz_dir
1546 check_for_commit_using_md5sum
1547 else
1548 pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1549 [ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1550 if [ "$pkg" ]; then
1551 get_pkg_files $pkg
1552 check_for_commit_using_md5sum
1553 rm -r $pkg_files_dir
1554 continue
1555 fi
1556 set_commited
1557 fi
1558 done
1559 report end-step
1562 gen_cook_list()
1564 if [ -s $PACKAGES_REPOSITORY/commit ]; then
1565 report step "Generate genpkg & cook lists."
1566 cd $PACKAGES_REPOSITORY
1567 #cp commit $tmp/commit
1568 #if [ -s broken ]; then
1569 ## dep_scan return deps including the packages given in argument.
1570 ## To avoid that, we firt generate a list of direct rdepends of
1571 ## brokens without packages in argument, then we generate the
1572 ## full rdeps list. We do this because we don't want to block
1573 ## packages at source of broken tree if a fix as been commited.
1574 #for PACKAGE in $(cat broken); do
1575 #look_for_rdep >> $tmp/broken
1576 #done
1577 #cat $tmp/broken
1578 #look_for=rdep && with_wanted=yes
1579 #for PACKAGE in $(dep_scan `cat $tmp/broken`); do
1580 #if grep -q ^$PACKAGE$ $tmp/commit; then
1581 #sed "/^$PACKAGE$/d" -i $tmp/commit
1582 #fi
1583 #done
1584 #rm $tmp/broken
1585 #fi
1586 for PACKAGE in $(cat commit); do
1587 WANTED="$(look_for_wanted)"
1588 if [ "$WANTED" ]; then
1590 # If cook of wanted package is planned, this one will be
1591 # packaged at the same time. Else if wanted package is
1592 # broken or blocked, ignore the commit. Else, put the
1593 # package in genpkglist.
1594 { grep -q ^$WANTED$ commit || grep -q ^$WANTED$ broken || \
1595 grep -q ^$WANTED$ cooklist || grep -q ^$WANTED$ blocked || \
1596 grep -q ^$WANTED$ genpkglist
1597 } && continue
1598 echo $WANTED >> genpkglist
1599 else
1600 { grep -q ^$PACKAGE$ blocked || grep -q ^$PACKAGE$ cooklist
1601 } && continue
1602 echo $PACKAGE >> cooklist
1603 sed "/^$PACKAGE$/d" -i broken
1604 fi
1605 done
1606 #rm $tmp/commit
1607 if [ -s genpkglist ]; then
1608 echo "genpkglist:"
1609 cat genpkglist
1610 fi
1611 report end-step
1612 fi
1613 cooklist=$PACKAGES_REPOSITORY/cooklist
1614 sort_cooklist
1617 sort_cooklist()
1619 [ ! "$cooklist" ] && cooklist=$PACKAGES_REPOSITORY/cooklist
1620 [ -s $cooklist ] || [ -s "$tmp/cooklist" ] || return
1621 [ -s $PACKAGES_REPOSITORY/cookorder.txt ] || gen_wok_db
1622 [ ! -s "$tmp/cooklist" ] && cp -a $cooklist $tmp/cooklist
1623 report step "Sorting cooklist"
1625 # Use cookorder.txt to sort cooklist.
1626 cat $PACKAGES_REPOSITORY/cookorder.txt | while read PACKAGE; do
1627 if grep -q ^$PACKAGE$ $tmp/cooklist; then
1628 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1629 echo $PACKAGE >> $tmp/cooklist.tmp
1630 fi
1631 done
1633 # Remaining packages in cooklist are thoses without compile_rules.
1634 # They can be cooked first in any order.
1635 mv -f $tmp/cooklist.tmp $tmp/cooklist
1636 [ "$cooklist" = "$PACKAGES_REPOSITORY/cooklist" ] && \
1637 cat $tmp/cooklist > $cooklist
1638 cat $tmp/cooklist
1639 report end-step
1642 check_for_incoming()
1644 [ -s $INCOMING_REPOSITORY/packages.txt ] || return
1645 report step "Checking packages-incoming repository"
1646 cd $INCOMING_REPOSITORY
1647 grep ^[0-9,a-z,A-Z] packages.txt > $tmp/incoming
1648 scan `cat $PACKAGES_REPOSITORY/broken` --look_for=bdep --with_wanted > $tmp/broken
1649 for PACKAGE in $(scan `cat $tmp/broken` --look_for=rdep --with_wanted --with_args); do
1650 sed "/^$PACKAGE$/d" -i $tmp/incoming
1651 for rwanted in $(look_for_rwanted); do
1652 sed "/^$rwanted$/d" -i $tmp/incoming
1653 done
1654 done
1655 rm $tmp/broken
1656 if [ "$incoming_delay" != 0 ]; then
1657 cat $tmp/incoming | while read PACKAGE; do
1658 [ "$(grep ^$PACKAGE$ $tmp/incoming)" ] || continue
1659 dep_list=$( { scan $PACKAGE --look_for=bdep --with_wanted && \
1660 scan $PACKAGE --look_for=rdep --with_wanted --with_args; } \
1661 | sort -u )
1662 for dep in $dep_list; do
1663 [ "$(find -name "`get_pkg_version $INCOMING_REPOSITORY`.tazpkg" -mtime +$incoming_delay)" ] && continue
1664 for pkg in $dep_list; do
1665 sed "/^$pkg$/d" -i $tmp/incoming
1666 done && break
1667 done
1668 done
1669 fi
1670 if [ -s "$tmp/incoming" ]; then
1671 for PACKAGE in $(cat $tmp/incoming); do
1672 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
1673 remove_previous_package $PACKAGES_REPOSITORY
1674 remove_previous_tarball
1675 cur_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
1676 mv -f $PACKAGE-$cur_VERSION.tazpkg $PACKAGES_REPOSITORY
1677 echo "Moving $PACKAGE to main repository."
1678 done
1679 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
1680 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
1681 fi
1682 report end-step
1685 ########################################################################
1686 # TAZWOK MAIN FUNCTIONS
1687 ########################
1689 clean()
1691 cd $WOK/$PACKAGE
1692 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
1693 -e ^stuff$ || return
1695 report step "Cleaning $PACKAGE"
1696 # Check for clean_wok function.
1697 if grep -q ^clean_wok $RECEIPT; then
1698 clean_wok
1699 fi
1700 # Clean should only have a receipt, stuff and optional desc.
1701 for f in `ls .`
1702 do
1703 case $f in
1704 receipt|stuff|description.txt)
1705 continue ;;
1706 *)
1707 echo "Removing: $f"
1708 rm -rf $f
1709 esac
1710 done
1711 report end-step
1714 # Configure and make a package with the receipt.
1715 compile_package()
1717 check_for_package_on_cmdline
1719 # Include the receipt to get all needed variables and functions
1720 # and cd into the work directory to start the work.
1721 check_for_receipt
1722 source_receipt
1724 # Log the package name and date.
1725 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
1726 echo "package $PACKAGE (compile)" >> $LOG
1728 # Set wanted $src variable to help compiling.
1729 [ ! "$src" ] && set_src_path
1730 check_for_build_depends || return 1
1731 check_for_wanted
1732 unset target
1733 check_for_tarball && check_for_compile_rules
1736 # Cook command also include all features to manage lists which keep
1737 # track of wok/packages state.
1738 cook()
1740 cook_code=
1741 set_common_path
1742 check_for_receipt
1743 source_receipt
1745 # Define log path and start report.
1746 [ -f $LOCAL_REPOSITORY/log/$PACKAGE.html ] && rm $LOCAL_REPOSITORY/log/$PACKAGE.html
1747 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
1748 report step "Cooking $PACKAGE"
1749 report open-bloc
1751 # Clean package if needed.
1752 clean $PACKAGE
1754 # Remove PACKAGE from commit & cook lists.
1755 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/commit
1756 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/cooklist
1757 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
1759 if compile_package; then
1760 refresh_packages_from_compile
1761 gen_package
1762 remove_src
1764 # Plan recook of reverse build depends if gen_package has detect
1765 # a change in libraries.
1766 if [ "$cook_rdep" ]; then
1767 report step "Look for packages which need a refresh"
1768 for rdep in $(scan $PACKAGE --look_for=rdep); do
1769 sed "/^$rdep$/d" -i $PACKAGES_REPOSITORY/broken
1770 if [ -f $WOK/$rdep/receipt ] && ! grep -q ^$rdep$ $tmp/cooklist; then
1771 echo "Add $rdep in cooklist to avoid broke caused by library update in $PACKAGE"
1772 echo $rdep >> $tmp/cooklist
1773 regen_cooklist=yes
1774 fi
1775 done
1776 report end-step
1777 fi
1779 # Update packages-incoming repository.
1780 store_pkgname=$PACKAGE
1781 pkg_repository=$INCOMING_REPOSITORY
1782 update_packages_db
1784 PACKAGE=$store_pkgname
1785 unset store_pkgname
1787 # Upgrade to cooked packages if it was previously installed.
1788 report step "Look for package(s) to upgrade"
1789 for pkg in $(look_for_rwanted) $PACKAGE; do
1790 if [ -d $INSTALLED/$pkg ]; then
1791 tazpkg get-install $pkg --forced
1792 fi
1793 done
1794 report end-step
1795 else
1797 # Set package as broken.
1798 if ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then
1799 echo $PACKAGE >> $PACKAGES_REPOSITORY/broken
1800 fi
1801 gen_cookmd5
1802 cook_code=1
1803 fi
1805 # Remove build_depends in cook mode (if in cooklist, it's done when
1806 # checking build_depends of next package and we remove only unneeded
1807 # packages to keep chroot minimal and gain some time).
1808 [ "$COMMAND" = cook ] && remove_build_depends $MISSING_PACKAGE
1810 # Regen the cooklist if it was planned and command is not cook.
1811 [ "$regen_cooklist" ] && unset regen_cooklist && \
1812 [ "$COMMAND" != cook ] && sort_cooklist
1814 # Some hacks to set the bloc & function status as failed if cook was
1815 # failed.
1816 report_return_code=$cook_code
1817 report close-bloc
1818 report end-sublog
1819 return $cook_code
1822 genpkg_list()
1824 while [ -s $PACKAGES_REPOSITORY/genpkglist ]; do
1825 PACKAGE=$(sed 1!d $PACKAGES_REPOSITORY/genpkglist)
1826 gen_package
1827 done
1830 cook_list()
1832 if [ ! -s $cooklist ]; then
1833 echo "Nothing to cook."
1834 return
1835 fi
1836 if [ -f /usr/bin/tazchroot ]; then
1837 # Note : options -main variables- are automatically keeped by
1838 # the sub-applications tazchroot/tazwok; as well as report data.
1839 cd $LOCAL_REPOSITORY
1840 [ ! -f tazchroot.conf ] && configure_tazchroot
1841 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
1842 return
1843 fi
1844 while [ -s $tmp/cooklist ]; do
1845 PACKAGE=$(sed 1!d $tmp/cooklist)
1846 cook
1847 done
1848 remove_build_depends $MISSING_PACKAGE $remove_later
1851 configure_tazchroot()
1853 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
1854 # Tazchroot configuration file - created by tazwok.
1856 # Default chroot path
1857 SLITAZ_DIR=$SLITAZ_DIR
1858 SLITAZ_VERSION=$SLITAZ_VERSION
1859 $( [ "$undigest" ] && echo "undigest=$undigest" )
1860 LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
1861 chroot_dir=\$LOCAL_REPOSITORY/chroot
1863 # Default scripts path (theses scripts are added in the
1864 # $chroot_dir/usr/bin and can be called with tazchroot script)
1865 script_dir=/var/lib/tazchroot
1867 # List of directories to mount.
1868 list_dir="$(for dir in packages wok src packages-incoming log flavors iso; do echo $LOCAL_REPOSITORY/$dir; done)
1869 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
1871 create_chroot()
1873 mkdir -p \$chroot_dir
1874 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
1875 tazpkg get-install \$pkg --root="\$chroot_dir"
1876 done
1878 # Store list of installed packages needed by cleanchroot.
1879 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
1881 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
1882 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
1883 -i \$chroot_dir/etc/slitaz/slitaz.conf
1884 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
1885 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
1888 mount_chroot()
1890 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
1891 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCALSTATE/mirror
1892 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
1893 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
1894 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION
1895 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror' )
1896 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
1897 mount -t proc proc \$chroot_dir/proc
1898 mount -t sysfs sysfs \$chroot_dir/sys
1899 mount -t devpts devpts \$chroot_dir/dev/pts
1900 mount -t tmpfs shm \$chroot_dir/dev/shm
1901 for dir in \$list_dir; do
1902 mkdir -p \$dir \$chroot_dir\$dir
1903 mount \$dir \$chroot_dir\$dir
1904 done
1907 umount_chroot()
1909 for dir in \$list_dir; do
1910 umount \$chroot_dir\$dir
1911 done
1912 umount \$chroot_dir/dev/shm
1913 umount \$chroot_dir/dev/pts
1914 umount \$chroot_dir/sys
1915 umount \$chroot_dir/proc
1917 EOF
1920 ########################################################################
1921 ######################### END OF NEW FUNCTIONS #########################
1922 ########################################################################
1924 # List packages providing a virtual package
1925 whoprovide()
1927 local i;
1928 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
1929 . $i
1930 case " $PROVIDE " in
1931 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
1932 esac
1933 done
1936 ########################################################################
1937 # TAZWOK COMMANDS
1938 ########################
1940 case "$COMMAND" in
1941 stats)
1942 # Tazwok general statistics from the wok config file.
1944 get_tazwok_config
1945 echo -e "\n\033[1mTazwok configuration statistics\033[0m
1946 ================================================================================
1947 Wok directory : $WOK
1948 Packages repository : $PACKAGES_REPOSITORY
1949 Incoming repository : $INCOMING_REPOSITORY
1950 Sources repository : $SOURCES_REPOSITORY
1951 Log directory : $LOCAL_REPOSITORY/log
1952 Packages in the wok : `ls -1 $WOK | wc -l`
1953 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
1954 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
1955 ================================================================================\n"
1956 ;;
1957 edit)
1958 get_tazwok_config
1959 check_for_package_on_cmdline
1960 check_for_receipt
1961 $EDITOR $WOK/$PACKAGE/receipt
1962 ;;
1963 build-depends)
1964 # List dependencies to rebuild wok, or only a package
1965 get_tazwok_config
1966 if [ "$PACKAGE" = toolchain-cooklist ]; then
1967 mkdir -p $tmp
1968 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1969 --cooklist
1970 elif [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
1971 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1972 --look_for=dep --with_dev --with_args
1973 else
1974 check_for_package_on_cmdline
1975 scan $PACKAGE --look_for=bdep --with_dev
1976 fi
1977 ;;
1978 gen-cooklist)
1979 get_options_list="list"
1980 get_tazwok_config
1981 if [ "$list" ]; then
1982 LIST="$list"
1983 check_for_list
1984 else
1985 LIST=$(for pkg in $@; do
1986 [ "$pkg" = "${pkg#--}" ] || continue
1987 echo -n "$pkg "
1988 done)
1989 if [ ! "$LIST" ]; then
1990 echo "Please give packages or a list file in argument." >&2
1991 exit
1992 fi
1993 fi
1994 scan $LIST --cooklist
1995 ;;
1996 check-depends)
1997 # Check package depends /!\
1998 get_tazwok_config
1999 echo ""
2000 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
2001 ================================================================================"
2002 TMPDIR=/tmp/tazwok$$
2003 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
2005 # Build ALL_DEPENDS variable
2006 scan_dep()
2008 local i
2009 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
2010 for i in $DEPENDS $SUGGESTED ; do
2011 case " $ALL_DEPENDS " in
2012 *\ $i\ *) continue;;
2013 esac
2014 [ -d $WOK/$i ] || {
2015 ALL_DEPENDS="$ALL_DEPENDS$i "
2016 continue
2018 DEPENDS=""
2019 SUGGESTED=""
2020 . $WOK/$i/receipt
2021 scan_dep
2022 done
2025 # Check for ELF file
2026 is_elf()
2028 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" \
2029 = "ELF" ]
2032 # Print shared library dependencies
2033 ldd()
2035 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
2038 mkdir $TMPDIR
2039 cd $TMPDIR
2040 for i in $LOCALSTATE/files.list.lzma \
2041 $LOCALSTATE/undigest/*/files.list.lzma ; do
2042 [ -f $i ] && lzma d $i -so >> files.list
2043 done
2044 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
2045 tazpkg extract $pkg > /dev/null 2>&1
2046 . */receipt
2047 ALL_DEPENDS="$DEFAULT_DEPENDS "
2048 scan_dep
2049 find */fs -type f | while read file ; do
2050 is_elf $file || continue
2051 case "$file" in
2052 *.o|*.ko|*.ko.gz) continue;;
2053 esac
2054 ldd $file | while read lib rem; do
2055 case "$lib" in
2056 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
2057 continue;;
2058 esac
2059 for dep in $(fgrep $lib files.list | cut -d: -f1); do
2060 case " $ALL_DEPENDS " in
2061 *\ $dep\ *) continue 2;;
2062 esac
2063 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
2064 case " $ALL_DEPENDS " in
2065 *\ $vdep\ *) continue 3;;
2066 esac
2067 done
2068 done
2069 [ -n "$dep" ] || dep="UNKNOWN"
2070 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
2071 done
2072 done
2073 rm -rf */
2074 done
2075 cd /tmp
2076 rm -rf $TMPDIR
2077 ;;
2078 check)
2079 # Check wok consistency
2080 get_tazwok_config
2081 echo ""
2082 echo -e "\033[1mWok and packages checking\033[0m
2083 ================================================================================"
2084 cd $WOK
2085 for pkg in $(ls)
2086 do
2087 [ -f $pkg/receipt ] || continue
2088 RECEIPT= $pkg/receipt
2089 source_receipt
2090 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
2091 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
2092 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
2093 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
2094 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
2095 if [ -n "$WANTED" ]; then
2096 if [ ! -f $WANTED/receipt ]; then
2097 echo "Package $PACKAGE wants unknown $WANTED package" >&2
2098 else
2099 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
2100 if [ "$VERSION" = "$WANTED" ]; then
2101 # BASEVERSION is computed in receipt
2102 fgrep -q '_pkg=' $pkg/receipt &&
2103 BASEVERSION=$VERSION
2104 fi
2105 if [ "$VERSION" != "$BASEVERSION" ]; then
2106 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
2107 fi
2108 fi
2109 fi
2111 if [ -n "$CATEGORY" ]; then
2112 case " $(echo $CATEGORIES) " in
2113 *\ $CATEGORY\ *);;
2114 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
2115 esac
2116 else
2117 echo"Package $PACKAGE has no CATEGORY" >&2
2118 fi
2119 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
2120 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
2121 case "$WGET_URL" in
2122 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
2123 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
2124 '') ;;
2125 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
2126 esac
2127 case "$WEB_SITE" in
2128 ftp*|http*);;
2129 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
2130 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
2131 esac
2132 case "$MAINTAINER" in
2133 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
2134 esac
2135 case "$MAINTAINER" in
2136 *@*);;
2137 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
2138 esac
2139 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2140 for i in $DEPENDS; do
2141 [ -d $i ] && continue
2142 [ -n "$(whoprovide $i)" ] && continue
2143 echo -e "$MSG $i"
2144 MSG=""
2145 done
2146 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2147 for i in $BUILD_DEPENDS; do
2148 [ -d $i ] && continue
2149 [ -n "$(whoprovide $i)" ] && continue
2150 echo -e "$MSG $i"
2151 MSG=""
2152 done
2153 MSG="Dependencies loop between $PACKAGE and :\n"
2154 ALL_DEPS=""
2155 check_for_deps_loop $PACKAGE $DEPENDS
2156 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
2157 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
2158 echo "$pkg should be rebuilt after $i installation"
2159 done
2160 done
2161 ;;
2162 list)
2163 # List packages in wok directory. User can specify a category.
2165 get_tazwok_config
2166 if [ "$2" = "category" ]; then
2167 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
2168 exit 0
2169 fi
2170 # Check for an asked category.
2171 if [ -n "$2" ]; then
2172 ASKED_CATEGORY=$2
2173 echo ""
2174 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
2175 echo "================================================================================"
2176 for pkg in $WOK/*
2177 do
2178 [ ! -f $pkg/receipt ] && continue
2179 . $pkg/receipt
2180 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
2181 echo -n "$PACKAGE"
2182 echo -e "\033[28G $VERSION"
2183 packages=$(($packages+1))
2184 fi
2185 done
2186 echo "================================================================================"
2187 echo -e "$PACKAGEs packages in category $ASKED_CATEGORY.\n"
2188 else
2189 # By default list all packages and version.
2190 echo ""
2191 echo -e "\033[1mList of packages in the wok\033[0m"
2192 echo "================================================================================"
2193 for pkg in $WOK/*
2194 do
2195 [ ! -f $pkg/receipt ] && continue
2196 . $pkg/receipt
2197 echo -n "$PACKAGE"
2198 echo -en "\033[28G $VERSION"
2199 echo -e "\033[42G $CATEGORY"
2200 packages=$(($packages+1))
2201 done
2202 echo "================================================================================"
2203 echo -e "$PACKAGEs packages available in the wok.\n"
2204 fi
2205 ;;
2206 info)
2207 # Information about a package.
2209 get_tazwok_config
2210 check_for_package_on_cmdline
2211 check_for_receipt
2212 . $WOK/$PACKAGE/receipt
2213 echo ""
2214 echo -e "\033[1mTazwok package information\033[0m
2215 ================================================================================
2216 Package : $PACKAGE
2217 Version : $VERSION
2218 Category : $CATEGORY
2219 Short desc : $SHORT_DESC
2220 Maintainer : $MAINTAINER"
2221 if [ ! "$WEB_SITE" = "" ]; then
2222 echo "Web site : $WEB_SITE"
2223 fi
2224 if [ ! "$DEPENDS" = "" ]; then
2225 echo "Depends : $DEPENDS"
2226 fi
2227 if [ ! "$WANTED" = "" ]; then
2228 echo "Wanted src : $WANTED"
2229 fi
2230 echo "================================================================================"
2231 echo ""
2232 ;;
2233 check-log)
2234 # We just cat the file log to view process info.
2236 get_tazwok_config
2237 if [ ! -f "$LOG" ]; then
2238 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
2239 exit 1
2240 else
2241 echo ""
2242 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
2243 echo "================================================================================"
2244 cat $LOG
2245 echo "================================================================================"
2246 echo ""
2247 fi
2248 ;;
2249 search)
2250 # Search for a package by pattern or name.
2252 get_tazwok_config
2253 if [ -z "$2" ]; then
2254 echo -e "\nPlease specify a pattern or a package name to search." >&2
2255 echo -e "Example : 'tazwok search gcc'.\n" >&2
2256 exit 1
2257 fi
2258 echo ""
2259 echo -e "\033[1mSearch result for :\033[0m $2"
2260 echo "================================================================================"
2261 list=`ls -1 $WOK | fgrep $2`
2262 for pkg in $list
2263 do
2264 . $WOK/$pkg/receipt
2265 echo -n "$PACKAGE "
2266 echo -en "\033[24G $VERSION"
2267 echo -e "\033[42G $CATEGORY"
2268 packages=$(($PACKAGEs+1))
2269 done
2270 echo "================================================================================"
2271 echo "$PACKAGEs packages found for : $2"
2272 echo ""
2273 ;;
2274 compile)
2275 # Configure and make a package with the receipt.
2277 get_tazwok_config
2278 source_lib report
2279 report start
2280 compile_package
2281 ;;
2282 genpkg)
2283 # Generate a package.
2285 get_tazwok_config
2286 source_lib report
2287 report start
2288 mkdir $tmp
2289 gen_package
2290 ;;
2291 cook)
2292 # Compile and generate a package. Just execute tazwok with
2293 # the good commands.
2295 check_root
2296 get_tazwok_config
2297 source_lib report
2298 report start
2299 mkdir -p $tmp
2300 cook
2301 ;;
2302 sort-cooklist)
2303 if [ ! "$LIST" ]; then
2304 echo "Usage : tazwok sort-cooklist cooklist" >&2\
2305 exit 1
2306 fi
2307 get_tazwok_config
2308 source_lib report
2309 report start
2310 mkdir -p $tmp
2311 cooklist=$LIST
2312 sort_cooklist
2313 cp -af $tmp/cooklist $cooklist
2314 ;;
2315 cook-list)
2316 # Cook all packages listed in a file. The path to the cooklist must
2317 # be specified on the cmdline.
2318 # /!\
2319 check_root
2320 get_tazwok_config
2321 source_lib report
2322 report start
2323 mkdir -p $tmp
2324 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2325 if [ "$LIST" ]; then
2326 sort_cooklist
2327 else
2328 cp $cooklist $tmp/cooklist
2329 fi
2330 cook_list
2331 ;;
2332 clean)
2333 # Clean up a package work directory + thoses which want it.
2335 get_tazwok_config
2336 check_for_package_on_cmdline
2337 check_for_receipt
2338 source_lib report
2339 report start
2340 . $RECEIPT
2341 clean
2342 ;;
2343 gen-clean-wok)
2344 # Generate a clean wok from the current wok by copying all receipts
2345 # and stuff directory.
2347 get_tazwok_config
2348 source_lib report
2349 report start
2350 if [ -z "$ARG" ]; then
2351 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
2352 exit 1
2353 else
2354 dest=$ARG
2355 mkdir -p $dest
2356 fi
2357 report step "Creating clean wok in : $dest"
2358 for pkg in `ls -1 $WOK`
2359 do
2360 mkdir -p $dest/$pkg
2361 cp -a $WOK/$pkg/receipt $dest/$pkg
2362 [ -f $WOK/$pkg/description.txt ] && \
2363 cp -a $WOK/$pkg/description.txt $dest/$pkg
2364 if [ -d "$WOK/$pkg/stuff" ]; then
2365 cp -a $WOK/$pkg/stuff $dest/$pkg
2366 fi
2367 done
2368 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
2369 report end-step
2370 echo "Packages cleaned : `ls -1 $dest | wc -l`"
2371 echo ""
2372 ;;
2373 clean-wok)
2374 # Clean all packages in the work directory
2376 get_tazwok_config
2377 source_lib report
2378 report start
2379 report step "Cleaning wok"
2380 report open-bloc
2381 for PACKAGE in `ls -1 $WOK`
2382 do
2383 set_common_path
2384 source_receipt
2385 clean
2386 done
2387 report close-bloc
2388 echo "`ls -1 $WOK | wc -l` packages cleaned."
2389 ;;
2390 gen-list)
2391 check_root
2392 get_tazwok_config
2393 source_lib report
2394 report start
2395 dbtype=packages
2396 mode=gen
2397 for pkg_repository in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
2398 files_list="$pkg_repository/files.list.lzma \
2399 $pkg_repository/packages.list \
2400 $pkg_repository/packages.txt \
2401 $pkg_repository/packages.desc \
2402 $pkg_repository/packages.equiv \
2403 $pkg_repository/packages.md5"
2404 gen_db
2405 echo "$pkgs packages in the repository."
2406 echo ""
2407 done
2408 ;;
2409 check-list)
2410 # The directory to move into by default is the repository,
2411 # if $2 is not empty cd into $2.
2413 get_tazwok_config
2414 if [ -z "$2" ]; then
2415 PACKAGES_REPOSITORY=$PACKAGES_REPOSITORY
2416 else
2417 if [ -d "$2" ]; then
2418 PACKAGES_REPOSITORY=$2
2419 else
2420 echo -e "\nUnable to find directory : $2\n" >&2
2421 exit 1
2422 fi
2423 fi
2425 # Use report shared library to control output.
2426 tmp=/tmp/tazwok-$$
2427 mkdir $tmp
2428 source_lib report
2429 dbtype=packages
2430 mode=update
2431 cd $PACKAGES_REPOSITORY
2432 for pkg in $(echo *.tazpkg); do
2433 package_md5=$(md5sum $pkg)
2434 [ "$package_md5" = "$(fgrep " $pkg" packages.md5)" ] && continue
2435 erase_package_info
2436 get_packages_info
2437 done
2438 echo "$pkgs packages in the repository."
2439 echo ""
2440 ;;
2441 new-tree)
2442 # Just create a few directories and generate an empty receipt to prepare
2443 # the creation of a new package.
2445 get_tazwok_config
2446 check_for_package_on_cmdline
2447 if [ -d $WOK/$PACKAGE ]; then
2448 echo -e "\n$PACKAGE package tree already exists.\n" >&2
2449 exit 1
2450 fi
2451 echo "Creating : $WOK/$PACKAGE"
2452 mkdir $WOK/$PACKAGE
2453 cd $WOK/$PACKAGE
2454 echo -n "Preparing the receipt..."
2456 # Default receipt begin.
2458 echo "# SliTaz package receipt." > receipt
2459 echo "" >> receipt
2460 echo "PACKAGE=\"$PACKAGE\"" >> receipt
2461 # Finish the empty receipt.
2462 cat >> receipt << "EOF"
2463 VERSION=""
2464 CATEGORY=""
2465 SHORT_DESC=""
2466 MAINTAINER=""
2467 DEPENDS=""
2468 TARBALL="$PACKAGE-$VERSION.tar.gz"
2469 WEB_SITE=""
2470 WGET_URL=""
2472 # Rules to configure and make the package.
2473 compile_rules()
2475 cd $src
2476 ./configure \
2477 --prefix=/usr \
2478 --infodir=/usr/share/info \
2479 --mandir=/usr/share/man \
2480 $CONFIGURE_ARGS &&
2481 make -j 4 && make DESTDIR=$PWD/_pkg install
2484 # Rules to gen a SliTaz package suitable for Tazpkg.
2485 genpkg_rules()
2487 mkdir -p $fs/usr
2488 cp -a $_pkg/usr/bin $fs/usr
2491 EOF
2493 # Default receipt end.
2495 status
2496 # Interactive mode, asking and seding.
2497 if [ "$3" = "--interactive" ]; then
2498 echo "Entering into interactive mode..."
2499 echo "================================================================================"
2500 echo "Package : $PACKAGE"
2501 # Version.
2502 echo -n "Version : " ; read anser
2503 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
2504 # Category.
2505 echo -n "Category : " ; read anser
2506 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
2507 # Short description.
2508 echo -n "Short desc : " ; read anser
2509 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
2510 # Maintainer.
2511 echo -n "Maintainer : " ; read anser
2512 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
2513 # Web site.
2514 echo -n "Web site : " ; read anser
2515 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
2516 echo ""
2517 # Wget URL.
2518 echo "Wget URL to download source tarball."
2519 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
2520 echo -n "Wget url : " ; read anser
2521 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
2522 # Ask for a stuff dir.
2523 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
2524 if [ "$anser" = "y" ]; then
2525 echo -n "Creating the stuff directory..."
2526 mkdir stuff && status
2527 fi
2528 # Ask for a description file.
2529 echo -n "Are you going to write a description ? (y/N) : " ; read anser
2530 if [ "$anser" = "y" ]; then
2531 echo -n "Creating the description.txt file..."
2532 echo "" > description.txt && status
2533 fi
2534 echo "================================================================================"
2535 echo ""
2536 fi
2537 ;;
2538 remove)
2539 # Remove a package from the wok.
2541 get_tazwok_config
2542 check_for_package_on_cmdline
2543 echo ""
2544 echo -n "Please confirm deletion (y/N) : "; read anser
2545 if [ "$anser" = "y" ]; then
2546 echo -n "Removing $PACKAGE..."
2547 rm -rf $WOK/$PACKAGE && status
2548 echo ""
2549 fi
2550 ;;
2551 hgup)
2552 # Pull and update a Hg wok.
2553 get_tazwok_config
2554 if ls -l $WOK/.hg/hgrc | fgrep -q "root"; then
2555 check_root
2556 fi
2557 cd $WOK
2558 hg pull && hg update
2559 ;;
2560 maintainers)
2561 get_tazwok_config
2562 echo ""
2563 echo "List of maintainers for: $WOK"
2564 echo "================================================================================"
2565 touch /tmp/slitaz-maintainers
2566 for pkg in $WOK/*
2567 do
2568 . $pkg/receipt
2569 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
2570 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
2571 echo "$MAINTAINER"
2572 fi
2573 done
2574 echo "================================================================================"
2575 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
2576 echo ""
2577 # Remove tmp files
2578 rm -f /tmp/slitaz-maintainers
2579 ;;
2580 maintained-by)
2581 # Search for packages maintained by a contributor.
2582 get_tazwok_config
2583 if [ ! -n "$2" ]; then
2584 echo "Specify a name or email of a maintainer." >&2
2585 exit 1
2586 fi
2587 echo "Maintainer packages"
2588 echo "================================================================================"
2589 for pkg in $WOK/*
2590 do
2591 . $pkg/receipt
2592 if echo "$MAINTAINER" | fgrep -q "$2"; then
2593 echo "$PACKAGE"
2594 packages=$(($PACKAGEs+1))
2595 fi
2596 done
2597 echo "================================================================================"
2598 echo "Packages maintained by $2: $PACKAGEs"
2599 echo ""
2600 ;;
2601 check-src)
2602 # Verify if upstream package is still available
2604 get_tazwok_config
2605 check_for_package_on_cmdline
2606 check_for_receipt
2607 source_receipt
2608 check_src()
2610 for url in $@; do
2611 busybox wget -s $url 2>/dev/null && break
2612 done
2614 if [ "$WGET_URL" ];then
2615 echo -n "$PACKAGE : "
2616 check_src $WGET_URL
2617 status
2618 else
2619 echo "No tarball to check for $PACKAGE"
2620 fi
2621 ;;
2622 get-src)
2623 check_root
2624 get_options_list="target"
2625 get_tazwok_config
2626 check_for_package_on_cmdline
2627 check_for_receipt
2628 source_receipt
2629 if [ "$WGET_URL" ];then
2630 source_lib report
2631 report start
2632 check_for_tarball
2633 else
2634 echo "No tarball to download for $PACKAGE"
2635 fi
2636 ;;
2637 check-commit)
2638 check_root
2639 get_tazwok_config
2640 source_lib report
2641 report start
2642 mkdir -p $tmp
2643 check_for_commit
2644 gen_cook_list
2645 ;;
2646 cook-commit)
2647 check_root
2648 get_tazwok_config
2649 source_lib report
2650 report start
2651 mkdir -p $tmp
2652 check_for_commit
2653 # 2) update cook-database (actually complete regeneration)
2654 dbtype=wok
2655 mode=gen
2656 files_list="$dep_db $wan_db $PACKAGE_REPOSITORY/cookorder.txt"
2657 gen_db
2658 # 3) check cooklist
2659 # 3.1) rename pkgs with wanted variable to wanted pkg
2660 gen_cook_list
2661 cook_list
2662 ;;
2663 cook-all)
2664 check_root
2665 get_tazwok_config
2666 source_lib report
2667 report start
2668 mkdir -p $tmp
2669 # 2) update cook-database (actually complete regeneration)
2670 dbtype=wok
2671 mode=gen
2672 files_list="$dep_db $wan_db $PACKAGE_REPOSITORY/cookorder.txt"
2673 gen_db
2674 # Add all packages, without toolchain, in cooklist.
2675 # Recook toolchain need to be coded.
2676 echo -n "" > $PACKAGES_REPOSITORY/cooklist
2677 for pkg in $(cd $WOK && echo *); do
2678 echo $pkg >> $PACKAGES_REPOSITORY/cooklist
2679 done
2680 for pkg in $(scan gcc --look_for=all --with_wanted --with_args); do
2681 sed "/^$pkg$/d" -i $PACKAGES_REPOSITORY/cooklist
2682 done
2683 sort_cooklist
2684 cook_list
2685 ;;
2686 gen-wok-db)
2687 check_root
2688 get_tazwok_config
2689 source_lib report
2690 report start
2691 mkdir $tmp
2692 dbtype=wok
2693 mode=gen
2694 files_list="$dep_db $wan_db $PACKAGE_REPOSITORY/cookorder.txt"
2695 gen_db
2696 ;;
2697 report)
2698 check_root
2699 get_tazwok_config
2700 cd $PACKAGES_REPOSITORY
2701 for i in commit genpkglist cooklist incoming broken blocked; do
2702 if [ -s $i ]; then
2703 echo -e "\n********************* $i *********************\n$(cat $i)\n*********************"
2704 fi
2705 done
2706 ;;
2707 check-incoming)
2708 check_root
2709 get_tazwok_config
2710 source_lib report
2711 report start
2712 mkdir $tmp
2713 check_for_incoming
2714 ;;
2715 remove-old)
2716 check_root
2717 get_tazwok_config
2718 source_lib report
2719 report start
2720 mkdir $tmp
2721 remove_old_packages
2722 ;;
2723 configure-chroot)
2724 check_root
2725 get_tazwok_config
2726 if [ -f /usr/bin/tazchroot ]; then
2727 cd $LOCAL_REPOSITORY
2728 configure_tazchroot
2729 else
2730 echo "The packages tazchroot need to be installed" >&2
2731 exit 1
2732 fi
2733 ;;
2734 chroot)
2735 check_root
2736 get_tazwok_config
2737 # Merge this and the other chroot function ?.
2738 if [ -f /usr/bin/tazchroot ]; then
2739 cd $LOCAL_REPOSITORY
2740 [ ! -f tazchroot.conf ] && configure_tazchroot
2741 tazchroot
2742 else
2743 echo "The packages tazchroot need to be installed" >&2
2744 exit 1
2745 fi
2746 ;;
2747 cook-toolchain)
2748 check_root
2749 get_tazwok_config
2750 echo -n "" > $PACKAGES_REPOSITORY/broken
2751 if [ -f /usr/bin/tazchroot ]; then
2752 cd $LOCAL_REPOSITORY
2753 [ ! -f tazchroot.conf ] && configure_tazchroot
2754 tazchroot cook-toolchain
2755 # Buggy : chroot can be elsewhere.
2756 rm -r $LOCAL_REPOSITORY/chroot
2757 # /!\ to be writed :
2758 # next rm chroot and plan cook-all by pushing all packages
2759 # in cooklist.
2760 else
2761 echo "The packages tazchroot need to be installed" >&2
2762 exit 1
2763 fi
2764 ;;
2765 usage|*)
2766 # Print usage also for all unknown commands.
2768 usage
2769 ;;
2770 esac
2772 [ -d "$tmp" ] && rm -r $tmp
2773 report stop 2>/dev/null || exit 0