tazwok view tazwok @ rev 206

Fixed order for cooktoolkit in tazwok.conf i think. Perl needs db, gdbm, and zlib to be compiled before perl is.
author Christopher Rogers <slaxemulator@gmail.com>
date Wed Jan 26 22:39:01 2011 +0000 (2011-01-26)
parents 992ea5bf6d66
children f9c33585ac83
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 unset updated_pkg
1033 for PACKAGE in $(grep ^[0-9,a-z,A-Z] packages.txt); do
1034 pkg="$pkg_repository/$(grep -m1 ^$PACKAGE- packages.list).tazpkg"
1035 if ! [ -f "$pkg" ]; then
1036 erase_package_info
1037 else
1038 if [ "$pkg" -nt "packages.list" ]; then
1039 updated_pkg="$updated_pkg $pkg"
1040 fi
1041 fi
1042 done
1044 for pkg in $updated_pkg; do
1045 erase_package_info
1046 get_packages_info
1047 done
1049 # Look for new packages.
1050 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1051 if ! fgrep -q " ${pkg##*/}" $pkg_repository/packages.md5; then
1052 get_packages_info
1053 fi
1054 done
1055 report end-step
1056 packages_db_end
1059 packages_db_start()
1061 if [ ! -s packages.txt ]; then
1062 echo "# SliTaz GNU/Linux - Packages list
1064 # Packages : unknow
1065 # Date : $(date +%Y-%m-%d\ \%H:%M:%S)
1066 #" > packages.txt
1067 else
1068 sed -e 's/^# Packages :.*/# Packages : unknow/' \
1069 -e "s/# Date :.*/# Date : $(date +%Y-%m-%d\ \%H:%M:%S)/" \
1070 -i packages.txt
1071 fi
1073 # Needed in some case as tazwok define RECEIPT at configuration time
1074 # in this particular case it can broke the script.
1075 unset RECEIPT
1078 erase_package_info()
1080 cd $pkg_repository
1081 sed "/^$PACKAGE$/,/^$/d" -i packages.txt
1082 sed "/^$PACKAGE /d" -i packages.desc
1083 sed -e "s/=$PACKAGE /= /" -e "s/ $PACKAGE / /" -e "s/ $PACKAGE$//" \
1084 -e "/=$PACKAGE$/d" -e "s/=[0-9,a-z,A-Z]:$PACKAGE /= /" \
1085 -e "s/ [0-9,a-z,A-Z]:$PACKAGE / /" -e "s/ [0-9,a-z,A-Z]:$PACKAGE$/ /" \
1086 -e "/=[0-9,a-z,A-Z]:$PACKAGE$/d" \
1087 -i packages.equiv
1088 sed "/^$PACKAGE:/d" -i files.list
1089 sed "/^$(basename ${pkg%.tazpkg})$/d" -i packages.list
1090 sed "/ $(basename $pkg)$/d" -i packages.md5
1093 get_packages_info()
1095 # If there's no taz folder in the wok, extract infos from the
1096 # package.
1097 get_pkg_files $pkg
1098 source_receipt
1099 echo "Getting datas from $PACKAGE"
1101 cat >> $pkg_repository/packages.txt << _EOT_
1103 $PACKAGE
1104 $VERSION$EXTRAVERSION
1105 $SHORT_DESC
1106 _EOT_
1107 [ "$PACKED_SIZE" ] && cat >> $pkg_repository/packages.txt << _EOT_
1108 $PACKED_SIZE ($UNPACKED_SIZE installed)
1109 _EOT_
1111 # Packages.desc is used by Tazpkgbox <tree>.
1112 echo "$PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> $pkg_repository/packages.desc
1114 # Packages.equiv is used by tazpkg install to check depends
1115 for i in $PROVIDE; do
1116 DEST=""
1117 echo $i | fgrep -q : && DEST="${i#*:}:"
1118 if grep -qs ^${i%:*}= $pkg_repository/packages.equiv; then
1119 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" $pkg_repository/packages.equiv
1120 else
1121 echo "${i%:*}=$DEST$PACKAGE" >> $pkg_repository/packages.equiv
1122 fi
1123 done
1125 if [ -f files.list ]; then
1126 { echo "$PACKAGE"; cat files.list; } | awk '
1127 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }' >> $pkg_repository/files.list
1128 fi
1130 cd .. && rm -r "$pkg_files_dir"
1132 cd $pkg_repository
1133 echo $(basename ${pkg%.tazpkg}) >> packages.list
1134 [ ! "$package_md5" ] && package_md5=$(md5sum $(basename $pkg))
1135 echo "$package_md5" >> packages.md5
1136 unset package_md5
1139 source_receipt()
1141 unset PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
1142 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
1143 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
1144 src _pkg DESTDIR CONFIG_SITE
1145 . ${RECEIPT:-$PWD/receipt}
1148 packages_db_end()
1150 cd $pkg_repository
1151 pkgs=$(wc -l packages.list | sed 's/ .*//')
1152 sed "s/# Packages : .*/# Packages : $pkgs/" -i packages.txt
1154 # If lists was updated it's generally needed to sort them well.
1155 if ! sort -c packages.list 2> /dev/null; then
1156 report step "Sorting packages lists"
1157 for file in packages.list packages.desc packages.equiv; do
1158 [ -f $file ] || continue
1159 sort -o $file $file
1160 done
1161 report end-step
1162 fi
1164 # Dont log this because lzma always output error.
1165 lzma e files.list files.list.lzma
1166 rm files.list 2>/dev/null
1169 ########################################################################
1170 # This section contains functions to generate wok database.
1171 ########################
1173 gen_wok_db()
1175 get_wok_info $(echo $WOK/*/receipt | sed -e "s~$WOK/~~g" -e "s~/receipt~~g")
1176 sort_db
1177 report close-bloc
1180 get_wok_info()
1182 report step "Getting datas from wok"
1183 report open-bloc
1185 report step "Generating wok-wanted.txt"
1186 for PACKAGE in $@; do
1187 RECEIPT=$WOK/$PACKAGE/receipt
1188 source_receipt
1189 [ "$WANTED" ] || continue
1190 echo -e $PACKAGE"\t"$WANTED >> $wan_db
1191 done
1193 report step "Generating wok-depends.txt"
1194 for PACKAGE in $@; do
1195 RECEIPT=$WOK/$PACKAGE/receipt
1196 if [ -s $RECEIPT ]; then
1197 source_receipt
1198 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
1199 fi
1200 done
1201 report end-step
1204 sort_db()
1206 report step "Generating cookorder.txt"
1207 rm $PACKAGES_REPOSITORY/blocked && touch $PACKAGES_REPOSITORY/blocked
1208 cat $dep_db | sed 's/ \t / /' | while read PACKAGE BUILD_DEPENDS; do
1209 grep -q ^$PACKAGE$'\t' $wan_db && continue
1211 # Replace each BUILD_DEPENDS with a WANTED package by it's
1212 # WANTED package.
1213 replace_by_wanted()
1215 for p in $BUILD_DEPENDS; do
1216 if grep -q ^$p$'\t' $wan_db; then
1217 echo -n $(grep ^$p$'\t' $wan_db | cut -f 2)' '
1218 else
1219 echo -n $p' '
1220 fi
1221 done | tr ' ' '\n' | sort -u | sed "/^$PACKAGE$/d" | tr '\n' ' '
1223 echo -e $PACKAGE"\t $(replace_by_wanted) "
1224 done > $tmp/db
1225 while [ -s "$tmp/db" ]; do
1226 status=start
1227 for pkg in $(cut -f 1 $tmp/db); do
1228 if ! fgrep -q ' '$pkg' ' $tmp/db; then
1229 echo $pkg >> $tmp/cookorder
1230 sed -e "/^$pkg\t/d" -e "s/ $pkg / /g" -i $tmp/db
1231 status=proceed
1232 fi
1233 done
1234 if [ "$status" = start ]; then
1235 cp -f $tmp/db /tmp/remain-depends.txt
1236 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
1237 for blocked in $(cut -f 1 $tmp/db); do
1238 echo "$blocked" >> $PACKAGES_REPOSITORY/blocked
1239 done
1240 break
1241 fi
1242 done
1243 [ -s $tmp/cookorder ] || touch $tmp/cookorder
1245 # The toolchain packages are moved in first position.
1246 grep $(for pkg in `scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1247 --look_for=all --with_args`; do echo " -e ^$pkg$"; done) \
1248 $tmp/cookorder | tac > $PACKAGES_REPOSITORY/cookorder.txt
1249 for pkg in $(cat $PACKAGES_REPOSITORY/cookorder.txt); do
1250 sed "/^$pkg$/d" -i $tmp/cookorder
1251 done
1253 tac $tmp/cookorder >> $PACKAGES_REPOSITORY/cookorder.txt
1254 report end-step
1257 ########################################################################
1258 # SCAN CORE
1259 ########################
1260 # Include various scan core-functions. It's not intended to be used
1261 # directly : prefer scan wrappers in next section.
1263 look_for_dep()
1265 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1266 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
1267 | cut -f 2
1268 else
1269 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1270 cut -f 2
1271 fi
1274 look_for_bdep()
1276 # if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1277 # grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
1278 # | cut -f 3
1279 # else
1280 # grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1281 # cut -f 3
1282 # fi
1283 look_for_all
1286 look_for_all()
1288 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1289 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
1290 | cut -f 2,3 | sed 's/ / /'
1291 else
1292 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1293 cut -f 2,3 | sed 's/ / /'
1294 fi
1297 filter()
1299 for pkg in $(cat); do
1300 if grep -q ^$pkg$'\t' $dep_db; then
1301 { grep ^$pkg$'\t' $wan_db || echo $pkg
1302 } | sed 's/\t/ /'
1303 else
1304 echo "Error: $pkg can't be found." >&2
1305 fi
1306 done
1309 look_for_all_filtered()
1311 look_for_all | filter
1314 look_for_rdep()
1316 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | cut -f 1
1317 if [ "$undigest" ]; then
1318 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt | cut -f 1); do
1319 if [ ! -f "WOK$/$rdep/receipt" ]; then
1320 echo "$rdep"
1321 fi
1322 done
1323 fi
1326 look_for_rbdep()
1328 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | \
1329 cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
1330 if [ "$undigest" ]; then
1331 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
1332 | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1); do
1333 if [ ! -f "WOK$/$rdep/receipt" ]; then
1334 echo "$rdep"
1335 fi
1336 done
1337 fi
1340 # Return WANTED if it exists.
1341 look_for_wanted()
1343 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1344 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-wanted.txt | cut -f 2
1345 else
1346 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 2
1347 fi
1350 # Return packages which wants PACKAGE.
1351 look_for_rwanted()
1353 grep $'\t'$PACKAGE$ $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 1
1354 if [ "$undigest" ]; then
1355 for rwanted in $(grep $'\t'$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-wanted.txt | cut -f 1); do
1356 if [ ! -f "$WOK/$rwanted/receipt" ]; then
1357 echo "$rwanted"
1358 fi
1359 done
1360 fi
1363 look_for_dev()
1365 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev && return
1366 [ "$undigest" ] && [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$PACKAGE-dev/receipt" ] && \
1367 echo $PACKAGE-dev
1370 ########################################################################
1371 # SCAN
1372 ########################
1373 # Use wok-wanted.txt and wok-depeds.txt to scan depends.
1374 # Option in command line (must be first arg) :
1375 # --look_for=bdep/rbdep - Look for depends or reverse depends.
1376 # --with_dev - Add development packages (*-dev) in the result.
1377 # --with_wanted - Add package+reverse wanted in the result.
1378 # --with_args - Include packages in argument in the result.
1380 scan()
1382 # With some commands we don't want report (list output).
1383 if [ "$COMMAND" = gen-cooklist ] || [ "$COMMAND" = build-depends ]; then
1384 report(){ : ; }
1385 fi
1387 # Generate wok data files if they're missing. Output message in
1388 # stderr as stdout output may be used as packages list.
1389 if [ ! -s "$wan_db" ] || [ ! -s "$dep_db" ]; then
1390 echo "Missing wok data files, generating them... This may take few minutes." >&2
1391 gen_wok_db
1392 fi
1394 # Get packages in argument.
1395 local PACKAGE pkg_list=
1396 for arg in $@; do
1397 [ "$arg" = "${arg#--}" ] || continue
1398 pkg_list="$pkg_list $arg"
1399 done
1401 # Get options.
1402 [ "$pkg_list" ] || return
1403 local cooklist= look_for= with_dev= with_wanted= with_args= log_command="$0 $@" \
1404 get_options_list="look_for with_dev with_wanted with_args cooklist"
1405 get_options
1407 # Cooklist is a special case where we need to modify a little
1408 # scan behavior
1409 if [ "$cooklist" ]; then
1410 look_for=all_filtered && with_args=yes && with_dev= && with_wanted= && rwan=yes
1411 pkg_list=$(echo $pkg_list | filter)
1412 fi
1414 ##############################################################
1415 # ADD TO LISTS PROPOSAL ######################################
1416 ##############################################################
1418 include_wanted()
1420 for pkg in $(cat); do
1421 { grep ^$pkg$'\t' $wan_db || echo $pkg
1422 } | sed 's/\t/ /'
1423 done
1426 no_duplication()
1428 for pkg in $(cat); do
1429 grep -q ^$pkg$ $tmp/list $tmp/dep && continue
1430 echo $pkg
1431 done
1434 append_to_list()
1436 no_duplication >> $tmp/list
1437 # OU
1438 include_wanted | no_duplication >> $tmp/list
1441 ##############################################################
1442 for PACKAGE in $(echo $pkg_list | filter); do
1443 look_for_$look_for
1444 done | tr ' ' '\n' | sort -u > $tmp/list
1445 [ "$look_for" = bdep ] && look_for=dep
1446 while [ -s $tmp/list ]; do
1447 PACKAGE=$(sed 1!d $tmp/list)
1448 sed 1d -i $tmp/list
1449 echo $PACKAGE >> $tmp/dep
1450 for depend in $(look_for_$look_for); do
1451 if ! grep -q ^$depend$ $tmp/list $tmp/dep; then
1452 echo $depend >> $tmp/list
1453 fi
1454 done
1455 done
1456 [ "$with_args" ] && echo $pkg_list | tr ' ' '\n' >> $tmp/dep
1457 if [ -s $tmp/dep ]; then
1458 if [ "$with_wanted" ]; then
1459 cat $tmp/dep | while read PACKAGE; do
1460 look_for_rwanted >> $tmp/dep
1461 done
1462 elif [ "$with_dev" ]; then
1463 cat $tmp/dep | while read PACKAGE; do
1464 look_for_dev >> $tmp/dep
1465 done
1466 fi
1467 if [ "$cooklist" ]; then
1468 mv $tmp/dep $tmp/cooklist
1469 sort_cooklist
1470 rm $tmp/cooklist
1471 else
1472 cat $tmp/dep | sort -u
1473 fi
1474 fi
1475 rm $tmp/dep $tmp/list 2>/dev/null
1478 ########################################################################
1479 # This section contains functions to check package repository and
1480 # find which packages to cook.
1481 ########################
1483 # Actually its becomes more than check commit... Maybe put this in report
1484 # function is a good idea.
1485 check_for_commit()
1487 report step "Checking for commits"
1489 # Clean the list... Later we will perfom a partial clean only to keep
1490 # some usefull informations
1491 rm $PACKAGES_REPOSITORY/commit 2>/dev/null
1493 # If there's a packages-incoming repository we need to check it too.
1494 for RECEIPT in $(echo $WOK/*/receipt | fgrep -v '*'); do
1495 source_receipt
1497 # We use md5 of cooking stuff in the packaged receipt to check
1498 # commit. We look consecutively in 3 different locations :
1499 # - in the wok/PACKAGE/taz folder
1500 # - in the receipt in the package in incoming repository
1501 # - in the receipt in the package in packages repository
1502 # If md5sum match, there's no commit.
1503 # If there's not md5sum datas, because the package was cooked
1504 # with a previous version of tazwok, we don't put in in commit
1505 # list (need a cook-all to refresh them)
1506 # If there's no receipt available, package is missing so we put
1507 # it in commit list.
1508 # First look for package in packages-incoming.
1509 check_for_commit_using_md5sum()
1511 if [ ! -f $WOK/$PACKAGE/md5 ]; then
1512 sed -n '/# md5sum of cooking stuff :/,$p' receipt | \
1513 sed -e 1d -e 's/^# //' > $WOK/$PACKAGE/md5
1514 cd $WOK/$PACKAGE
1515 fi
1517 # Use md5sum list in receipt to check for commit.
1518 if [ -s md5 ]; then
1519 if md5sum -cs md5; then
1520 return_code=0
1522 # If md5sum check if ok, check for new files in
1523 # cooking stuff.
1524 for file in receipt description.txt $( [ -d stuff ] && find stuff); do
1525 if [ -f $file ] && ! fgrep -q " $file" md5; then
1526 set_commited
1527 fi
1528 done
1529 else
1530 set_commited
1531 fi
1532 else
1533 gen_cookmd5
1534 fi
1536 set_commited()
1538 echo $PACKAGE >> $PACKAGES_REPOSITORY/commit
1539 echo "Commit: $PACKAGE ($VERSION)"
1540 gen_cookmd5
1542 taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | fgrep -v '*')
1543 if [ -f $WOK/$PACKAGE/md5 ]; then
1544 cd $WOK/$PACKAGE
1545 check_for_commit_using_md5sum
1546 elif [ "$taz_dir" ]; then
1547 cd $taz_dir
1548 check_for_commit_using_md5sum
1549 else
1550 pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1551 [ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1552 if [ "$pkg" ]; then
1553 get_pkg_files $pkg
1554 check_for_commit_using_md5sum
1555 rm -r $pkg_files_dir
1556 continue
1557 fi
1558 set_commited
1559 fi
1560 done
1561 report end-step
1564 gen_cook_list()
1566 if [ -s $PACKAGES_REPOSITORY/commit ]; then
1567 report step "Generate genpkg & cook lists."
1568 cd $PACKAGES_REPOSITORY
1569 #cp commit $tmp/commit
1570 #if [ -s broken ]; then
1571 ## dep_scan return deps including the packages given in argument.
1572 ## To avoid that, we firt generate a list of direct rdepends of
1573 ## brokens without packages in argument, then we generate the
1574 ## full rdeps list. We do this because we don't want to block
1575 ## packages at source of broken tree if a fix as been commited.
1576 #for PACKAGE in $(cat broken); do
1577 #look_for_rdep >> $tmp/broken
1578 #done
1579 #cat $tmp/broken
1580 #look_for=rdep && with_wanted=yes
1581 #for PACKAGE in $(dep_scan `cat $tmp/broken`); do
1582 #if grep -q ^$PACKAGE$ $tmp/commit; then
1583 #sed "/^$PACKAGE$/d" -i $tmp/commit
1584 #fi
1585 #done
1586 #rm $tmp/broken
1587 #fi
1588 for PACKAGE in $(cat commit); do
1589 WANTED="$(look_for_wanted)"
1590 if [ "$WANTED" ]; then
1592 # If cook of wanted package is planned, this one will be
1593 # packaged at the same time. Else if wanted package is
1594 # broken or blocked, ignore the commit. Else, put the
1595 # package in genpkglist.
1596 { grep -q ^$WANTED$ commit || grep -q ^$WANTED$ broken || \
1597 grep -q ^$WANTED$ cooklist || grep -q ^$WANTED$ blocked || \
1598 grep -q ^$WANTED$ genpkglist
1599 } && continue
1600 echo $WANTED >> genpkglist
1601 else
1602 { grep -q ^$PACKAGE$ blocked || grep -q ^$PACKAGE$ cooklist
1603 } && continue
1604 echo $PACKAGE >> cooklist
1605 sed "/^$PACKAGE$/d" -i broken
1606 fi
1607 done
1608 #rm $tmp/commit
1609 if [ -s genpkglist ]; then
1610 echo "genpkglist:"
1611 cat genpkglist
1612 fi
1613 report end-step
1614 fi
1615 cooklist=$PACKAGES_REPOSITORY/cooklist
1616 sort_cooklist
1619 sort_cooklist()
1621 [ ! "$cooklist" ] && cooklist=$PACKAGES_REPOSITORY/cooklist
1622 [ -s $cooklist ] || [ -s "$tmp/cooklist" ] || return
1623 [ -s $PACKAGES_REPOSITORY/cookorder.txt ] || gen_wok_db
1624 [ ! -s "$tmp/cooklist" ] && cp -a $cooklist $tmp/cooklist
1625 report step "Sorting cooklist"
1627 # Use cookorder.txt to sort cooklist.
1628 cat $PACKAGES_REPOSITORY/cookorder.txt | while read PACKAGE; do
1629 if grep -q ^$PACKAGE$ $tmp/cooklist; then
1630 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1631 echo $PACKAGE >> $tmp/cooklist.tmp
1632 fi
1633 done
1635 # Remaining packages in cooklist are thoses without compile_rules.
1636 # They can be cooked first in any order.
1637 mv -f $tmp/cooklist.tmp $tmp/cooklist
1638 [ "$cooklist" = "$PACKAGES_REPOSITORY/cooklist" ] && \
1639 cat $tmp/cooklist > $cooklist
1640 cat $tmp/cooklist
1641 report end-step
1644 check_for_incoming()
1646 [ -s $INCOMING_REPOSITORY/packages.txt ] || return
1647 report step "Checking packages-incoming repository"
1648 cd $INCOMING_REPOSITORY
1649 grep ^[0-9,a-z,A-Z] packages.txt > $tmp/incoming
1650 scan `cat $PACKAGES_REPOSITORY/broken` --look_for=bdep --with_wanted > $tmp/broken
1651 for PACKAGE in $(scan `cat $tmp/broken` --look_for=rdep --with_wanted --with_args); do
1652 sed "/^$PACKAGE$/d" -i $tmp/incoming
1653 for rwanted in $(look_for_rwanted); do
1654 sed "/^$rwanted$/d" -i $tmp/incoming
1655 done
1656 done
1657 rm $tmp/broken
1658 if [ "$incoming_delay" != 0 ]; then
1659 cat $tmp/incoming | while read PACKAGE; do
1660 [ "$(grep ^$PACKAGE$ $tmp/incoming)" ] || continue
1661 dep_list=$( { scan $PACKAGE --look_for=bdep --with_wanted && \
1662 scan $PACKAGE --look_for=rdep --with_wanted --with_args; } \
1663 | sort -u )
1664 for dep in $dep_list; do
1665 [ "$(find -name "`get_pkg_version $INCOMING_REPOSITORY`.tazpkg" -mtime +$incoming_delay)" ] && continue
1666 for pkg in $dep_list; do
1667 sed "/^$pkg$/d" -i $tmp/incoming
1668 done && break
1669 done
1670 done
1671 fi
1672 if [ -s "$tmp/incoming" ]; then
1673 for PACKAGE in $(cat $tmp/incoming); do
1674 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
1675 remove_previous_package $PACKAGES_REPOSITORY
1676 remove_previous_tarball
1677 cur_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
1678 mv -f $PACKAGE-$cur_VERSION.tazpkg $PACKAGES_REPOSITORY
1679 echo "Moving $PACKAGE to main repository."
1680 done
1681 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
1682 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
1683 fi
1684 report end-step
1687 ########################################################################
1688 # TAZWOK MAIN FUNCTIONS
1689 ########################
1691 clean()
1693 cd $WOK/$PACKAGE
1694 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
1695 -e ^stuff$ || return
1697 report step "Cleaning $PACKAGE"
1698 # Check for clean_wok function.
1699 if grep -q ^clean_wok $RECEIPT; then
1700 clean_wok
1701 fi
1702 # Clean should only have a receipt, stuff and optional desc.
1703 for f in `ls .`
1704 do
1705 case $f in
1706 receipt|stuff|description.txt)
1707 continue ;;
1708 *)
1709 echo "Removing: $f"
1710 rm -rf $f
1711 esac
1712 done
1713 report end-step
1716 # Configure and make a package with the receipt.
1717 compile_package()
1719 check_for_package_on_cmdline
1721 # Include the receipt to get all needed variables and functions
1722 # and cd into the work directory to start the work.
1723 check_for_receipt
1724 source_receipt
1726 # Log the package name and date.
1727 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
1728 echo "package $PACKAGE (compile)" >> $LOG
1730 # Set wanted $src variable to help compiling.
1731 [ ! "$src" ] && set_src_path
1732 check_for_build_depends || return 1
1733 check_for_wanted
1734 unset target
1735 check_for_tarball && check_for_compile_rules
1738 # Cook command also include all features to manage lists which keep
1739 # track of wok/packages state.
1740 cook()
1742 cook_code=
1743 set_common_path
1744 check_for_receipt
1745 source_receipt
1747 # Define log path and start report.
1748 [ -f $LOCAL_REPOSITORY/log/$PACKAGE.html ] && rm $LOCAL_REPOSITORY/log/$PACKAGE.html
1749 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
1750 report step "Cooking $PACKAGE"
1751 report open-bloc
1753 # Clean package if needed.
1754 clean $PACKAGE
1756 # Remove PACKAGE from commit & cook lists.
1757 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/commit
1758 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/cooklist
1759 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
1761 if compile_package; then
1762 refresh_packages_from_compile
1763 gen_package
1764 remove_src
1766 # Plan recook of reverse build depends if gen_package has detect
1767 # a change in libraries.
1768 if [ "$cook_rdep" ]; then
1769 report step "Look for packages which need a refresh"
1770 for rdep in $(scan $PACKAGE --look_for=rdep); do
1771 sed "/^$rdep$/d" -i $PACKAGES_REPOSITORY/broken
1772 if [ -f $WOK/$rdep/receipt ] && ! grep -q ^$rdep$ $tmp/cooklist; then
1773 echo "Add $rdep in cooklist to avoid broke caused by library update in $PACKAGE"
1774 echo $rdep >> $tmp/cooklist
1775 regen_cooklist=yes
1776 fi
1777 done
1778 report end-step
1779 fi
1781 # Update packages-incoming repository.
1782 store_pkgname=$PACKAGE
1783 pkg_repository=$INCOMING_REPOSITORY
1784 update_packages_db
1786 PACKAGE=$store_pkgname
1787 unset store_pkgname
1789 # Upgrade to cooked packages if it was previously installed.
1790 report step "Look for package(s) to upgrade"
1791 for pkg in $(look_for_rwanted) $PACKAGE; do
1792 if [ -d $INSTALLED/$pkg ]; then
1793 tazpkg get-install $pkg --forced
1794 fi
1795 done
1796 report end-step
1797 else
1799 # Set package as broken.
1800 if ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then
1801 echo $PACKAGE >> $PACKAGES_REPOSITORY/broken
1802 fi
1803 gen_cookmd5
1804 cook_code=1
1805 fi
1807 # Remove build_depends in cook mode (if in cooklist, it's done when
1808 # checking build_depends of next package and we remove only unneeded
1809 # packages to keep chroot minimal and gain some time).
1810 [ "$COMMAND" = cook ] && remove_build_depends $MISSING_PACKAGE
1812 # Regen the cooklist if it was planned and command is not cook.
1813 [ "$regen_cooklist" ] && unset regen_cooklist && \
1814 [ "$COMMAND" != cook ] && sort_cooklist
1816 # Some hacks to set the bloc & function status as failed if cook was
1817 # failed.
1818 report_return_code=$cook_code
1819 report close-bloc
1820 report end-sublog
1821 return $cook_code
1824 genpkg_list()
1826 while [ -s $PACKAGES_REPOSITORY/genpkglist ]; do
1827 PACKAGE=$(sed 1!d $PACKAGES_REPOSITORY/genpkglist)
1828 gen_package
1829 done
1832 cook_list()
1834 if [ ! -s $cooklist ]; then
1835 echo "Nothing to cook."
1836 return
1837 fi
1838 if [ -f /usr/bin/tazchroot ]; then
1839 # Note : options -main variables- are automatically keeped by
1840 # the sub-applications tazchroot/tazwok; as well as report data.
1841 cd $LOCAL_REPOSITORY
1842 [ ! -f tazchroot.conf ] && configure_tazchroot
1843 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
1844 return
1845 fi
1846 while [ -s $tmp/cooklist ]; do
1847 PACKAGE=$(sed 1!d $tmp/cooklist)
1848 cook
1849 done
1850 remove_build_depends $MISSING_PACKAGE $remove_later
1853 configure_tazchroot()
1855 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
1856 # Tazchroot configuration file - created by tazwok.
1858 # Default chroot path
1859 SLITAZ_DIR=$SLITAZ_DIR
1860 SLITAZ_VERSION=$SLITAZ_VERSION
1861 $( [ "$undigest" ] && echo "undigest=$undigest" )
1862 LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
1863 chroot_dir=\$LOCAL_REPOSITORY/chroot
1865 # Default scripts path (theses scripts are added in the
1866 # $chroot_dir/usr/bin and can be called with tazchroot script)
1867 script_dir=/var/lib/tazchroot
1869 # List of directories to mount.
1870 list_dir="$(for dir in packages wok src packages-incoming log flavors iso; do echo $LOCAL_REPOSITORY/$dir; done)
1871 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
1873 create_chroot()
1875 mkdir -p \$chroot_dir
1876 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
1877 tazpkg get-install \$pkg --root="\$chroot_dir"
1878 done
1880 # Store list of installed packages needed by cleanchroot.
1881 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
1883 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
1884 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
1885 -i \$chroot_dir/etc/slitaz/slitaz.conf
1886 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
1887 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
1890 mount_chroot()
1892 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
1893 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCALSTATE/mirror
1894 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
1895 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
1896 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION
1897 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror' )
1898 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
1899 mount -t proc proc \$chroot_dir/proc
1900 mount -t sysfs sysfs \$chroot_dir/sys
1901 mount -t devpts devpts \$chroot_dir/dev/pts
1902 mount -t tmpfs shm \$chroot_dir/dev/shm
1903 for dir in \$list_dir; do
1904 mkdir -p \$dir \$chroot_dir\$dir
1905 mount \$dir \$chroot_dir\$dir
1906 done
1909 umount_chroot()
1911 for dir in \$list_dir; do
1912 umount \$chroot_dir\$dir
1913 done
1914 umount \$chroot_dir/dev/shm
1915 umount \$chroot_dir/dev/pts
1916 umount \$chroot_dir/sys
1917 umount \$chroot_dir/proc
1919 EOF
1922 ########################################################################
1923 ######################### END OF NEW FUNCTIONS #########################
1924 ########################################################################
1926 # List packages providing a virtual package
1927 whoprovide()
1929 local i;
1930 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
1931 . $i
1932 case " $PROVIDE " in
1933 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
1934 esac
1935 done
1938 ########################################################################
1939 # TAZWOK COMMANDS
1940 ########################
1942 case "$COMMAND" in
1943 stats)
1944 # Tazwok general statistics from the wok config file.
1946 get_tazwok_config
1947 echo -e "\n\033[1mTazwok configuration statistics\033[0m
1948 ================================================================================
1949 Wok directory : $WOK
1950 Packages repository : $PACKAGES_REPOSITORY
1951 Incoming repository : $INCOMING_REPOSITORY
1952 Sources repository : $SOURCES_REPOSITORY
1953 Log directory : $LOCAL_REPOSITORY/log
1954 Packages in the wok : `ls -1 $WOK | wc -l`
1955 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
1956 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
1957 ================================================================================\n"
1958 ;;
1959 edit)
1960 get_tazwok_config
1961 check_for_package_on_cmdline
1962 check_for_receipt
1963 $EDITOR $WOK/$PACKAGE/receipt
1964 ;;
1965 build-depends)
1966 # List dependencies to rebuild wok, or only a package
1967 get_tazwok_config
1968 if [ "$PACKAGE" = toolchain-cooklist ]; then
1969 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1970 --cooklist
1971 elif [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
1972 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1973 --look_for=dep --with_dev --with_args
1974 else
1975 check_for_package_on_cmdline
1976 scan $PACKAGE --look_for=bdep --with_dev
1977 fi
1978 ;;
1979 gen-cooklist)
1980 get_options_list="list"
1981 get_tazwok_config
1982 if [ "$list" ]; then
1983 LIST="$list"
1984 check_for_list
1985 else
1986 LIST=$(for pkg in $@; do
1987 [ "$pkg" = "${pkg#--}" ] || continue
1988 echo -n "$pkg "
1989 done)
1990 if [ ! "$LIST" ]; then
1991 echo "Please give packages or a list file in argument." >&2
1992 exit
1993 fi
1994 fi
1995 scan $LIST --cooklist
1996 ;;
1997 check-depends)
1998 # Check package depends /!\
1999 get_tazwok_config
2000 echo ""
2001 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
2002 ================================================================================"
2003 TMPDIR=/tmp/tazwok$$
2004 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
2006 # Build ALL_DEPENDS variable
2007 scan_dep()
2009 local i
2010 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
2011 for i in $DEPENDS $SUGGESTED ; do
2012 case " $ALL_DEPENDS " in
2013 *\ $i\ *) continue;;
2014 esac
2015 [ -d $WOK/$i ] || {
2016 ALL_DEPENDS="$ALL_DEPENDS$i "
2017 continue
2019 DEPENDS=""
2020 SUGGESTED=""
2021 . $WOK/$i/receipt
2022 scan_dep
2023 done
2026 # Check for ELF file
2027 is_elf()
2029 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" \
2030 = "ELF" ]
2033 # Print shared library dependencies
2034 ldd()
2036 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
2039 mkdir $TMPDIR
2040 cd $TMPDIR
2041 for i in $LOCALSTATE/files.list.lzma \
2042 $LOCALSTATE/undigest/*/files.list.lzma ; do
2043 [ -f $i ] && lzma d $i -so >> files.list
2044 done
2045 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
2046 tazpkg extract $pkg > /dev/null 2>&1
2047 . */receipt
2048 ALL_DEPENDS="$DEFAULT_DEPENDS "
2049 scan_dep
2050 find */fs -type f | while read file ; do
2051 is_elf $file || continue
2052 case "$file" in
2053 *.o|*.ko|*.ko.gz) continue;;
2054 esac
2055 ldd $file | while read lib rem; do
2056 case "$lib" in
2057 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
2058 continue;;
2059 esac
2060 for dep in $(fgrep $lib files.list | cut -d: -f1); do
2061 case " $ALL_DEPENDS " in
2062 *\ $dep\ *) continue 2;;
2063 esac
2064 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
2065 case " $ALL_DEPENDS " in
2066 *\ $vdep\ *) continue 3;;
2067 esac
2068 done
2069 done
2070 [ -n "$dep" ] || dep="UNKNOWN"
2071 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
2072 done
2073 done
2074 rm -rf */
2075 done
2076 cd /tmp
2077 rm -rf $TMPDIR
2078 ;;
2079 check)
2080 # Check wok consistency
2081 get_tazwok_config
2082 echo ""
2083 echo -e "\033[1mWok and packages checking\033[0m
2084 ================================================================================"
2085 cd $WOK
2086 for pkg in $(ls)
2087 do
2088 [ -f $pkg/receipt ] || continue
2089 RECEIPT= $pkg/receipt
2090 source_receipt
2091 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
2092 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
2093 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
2094 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
2095 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
2096 if [ -n "$WANTED" ]; then
2097 if [ ! -f $WANTED/receipt ]; then
2098 echo "Package $PACKAGE wants unknown $WANTED package" >&2
2099 else
2100 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
2101 if [ "$VERSION" = "$WANTED" ]; then
2102 # BASEVERSION is computed in receipt
2103 fgrep -q '_pkg=' $pkg/receipt &&
2104 BASEVERSION=$VERSION
2105 fi
2106 if [ "$VERSION" != "$BASEVERSION" ]; then
2107 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
2108 fi
2109 fi
2110 fi
2112 if [ -n "$CATEGORY" ]; then
2113 case " $(echo $CATEGORIES) " in
2114 *\ $CATEGORY\ *);;
2115 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
2116 esac
2117 else
2118 echo"Package $PACKAGE has no CATEGORY" >&2
2119 fi
2120 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
2121 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
2122 case "$WGET_URL" in
2123 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
2124 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
2125 '') ;;
2126 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
2127 esac
2128 case "$WEB_SITE" in
2129 ftp*|http*);;
2130 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
2131 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
2132 esac
2133 case "$MAINTAINER" in
2134 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
2135 esac
2136 case "$MAINTAINER" in
2137 *@*);;
2138 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
2139 esac
2140 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2141 for i in $DEPENDS; do
2142 [ -d $i ] && continue
2143 [ -n "$(whoprovide $i)" ] && continue
2144 echo -e "$MSG $i"
2145 MSG=""
2146 done
2147 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2148 for i in $BUILD_DEPENDS; do
2149 [ -d $i ] && continue
2150 [ -n "$(whoprovide $i)" ] && continue
2151 echo -e "$MSG $i"
2152 MSG=""
2153 done
2154 MSG="Dependencies loop between $PACKAGE and :\n"
2155 ALL_DEPS=""
2156 check_for_deps_loop $PACKAGE $DEPENDS
2157 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
2158 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
2159 echo "$pkg should be rebuilt after $i installation"
2160 done
2161 done
2162 ;;
2163 list)
2164 # List packages in wok directory. User can specify a category.
2166 get_tazwok_config
2167 if [ "$2" = "category" ]; then
2168 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
2169 exit 0
2170 fi
2171 # Check for an asked category.
2172 if [ -n "$2" ]; then
2173 ASKED_CATEGORY=$2
2174 echo ""
2175 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
2176 echo "================================================================================"
2177 for pkg in $WOK/*
2178 do
2179 [ ! -f $pkg/receipt ] && continue
2180 . $pkg/receipt
2181 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
2182 echo -n "$PACKAGE"
2183 echo -e "\033[28G $VERSION"
2184 packages=$(($packages+1))
2185 fi
2186 done
2187 echo "================================================================================"
2188 echo -e "$PACKAGEs packages in category $ASKED_CATEGORY.\n"
2189 else
2190 # By default list all packages and version.
2191 echo ""
2192 echo -e "\033[1mList of packages in the wok\033[0m"
2193 echo "================================================================================"
2194 for pkg in $WOK/*
2195 do
2196 [ ! -f $pkg/receipt ] && continue
2197 . $pkg/receipt
2198 echo -n "$PACKAGE"
2199 echo -en "\033[28G $VERSION"
2200 echo -e "\033[42G $CATEGORY"
2201 packages=$(($packages+1))
2202 done
2203 echo "================================================================================"
2204 echo -e "$PACKAGEs packages available in the wok.\n"
2205 fi
2206 ;;
2207 info)
2208 # Information about a package.
2210 get_tazwok_config
2211 check_for_package_on_cmdline
2212 check_for_receipt
2213 . $WOK/$PACKAGE/receipt
2214 echo ""
2215 echo -e "\033[1mTazwok package information\033[0m
2216 ================================================================================
2217 Package : $PACKAGE
2218 Version : $VERSION
2219 Category : $CATEGORY
2220 Short desc : $SHORT_DESC
2221 Maintainer : $MAINTAINER"
2222 if [ ! "$WEB_SITE" = "" ]; then
2223 echo "Web site : $WEB_SITE"
2224 fi
2225 if [ ! "$DEPENDS" = "" ]; then
2226 echo "Depends : $DEPENDS"
2227 fi
2228 if [ ! "$WANTED" = "" ]; then
2229 echo "Wanted src : $WANTED"
2230 fi
2231 echo "================================================================================"
2232 echo ""
2233 ;;
2234 check-log)
2235 # We just cat the file log to view process info.
2237 get_tazwok_config
2238 if [ ! -f "$LOG" ]; then
2239 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
2240 exit 1
2241 else
2242 echo ""
2243 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
2244 echo "================================================================================"
2245 cat $LOG
2246 echo "================================================================================"
2247 echo ""
2248 fi
2249 ;;
2250 search)
2251 # Search for a package by pattern or name.
2253 get_tazwok_config
2254 if [ -z "$2" ]; then
2255 echo -e "\nPlease specify a pattern or a package name to search." >&2
2256 echo -e "Example : 'tazwok search gcc'.\n" >&2
2257 exit 1
2258 fi
2259 echo ""
2260 echo -e "\033[1mSearch result for :\033[0m $2"
2261 echo "================================================================================"
2262 list=`ls -1 $WOK | fgrep $2`
2263 for pkg in $list
2264 do
2265 . $WOK/$pkg/receipt
2266 echo -n "$PACKAGE "
2267 echo -en "\033[24G $VERSION"
2268 echo -e "\033[42G $CATEGORY"
2269 packages=$(($PACKAGEs+1))
2270 done
2271 echo "================================================================================"
2272 echo "$PACKAGEs packages found for : $2"
2273 echo ""
2274 ;;
2275 compile)
2276 # Configure and make a package with the receipt.
2278 get_tazwok_config
2279 source_lib report
2280 report start
2281 compile_package
2282 ;;
2283 genpkg)
2284 # Generate a package.
2286 get_tazwok_config
2287 source_lib report
2288 report start
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 cook
2300 ;;
2301 sort-cooklist)
2302 if [ ! "$LIST" ]; then
2303 echo "Usage : tazwok sort-cooklist cooklist" >&2\
2304 exit 1
2305 fi
2306 get_tazwok_config
2307 source_lib report
2308 report start
2309 cooklist=$LIST
2310 sort_cooklist
2311 cp -af $tmp/cooklist $cooklist
2312 ;;
2313 cook-list)
2314 # Cook all packages listed in a file. The path to the cooklist must
2315 # be specified on the cmdline.
2316 # /!\
2317 check_root
2318 get_tazwok_config
2319 source_lib report
2320 report start
2321 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2322 if [ "$LIST" ]; then
2323 sort_cooklist
2324 else
2325 cp $cooklist $tmp/cooklist
2326 fi
2327 cook_list
2328 ;;
2329 clean)
2330 # Clean up a package work directory + thoses which want it.
2332 get_tazwok_config
2333 check_for_package_on_cmdline
2334 check_for_receipt
2335 source_lib report
2336 report start
2337 . $RECEIPT
2338 clean
2339 ;;
2340 gen-clean-wok)
2341 # Generate a clean wok from the current wok by copying all receipts
2342 # and stuff directory.
2344 get_tazwok_config
2345 source_lib report
2346 report start
2347 if [ -z "$ARG" ]; then
2348 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
2349 exit 1
2350 else
2351 dest=$ARG
2352 mkdir -p $dest
2353 fi
2354 report step "Creating clean wok in : $dest"
2355 for pkg in `ls -1 $WOK`
2356 do
2357 mkdir -p $dest/$pkg
2358 cp -a $WOK/$pkg/receipt $dest/$pkg
2359 [ -f $WOK/$pkg/description.txt ] && \
2360 cp -a $WOK/$pkg/description.txt $dest/$pkg
2361 if [ -d "$WOK/$pkg/stuff" ]; then
2362 cp -a $WOK/$pkg/stuff $dest/$pkg
2363 fi
2364 done
2365 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
2366 report end-step
2367 echo "Packages cleaned : `ls -1 $dest | wc -l`"
2368 echo ""
2369 ;;
2370 clean-wok)
2371 # Clean all packages in the work directory
2373 get_tazwok_config
2374 source_lib report
2375 report start
2376 report step "Cleaning wok"
2377 report open-bloc
2378 for PACKAGE in `ls -1 $WOK`
2379 do
2380 set_common_path
2381 source_receipt
2382 clean
2383 done
2384 report close-bloc
2385 echo "`ls -1 $WOK | wc -l` packages cleaned."
2386 ;;
2387 gen-list)
2388 check_root
2389 get_tazwok_config
2390 source_lib report
2391 report start
2392 dbtype=packages
2393 mode=gen
2394 for pkg_repository in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
2395 files_list="$pkg_repository/files.list.lzma \
2396 $pkg_repository/packages.list \
2397 $pkg_repository/packages.txt \
2398 $pkg_repository/packages.desc \
2399 $pkg_repository/packages.equiv \
2400 $pkg_repository/packages.md5"
2401 gen_db
2402 echo "$pkgs packages in the repository."
2403 echo ""
2404 done
2405 ;;
2406 check-list)
2407 # The directory to move into by default is the repository,
2408 # if $2 is not empty cd into $2.
2410 get_tazwok_config
2411 if [ -z "$2" ]; then
2412 PACKAGES_REPOSITORY=$PACKAGES_REPOSITORY
2413 else
2414 if [ -d "$2" ]; then
2415 PACKAGES_REPOSITORY=$2
2416 else
2417 echo -e "\nUnable to find directory : $2\n" >&2
2418 exit 1
2419 fi
2420 fi
2422 # Use report shared library to control output.
2423 tmp=/tmp/tazwok-$$
2424 source_lib report
2425 dbtype=packages
2426 mode=update
2427 cd $PACKAGES_REPOSITORY
2428 for pkg in $(echo *.tazpkg); do
2429 package_md5=$(md5sum $pkg)
2430 [ "$package_md5" = "$(fgrep " $pkg" packages.md5)" ] && continue
2431 erase_package_info
2432 get_packages_info
2433 done
2434 echo "$pkgs packages in the repository."
2435 echo ""
2436 ;;
2437 new-tree)
2438 # Just create a few directories and generate an empty receipt to prepare
2439 # the creation of a new package.
2441 get_tazwok_config
2442 check_for_package_on_cmdline
2443 if [ -d $WOK/$PACKAGE ]; then
2444 echo -e "\n$PACKAGE package tree already exists.\n" >&2
2445 exit 1
2446 fi
2447 echo "Creating : $WOK/$PACKAGE"
2448 mkdir $WOK/$PACKAGE
2449 cd $WOK/$PACKAGE
2450 echo -n "Preparing the receipt..."
2452 # Default receipt begin.
2454 echo "# SliTaz package receipt." > receipt
2455 echo "" >> receipt
2456 echo "PACKAGE=\"$PACKAGE\"" >> receipt
2457 # Finish the empty receipt.
2458 cat >> receipt << "EOF"
2459 VERSION=""
2460 CATEGORY=""
2461 SHORT_DESC=""
2462 MAINTAINER=""
2463 DEPENDS=""
2464 TARBALL="$PACKAGE-$VERSION.tar.gz"
2465 WEB_SITE=""
2466 WGET_URL=""
2468 # Rules to configure and make the package.
2469 compile_rules()
2471 cd $src
2472 ./configure \
2473 --prefix=/usr \
2474 --infodir=/usr/share/info \
2475 --mandir=/usr/share/man \
2476 $CONFIGURE_ARGS &&
2477 make -j 4 && make DESTDIR=$PWD/_pkg install
2480 # Rules to gen a SliTaz package suitable for Tazpkg.
2481 genpkg_rules()
2483 mkdir -p $fs/usr
2484 cp -a $_pkg/usr/bin $fs/usr
2487 EOF
2489 # Default receipt end.
2491 status
2492 # Interactive mode, asking and seding.
2493 if [ "$3" = "--interactive" ]; then
2494 echo "Entering into interactive mode..."
2495 echo "================================================================================"
2496 echo "Package : $PACKAGE"
2497 # Version.
2498 echo -n "Version : " ; read anser
2499 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
2500 # Category.
2501 echo -n "Category : " ; read anser
2502 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
2503 # Short description.
2504 echo -n "Short desc : " ; read anser
2505 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
2506 # Maintainer.
2507 echo -n "Maintainer : " ; read anser
2508 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
2509 # Web site.
2510 echo -n "Web site : " ; read anser
2511 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
2512 echo ""
2513 # Wget URL.
2514 echo "Wget URL to download source tarball."
2515 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
2516 echo -n "Wget url : " ; read anser
2517 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
2518 # Ask for a stuff dir.
2519 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
2520 if [ "$anser" = "y" ]; then
2521 echo -n "Creating the stuff directory..."
2522 mkdir stuff && status
2523 fi
2524 # Ask for a description file.
2525 echo -n "Are you going to write a description ? (y/N) : " ; read anser
2526 if [ "$anser" = "y" ]; then
2527 echo -n "Creating the description.txt file..."
2528 echo "" > description.txt && status
2529 fi
2530 echo "================================================================================"
2531 echo ""
2532 fi
2533 ;;
2534 remove)
2535 # Remove a package from the wok.
2537 get_tazwok_config
2538 check_for_package_on_cmdline
2539 echo ""
2540 echo -n "Please confirm deletion (y/N) : "; read anser
2541 if [ "$anser" = "y" ]; then
2542 echo -n "Removing $PACKAGE..."
2543 rm -rf $WOK/$PACKAGE && status
2544 echo ""
2545 fi
2546 ;;
2547 hgup)
2548 # Pull and update a Hg wok.
2549 get_tazwok_config
2550 if ls -l $WOK/.hg/hgrc | fgrep -q "root"; then
2551 check_root
2552 fi
2553 cd $WOK
2554 hg pull && hg update
2555 ;;
2556 maintainers)
2557 get_tazwok_config
2558 echo ""
2559 echo "List of maintainers for: $WOK"
2560 echo "================================================================================"
2561 touch /tmp/slitaz-maintainers
2562 for pkg in $WOK/*
2563 do
2564 . $pkg/receipt
2565 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
2566 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
2567 echo "$MAINTAINER"
2568 fi
2569 done
2570 echo "================================================================================"
2571 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
2572 echo ""
2573 # Remove tmp files
2574 rm -f /tmp/slitaz-maintainers
2575 ;;
2576 maintained-by)
2577 # Search for packages maintained by a contributor.
2578 get_tazwok_config
2579 if [ ! -n "$2" ]; then
2580 echo "Specify a name or email of a maintainer." >&2
2581 exit 1
2582 fi
2583 echo "Maintainer packages"
2584 echo "================================================================================"
2585 for pkg in $WOK/*
2586 do
2587 . $pkg/receipt
2588 if echo "$MAINTAINER" | fgrep -q "$2"; then
2589 echo "$PACKAGE"
2590 packages=$(($PACKAGEs+1))
2591 fi
2592 done
2593 echo "================================================================================"
2594 echo "Packages maintained by $2: $PACKAGEs"
2595 echo ""
2596 ;;
2597 check-src)
2598 # Verify if upstream package is still available
2600 get_tazwok_config
2601 check_for_package_on_cmdline
2602 check_for_receipt
2603 source_receipt
2604 check_src()
2606 for url in $@; do
2607 busybox wget -s $url 2>/dev/null && break
2608 done
2610 if [ "$WGET_URL" ];then
2611 echo -n "$PACKAGE : "
2612 check_src $WGET_URL
2613 status
2614 else
2615 echo "No tarball to check for $PACKAGE"
2616 fi
2617 ;;
2618 get-src)
2619 check_root
2620 get_options_list="target"
2621 get_tazwok_config
2622 check_for_package_on_cmdline
2623 check_for_receipt
2624 source_receipt
2625 if [ "$WGET_URL" ];then
2626 source_lib report
2627 report start
2628 check_for_tarball
2629 else
2630 echo "No tarball to download for $PACKAGE"
2631 fi
2632 ;;
2633 rec-commit)
2634 check_root
2635 get_tazwok_config
2636 source_lib report
2637 report start
2638 check_for_commit
2639 gen_cook_list
2640 ;;
2641 cook-commit)
2642 check_root
2643 get_tazwok_config
2644 source_lib report
2645 report start
2646 check_for_commit
2647 # 2) update cook-database (actually complete regeneration)
2648 dbtype=wok
2649 mode=gen
2650 files_list="$dep_db $wan_db $PACKAGE_REPOSITORY/cookorder.txt"
2651 gen_db
2652 # 3) check cooklist
2653 # 3.1) rename pkgs with wanted variable to wanted pkg
2654 gen_cook_list
2655 cook_list
2656 ;;
2657 cook-all)
2658 check_root
2659 get_tazwok_config
2660 source_lib report
2661 report start
2662 # 2) update cook-database (actually complete regeneration)
2663 dbtype=wok
2664 mode=gen
2665 files_list="$dep_db $wan_db $PACKAGE_REPOSITORY/cookorder.txt"
2666 gen_db
2667 # Add all packages, without toolchain, in cooklist.
2668 # Recook toolchain need to be coded.
2669 echo -n "" > $PACKAGES_REPOSITORY/cooklist
2670 for pkg in $(cd $WOK && echo *); do
2671 echo $pkg >> $PACKAGES_REPOSITORY/cooklist
2672 done
2673 for pkg in $(scan gcc --look_for=all --with_wanted --with_args); do
2674 sed "/^$pkg$/d" -i $PACKAGES_REPOSITORY/cooklist
2675 done
2676 sort_cooklist
2677 cook_list
2678 ;;
2679 gen-wok-db)
2680 check_root
2681 get_tazwok_config
2682 source_lib report
2683 report start
2684 dbtype=wok
2685 mode=gen
2686 files_list="$dep_db $wan_db $PACKAGE_REPOSITORY/cookorder.txt"
2687 gen_db
2688 ;;
2689 report)
2690 check_root
2691 get_tazwok_config
2692 cd $PACKAGES_REPOSITORY
2693 for i in commit genpkglist cooklist incoming broken blocked; do
2694 if [ -s $i ]; then
2695 echo -e "\n********************* $i *********************\n$(cat $i)\n*********************"
2696 fi
2697 done
2698 ;;
2699 check-incoming)
2700 check_root
2701 get_tazwok_config
2702 source_lib report
2703 report start
2704 check_for_incoming
2705 ;;
2706 configure-chroot)
2707 check_root
2708 get_tazwok_config
2709 if [ -f /usr/bin/tazchroot ]; then
2710 cd $LOCAL_REPOSITORY
2711 configure_tazchroot
2712 else
2713 echo "The packages tazchroot need to be installed" >&2
2714 exit 1
2715 fi
2716 ;;
2717 chroot)
2718 check_root
2719 get_tazwok_config
2720 # Merge this and the other chroot function ?.
2721 if [ -f /usr/bin/tazchroot ]; then
2722 cd $LOCAL_REPOSITORY
2723 [ ! -f tazchroot.conf ] && configure_tazchroot
2724 tazchroot
2725 else
2726 echo "The packages tazchroot need to be installed" >&2
2727 exit 1
2728 fi
2729 ;;
2730 cook-toolchain)
2731 check_root
2732 get_tazwok_config
2733 echo -n "" > $PACKAGES_REPOSITORY/broken
2734 if [ -f /usr/bin/tazchroot ]; then
2735 cd $LOCAL_REPOSITORY
2736 [ ! -f tazchroot.conf ] && configure_tazchroot
2737 tazchroot cook-toolchain
2738 # Buggy : chroot can be elsewhere.
2739 rm -r $LOCAL_REPOSITORY/chroot
2740 # /!\ to be writed :
2741 # next rm chroot and plan cook-all by pushing all packages
2742 # in cooklist.
2743 else
2744 echo "The packages tazchroot need to be installed" >&2
2745 exit 1
2746 fi
2747 ;;
2748 usage|*)
2749 # Print usage also for all unknown commands.
2751 usage
2752 ;;
2753 esac
2755 [ -d "$tmp" ] && rm -r $tmp
2756 report stop 2>/dev/null || exit 0