tazwok view tazwok @ rev 199

Fix an fgrep command
author Antoine Bodin <gokhlayeh@slitaz.org>
date Wed Jan 26 21:45:21 2011 +0100 (2011-01-26)
parents 19a093324a4e
children 992ea5bf6d66
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 -q " ${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 for PACKAGE in $(echo $pkg_list | filter); do
1440 look_for_$look_for
1441 done | tr ' ' '\n' | sort -u > $tmp/list
1442 [ "$look_for" = bdep ] && look_for=dep
1443 while [ -s $tmp/list ]; do
1444 PACKAGE=$(sed 1!d $tmp/list)
1445 sed 1d -i $tmp/list
1446 echo $PACKAGE >> $tmp/dep
1447 for depend in $(look_for_$look_for); do
1448 if ! grep -q ^$depend$ $tmp/list $tmp/dep; then
1449 echo $depend >> $tmp/list
1450 fi
1451 done
1452 done
1453 [ "$with_args" ] && echo $pkg_list | tr ' ' '\n' >> $tmp/dep
1454 if [ -s $tmp/dep ]; then
1455 if [ "$with_wanted" ]; then
1456 cat $tmp/dep | while read PACKAGE; do
1457 look_for_rwanted >> $tmp/dep
1458 done
1459 elif [ "$with_dev" ]; then
1460 cat $tmp/dep | while read PACKAGE; do
1461 look_for_dev >> $tmp/dep
1462 done
1463 fi
1464 if [ "$cooklist" ]; then
1465 mv $tmp/dep $tmp/cooklist
1466 sort_cooklist
1467 rm $tmp/cooklist
1468 else
1469 cat $tmp/dep | sort -u
1470 fi
1471 fi
1472 rm $tmp/dep $tmp/list 2>/dev/null
1475 ########################################################################
1476 # This section contains functions to check package repository and
1477 # find which packages to cook.
1478 ########################
1480 # Actually its becomes more than check commit... Maybe put this in report
1481 # function is a good idea.
1482 check_for_commit()
1484 report step "Checking for commits"
1486 # Clean the list... Later we will perfom a partial clean only to keep
1487 # some usefull informations
1488 rm $PACKAGES_REPOSITORY/commit 2>/dev/null
1490 # If there's a packages-incoming repository we need to check it too.
1491 for RECEIPT in $(echo $WOK/*/receipt | fgrep -v '*'); do
1492 source_receipt
1494 # We use md5 of cooking stuff in the packaged receipt to check
1495 # commit. We look consecutively in 3 different locations :
1496 # - in the wok/PACKAGE/taz folder
1497 # - in the receipt in the package in incoming repository
1498 # - in the receipt in the package in packages repository
1499 # If md5sum match, there's no commit.
1500 # If there's not md5sum datas, because the package was cooked
1501 # with a previous version of tazwok, we don't put in in commit
1502 # list (need a cook-all to refresh them)
1503 # If there's no receipt available, package is missing so we put
1504 # it in commit list.
1505 # First look for package in packages-incoming.
1506 check_for_commit_using_md5sum()
1508 if [ ! -f $WOK/$PACKAGE/md5 ]; then
1509 sed -n '/# md5sum of cooking stuff :/,$p' receipt | \
1510 sed -e 1d -e 's/^# //' > $WOK/$PACKAGE/md5
1511 cd $WOK/$PACKAGE
1512 fi
1514 # Use md5sum list in receipt to check for commit.
1515 if [ -s md5 ]; then
1516 if md5sum -cs md5; then
1517 return_code=0
1519 # If md5sum check if ok, check for new files in
1520 # cooking stuff.
1521 for file in receipt description.txt $( [ -d stuff ] && find stuff); do
1522 if [ -f $file ] && ! fgrep -q " $file" md5; then
1523 set_commited
1524 fi
1525 done
1526 else
1527 set_commited
1528 fi
1529 else
1530 gen_cookmd5
1531 fi
1533 set_commited()
1535 echo $PACKAGE >> $PACKAGES_REPOSITORY/commit
1536 echo "Commit: $PACKAGE ($VERSION)"
1537 gen_cookmd5
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 continue
1554 fi
1555 set_commited
1556 fi
1557 done
1558 report end-step
1561 gen_cook_list()
1563 if [ -s $PACKAGES_REPOSITORY/commit ]; then
1564 report step "Generate genpkg & cook lists."
1565 cd $PACKAGES_REPOSITORY
1566 #cp commit $tmp/commit
1567 #if [ -s broken ]; then
1568 ## dep_scan return deps including the packages given in argument.
1569 ## To avoid that, we firt generate a list of direct rdepends of
1570 ## brokens without packages in argument, then we generate the
1571 ## full rdeps list. We do this because we don't want to block
1572 ## packages at source of broken tree if a fix as been commited.
1573 #for PACKAGE in $(cat broken); do
1574 #look_for_rdep >> $tmp/broken
1575 #done
1576 #cat $tmp/broken
1577 #look_for=rdep && with_wanted=yes
1578 #for PACKAGE in $(dep_scan `cat $tmp/broken`); do
1579 #if grep -q ^$PACKAGE$ $tmp/commit; then
1580 #sed "/^$PACKAGE$/d" -i $tmp/commit
1581 #fi
1582 #done
1583 #rm $tmp/broken
1584 #fi
1585 for PACKAGE in $(cat commit); do
1586 WANTED="$(look_for_wanted)"
1587 if [ "$WANTED" ]; then
1589 # If cook of wanted package is planned, this one will be
1590 # packaged at the same time. Else if wanted package is
1591 # broken or blocked, ignore the commit. Else, put the
1592 # package in genpkglist.
1593 { grep -q ^$WANTED$ commit || grep -q ^$WANTED$ broken || \
1594 grep -q ^$WANTED$ cooklist || grep -q ^$WANTED$ blocked || \
1595 grep -q ^$WANTED$ genpkglist
1596 } && continue
1597 echo $WANTED >> genpkglist
1598 else
1599 { grep -q ^$PACKAGE$ blocked || grep -q ^$PACKAGE$ cooklist
1600 } && continue
1601 echo $PACKAGE >> cooklist
1602 sed "/^$PACKAGE$/d" -i broken
1603 fi
1604 done
1605 #rm $tmp/commit
1606 if [ -s genpkglist ]; then
1607 echo "genpkglist:"
1608 cat genpkglist
1609 fi
1610 report end-step
1611 fi
1612 cooklist=$PACKAGES_REPOSITORY/cooklist
1613 sort_cooklist
1616 sort_cooklist()
1618 [ ! "$cooklist" ] && cooklist=$PACKAGES_REPOSITORY/cooklist
1619 [ -s $cooklist ] || [ -s "$tmp/cooklist" ] || return
1620 [ -s $PACKAGES_REPOSITORY/cookorder.txt ] || gen_wok_db
1621 [ ! -s "$tmp/cooklist" ] && cp -a $cooklist $tmp/cooklist
1622 report step "Sorting cooklist"
1624 # Use cookorder.txt to sort cooklist.
1625 cat $PACKAGES_REPOSITORY/cookorder.txt | while read PACKAGE; do
1626 if grep -q ^$PACKAGE$ $tmp/cooklist; then
1627 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1628 echo $PACKAGE >> $tmp/cooklist.tmp
1629 fi
1630 done
1632 # Remaining packages in cooklist are thoses without compile_rules.
1633 # They can be cooked first in any order.
1634 mv -f $tmp/cooklist.tmp $tmp/cooklist
1635 [ "$cooklist" = "$PACKAGES_REPOSITORY/cooklist" ] && \
1636 cat $tmp/cooklist > $cooklist
1637 cat $tmp/cooklist
1638 report end-step
1641 check_for_incoming()
1643 [ -s $INCOMING_REPOSITORY/packages.txt ] || return
1644 report step "Checking packages-incoming repository"
1645 cd $INCOMING_REPOSITORY
1646 grep ^[0-9,a-z,A-Z] packages.txt > $tmp/incoming
1647 scan `cat $PACKAGES_REPOSITORY/broken` --look_for=bdep --with_wanted > $tmp/broken
1648 for PACKAGE in $(scan `cat $tmp/broken` --look_for=rdep --with_wanted --with_args); do
1649 sed "/^$PACKAGE$/d" -i $tmp/incoming
1650 for rwanted in $(look_for_rwanted); do
1651 sed "/^$rwanted$/d" -i $tmp/incoming
1652 done
1653 done
1654 rm $tmp/broken
1655 if [ "$incoming_delay" != 0 ]; then
1656 cat $tmp/incoming | while read PACKAGE; do
1657 [ "$(grep ^$PACKAGE$ $tmp/incoming)" ] || continue
1658 dep_list=$( { scan $PACKAGE --look_for=bdep --with_wanted && \
1659 scan $PACKAGE --look_for=rdep --with_wanted --with_args; } \
1660 | sort -u )
1661 for dep in $dep_list; do
1662 [ "$(find -name "`get_pkg_version $INCOMING_REPOSITORY`.tazpkg" -mtime +$incoming_delay)" ] && continue
1663 for pkg in $dep_list; do
1664 sed "/^$pkg$/d" -i $tmp/incoming
1665 done && break
1666 done
1667 done
1668 fi
1669 if [ -s "$tmp/incoming" ]; then
1670 for PACKAGE in $(cat $tmp/incoming); do
1671 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
1672 remove_previous_package $PACKAGES_REPOSITORY
1673 remove_previous_tarball
1674 cur_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
1675 mv -f $PACKAGE-$cur_VERSION.tazpkg $PACKAGES_REPOSITORY
1676 echo "Moving $PACKAGE to main repository."
1677 done
1678 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
1679 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
1680 fi
1681 report end-step
1684 ########################################################################
1685 # TAZWOK MAIN FUNCTIONS
1686 ########################
1688 clean()
1690 cd $WOK/$PACKAGE
1691 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
1692 -e ^stuff$ || return
1694 report step "Cleaning $PACKAGE"
1695 # Check for clean_wok function.
1696 if grep -q ^clean_wok $RECEIPT; then
1697 clean_wok
1698 fi
1699 # Clean should only have a receipt, stuff and optional desc.
1700 for f in `ls .`
1701 do
1702 case $f in
1703 receipt|stuff|description.txt)
1704 continue ;;
1705 *)
1706 echo "Removing: $f"
1707 rm -rf $f
1708 esac
1709 done
1710 report end-step
1713 # Configure and make a package with the receipt.
1714 compile_package()
1716 check_for_package_on_cmdline
1718 # Include the receipt to get all needed variables and functions
1719 # and cd into the work directory to start the work.
1720 check_for_receipt
1721 source_receipt
1723 # Log the package name and date.
1724 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
1725 echo "package $PACKAGE (compile)" >> $LOG
1727 # Set wanted $src variable to help compiling.
1728 [ ! "$src" ] && set_src_path
1729 check_for_build_depends || return 1
1730 check_for_wanted
1731 unset target
1732 check_for_tarball && check_for_compile_rules
1735 # Cook command also include all features to manage lists which keep
1736 # track of wok/packages state.
1737 cook()
1739 cook_code=
1740 set_common_path
1741 check_for_receipt
1742 source_receipt
1744 # Define log path and start report.
1745 [ -f $LOCAL_REPOSITORY/log/$PACKAGE.html ] && rm $LOCAL_REPOSITORY/log/$PACKAGE.html
1746 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
1747 report step "Cooking $PACKAGE"
1748 report open-bloc
1750 # Clean package if needed.
1751 clean $PACKAGE
1753 # Remove PACKAGE from commit & cook lists.
1754 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/commit
1755 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/cooklist
1756 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
1758 if compile_package; then
1759 refresh_packages_from_compile
1760 gen_package
1761 remove_src
1763 # Plan recook of reverse build depends if gen_package has detect
1764 # a change in libraries.
1765 if [ "$cook_rdep" ]; then
1766 report step "Look for packages which need a refresh"
1767 for rdep in $(scan $PACKAGE --look_for=rdep); do
1768 sed "/^$rdep$/d" -i $PACKAGES_REPOSITORY/broken
1769 if [ -f $WOK/$rdep/receipt ] && ! grep -q ^$rdep$ $tmp/cooklist; then
1770 echo "Add $rdep in cooklist to avoid broke caused by library update in $PACKAGE"
1771 echo $rdep >> $tmp/cooklist
1772 regen_cooklist=yes
1773 fi
1774 done
1775 report end-step
1776 fi
1778 # Update packages-incoming repository.
1779 store_pkgname=$PACKAGE
1780 pkg_repository=$INCOMING_REPOSITORY
1781 update_packages_db
1783 PACKAGE=$store_pkgname
1784 unset store_pkgname
1786 # Upgrade to cooked packages if it was previously installed.
1787 report step "Look for package(s) to upgrade"
1788 for pkg in $(look_for_rwanted) $PACKAGE; do
1789 if [ -d $INSTALLED/$pkg ]; then
1790 tazpkg get-install $pkg --forced
1791 fi
1792 done
1793 report end-step
1794 else
1796 # Set package as broken.
1797 if ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then
1798 echo $PACKAGE >> $PACKAGES_REPOSITORY/broken
1799 fi
1800 gen_cookmd5
1801 cook_code=1
1802 fi
1804 # Remove build_depends in cook mode (if in cooklist, it's done when
1805 # checking build_depends of next package and we remove only unneeded
1806 # packages to keep chroot minimal and gain some time).
1807 [ "$COMMAND" = cook ] && remove_build_depends $MISSING_PACKAGE
1809 # Regen the cooklist if it was planned and command is not cook.
1810 [ "$regen_cooklist" ] && unset regen_cooklist && \
1811 [ "$COMMAND" != cook ] && sort_cooklist
1813 # Some hacks to set the bloc & function status as failed if cook was
1814 # failed.
1815 report_return_code=$cook_code
1816 report close-bloc
1817 report end-sublog
1818 return $cook_code
1821 genpkg_list()
1823 while [ -s $PACKAGES_REPOSITORY/genpkglist ]; do
1824 PACKAGE=$(sed 1!d $PACKAGES_REPOSITORY/genpkglist)
1825 gen_package
1826 done
1829 cook_list()
1831 if [ ! -s $cooklist ]; then
1832 echo "Nothing to cook."
1833 return
1834 fi
1835 if [ -f /usr/bin/tazchroot ]; then
1836 # Note : options -main variables- are automatically keeped by
1837 # the sub-applications tazchroot/tazwok; as well as report data.
1838 cd $LOCAL_REPOSITORY
1839 [ ! -f tazchroot.conf ] && configure_tazchroot
1840 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
1841 return
1842 fi
1843 while [ -s $tmp/cooklist ]; do
1844 PACKAGE=$(sed 1!d $tmp/cooklist)
1845 cook
1846 done
1847 remove_build_depends $MISSING_PACKAGE $remove_later
1850 configure_tazchroot()
1852 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
1853 # Tazchroot configuration file - created by tazwok.
1855 # Default chroot path
1856 SLITAZ_DIR=$SLITAZ_DIR
1857 SLITAZ_VERSION=$SLITAZ_VERSION
1858 $( [ "$undigest" ] && echo "undigest=$undigest" )
1859 LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
1860 chroot_dir=\$LOCAL_REPOSITORY/chroot
1862 # Default scripts path (theses scripts are added in the
1863 # $chroot_dir/usr/bin and can be called with tazchroot script)
1864 script_dir=/var/lib/tazchroot
1866 # List of directories to mount.
1867 list_dir="$(for dir in packages wok src packages-incoming log flavors iso; do echo $LOCAL_REPOSITORY/$dir; done)
1868 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
1870 create_chroot()
1872 mkdir -p \$chroot_dir
1873 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
1874 tazpkg get-install \$pkg --root="\$chroot_dir"
1875 done
1877 # Store list of installed packages needed by cleanchroot.
1878 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
1880 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
1881 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
1882 -i \$chroot_dir/etc/slitaz/slitaz.conf
1883 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
1884 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
1887 mount_chroot()
1889 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
1890 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCALSTATE/mirror
1891 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
1892 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
1893 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION
1894 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror' )
1895 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
1896 mount -t proc proc \$chroot_dir/proc
1897 mount -t sysfs sysfs \$chroot_dir/sys
1898 mount -t devpts devpts \$chroot_dir/dev/pts
1899 mount -t tmpfs shm \$chroot_dir/dev/shm
1900 for dir in \$list_dir; do
1901 mkdir -p \$dir \$chroot_dir\$dir
1902 mount \$dir \$chroot_dir\$dir
1903 done
1906 umount_chroot()
1908 for dir in \$list_dir; do
1909 umount \$chroot_dir\$dir
1910 done
1911 umount \$chroot_dir/dev/shm
1912 umount \$chroot_dir/dev/pts
1913 umount \$chroot_dir/sys
1914 umount \$chroot_dir/proc
1916 EOF
1919 ########################################################################
1920 ######################### END OF NEW FUNCTIONS #########################
1921 ########################################################################
1923 # List packages providing a virtual package
1924 whoprovide()
1926 local i;
1927 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
1928 . $i
1929 case " $PROVIDE " in
1930 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
1931 esac
1932 done
1935 ########################################################################
1936 # TAZWOK COMMANDS
1937 ########################
1939 case "$COMMAND" in
1940 stats)
1941 # Tazwok general statistics from the wok config file.
1943 get_tazwok_config
1944 echo -e "\n\033[1mTazwok configuration statistics\033[0m
1945 ================================================================================
1946 Wok directory : $WOK
1947 Packages repository : $PACKAGES_REPOSITORY
1948 Incoming repository : $INCOMING_REPOSITORY
1949 Sources repository : $SOURCES_REPOSITORY
1950 Log directory : $LOCAL_REPOSITORY/log
1951 Packages in the wok : `ls -1 $WOK | wc -l`
1952 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
1953 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
1954 ================================================================================\n"
1955 ;;
1956 edit)
1957 get_tazwok_config
1958 check_for_package_on_cmdline
1959 check_for_receipt
1960 $EDITOR $WOK/$PACKAGE/receipt
1961 ;;
1962 build-depends)
1963 # List dependencies to rebuild wok, or only a package
1964 get_tazwok_config
1965 if [ "$PACKAGE" = toolchain-cooklist ]; then
1966 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1967 --cooklist
1968 elif [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
1969 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1970 --look_for=dep --with_dev --with_args
1971 else
1972 check_for_package_on_cmdline
1973 scan $PACKAGE --look_for=bdep --with_dev
1974 fi
1975 ;;
1976 gen-cooklist)
1977 get_options_list="list"
1978 get_tazwok_config
1979 if [ "$list" ]; then
1980 LIST="$list"
1981 check_for_list
1982 else
1983 LIST=$(for pkg in $@; do
1984 [ "$pkg" = "${pkg#--}" ] || continue
1985 echo -n "$pkg "
1986 done)
1987 if [ ! "$LIST" ]; then
1988 echo "Please give packages or a list file in argument." >&2
1989 exit
1990 fi
1991 fi
1992 scan $LIST --cooklist
1993 ;;
1994 check-depends)
1995 # Check package depends /!\
1996 get_tazwok_config
1997 echo ""
1998 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
1999 ================================================================================"
2000 TMPDIR=/tmp/tazwok$$
2001 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
2003 # Build ALL_DEPENDS variable
2004 scan_dep()
2006 local i
2007 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
2008 for i in $DEPENDS $SUGGESTED ; do
2009 case " $ALL_DEPENDS " in
2010 *\ $i\ *) continue;;
2011 esac
2012 [ -d $WOK/$i ] || {
2013 ALL_DEPENDS="$ALL_DEPENDS$i "
2014 continue
2016 DEPENDS=""
2017 SUGGESTED=""
2018 . $WOK/$i/receipt
2019 scan_dep
2020 done
2023 # Check for ELF file
2024 is_elf()
2026 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" \
2027 = "ELF" ]
2030 # Print shared library dependencies
2031 ldd()
2033 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
2036 mkdir $TMPDIR
2037 cd $TMPDIR
2038 for i in $LOCALSTATE/files.list.lzma \
2039 $LOCALSTATE/undigest/*/files.list.lzma ; do
2040 [ -f $i ] && lzma d $i -so >> files.list
2041 done
2042 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
2043 tazpkg extract $pkg > /dev/null 2>&1
2044 . */receipt
2045 ALL_DEPENDS="$DEFAULT_DEPENDS "
2046 scan_dep
2047 find */fs -type f | while read file ; do
2048 is_elf $file || continue
2049 case "$file" in
2050 *.o|*.ko|*.ko.gz) continue;;
2051 esac
2052 ldd $file | while read lib rem; do
2053 case "$lib" in
2054 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
2055 continue;;
2056 esac
2057 for dep in $(fgrep $lib files.list | cut -d: -f1); do
2058 case " $ALL_DEPENDS " in
2059 *\ $dep\ *) continue 2;;
2060 esac
2061 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
2062 case " $ALL_DEPENDS " in
2063 *\ $vdep\ *) continue 3;;
2064 esac
2065 done
2066 done
2067 [ -n "$dep" ] || dep="UNKNOWN"
2068 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
2069 done
2070 done
2071 rm -rf */
2072 done
2073 cd /tmp
2074 rm -rf $TMPDIR
2075 ;;
2076 check)
2077 # Check wok consistency
2078 get_tazwok_config
2079 echo ""
2080 echo -e "\033[1mWok and packages checking\033[0m
2081 ================================================================================"
2082 cd $WOK
2083 for pkg in $(ls)
2084 do
2085 [ -f $pkg/receipt ] || continue
2086 RECEIPT= $pkg/receipt
2087 source_receipt
2088 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
2089 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
2090 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
2091 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
2092 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
2093 if [ -n "$WANTED" ]; then
2094 if [ ! -f $WANTED/receipt ]; then
2095 echo "Package $PACKAGE wants unknown $WANTED package" >&2
2096 else
2097 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
2098 if [ "$VERSION" = "$WANTED" ]; then
2099 # BASEVERSION is computed in receipt
2100 fgrep -q '_pkg=' $pkg/receipt &&
2101 BASEVERSION=$VERSION
2102 fi
2103 if [ "$VERSION" != "$BASEVERSION" ]; then
2104 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
2105 fi
2106 fi
2107 fi
2109 if [ -n "$CATEGORY" ]; then
2110 case " $(echo $CATEGORIES) " in
2111 *\ $CATEGORY\ *);;
2112 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
2113 esac
2114 else
2115 echo"Package $PACKAGE has no CATEGORY" >&2
2116 fi
2117 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
2118 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
2119 case "$WGET_URL" in
2120 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
2121 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
2122 '') ;;
2123 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
2124 esac
2125 case "$WEB_SITE" in
2126 ftp*|http*);;
2127 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
2128 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
2129 esac
2130 case "$MAINTAINER" in
2131 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
2132 esac
2133 case "$MAINTAINER" in
2134 *@*);;
2135 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
2136 esac
2137 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2138 for i in $DEPENDS; do
2139 [ -d $i ] && continue
2140 [ -n "$(whoprovide $i)" ] && continue
2141 echo -e "$MSG $i"
2142 MSG=""
2143 done
2144 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2145 for i in $BUILD_DEPENDS; do
2146 [ -d $i ] && continue
2147 [ -n "$(whoprovide $i)" ] && continue
2148 echo -e "$MSG $i"
2149 MSG=""
2150 done
2151 MSG="Dependencies loop between $PACKAGE and :\n"
2152 ALL_DEPS=""
2153 check_for_deps_loop $PACKAGE $DEPENDS
2154 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
2155 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
2156 echo "$pkg should be rebuilt after $i installation"
2157 done
2158 done
2159 ;;
2160 list)
2161 # List packages in wok directory. User can specify a category.
2163 get_tazwok_config
2164 if [ "$2" = "category" ]; then
2165 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
2166 exit 0
2167 fi
2168 # Check for an asked category.
2169 if [ -n "$2" ]; then
2170 ASKED_CATEGORY=$2
2171 echo ""
2172 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
2173 echo "================================================================================"
2174 for pkg in $WOK/*
2175 do
2176 [ ! -f $pkg/receipt ] && continue
2177 . $pkg/receipt
2178 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
2179 echo -n "$PACKAGE"
2180 echo -e "\033[28G $VERSION"
2181 packages=$(($packages+1))
2182 fi
2183 done
2184 echo "================================================================================"
2185 echo -e "$PACKAGEs packages in category $ASKED_CATEGORY.\n"
2186 else
2187 # By default list all packages and version.
2188 echo ""
2189 echo -e "\033[1mList of packages in the wok\033[0m"
2190 echo "================================================================================"
2191 for pkg in $WOK/*
2192 do
2193 [ ! -f $pkg/receipt ] && continue
2194 . $pkg/receipt
2195 echo -n "$PACKAGE"
2196 echo -en "\033[28G $VERSION"
2197 echo -e "\033[42G $CATEGORY"
2198 packages=$(($packages+1))
2199 done
2200 echo "================================================================================"
2201 echo -e "$PACKAGEs packages available in the wok.\n"
2202 fi
2203 ;;
2204 info)
2205 # Information about a package.
2207 get_tazwok_config
2208 check_for_package_on_cmdline
2209 check_for_receipt
2210 . $WOK/$PACKAGE/receipt
2211 echo ""
2212 echo -e "\033[1mTazwok package information\033[0m
2213 ================================================================================
2214 Package : $PACKAGE
2215 Version : $VERSION
2216 Category : $CATEGORY
2217 Short desc : $SHORT_DESC
2218 Maintainer : $MAINTAINER"
2219 if [ ! "$WEB_SITE" = "" ]; then
2220 echo "Web site : $WEB_SITE"
2221 fi
2222 if [ ! "$DEPENDS" = "" ]; then
2223 echo "Depends : $DEPENDS"
2224 fi
2225 if [ ! "$WANTED" = "" ]; then
2226 echo "Wanted src : $WANTED"
2227 fi
2228 echo "================================================================================"
2229 echo ""
2230 ;;
2231 check-log)
2232 # We just cat the file log to view process info.
2234 get_tazwok_config
2235 if [ ! -f "$LOG" ]; then
2236 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
2237 exit 1
2238 else
2239 echo ""
2240 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
2241 echo "================================================================================"
2242 cat $LOG
2243 echo "================================================================================"
2244 echo ""
2245 fi
2246 ;;
2247 search)
2248 # Search for a package by pattern or name.
2250 get_tazwok_config
2251 if [ -z "$2" ]; then
2252 echo -e "\nPlease specify a pattern or a package name to search." >&2
2253 echo -e "Example : 'tazwok search gcc'.\n" >&2
2254 exit 1
2255 fi
2256 echo ""
2257 echo -e "\033[1mSearch result for :\033[0m $2"
2258 echo "================================================================================"
2259 list=`ls -1 $WOK | fgrep $2`
2260 for pkg in $list
2261 do
2262 . $WOK/$pkg/receipt
2263 echo -n "$PACKAGE "
2264 echo -en "\033[24G $VERSION"
2265 echo -e "\033[42G $CATEGORY"
2266 packages=$(($PACKAGEs+1))
2267 done
2268 echo "================================================================================"
2269 echo "$PACKAGEs packages found for : $2"
2270 echo ""
2271 ;;
2272 compile)
2273 # Configure and make a package with the receipt.
2275 get_tazwok_config
2276 source_lib report
2277 report start
2278 compile_package
2279 ;;
2280 genpkg)
2281 # Generate a package.
2283 get_tazwok_config
2284 source_lib report
2285 report start
2286 gen_package
2287 ;;
2288 cook)
2289 # Compile and generate a package. Just execute tazwok with
2290 # the good commands.
2292 check_root
2293 get_tazwok_config
2294 source_lib report
2295 report start
2296 cook
2297 ;;
2298 sort-cooklist)
2299 if [ ! "$LIST" ]; then
2300 echo "Usage : tazwok sort-cooklist cooklist" >&2\
2301 exit 1
2302 fi
2303 get_tazwok_config
2304 source_lib report
2305 report start
2306 cooklist=$LIST
2307 sort_cooklist
2308 cp -af $tmp/cooklist $cooklist
2309 ;;
2310 cook-list)
2311 # Cook all packages listed in a file. The path to the cooklist must
2312 # be specified on the cmdline.
2313 # /!\
2314 check_root
2315 get_tazwok_config
2316 source_lib report
2317 report start
2318 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2319 if [ "$LIST" ]; then
2320 sort_cooklist
2321 else
2322 cp $cooklist $tmp/cooklist
2323 fi
2324 cook_list
2325 ;;
2326 clean)
2327 # Clean up a package work directory + thoses which want it.
2329 get_tazwok_config
2330 check_for_package_on_cmdline
2331 check_for_receipt
2332 source_lib report
2333 report start
2334 . $RECEIPT
2335 clean
2336 ;;
2337 gen-clean-wok)
2338 # Generate a clean wok from the current wok by copying all receipts
2339 # and stuff directory.
2341 get_tazwok_config
2342 source_lib report
2343 report start
2344 if [ -z "$ARG" ]; then
2345 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
2346 exit 1
2347 else
2348 dest=$ARG
2349 mkdir -p $dest
2350 fi
2351 report step "Creating clean wok in : $dest"
2352 for pkg in `ls -1 $WOK`
2353 do
2354 mkdir -p $dest/$pkg
2355 cp -a $WOK/$pkg/receipt $dest/$pkg
2356 [ -f $WOK/$pkg/description.txt ] && \
2357 cp -a $WOK/$pkg/description.txt $dest/$pkg
2358 if [ -d "$WOK/$pkg/stuff" ]; then
2359 cp -a $WOK/$pkg/stuff $dest/$pkg
2360 fi
2361 done
2362 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
2363 report end-step
2364 echo "Packages cleaned : `ls -1 $dest | wc -l`"
2365 echo ""
2366 ;;
2367 clean-wok)
2368 # Clean all packages in the work directory
2370 get_tazwok_config
2371 source_lib report
2372 report start
2373 report step "Cleaning wok"
2374 report open-bloc
2375 for PACKAGE in `ls -1 $WOK`
2376 do
2377 set_common_path
2378 source_receipt
2379 clean
2380 done
2381 report close-bloc
2382 echo "`ls -1 $WOK | wc -l` packages cleaned."
2383 ;;
2384 gen-list)
2385 check_root
2386 get_tazwok_config
2387 source_lib report
2388 report start
2389 dbtype=packages
2390 mode=gen
2391 for pkg_repository in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
2392 files_list="$pkg_repository/files.list.lzma \
2393 $pkg_repository/packages.list \
2394 $pkg_repository/packages.txt \
2395 $pkg_repository/packages.desc \
2396 $pkg_repository/packages.equiv \
2397 $pkg_repository/packages.md5"
2398 gen_db
2399 echo "$pkgs packages in the repository."
2400 echo ""
2401 done
2402 ;;
2403 check-list)
2404 # The directory to move into by default is the repository,
2405 # if $2 is not empty cd into $2.
2407 get_tazwok_config
2408 if [ -z "$2" ]; then
2409 PACKAGES_REPOSITORY=$PACKAGES_REPOSITORY
2410 else
2411 if [ -d "$2" ]; then
2412 PACKAGES_REPOSITORY=$2
2413 else
2414 echo -e "\nUnable to find directory : $2\n" >&2
2415 exit 1
2416 fi
2417 fi
2419 # Use report shared library to control output.
2420 tmp=/tmp/tazwok-$$
2421 source_lib report
2422 dbtype=packages
2423 mode=update
2424 cd $PACKAGES_REPOSITORY
2425 for pkg in $(echo *.tazpkg); do
2426 package_md5=$(md5sum $pkg)
2427 [ "$package_md5" = "$(fgrep " $pkg" packages.md5)" ] && continue
2428 erase_package_info
2429 get_packages_info
2430 done
2431 echo "$pkgs packages in the repository."
2432 echo ""
2433 ;;
2434 new-tree)
2435 # Just create a few directories and generate an empty receipt to prepare
2436 # the creation of a new package.
2438 get_tazwok_config
2439 check_for_package_on_cmdline
2440 if [ -d $WOK/$PACKAGE ]; then
2441 echo -e "\n$PACKAGE package tree already exists.\n" >&2
2442 exit 1
2443 fi
2444 echo "Creating : $WOK/$PACKAGE"
2445 mkdir $WOK/$PACKAGE
2446 cd $WOK/$PACKAGE
2447 echo -n "Preparing the receipt..."
2449 # Default receipt begin.
2451 echo "# SliTaz package receipt." > receipt
2452 echo "" >> receipt
2453 echo "PACKAGE=\"$PACKAGE\"" >> receipt
2454 # Finish the empty receipt.
2455 cat >> receipt << "EOF"
2456 VERSION=""
2457 CATEGORY=""
2458 SHORT_DESC=""
2459 MAINTAINER=""
2460 DEPENDS=""
2461 TARBALL="$PACKAGE-$VERSION.tar.gz"
2462 WEB_SITE=""
2463 WGET_URL=""
2465 # Rules to configure and make the package.
2466 compile_rules()
2468 cd $src
2469 ./configure \
2470 --prefix=/usr \
2471 --infodir=/usr/share/info \
2472 --mandir=/usr/share/man \
2473 $CONFIGURE_ARGS &&
2474 make -j 4 && make DESTDIR=$PWD/_pkg install
2477 # Rules to gen a SliTaz package suitable for Tazpkg.
2478 genpkg_rules()
2480 mkdir -p $fs/usr
2481 cp -a $_pkg/usr/bin $fs/usr
2484 EOF
2486 # Default receipt end.
2488 status
2489 # Interactive mode, asking and seding.
2490 if [ "$3" = "--interactive" ]; then
2491 echo "Entering into interactive mode..."
2492 echo "================================================================================"
2493 echo "Package : $PACKAGE"
2494 # Version.
2495 echo -n "Version : " ; read anser
2496 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
2497 # Category.
2498 echo -n "Category : " ; read anser
2499 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
2500 # Short description.
2501 echo -n "Short desc : " ; read anser
2502 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
2503 # Maintainer.
2504 echo -n "Maintainer : " ; read anser
2505 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
2506 # Web site.
2507 echo -n "Web site : " ; read anser
2508 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
2509 echo ""
2510 # Wget URL.
2511 echo "Wget URL to download source tarball."
2512 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
2513 echo -n "Wget url : " ; read anser
2514 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
2515 # Ask for a stuff dir.
2516 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
2517 if [ "$anser" = "y" ]; then
2518 echo -n "Creating the stuff directory..."
2519 mkdir stuff && status
2520 fi
2521 # Ask for a description file.
2522 echo -n "Are you going to write a description ? (y/N) : " ; read anser
2523 if [ "$anser" = "y" ]; then
2524 echo -n "Creating the description.txt file..."
2525 echo "" > description.txt && status
2526 fi
2527 echo "================================================================================"
2528 echo ""
2529 fi
2530 ;;
2531 remove)
2532 # Remove a package from the wok.
2534 get_tazwok_config
2535 check_for_package_on_cmdline
2536 echo ""
2537 echo -n "Please confirm deletion (y/N) : "; read anser
2538 if [ "$anser" = "y" ]; then
2539 echo -n "Removing $PACKAGE..."
2540 rm -rf $WOK/$PACKAGE && status
2541 echo ""
2542 fi
2543 ;;
2544 hgup)
2545 # Pull and update a Hg wok.
2546 get_tazwok_config
2547 if ls -l $WOK/.hg/hgrc | fgrep -q "root"; then
2548 check_root
2549 fi
2550 cd $WOK
2551 hg pull && hg update
2552 ;;
2553 maintainers)
2554 get_tazwok_config
2555 echo ""
2556 echo "List of maintainers for: $WOK"
2557 echo "================================================================================"
2558 touch /tmp/slitaz-maintainers
2559 for pkg in $WOK/*
2560 do
2561 . $pkg/receipt
2562 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
2563 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
2564 echo "$MAINTAINER"
2565 fi
2566 done
2567 echo "================================================================================"
2568 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
2569 echo ""
2570 # Remove tmp files
2571 rm -f /tmp/slitaz-maintainers
2572 ;;
2573 maintained-by)
2574 # Search for packages maintained by a contributor.
2575 get_tazwok_config
2576 if [ ! -n "$2" ]; then
2577 echo "Specify a name or email of a maintainer." >&2
2578 exit 1
2579 fi
2580 echo "Maintainer packages"
2581 echo "================================================================================"
2582 for pkg in $WOK/*
2583 do
2584 . $pkg/receipt
2585 if echo "$MAINTAINER" | fgrep -q "$2"; then
2586 echo "$PACKAGE"
2587 packages=$(($PACKAGEs+1))
2588 fi
2589 done
2590 echo "================================================================================"
2591 echo "Packages maintained by $2: $PACKAGEs"
2592 echo ""
2593 ;;
2594 check-src)
2595 # Verify if upstream package is still available
2597 get_tazwok_config
2598 check_for_package_on_cmdline
2599 check_for_receipt
2600 source_receipt
2601 check_src()
2603 for url in $@; do
2604 busybox wget -s $url 2>/dev/null && break
2605 done
2607 if [ "$WGET_URL" ];then
2608 echo -n "$PACKAGE : "
2609 check_src $WGET_URL
2610 status
2611 else
2612 echo "No tarball to check for $PACKAGE"
2613 fi
2614 ;;
2615 get-src)
2616 check_root
2617 get_options_list="target"
2618 get_tazwok_config
2619 check_for_package_on_cmdline
2620 check_for_receipt
2621 source_receipt
2622 if [ "$WGET_URL" ];then
2623 source_lib report
2624 report start
2625 check_for_tarball
2626 else
2627 echo "No tarball to download for $PACKAGE"
2628 fi
2629 ;;
2630 rec-commit)
2631 check_root
2632 get_tazwok_config
2633 source_lib report
2634 report start
2635 check_for_commit
2636 gen_cook_list
2637 ;;
2638 cook-commit)
2639 check_root
2640 get_tazwok_config
2641 source_lib report
2642 report start
2643 check_for_commit
2644 # 2) update cook-database (actually complete regeneration)
2645 dbtype=wok
2646 mode=gen
2647 files_list="$dep_db $wan_db $PACKAGE_REPOSITORY/cookorder.txt"
2648 gen_db
2649 # 3) check cooklist
2650 # 3.1) rename pkgs with wanted variable to wanted pkg
2651 gen_cook_list
2652 cook_list
2653 ;;
2654 cook-all)
2655 check_root
2656 get_tazwok_config
2657 source_lib report
2658 report start
2659 # 2) update cook-database (actually complete regeneration)
2660 dbtype=wok
2661 mode=gen
2662 files_list="$dep_db $wan_db $PACKAGE_REPOSITORY/cookorder.txt"
2663 gen_db
2664 # Add all packages, without toolchain, in cooklist.
2665 # Recook toolchain need to be coded.
2666 echo -n "" > $PACKAGES_REPOSITORY/cooklist
2667 for pkg in $(cd $WOK && echo *); do
2668 echo $pkg >> $PACKAGES_REPOSITORY/cooklist
2669 done
2670 for pkg in $(scan gcc --look_for=all --with_wanted --with_args); do
2671 sed "/^$pkg$/d" -i $PACKAGES_REPOSITORY/cooklist
2672 done
2673 sort_cooklist
2674 cook_list
2675 ;;
2676 gen-wok-db)
2677 check_root
2678 get_tazwok_config
2679 source_lib report
2680 report start
2681 dbtype=wok
2682 mode=gen
2683 files_list="$dep_db $wan_db $PACKAGE_REPOSITORY/cookorder.txt"
2684 gen_db
2685 ;;
2686 report)
2687 check_root
2688 get_tazwok_config
2689 cd $PACKAGES_REPOSITORY
2690 for i in commit genpkglist cooklist incoming broken blocked; do
2691 if [ -s $i ]; then
2692 echo -e "\n********************* $i *********************\n$(cat $i)\n*********************"
2693 fi
2694 done
2695 ;;
2696 check-incoming)
2697 check_root
2698 get_tazwok_config
2699 source_lib report
2700 report start
2701 check_for_incoming
2702 ;;
2703 configure-chroot)
2704 check_root
2705 get_tazwok_config
2706 if [ -f /usr/bin/tazchroot ]; then
2707 cd $LOCAL_REPOSITORY
2708 configure_tazchroot
2709 else
2710 echo "The packages tazchroot need to be installed" >&2
2711 exit 1
2712 fi
2713 ;;
2714 chroot)
2715 check_root
2716 get_tazwok_config
2717 # Merge this and the other chroot function ?.
2718 if [ -f /usr/bin/tazchroot ]; then
2719 cd $LOCAL_REPOSITORY
2720 [ ! -f tazchroot.conf ] && configure_tazchroot
2721 tazchroot
2722 else
2723 echo "The packages tazchroot need to be installed" >&2
2724 exit 1
2725 fi
2726 ;;
2727 cook-toolchain)
2728 check_root
2729 get_tazwok_config
2730 echo -n "" > $PACKAGES_REPOSITORY/broken
2731 if [ -f /usr/bin/tazchroot ]; then
2732 cd $LOCAL_REPOSITORY
2733 [ ! -f tazchroot.conf ] && configure_tazchroot
2734 tazchroot cook-toolchain
2735 # Buggy : chroot can be elsewhere.
2736 rm -r $LOCAL_REPOSITORY/chroot
2737 # /!\ to be writed :
2738 # next rm chroot and plan cook-all by pushing all packages
2739 # in cooklist.
2740 else
2741 echo "The packages tazchroot need to be installed" >&2
2742 exit 1
2743 fi
2744 ;;
2745 usage|*)
2746 # Print usage also for all unknown commands.
2748 usage
2749 ;;
2750 esac
2752 [ -d "$tmp" ] && rm -r $tmp
2753 report stop 2>/dev/null || exit 0