tazwok view tazwok @ rev 188

Use tazwok-experimental in toolchain
author Antoine Bodin <gokhlayeh@slitaz.org>
date Tue Jan 18 15:08:13 2011 +0100 (2011-01-18)
parents 92fd61a02140
children cdd73b8ec00c
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 grep -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 grep -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 grep -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 | grep '^-/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
532 #if [ "$clean_cache" = yes ] && [ "$freeram" -lt 524288 ]; then
533 # sync; echo 3 > /proc/sys/vm/drop_caches
534 # freeram=$(free | grep ^Total | tr -s ' ' | cut -f 4 -d ' ')
535 #fi
537 # Disable -pipe in CFLAGS/CXXFLAGS if less than 512Mb of free
538 # RAM are available.
539 if [ "$CFLAGS" != "${CFLAGS/-pipe}" ] || \
540 [ "$CXXFLAGS" != "${CXXFLAGS/-pipe}" ]; then
542 if [ "$freeram" -lt 524288 ]; then
543 tazwok_warning "Disabling -pipe compile flag because only $freeramb of RAM are available."
544 CFLAGS="${CFLAGS/-pipe}"
545 CXXFLAGS="${CXXFLAGS/-pipe}"
546 fi
547 fi
548 unset freeram
550 # Set cook environnement variables.
551 [ "$src" ] || set_src_path
552 [ "$DESTDIR" ] || DESTDIR="$WOK/$PACKAGE/install"
553 [ "$CONFIG_SITE" ] || CONFIG_SITE=/etc/config.site
554 export CFLAGS CXXFLAGS MAKEFLAGS DESTDIR BUILD_HOST \
555 CONFIG_SITE default_prefix \
556 default_datarootdir default_datadir default_localedir \
557 default_infodir default_mandir default_build default_host
558 local LC_ALL=POSIX LANG=POSIX
559 compile_rules
561 # Check if config.site has been used.
562 # /!\ disabled since it screw the return_code of the step.
563 #if [ -f /tmp/config.site ]; then
564 # rm /tmp/config.site
565 #else
566 # tazwok_warning "config.site hasn't been used during \
567 #configuration process."
568 #fi
570 report end-step
571 fi
572 }
574 # Check for loop in deps tree. /!\ can be removed
575 check_for_deps_loop()
576 {
577 local list
578 local pkg
579 local deps
580 pkg=$1
581 shift
582 [ -n "$1" ] || return
583 list=""
585 # Filter out already processed deps
586 for i in $@; do
587 case " $ALL_DEPS" in
588 *\ $i\ *);;
589 *) list="$list $i";;
590 esac
591 done
592 ALL_DEPS="$ALL_DEPS$list "
593 for i in $list; do
594 [ -f $i/receipt ] || continue
595 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
596 case " $deps " in
597 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
598 *) check_for_deps_loop $pkg $deps;;
599 esac
600 done
601 }
603 download()
604 {
605 for file in $@; do
606 wget -q $file && break
607 done
608 }
610 # Regenerate every package that wants a PACKAGE compiled
611 # /!\
613 refresh_packages_from_compile()
614 {
615 # make tazwok genpkg happy
616 mkdir $WOK/$PACKAGE/taz
618 # Cook rwanted in default or specied order
619 genlist=" $(look_for_rwanted | tr '\n' ' ') "
620 for i in $(look_for_cookopt genpkg | tac); do
621 [ "${genlist/ $i }" = "$genlist" ] && continue
622 genlist=" $i${genlist/ $i / }"
623 done
624 for i in $genlist; do
625 tazwok genpkg $i --SLITAZ_VERSION=$SLITAZ_VERSION \
626 --undigest=$undigest --SLITAZ_DIR=$SLITAZ_DIR
627 done
629 # Still needs tazwok genpkg for this package
630 rm -rf $WOK/$PACKAGE/taz
631 }
633 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
634 # so some packages need to copy these files with the receipt and genpkg_rules.
635 # This function is executed by gen_package when 'tazwok genpkg'.
636 copy_generic_files()
637 {
638 # In most cases, locales are in $_pkg/usr/share/locale so we copy files
639 # using generic variables and $LOCALE from Tazwok config file.
640 if [ "$LOCALE" ]; then
641 if [ -d "$_pkg/usr/share/locale" ]; then
642 for i in $LOCALE
643 do
644 if [ -d "$_pkg/usr/share/locale/$i" ]; then
645 mkdir -p $fs/usr/share/locale
646 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
647 fi
648 done
649 fi
650 fi
652 # Pixmaps (PNG or/and XPM only). Some icons/images can be added through
653 # genpkg_rules and generic copy can be disabled with GENERIC_PIXMAPS="no"
654 # in pkg receipt.
655 if [ "$GENERIC_PIXMAPS" != "no" ]; then
656 if [ -d "$_pkg/usr/share/pixmaps" ]; then
657 mkdir -p $fs/usr/share/pixmaps
658 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
659 $fs/usr/share/pixmaps 2>/dev/null
660 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
661 $fs/usr/share/pixmaps 2>/dev/null
662 fi
664 # Custom or homemade PNG pixmap can be in stuff.
665 if [ -f "stuff/$PACKAGE.png" ]; then
666 mkdir -p $fs/usr/share/pixmaps
667 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
668 fi
669 fi
671 # Desktop entry (.desktop).
672 if [ -d "$_pkg/usr/share/applications" ]; then
673 cp -a $_pkg/usr/share/applications $fs/usr/share
674 fi
676 # Homemade desktop file(s) can be in stuff.
677 if [ -d "stuff/applications" ]; then
678 mkdir -p $fs/usr/share
679 cp -a stuff/applications $fs/usr/share
680 fi
681 if [ -f "stuff/$PACKAGE.desktop" ]; then
682 mkdir -p $fs/usr/share/applications
683 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
684 fi
685 }
687 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
688 strip_package()
689 {
690 look_for_cookopt !strip && return
691 report step "Executing strip on all files"
693 # Binaries.
694 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
695 do
696 if [ -d "$dir" ]; then
697 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
698 fi
699 done
701 # Libraries.
702 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
703 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
704 report end-step
705 }
707 # Remove .pyc and .pyo files from packages
708 py_compiled_files_remove()
709 {
710 report step "Removing all .pyc and .pyo files from package ..."
711 find $fs -type f -name "*.pyc" -delete 2>/dev/null
712 find $fs -type f -name "*.pyo" -delete 2>/dev/null
713 report end-step
714 }
716 # Check FSH in a slitaz package (Path: /:/usr)
717 check_fsh()
718 {
719 cd $WOK/$PACKAGE/taz/*/fs
720 [ -n "$FSH" ] || FSH="bin boot dev etc home init lib media mnt proc \
721 root sbin share sys tmp usr var vz usr/bin usr/games usr/include usr/lib \
722 usr/local usr/sbin usr/share usr/src"
723 for i in `ls -d * usr/* 2>/dev/null`
724 do
725 if ! echo $FSH | grep -q $i; then
726 echo "Wrong path: /$i" >&2
727 error=1
728 fi
729 done
730 if [ "$error" = "1" ]; then
731 cat << _EOT_
733 Package will install files in a non standard directory and won't be generated.
734 You may have a wrong copy path in genpkg_rules or need to add some options to
735 configure in compile_rules. Some valid options for SliTaz (Linux FSH):
737 --prefix=/usr
738 --sysconfdir=/etc
739 --libexecdir=/usr/lib/(pkgname)
740 --localstatedir=/var
741 --mandir=/usr/share/man
742 --infodir=/usr/share/info
744 For more information please read SliTaz docs and run: ./configure --help
745 ================================================================================
746 $PACKAGE package generation aborted.
748 _EOT_
750 # Dont generate a corrupted package.
751 cd $WOK/$PACKAGE && rm -rf taz
752 report exit
753 fi
754 }
756 gen_cookmd5()
757 {
758 # md5sum of cooking stuff make tazwok able to check for changes
759 # without hg.
760 cd $WOK/$PACKAGE
761 md5sum receipt > md5
762 [ -f description.txt ] && md5sum description.txt >> md5
763 if [ -d stuff ]; then
764 find stuff | while read file; do
765 md5sum $file >> md5
766 done
767 fi
768 }
770 # Create a package tree and build the gziped cpio archive
771 # to make a SliTaz (.tazpkg) package.
772 gen_package()
773 {
774 check_root
775 check_for_package_on_cmdline
776 check_for_receipt
777 EXTRAVERSION=""
778 . $RECEIPT
780 # May compute VERSION
781 if grep -q ^get_version $RECEIPT; then
782 get_version
783 fi
784 check_for_wanted
785 cd $WOK/$PACKAGE
787 # Remove old Tazwok package files.
788 [ -d "taz" ] && rm -rf taz
790 # Create the package tree and set useful variables.
791 mkdir -p taz/$PACKAGE-$VERSION/fs
792 fs=taz/$PACKAGE-$VERSION/fs
794 # Set $src for standard package and $_pkg variables.
795 set_src_path && set_pkg_path
797 # Execute genpkg_rules, check package and copy generic files to build
798 # the package.
799 report step "Building $PACKAGE with the receipt"
800 report open-bloc
801 if grep -q ^genpkg_rules $RECEIPT; then
803 # Log process.
804 echo "executing genpkg_rules" >> $LOG
805 report step "Executing genpkg_rules"
806 genpkg_rules
807 report end-step
808 check_fsh
809 cd $WOK/$PACKAGE
811 # Skip generic files for packages with a WANTED variable
812 # (dev and splited pkgs).
813 if [ ! "$WANTED" ]; then
814 copy_generic_files
815 fi
816 strip_package
817 py_compiled_files_remove
818 else
819 echo "No package rules to gen $PACKAGE..." >&2
820 report exit
821 fi
823 # Copy the receipt and description (if exists) into the binary package tree.
824 cd $WOK/$PACKAGE
825 report step "Copying the receipt"
826 cp receipt taz/$PACKAGE-$VERSION
827 report end-step
828 if grep -q ^get_version $RECEIPT; then
829 report step "Updating version in receipt"
830 sed -i "s/^VERSION=.*/VERSION=\"$VERSION\"/" \
831 taz/$PACKAGE-$VERSION/receipt
832 report end-step
833 fi
834 if [ -f "description.txt" ]; then
835 report step "Copying the description file"
836 cp description.txt taz/$PACKAGE-$VERSION
837 report end-step
838 fi
840 # Generate md5 of cooking stuff to look for commit later.
841 gen_cookmd5
842 echo -e "\n# md5sum of cooking stuff :" >> taz/$PACKAGE-$VERSION/receipt
843 cat md5 | sed 's/^/# /' >> taz/$PACKAGE-$VERSION/receipt
845 # Create the files.list by redirecting find output.
846 report step "Creating the list of files"
847 cd taz/$PACKAGE-$VERSION
848 LAST_FILE=""
849 ( find fs -print; echo ) | while read file; do
850 if [ "$LAST_FILE" ]; then
851 case "$file" in
852 $LAST_FILE/*)
853 case "$(ls -ld "$LAST_FILE")" in
854 drwxr-xr-x\ *\ root\ *\ root\ *);;
855 *) echo ${LAST_FILE#fs};;
856 esac;;
857 *) echo ${LAST_FILE#fs};;
858 esac
859 fi
860 LAST_FILE="$file"
861 done > files.list
863 # Next, check if something has changed in lib files.
864 if [ ! "$cook_rdep" ]; then
865 report step "Look for changes in libraries"
867 # Find the most recent previous files.list.
868 # /!\ need some work to check only for minor update (not micro)
869 if grep -q ^$PACKAGE$ $INCOMING_REPOSITORY/packages.txt 2>/dev/null; then
870 files_list_dir=$PACKAGES_INCOMING
871 elif grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/packages.txt 2>/dev/null; then
872 files_list_dir=$PACKAGES_REPOSITORY
873 elif [ "$undigest" ] && grep -q ^$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/packages.txt 2>/dev/null; then
874 files_list_dir=$SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming
875 elif [ "$undigest" ] && grep -q ^$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages/packages.txt 2>/dev/null; then
876 files_list_dir=$SLITAZ_DIR/$SLITAZ_VERSION/packages
877 fi
879 # If founded, generate libs.list (new and previous)
880 if [ "$files_list_dir" ] && [ -f $files_list_dir/files.list.lzma ]; then
881 grep -e '\.so$' -e '\.so.[0-9]' files.list >> $tmp/libs.list.new
882 if [ -f $tmp/libs.list.new ]; then
883 lzma d $files_list_dir/files.list.lzma $tmp/files.list 2>/dev/null
884 grep ^$PACKAGE: $tmp/files.list >> $tmp/libs.list.previous
886 # If something as changed in libs path/names, plan recook of all
887 # reverse build depends.
888 [ "$(diff -q $tmp/libs.list.old $tmp/libs.list.previous 2>/dev/null)" ] && cook_rdep=yes
889 rm $tmp/libs.list.new $tmp/files.list $tmp/libs.list.old 2>/dev/null
890 unset files_list_dir
891 fi
892 fi
893 report end-step
894 fi
895 if [ ! "$EXTRAVERSION" ]; then
896 case "$PACKAGE" in
897 linux*);;
898 *) EXTRAVERSION="$(grep '/lib/modules/.*-slitaz/' files.list |\
899 head -1 | sed 's|/lib/modules/\(.*\)-slitaz/.*|_\1|')";;
900 esac
901 fi
902 rm -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
903 report step "Creating md5sum of files"
904 while read file; do
905 [ -L "fs$file" ] && continue
906 [ -f "fs$file" ] || continue
907 md5sum "fs$file" | sed 's/ fs/ /'
908 done < files.list > md5sum
909 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
910 2> /dev/null | awk '{ sz=$1 } END { print sz }')
912 # Build cpio archives. Find, cpio and gzip the fs, finish by
913 # removing the fs tree.
914 # Don't log this because compression always output error messages.
915 report end-step
916 find fs -print | cpio -o -H newc | case "$PACKAGE-$COMPRESSION" in
917 tazpkg-lzma) gzip > fs.cpio.gz;;
918 *-lzma) lzma e fs.cpio.lzma -si;;
919 *) gzip > fs.cpio.gz;;
920 esac && rm -rf fs
921 PACKED_SIZE=$(du -chs fs.cpio.* receipt files.list md5sum \
922 description.txt 2> /dev/null | awk '{ sz=$1 } END { print sz }')
923 report step "Updating receipt sizes"
924 sed -i '/^PACKED_SIZE/d' receipt
925 sed -i '/^UNPACKED_SIZE/d' receipt
926 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
927 sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
928 if [ -n "$EXTRAVERSION" ]; then
929 report step "Updating receipt EXTRAVERSION"
930 sed -i s/^EXTRAVERSION.*$// receipt
931 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
932 fi
933 prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
934 remove_previous_package $INCOMING_REPOSITORY
935 report step "Creating full cpio archive"
936 find . -print | cpio -o -H newc > $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
938 # Restore package tree in case we want to browse it.
939 report step "Restoring original package tree"
940 ( zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma ) | cpio --quiet -id
941 rm fs.cpio.* && cd ..
943 # Log process.
944 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
945 report close-bloc
946 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
947 echo "Size : `du -sh $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
948 echo ""
950 # Remove package from broken & genpkg list if needed.
951 if grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then
952 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/broken
953 regen_cooklist=yes
954 fi
956 # Remove package from genpkglist.
957 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/genpkglist
958 }
960 ########################################################################
961 ######################## START OF NEW FUNCTIONS ########################
962 ########################################################################
964 ########################################################################
965 # This section contains functions used by several other functions
966 # bellow.
967 ########################
969 # Look for receipt/files.list in wok. If they can't be found, get them
970 # from package. Accept one argument : absolute path to package.
971 get_pkg_files()
972 {
973 pkg_files_dir=$tmp/$(basename ${1%.tazpkg})
974 mkdir -p $pkg_files_dir && \
975 cd $pkg_files_dir && \
976 cpio --quiet -idm receipt < $1 && \
977 cpio --quiet -idm files.list < $1
978 }
980 ########################################################################
981 # This section contains functions to generate packages/wok databases.
982 ########################
984 # Generic actions in both gen-packages-db/gen-wok-db
985 gen_db()
986 {
987 report step "Generating $dbtype database"
988 report open-bloc
989 report step "Removing old files"
990 for file in $files_list; do
991 [ -f $file ] && rm $file
992 [ "${file##*.}" != lzma ] && touch $file
993 done
995 # Generate wok/packages data lists.
996 gen_${dbtype}_db
997 report close-bloc
998 }
1000 gen_packages_db()
1002 # pkg_repository can be $PACKAGES_REPOSITORY or $INCOMING_REPOSITORY.
1003 [ ! "$pkg_repository" ] && pkg_repository=$PACKAGES_REPOSITORY
1004 cd $pkg_repository
1005 packages_db_start
1006 unset RECEIPT
1007 report step "Reading datas from all packages"
1008 for pkg in $(echo $pkg_repository/*.tazpkg | grep -v '\*'); do
1009 get_packages_info
1010 done
1011 report end-step
1012 packages_db_end
1015 update_packages_db()
1017 [ ! "$pkg_repository" ] && pkg_repository=$PACKAGES_REPOSITORY
1018 cd $pkg_repository
1020 # If files are missing, generate the lists - not only update.
1021 dbtype=packages
1022 files_list="packages.list packages.equiv packages.md5 packages.desc packages.txt"
1023 for file in $files_list; do
1024 if [ ! -f "$file" ]; then
1025 gen_db
1026 return
1027 fi
1028 done
1029 if [ -f files.list.lzma ]; then
1030 lzma d files.list.lzma files.list
1031 else
1032 gen_db
1033 fi
1034 packages_db_start
1035 report step "Updating packages lists"
1036 touch $tmp/pkglist
1038 # Look for removed/update packages.
1039 for PACKAGE in $(grep ^[0-9,a-z,A-Z] packages.txt); do
1040 pkg=$(echo $pkg_repository/`grep ^$PACKAGE- packages.list | sed 1!d`*.tazpkg | grep -v '\*')
1041 if [ ! "$pkg" ]; then
1042 pkg=$(grep ^$PACKAGE- packages.list | sed 1!d).tazpkg
1043 erase_package_info
1044 else
1045 echo $pkg >> $tmp/pkglist
1046 if [ "$pkg" -nt "packages.list" ]; then
1047 erase_package_info
1048 get_packages_info
1049 fi
1050 fi
1051 done
1053 # Look for new packages.
1054 for pkg in $(echo $pkg_repository/*.tazpkg | grep -v '\*'); do
1055 if ! grep -q ^$pkg$ $tmp/pkglist; then
1056 get_packages_info
1057 fi
1058 done
1059 rm $tmp/pkglist
1060 report end-step
1061 packages_db_end
1064 packages_db_start()
1066 if [ ! -s packages.txt ]; then
1067 echo "# SliTaz GNU/Linux - Packages list
1069 # Packages : unknow
1070 # Date : $(date +%Y-%m-%d\ \%H:%M:%S)
1071 #" > packages.txt
1072 else
1073 sed -e 's/^# Packages :.*/# Packages : unknow/' \
1074 -e "s/# Date :.*/# Date : $(date +%Y-%m-%d\ \%H:%M:%S)/" \
1075 -i packages.txt
1076 fi
1078 # Needed in some case as tazwok define RECEIPT at configuration time
1079 # in this particular case it can broke the script.
1080 unset RECEIPT
1083 erase_package_info()
1085 cd $pkg_repository
1086 sed "/^$PACKAGE$/,/^$/d" -i packages.txt
1087 sed "/^$PACKAGE /d" -i packages.desc
1088 sed -e "s/=$PACKAGE /= /" -e "s/ $PACKAGE / /" -e "s/ $PACKAGE$//" \
1089 -e "/=$PACKAGE$/d" -e "s/=[0-9,a-z,A-Z]:$PACKAGE /= /" \
1090 -e "s/ [0-9,a-z,A-Z]:$PACKAGE / /" -e "s/ [0-9,a-z,A-Z]:$PACKAGE$/ /" \
1091 -e "/=[0-9,a-z,A-Z]:$PACKAGE$/d" \
1092 -i packages.equiv
1093 sed "/^$PACKAGE:/d" -i files.list
1094 sed "/^$(basename ${pkg%.tazpkg})$/d" -i packages.list
1095 sed "/ $(basename $pkg)$/d" -i packages.md5
1098 get_packages_info()
1100 # If there's no taz folder in the wok, extract infos from the
1101 # package.
1102 get_pkg_files $pkg
1103 source_receipt
1104 echo "Getting datas from $PACKAGE"
1106 cat >> $pkg_repository/packages.txt << _EOT_
1108 $PACKAGE
1109 $VERSION$EXTRAVERSION
1110 $SHORT_DESC
1111 _EOT_
1112 [ "$PACKED_SIZE" ] && cat >> $pkg_repository/packages.txt << _EOT_
1113 $PACKED_SIZE ($UNPACKED_SIZE installed)
1114 _EOT_
1116 # Packages.desc is used by Tazpkgbox <tree>.
1117 echo "$PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> $pkg_repository/packages.desc
1119 # Packages.equiv is used by tazpkg install to check depends
1120 for i in $PROVIDE; do
1121 DEST=""
1122 echo $i | grep -q : && DEST="${i#*:}:"
1123 if grep -qs ^${i%:*}= $pkg_repository/packages.equiv; then
1124 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" $pkg_repository/packages.equiv
1125 else
1126 echo "${i%:*}=$DEST$PACKAGE" >> $pkg_repository/packages.equiv
1127 fi
1128 done
1130 if [ -f files.list ]; then
1131 { echo "$PACKAGE"; cat files.list; } | awk '
1132 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }' >> $pkg_repository/files.list
1133 fi
1135 cd .. && rm -r "$pkg_files_dir"
1137 cd $pkg_repository
1138 echo $(basename ${pkg%.tazpkg}) >> packages.list
1139 [ ! "$package_md5" ] && package_md5=$(md5sum $(basename $pkg))
1140 echo "$package_md5" >> packages.md5
1141 unset package_md5
1144 source_receipt()
1146 unset PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
1147 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
1148 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
1149 src _pkg DESTDIR CONFIG_SITE
1150 . ${RECEIPT:-$PWD/receipt}
1153 packages_db_end()
1155 cd $pkg_repository
1156 pkgs=$(wc -l packages.list | sed 's/ .*//')
1157 sed "s/# Packages : .*/# Packages : $pkgs/" -i packages.txt
1159 # If lists was updated it's generally needed to sort them well.
1160 if ! sort -c packages.list 2> /dev/null; then
1161 report step "Sorting packages lists"
1162 for file in packages.list packages.desc packages.equiv; do
1163 [ -f $file ] || continue
1164 sort -o $file $file
1165 done
1166 report end-step
1167 fi
1169 # Dont log this because lzma always output error.
1170 lzma e files.list files.list.lzma
1171 rm files.list 2>/dev/null
1172 if ! grep -q ^$pkg_repository$ $LOCAL_STATE/mirror && \
1173 ! { [ -d $LOCAL_STATE/undigest ] && \
1174 grep -q ^$pkg_repository$ $LOCAL_STATE/undigest/*/mirror; }; then
1175 tazpkg add-undigest $(basename `echo $pkg_repository | sed 's~/packages~~'`) $pkg_repository
1176 fi
1179 ########################################################################
1180 # This section contains functions to generate wok database.
1181 ########################
1183 gen_wok_db()
1185 get_wok_info $(echo $WOK/*/receipt | sed -e "s~$WOK/~~g" -e "s~/receipt~~g")
1186 sort_db
1187 report close-bloc
1190 get_wok_info()
1192 report step "Getting datas from wok"
1193 report open-bloc
1195 report step "Generating wok-wanted.txt"
1196 for PACKAGE in $@; do
1197 RECEIPT=$WOK/$PACKAGE/receipt
1198 source_receipt
1199 [ "$WANTED" ] || continue
1200 echo -e $PACKAGE"\t"$WANTED >> $wan_db
1201 done
1203 report step "Generating wok-depends.txt"
1204 for PACKAGE in $@; do
1205 RECEIPT=$WOK/$PACKAGE/receipt
1206 if [ -s $RECEIPT ]; then
1207 source_receipt
1208 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
1209 fi
1210 done
1211 report end-step
1214 sort_db()
1216 report step "Generating cookorder.txt"
1217 rm $PACKAGES_REPOSITORY/blocked && touch $PACKAGES_REPOSITORY/blocked
1218 cat $dep_db | sed 's/ \t / /' | while read PACKAGE BUILD_DEPENDS; do
1219 grep -q ^$PACKAGE$'\t' $wan_db && continue
1221 # Replace each BUILD_DEPENDS with a WANTED package by it's
1222 # WANTED package.
1223 replace_by_wanted()
1225 for p in $BUILD_DEPENDS; do
1226 if grep -q ^$p$'\t' $wan_db; then
1227 echo -n $(grep ^$p$'\t' $wan_db | cut -f 2)' '
1228 else
1229 echo -n $p' '
1230 fi
1231 done | tr ' ' '\n' | sort -u | sed "/^$PACKAGE$/d" | tr '\n' ' '
1233 echo -e $PACKAGE"\t $(replace_by_wanted) "
1234 done > $tmp/db
1235 while [ -s "$tmp/db" ]; do
1236 status=start
1237 for pkg in $(cut -f 1 $tmp/db); do
1238 if ! grep -q ' '$pkg' ' $tmp/db; then
1239 echo $pkg >> $tmp/cookorder
1240 sed -e "/^$pkg\t/d" -e "s/ $pkg / /g" -i $tmp/db
1241 status=proceed
1242 fi
1243 done
1244 if [ "$status" = start ]; then
1245 cp -f $tmp/db /tmp/remain-depends.txt
1246 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
1247 for blocked in $(cut -f 1 $tmp/db); do
1248 echo "$blocked" >> $PACKAGES_REPOSITORY/blocked
1249 done
1250 break
1251 fi
1252 done
1253 [ -s $tmp/cookorder ] || touch $tmp/cookorder
1255 # The toolchain packages are moved in first position.
1256 grep $(for pkg in `scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1257 --look_for=all --with_args`; do echo " -e ^$pkg$"; done) \
1258 $tmp/cookorder | tac
1259 grep $(for pkg in `scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1260 --look_for=all --with_args`; do echo " -e ^$pkg$"; done) \
1261 $tmp/cookorder | tac > $PACKAGES_REPOSITORY/cookorder.txt
1262 for pkg in $(cat $PACKAGES_REPOSITORY/cookorder.txt); do
1263 sed "/^$pkg$/d" -i $tmp/cookorder
1264 done
1266 tac $tmp/cookorder >> $PACKAGES_REPOSITORY/cookorder.txt
1267 report end-step
1270 ########################################################################
1271 # SCAN CORE
1272 ########################
1273 # Include various scan core-functions. It's not intended to be used
1274 # directly : prefer scan wrappers in next section.
1276 look_for_dep()
1278 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1279 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
1280 | cut -f 2
1281 else
1282 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1283 cut -f 2
1284 fi
1287 look_for_bdep()
1289 # if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1290 # grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
1291 # | cut -f 3
1292 # else
1293 # grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1294 # cut -f 3
1295 # fi
1296 look_for_all
1299 look_for_all()
1301 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1302 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
1303 | cut -f 2,3 | sed 's/ / /'
1304 else
1305 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1306 cut -f 2,3 | sed 's/ / /'
1307 fi
1310 filter()
1312 for pkg in $(cat); do
1313 if grep -q ^$pkg$'\t' $dep_db; then
1314 { grep ^$pkg$'\t' $wan_db || echo $pkg
1315 } | sed 's/\t/ /'
1316 else
1317 echo "Error: $pkg can't be found." >&2
1318 fi
1319 done
1322 look_for_all_filtered()
1324 look_for_all | filter
1327 look_for_rdep()
1329 grep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | cut -f 1
1330 if [ "$undigest" ]; then
1331 for rdep in $(grep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt | cut -f 1); do
1332 if [ ! -f "WOK$/$rdep/receipt" ]; then
1333 echo "$rdep"
1334 fi
1335 done
1336 fi
1339 look_for_rbdep()
1341 grep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | \
1342 cut -f 1,3 | grep ' '$PACKAGE' ' | cut -f 1
1343 if [ "$undigest" ]; then
1344 for rdep in $(grep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-depends.txt \
1345 | cut -f 1,3 | grep ' '$PACKAGE' ' | cut -f 1); do
1346 if [ ! -f "WOK$/$rdep/receipt" ]; then
1347 echo "$rdep"
1348 fi
1349 done
1350 fi
1353 # Return WANTED if it exists.
1354 look_for_wanted()
1356 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1357 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-wanted.txt | cut -f 2
1358 else
1359 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 2
1360 fi
1363 # Return packages which wants PACKAGE.
1364 look_for_rwanted()
1366 grep $'\t'$PACKAGE$ $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 1
1367 if [ "$undigest" ]; then
1368 for rwanted in $(grep $'\t'$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages/wok-wanted.txt | cut -f 1); do
1369 if [ ! -f "$WOK/$rwanted/receipt" ]; then
1370 echo "$rwanted"
1371 fi
1372 done
1373 fi
1376 look_for_dev()
1378 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev && return
1379 [ "$undigest" ] && [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$PACKAGE-dev/receipt" ] && \
1380 echo $PACKAGE-dev
1383 ########################################################################
1384 # SCAN
1385 ########################
1386 # Use wok-wanted.txt and wok-depeds.txt to scan depends.
1387 # Option in command line (must be first arg) :
1388 # --look_for=bdep/rbdep - Look for depends or reverse depends.
1389 # --with_dev - Add development packages (*-dev) in the result.
1390 # --with_wanted - Add package+reverse wanted in the result.
1391 # --with_args - Include packages in argument in the result.
1393 scan()
1395 # Get packages in argument.
1396 local PACKAGE pkg_list=
1397 for arg in $@; do
1398 [ "$arg" = "${arg#--}" ] || continue
1399 pkg_list="$pkg_list $arg"
1400 done
1402 # Get options.
1403 [ "$pkg_list" ] || return
1404 local cooklist= look_for= with_dev= with_wanted= with_args= log_command="$0 $@" \
1405 get_options_list="look_for with_dev with_wanted with_args cooklist"
1406 get_options
1408 # Cooklist is a special case where we need to modify a little
1409 # scan behavior
1410 if [ "$cooklist" ]; then
1411 look_for=all_filtered && with_args=yes && with_dev= && with_wanted= && rwan=yes
1412 pkg_list=$(echo $pkg_list | filter)
1413 fi
1415 ##############################################################
1416 # ADD TO LISTS PROPOSAL ######################################
1417 ##############################################################
1419 include_wanted()
1421 for pkg in $(cat); do
1422 { grep ^$pkg$'\t' $wan_db || echo $pkg
1423 } | sed 's/\t/ /'
1424 done
1427 no_duplication()
1429 for pkg in $(cat); do
1430 grep -q ^$pkg$ $tmp/list $tmp/dep && continue
1431 echo $pkg
1432 done
1435 append_to_list()
1437 no_duplication >> $tmp/list
1438 # OU
1439 include_wanted | no_duplication >> $tmp/list
1442 ##############################################################
1443 mkdir -p $tmp
1444 for PACKAGE in $(echo $pkg_list | filter); do
1445 look_for_$look_for
1446 done | tr ' ' '\n' | sort -u > $tmp/list
1447 [ "$look_for" = bdep ] && look_for=dep
1448 while [ -s $tmp/list ]; do
1449 PACKAGE=$(sed 1!d $tmp/list)
1450 sed 1d -i $tmp/list
1451 echo $PACKAGE >> $tmp/dep
1452 for depend in $(look_for_$look_for); do
1453 if ! grep -q ^$depend$ $tmp/list $tmp/dep; then
1454 echo $depend >> $tmp/list
1455 fi
1456 done
1457 done
1458 [ "$with_args" ] && echo $pkg_list | tr ' ' '\n' >> $tmp/dep
1459 if [ -s $tmp/dep ]; then
1460 if [ "$with_wanted" ]; then
1461 cat $tmp/dep | while read PACKAGE; do
1462 look_for_rwanted >> $tmp/dep
1463 done
1464 elif [ "$with_dev" ]; then
1465 cat $tmp/dep | while read PACKAGE; do
1466 look_for_dev >> $tmp/dep
1467 done
1468 fi
1469 if [ "$cooklist" ]; then
1471 # Make report quiet.
1472 report(){ : ; }
1474 mv $tmp/dep $tmp/cooklist
1475 sort_cooklist
1476 rm $tmp/cooklist
1477 else
1478 cat $tmp/dep | sort -u
1479 fi
1480 fi
1481 rm $tmp/dep $tmp/list 2>/dev/null
1484 ########################################################################
1485 # This section contains functions to check package repository and
1486 # find which packages to cook.
1487 ########################
1489 # Actually its becomes more than check commit... Maybe put this in report
1490 # function is a good idea.
1491 check_for_commit()
1493 report step "Checking for commits"
1495 # Clean the list... Later we will perfom a partial clean only to keep
1496 # some usefull informations
1497 rm $PACKAGES_REPOSITORY/commit 2>/dev/null
1499 # If there's a packages-incoming repository we need to check it too.
1500 for RECEIPT in $(echo $WOK/*/receipt | grep -v '\*'); do
1501 source_receipt
1503 # We use md5 of cooking stuff in the packaged receipt to check
1504 # commit. We look consecutively in 3 different locations :
1505 # - in the wok/PACKAGE/taz folder
1506 # - in the receipt in the package in incoming repository
1507 # - in the receipt in the package in packages repository
1508 # If md5sum match, there's no commit.
1509 # If there's not md5sum datas, because the package was cooked
1510 # with a previous version of tazwok, we don't put in in commit
1511 # list (need a cook-all to refresh them)
1512 # If there's no receipt available, package is missing so we put
1513 # it in commit list.
1514 # First look for package in packages-incoming.
1515 check_for_commit_using_md5sum()
1517 if [ ! -f $WOK/$PACKAGE/md5 ]; then
1518 sed -n '/# md5sum of cooking stuff :/,$p' receipt | \
1519 sed -e 1d -e 's/^# //' > $WOK/$PACKAGE/md5
1520 cd $WOK/$PACKAGE
1521 fi
1523 # Use md5sum list in receipt to check for commit.
1524 if [ -s md5 ]; then
1525 if md5sum -cs md5; then
1526 return_code=0
1528 # If md5sum check if ok, check for new files in
1529 # cooking stuff.
1530 for file in receipt description.txt $( [ -d stuff ] && find stuff); do
1531 if [ -f $file ] && ! grep -q ' '$file$ md5; then
1532 set_commited
1533 fi
1534 done
1535 else
1536 set_commited
1537 fi
1538 else
1539 gen_cookmd5
1540 fi
1542 set_commited()
1544 echo $PACKAGE >> $PACKAGES_REPOSITORY/commit
1545 echo "Commit: $PACKAGE ($VERSION)"
1546 gen_cookmd5
1548 taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | grep -v '\*')
1549 if [ -f $WOK/$PACKAGE/md5 ]; then
1550 cd $WOK/$PACKAGE
1551 check_for_commit_using_md5sum
1552 elif [ "$taz_dir" ]; then
1553 cd $taz_dir
1554 check_for_commit_using_md5sum
1555 else
1556 pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | grep -v '\*')
1557 [ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | grep -v '\*')
1558 if [ "$pkg" ]; then
1559 get_pkg_files $pkg
1560 check_for_commit_using_md5sum
1561 rm -r $pkg_files_dir
1562 continue
1563 fi
1564 set_commited
1565 fi
1566 done
1567 report end-step
1570 gen_cook_list()
1572 if [ -s $PACKAGES_REPOSITORY/commit ]; then
1573 report step "Generate genpkg & cook lists."
1574 cd $PACKAGES_REPOSITORY
1575 #cp commit $tmp/commit
1576 #if [ -s broken ]; then
1577 ## dep_scan return deps including the packages given in argument.
1578 ## To avoid that, we firt generate a list of direct rdepends of
1579 ## brokens without packages in argument, then we generate the
1580 ## full rdeps list. We do this because we don't want to block
1581 ## packages at source of broken tree if a fix as been commited.
1582 #for PACKAGE in $(cat broken); do
1583 #look_for_rdep >> $tmp/broken
1584 #done
1585 #cat $tmp/broken
1586 #look_for=rdep && with_wanted=yes
1587 #for PACKAGE in $(dep_scan `cat $tmp/broken`); do
1588 #if grep -q ^$PACKAGE$ $tmp/commit; then
1589 #sed "/^$PACKAGE$/d" -i $tmp/commit
1590 #fi
1591 #done
1592 #rm $tmp/broken
1593 #fi
1594 for PACKAGE in $(cat commit); do
1595 WANTED="$(look_for_wanted)"
1596 if [ "$WANTED" ]; then
1598 # If cook of wanted package is planned, this one will be
1599 # packaged at the same time. Else if wanted package is
1600 # broken or blocked, ignore the commit. Else, put the
1601 # package in genpkglist.
1602 { grep -q ^$WANTED$ commit || grep -q ^$WANTED$ broken || \
1603 grep -q ^$WANTED$ cooklist || grep -q ^$WANTED$ blocked || \
1604 grep -q ^$WANTED$ genpkglist
1605 } && continue
1606 echo $WANTED >> genpkglist
1607 else
1608 { grep -q ^$PACKAGE$ blocked || grep -q ^$PACKAGE$ cooklist
1609 } && continue
1610 echo $PACKAGE >> cooklist
1611 sed "/^$PACKAGE$/d" -i broken
1612 fi
1613 done
1614 #rm $tmp/commit
1615 if [ -s genpkglist ]; then
1616 echo "genpkglist:"
1617 cat genpkglist
1618 fi
1619 report end-step
1620 fi
1621 cooklist=$PACKAGES_REPOSITORY/cooklist
1622 sort_cooklist
1625 sort_cooklist()
1627 [ ! "$cooklist" ] && cooklist=$PACKAGES_REPOSITORY/cooklist
1628 [ -s $cooklist ] || [ -s "$tmp/cooklist" ] || return
1629 [ -s $PACKAGES_REPOSITORY/cookorder.txt ] || gen_wok_db
1630 [ ! -s "$tmp/cooklist" ] && cp -a $cooklist $tmp/cooklist
1631 report step "Sorting cooklist"
1633 # Use cookorder.txt to sort cooklist.
1634 cat $PACKAGES_REPOSITORY/cookorder.txt | while read PACKAGE; do
1635 if grep -q ^$PACKAGE$ $tmp/cooklist; then
1636 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1637 echo $PACKAGE >> $tmp/cooklist.tmp
1638 fi
1639 done
1641 # Remaining packages in cooklist are thoses without compile_rules.
1642 # They can be cooked first in any order.
1643 mv -f $tmp/cooklist.tmp $tmp/cooklist
1644 [ "$cooklist" = "$PACKAGES_REPOSITORY/cooklist" ] && \
1645 cat $tmp/cooklist > $cooklist
1646 cat $tmp/cooklist
1647 report end-step
1652 #remove_old_packages()
1653 #{
1654 #report step "Removing old packages"
1655 #echo -n "" >> $tmp/oldpkg
1656 #if [ -f $INCOMING_REPOSITORY/packages.txt ]; then
1658 #&& incoming=y
1659 #for RECEIPT in $(echo $WOK/*/receipt | grep -v '\*'); do
1660 #source_receipt
1661 ## First look for package in packages-incoming.
1662 #if [ "$incoming" ]; then
1663 #pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | grep -v '\*')
1664 #fi
1665 #if [ "$pkg" ]; then
1666 #echo $pkg >> $tmp/oldpkg
1667 ## The package in PACKAGES_REPOSITORY, even if old, should not be removed yet.
1668 #echo $PACKAGES_REPOSITORY/$(grep ^$PACKAGE- $PACKAGES_REPOSITORY/packages.list 2>/dev/null)*.tazpkg >> $tmp/oldpkg
1669 #else
1670 #echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg >> $tmp/oldpkg
1671 #fi
1672 #done
1673 #for pkg in $(echo $PACKAGES_REPOSITORY/*.tazpkg | grep -v '\*') \
1674 #$(echo $INCOMING_REPOSITORY/*.tazpkg | grep -v '\*'); do
1675 #grep -q ^$pkg$ $tmp/oldpkg && continue
1676 #echo "Removing $pkg"
1677 ##rm $pkg
1678 #done
1679 #rm $tmp/oldpkg
1680 #}
1682 check_for_incoming()
1684 [ -s $INCOMING_REPOSITORY/packages.txt ] || return
1685 report step "Checking packages-incoming repository"
1686 cd $INCOMING_REPOSITORY
1687 grep ^[0-9,a-z,A-Z] packages.txt > $tmp/incoming
1688 scan `cat $PACKAGES_REPOSITORY/broken` --look_for=bdep --with_wanted > $tmp/broken
1689 for PACKAGE in $(scan `cat $tmp/broken` --look_for=rdep --with_wanted --with_args); do
1690 sed "/^$PACKAGE$/d" -i $tmp/incoming
1691 for rwanted in $(look_for_rwanted); do
1692 sed "/^$rwanted$/d" -i $tmp/incoming
1693 done
1694 done
1695 rm $tmp/broken
1696 if [ "$incoming_delay" != 0 ]; then
1697 cat $tmp/incoming | while read PACKAGE; do
1698 [ "$(grep ^$PACKAGE$ $tmp/incoming)" ] || continue
1699 dep_list=$( { scan $PACKAGE --look_for=bdep --with_wanted && \
1700 scan $PACKAGE --look_for=rdep --with_wanted --with_args; } \
1701 | sort -u )
1702 for dep in $dep_list; do
1703 [ "$(find -name "`get_pkg_version $INCOMING_REPOSITORY`.tazpkg" -mtime +$incoming_delay)" ] && continue
1704 for pkg in $dep_list; do
1705 sed "/^$pkg$/d" -i $tmp/incoming
1706 done && break
1707 done
1708 done
1709 fi
1710 if [ -s "$tmp/incoming" ]; then
1711 for PACKAGE in $(cat $tmp/incoming); do
1712 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
1713 remove_previous_package $PACKAGES_REPOSITORY
1714 remove_previous_tarball
1715 cur_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
1716 mv -f $PACKAGE-$cur_VERSION.tazpkg $PACKAGES_REPOSITORY
1717 echo "Moving $PACKAGE to main repository."
1718 done
1719 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
1720 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
1721 fi
1722 report end-step
1725 ########################################################################
1726 # TAZWOK MAIN FUNCTIONS
1727 ########################
1729 clean()
1731 cd $WOK/$PACKAGE
1732 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
1733 -e ^stuff$ || return
1735 report step "Cleaning $PACKAGE"
1736 # Check for clean_wok function.
1737 if grep -q ^clean_wok $RECEIPT; then
1738 clean_wok
1739 fi
1740 # Clean should only have a receipt, stuff and optional desc.
1741 for f in `ls .`
1742 do
1743 case $f in
1744 receipt|stuff|description.txt)
1745 continue ;;
1746 *)
1747 echo "Removing: $f"
1748 rm -rf $f
1749 esac
1750 done
1751 report end-step
1754 # Configure and make a package with the receipt.
1755 compile_package()
1757 check_for_package_on_cmdline
1759 # Include the receipt to get all needed variables and functions
1760 # and cd into the work directory to start the work.
1761 check_for_receipt
1762 source_receipt
1764 # Log the package name and date.
1765 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
1766 echo "package $PACKAGE (compile)" >> $LOG
1768 # Set wanted $src variable to help compiling.
1769 [ ! "$src" ] && set_src_path
1770 check_for_build_depends || return 1
1771 check_for_wanted
1772 unset target
1773 check_for_tarball && check_for_compile_rules
1776 # Cook command also include all features to manage lists which keep
1777 # track of wok/packages state.
1778 cook()
1780 cook_code=
1781 set_common_path
1782 check_for_receipt
1783 source_receipt
1785 # Define log path and start report.
1786 [ -f $LOCAL_REPOSITORY/log/$PACKAGE.html ] && rm $LOCAL_REPOSITORY/log/$PACKAGE.html
1787 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
1788 report step "Cooking $PACKAGE"
1789 report open-bloc
1791 # Clean package if needed.
1792 clean $PACKAGE
1794 # Remove PACKAGE from commit & cook lists.
1795 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/commit
1796 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/cooklist
1797 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
1799 if compile_package; then
1800 refresh_packages_from_compile
1801 gen_package
1802 remove_src
1804 # Plan recook of reverse build depends if gen_package has detect
1805 # a change in libraries.
1806 if [ "$cook_rdep" ]; then
1807 report step "Look for packages which need a refresh"
1808 for rdep in $(scan $PACKAGE --look_for=rdep); do
1809 sed "/^$rdep$/d" -i $PACKAGES_REPOSITORY/broken
1810 if [ -f $WOK/$rdep/receipt ] && ! grep -q ^$rdep$ $tmp/cooklist; then
1811 echo "Add $rdep in cooklist to avoid broke caused by library update in $PACKAGE"
1812 echo $rdep >> $tmp/cooklist
1813 regen_cooklist=yes
1814 fi
1815 done
1816 report end-step
1817 fi
1819 # Update packages-incoming repository.
1820 store_pkgname=$PACKAGE
1821 pkg_repository=$INCOMING_REPOSITORY
1822 update_packages_db
1824 PACKAGE=$store_pkgname
1825 unset store_pkgname
1827 # Upgrade to cooked packages if it was previously installed.
1828 report step "Look for package(s) to upgrade"
1829 for pkg in $(look_for_rwanted) $PACKAGE; do
1830 if [ -d $INSTALLED/$pkg ]; then
1831 tazpkg get-install $pkg --forced
1832 fi
1833 done
1834 report end-step
1835 else
1837 # Set package as broken.
1838 if ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then
1839 echo $PACKAGE >> $PACKAGES_REPOSITORY/broken
1840 fi
1841 gen_cookmd5
1842 cook_code=1
1843 fi
1845 # Remove build_depends in cook mode (if in cooklist, it's done when
1846 # checking build_depends of next package and we remove only unneeded
1847 # packages to keep chroot minimal and gain some time).
1848 [ "$COMMAND" = cook ] && remove_build_depends $MISSING_PACKAGE
1850 # Regen the cooklist if it was planned and command is not cook.
1851 [ "$regen_cooklist" ] && unset regen_cooklist && \
1852 [ "$COMMAND" != cook ] && sort_cooklist
1854 # Some hacks to set the bloc & function status as failed if cook was
1855 # failed.
1856 report_return_code=$cook_code
1857 report close-bloc
1858 report end-sublog
1859 return $cook_code
1862 genpkg_list()
1864 while [ -s $PACKAGES_REPOSITORY/genpkglist ]; do
1865 PACKAGE=$(sed 1!d $PACKAGES_REPOSITORY/genpkglist)
1866 gen_package
1867 done
1870 cook_list()
1872 if [ ! -s $cooklist ]; then
1873 echo "Nothing to cook."
1874 return
1875 fi
1876 if [ -f /usr/bin/tazchroot ]; then
1877 # Note : options -main variables- are automatically keeped by
1878 # the sub-applications tazchroot/tazwok; as well as report data.
1879 cd $LOCAL_REPOSITORY
1880 [ ! -f tazchroot.conf ] && configure_tazchroot
1881 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
1882 return
1883 fi
1884 while [ -s $tmp/cooklist ]; do
1885 PACKAGE=$(sed 1!d $tmp/cooklist)
1886 cook
1887 done
1888 remove_build_depends $MISSING_PACKAGE $remove_later
1891 configure_tazchroot()
1893 cat >> $LOCAL_REPOSITORY/tazchroot.conf << EOF
1894 # Tazchroot configuration file - created by tazwok.
1896 # Default chroot path
1897 SLITAZ_DIR=$SLITAZ_DIR
1898 SLITAZ_VERSION=$SLITAZ_VERSION
1899 $( [ "$undigest" ] && echo "undigest=$undigest" )
1900 LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
1901 chroot_dir=\$LOCAL_REPOSITORY/chroot
1903 # Default scripts path (theses scripts are added in the
1904 # $chroot_dir/usr/bin and can be called with tazchroot script)
1905 script_dir=/var/lib/tazchroot
1907 # List of directories to mount.
1908 list_dir="$(for dir in packages wok src packages-incoming log flavors iso; do [ -d "$LOCAL_REPOSITORY/$dir" ] && echo $LOCAL_REPOSITORY/$dir; done)
1909 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
1911 create_chroot()
1913 mkdir -p \$chroot_dir
1914 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
1915 tazpkg get-install \$pkg --root="\$chroot_dir"
1916 done
1918 # Store list of installed packages needed by cleanchroot.
1919 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCAL_STATE/chroot-pkgs
1921 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
1922 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
1923 -i \$chroot_dir/etc/slitaz/slitaz.conf
1924 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
1925 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
1928 mount_chroot()
1930 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
1931 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCAL_STATE/mirror
1932 mkdir -p \$chroot_dir\$LOCAL_STATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
1933 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCAL_STATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
1934 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCAL_STATE/undigest/$SLITAZ_VERSION
1935 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCAL_STATE/undigest/$SLITAZ_VERSION/mirror' )
1936 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCAL_STATE/priority
1937 mount -t proc proc \$chroot_dir/proc
1938 mount -t sysfs sysfs \$chroot_dir/sys
1939 mount -t devpts devpts \$chroot_dir/dev/pts
1940 mount -t tmpfs shm \$chroot_dir/dev/shm
1941 for dir in \$list_dir; do
1942 mkdir -p \$dir \$chroot_dir\$dir
1943 mount \$dir \$chroot_dir\$dir
1944 done
1947 umount_chroot()
1949 for dir in \$list_dir; do
1950 umount \$chroot_dir\$dir
1951 done
1952 umount \$chroot_dir/dev/shm
1953 umount \$chroot_dir/dev/pts
1954 umount \$chroot_dir/sys
1955 umount \$chroot_dir/proc
1957 EOF
1960 ########################################################################
1961 ######################### END OF NEW FUNCTIONS #########################
1962 ########################################################################
1964 # List packages providing a virtual package
1965 whoprovide()
1967 local i;
1968 for i in $(grep -l PROVIDE $WOK/*/receipt); do
1969 . $i
1970 case " $PROVIDE " in
1971 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
1972 esac
1973 done
1976 ########################################################################
1977 # TAZWOK COMMANDS
1978 ########################
1980 case "$COMMAND" in
1981 stats)
1982 # Tazwok general statistics from the wok config file.
1984 get_tazwok_config
1985 echo -e "\n\033[1mTazwok configuration statistics\033[0m
1986 ================================================================================
1987 Wok directory : $WOK
1988 Packages repository : $PACKAGES_REPOSITORY
1989 Incoming repository : $INCOMING_REPOSITORY
1990 Sources repository : $SOURCES_REPOSITORY
1991 Log directory : $LOCAL_REPOSITORY/log
1992 Packages in the wok : `ls -1 $WOK | wc -l`
1993 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
1994 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
1995 ================================================================================\n"
1996 ;;
1997 edit)
1998 get_tazwok_config
1999 check_for_package_on_cmdline
2000 check_for_receipt
2001 $EDITOR $WOK/$PACKAGE/receipt
2002 ;;
2003 build-depends)
2004 # List dependencies to rebuild wok, or only a package
2005 get_tazwok_config
2006 if [ "$PACKAGE" = toolchain-cooklist ]; then
2007 mkdir -p $tmp
2008 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
2009 --cooklist
2010 elif [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
2011 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
2012 --look_for=dep --with_dev --with_args
2013 else
2014 check_for_package_on_cmdline
2015 scan $PACKAGE --look_for=bdep --with_dev
2016 fi
2017 ;;
2018 gen-cooklist)
2019 get_options_list="list"
2020 get_tazwok_config
2021 if [ "$list" ]; then
2022 LIST="$list"
2023 check_for_list
2024 else
2025 LIST=$(for pkg in $@; do
2026 [ "$pkg" = "${pkg#--}" ] || continue
2027 echo -n "$pkg "
2028 done)
2029 if [ ! "$LIST" ]; then
2030 echo "Please give packages or a list file in argument." >&2
2031 exit
2032 fi
2033 fi
2034 scan $LIST --cooklist
2035 ;;
2036 check-depends)
2037 # Check package depends /!\
2038 get_tazwok_config
2039 echo ""
2040 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
2041 ================================================================================"
2042 TMPDIR=/tmp/tazwok$$
2043 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
2045 # Build ALL_DEPENDS variable
2046 scan_dep()
2048 local i
2049 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
2050 for i in $DEPENDS $SUGGESTED ; do
2051 case " $ALL_DEPENDS " in
2052 *\ $i\ *) continue;;
2053 esac
2054 [ -d $WOK/$i ] || {
2055 ALL_DEPENDS="$ALL_DEPENDS$i "
2056 continue
2058 DEPENDS=""
2059 SUGGESTED=""
2060 . $WOK/$i/receipt
2061 scan_dep
2062 done
2065 # Check for ELF file
2066 is_elf()
2068 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" \
2069 = "ELF" ]
2072 # Print shared library dependencies
2073 ldd()
2075 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
2078 mkdir $TMPDIR
2079 cd $TMPDIR
2080 for i in $LOCALSTATE/files.list.lzma \
2081 $LOCALSTATE/undigest/*/files.list.lzma ; do
2082 [ -f $i ] && lzma d $i -so >> files.list
2083 done
2084 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
2085 tazpkg extract $pkg > /dev/null 2>&1
2086 . */receipt
2087 ALL_DEPENDS="$DEFAULT_DEPENDS "
2088 scan_dep
2089 find */fs -type f | while read file ; do
2090 is_elf $file || continue
2091 case "$file" in
2092 *.o|*.ko|*.ko.gz) continue;;
2093 esac
2094 ldd $file | while read lib rem; do
2095 case "$lib" in
2096 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
2097 continue;;
2098 esac
2099 for dep in $(grep $lib files.list | cut -d: -f1); do
2100 case " $ALL_DEPENDS " in
2101 *\ $dep\ *) continue 2;;
2102 esac
2103 for vdep in $(grep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
2104 case " $ALL_DEPENDS " in
2105 *\ $vdep\ *) continue 3;;
2106 esac
2107 done
2108 done
2109 [ -n "$dep" ] || dep="UNKNOWN"
2110 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
2111 done
2112 done
2113 rm -rf */
2114 done
2115 cd /tmp
2116 rm -rf $TMPDIR
2117 ;;
2118 check)
2119 # Check wok consistency
2120 get_tazwok_config
2121 echo ""
2122 echo -e "\033[1mWok and packages checking\033[0m
2123 ================================================================================"
2124 cd $WOK
2125 for pkg in $(ls)
2126 do
2127 [ -f $pkg/receipt ] || continue
2128 RECEIPT= $pkg/receipt
2129 source_receipt
2130 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
2131 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
2132 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
2133 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
2134 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
2135 if [ -n "$WANTED" ]; then
2136 if [ ! -f $WANTED/receipt ]; then
2137 echo "Package $PACKAGE wants unknown $WANTED package" >&2
2138 else
2139 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
2140 if [ "$VERSION" = "$WANTED" ]; then
2141 # BASEVERSION is computed in receipt
2142 grep -q '_pkg=' $pkg/receipt &&
2143 BASEVERSION=$VERSION
2144 fi
2145 if [ "$VERSION" != "$BASEVERSION" ]; then
2146 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
2147 fi
2148 fi
2149 fi
2151 if [ -n "$CATEGORY" ]; then
2152 case " $(echo $CATEGORIES) " in
2153 *\ $CATEGORY\ *);;
2154 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
2155 esac
2156 else
2157 echo"Package $PACKAGE has no CATEGORY" >&2
2158 fi
2159 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
2160 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
2161 case "$WGET_URL" in
2162 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
2163 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
2164 '') ;;
2165 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
2166 esac
2167 case "$WEB_SITE" in
2168 ftp*|http*);;
2169 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
2170 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
2171 esac
2172 case "$MAINTAINER" in
2173 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
2174 esac
2175 case "$MAINTAINER" in
2176 *@*);;
2177 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
2178 esac
2179 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2180 for i in $DEPENDS; do
2181 [ -d $i ] && continue
2182 [ -n "$(whoprovide $i)" ] && continue
2183 echo -e "$MSG $i"
2184 MSG=""
2185 done
2186 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2187 for i in $BUILD_DEPENDS; do
2188 [ -d $i ] && continue
2189 [ -n "$(whoprovide $i)" ] && continue
2190 echo -e "$MSG $i"
2191 MSG=""
2192 done
2193 MSG="Dependencies loop between $PACKAGE and :\n"
2194 ALL_DEPS=""
2195 check_for_deps_loop $PACKAGE $DEPENDS
2196 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
2197 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
2198 echo "$pkg should be rebuilt after $i installation"
2199 done
2200 done
2201 ;;
2202 list)
2203 # List packages in wok directory. User can specify a category.
2205 get_tazwok_config
2206 if [ "$2" = "category" ]; then
2207 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
2208 exit 0
2209 fi
2210 # Check for an asked category.
2211 if [ -n "$2" ]; then
2212 ASKED_CATEGORY=$2
2213 echo ""
2214 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
2215 echo "================================================================================"
2216 for pkg in $WOK/*
2217 do
2218 [ ! -f $pkg/receipt ] && continue
2219 . $pkg/receipt
2220 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
2221 echo -n "$PACKAGE"
2222 echo -e "\033[28G $VERSION"
2223 packages=$(($packages+1))
2224 fi
2225 done
2226 echo "================================================================================"
2227 echo -e "$PACKAGEs packages in category $ASKED_CATEGORY.\n"
2228 else
2229 # By default list all packages and version.
2230 echo ""
2231 echo -e "\033[1mList of packages in the wok\033[0m"
2232 echo "================================================================================"
2233 for pkg in $WOK/*
2234 do
2235 [ ! -f $pkg/receipt ] && continue
2236 . $pkg/receipt
2237 echo -n "$PACKAGE"
2238 echo -en "\033[28G $VERSION"
2239 echo -e "\033[42G $CATEGORY"
2240 packages=$(($packages+1))
2241 done
2242 echo "================================================================================"
2243 echo -e "$PACKAGEs packages available in the wok.\n"
2244 fi
2245 ;;
2246 info)
2247 # Information about a package.
2249 get_tazwok_config
2250 check_for_package_on_cmdline
2251 check_for_receipt
2252 . $WOK/$PACKAGE/receipt
2253 echo ""
2254 echo -e "\033[1mTazwok package information\033[0m
2255 ================================================================================
2256 Package : $PACKAGE
2257 Version : $VERSION
2258 Category : $CATEGORY
2259 Short desc : $SHORT_DESC
2260 Maintainer : $MAINTAINER"
2261 if [ ! "$WEB_SITE" = "" ]; then
2262 echo "Web site : $WEB_SITE"
2263 fi
2264 if [ ! "$DEPENDS" = "" ]; then
2265 echo "Depends : $DEPENDS"
2266 fi
2267 if [ ! "$WANTED" = "" ]; then
2268 echo "Wanted src : $WANTED"
2269 fi
2270 echo "================================================================================"
2271 echo ""
2272 ;;
2273 check-log)
2274 # We just cat the file log to view process info.
2276 get_tazwok_config
2277 if [ ! -f "$LOG" ]; then
2278 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
2279 exit 1
2280 else
2281 echo ""
2282 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
2283 echo "================================================================================"
2284 cat $LOG
2285 echo "================================================================================"
2286 echo ""
2287 fi
2288 ;;
2289 search)
2290 # Search for a package by pattern or name.
2292 get_tazwok_config
2293 if [ -z "$2" ]; then
2294 echo -e "\nPlease specify a pattern or a package name to search." >&2
2295 echo -e "Example : 'tazwok search gcc'.\n" >&2
2296 exit 1
2297 fi
2298 echo ""
2299 echo -e "\033[1mSearch result for :\033[0m $2"
2300 echo "================================================================================"
2301 list=`ls -1 $WOK | grep $2`
2302 for pkg in $list
2303 do
2304 . $WOK/$pkg/receipt
2305 echo -n "$PACKAGE "
2306 echo -en "\033[24G $VERSION"
2307 echo -e "\033[42G $CATEGORY"
2308 packages=$(($PACKAGEs+1))
2309 done
2310 echo "================================================================================"
2311 echo "$PACKAGEs packages found for : $2"
2312 echo ""
2313 ;;
2314 compile)
2315 # Configure and make a package with the receipt.
2317 get_tazwok_config
2318 source_lib report
2319 report start
2320 compile_package
2321 ;;
2322 genpkg)
2323 # Generate a package.
2325 get_tazwok_config
2326 source_lib report
2327 report start
2328 mkdir $tmp
2329 gen_package
2330 ;;
2331 cook)
2332 # Compile and generate a package. Just execute tazwok with
2333 # the good commands.
2335 check_root
2336 get_tazwok_config
2337 source_lib report
2338 report start
2339 mkdir -p $tmp
2340 cook
2341 ;;
2342 sort-cooklist)
2343 if [ ! "$LIST" ]; then
2344 echo "Usage : tazwok sort-cooklist cooklist" >&2\
2345 exit 1
2346 fi
2347 get_tazwok_config
2348 source_lib report
2349 report start
2350 mkdir -p $tmp
2351 cooklist=$LIST
2352 sort_cooklist
2353 cp -af $tmp/cooklist $cooklist
2354 ;;
2355 cook-list)
2356 # Cook all packages listed in a file. The path to the cooklist must
2357 # be specified on the cmdline.
2358 # /!\
2359 check_root
2360 get_tazwok_config
2361 source_lib report
2362 report start
2363 mkdir -p $tmp
2364 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2365 if [ "$LIST" ]; then
2366 sort_cooklist
2367 else
2368 cp $cooklist $tmp/cooklist
2369 fi
2370 cook_list
2371 ;;
2372 clean)
2373 # Clean up a package work directory + thoses which want it.
2375 get_tazwok_config
2376 check_for_package_on_cmdline
2377 check_for_receipt
2378 source_lib report
2379 report start
2380 . $RECEIPT
2381 clean
2382 ;;
2383 gen-clean-wok)
2384 # Generate a clean wok from the current wok by copying all receipts
2385 # and stuff directory.
2387 get_tazwok_config
2388 source_lib report
2389 report start
2390 if [ -z "$ARG" ]; then
2391 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
2392 exit 1
2393 else
2394 dest=$ARG
2395 mkdir -p $dest
2396 fi
2397 report step "Creating clean wok in : $dest"
2398 for pkg in `ls -1 $WOK`
2399 do
2400 mkdir -p $dest/$pkg
2401 cp -a $WOK/$pkg/receipt $dest/$pkg
2402 [ -f $WOK/$pkg/description.txt ] && \
2403 cp -a $WOK/$pkg/description.txt $dest/$pkg
2404 if [ -d "$WOK/$pkg/stuff" ]; then
2405 cp -a $WOK/$pkg/stuff $dest/$pkg
2406 fi
2407 done
2408 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
2409 report end-step
2410 echo "Packages cleaned : `ls -1 $dest | wc -l`"
2411 echo ""
2412 ;;
2413 clean-wok)
2414 # Clean all packages in the work directory
2416 get_tazwok_config
2417 source_lib report
2418 report start
2419 report step "Cleaning wok"
2420 report open-bloc
2421 for PACKAGE in `ls -1 $WOK`
2422 do
2423 set_common_path
2424 source_receipt
2425 clean
2426 done
2427 report close-bloc
2428 echo "`ls -1 $WOK | wc -l` packages cleaned."
2429 ;;
2430 gen-list)
2431 check_root
2432 get_tazwok_config
2433 source_lib report
2434 report start
2435 dbtype=packages
2436 mode=gen
2437 for pkg_repository in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
2438 files_list="$pkg_repository/files.list.lzma \
2439 $pkg_repository/packages.list \
2440 $pkg_repository/packages.txt \
2441 $pkg_repository/packages.desc \
2442 $pkg_repository/packages.equiv \
2443 $pkg_repository/packages.md5"
2444 gen_db
2445 echo "$pkgs packages in the repository."
2446 echo ""
2447 done
2448 ;;
2449 check-list)
2450 # The directory to move into by default is the repository,
2451 # if $2 is not empty cd into $2.
2453 get_tazwok_config
2454 if [ -z "$2" ]; then
2455 PACKAGES_REPOSITORY=$PACKAGES_REPOSITORY
2456 else
2457 if [ -d "$2" ]; then
2458 PACKAGES_REPOSITORY=$2
2459 else
2460 echo -e "\nUnable to find directory : $2\n" >&2
2461 exit 1
2462 fi
2463 fi
2465 # Use report shared library to control output.
2466 tmp=/tmp/tazwok-$$
2467 mkdir $tmp
2468 source_lib report
2469 dbtype=packages
2470 mode=update
2471 cd $PACKAGES_REPOSITORY
2472 for pkg in $(echo *.tazpkg); do
2473 package_md5=$(md5sum $pkg)
2474 [ "$PACKAGE_md5" = "$(grep ' '$pkg$ packages.md5)" ] && continue
2475 erase_package_info
2476 get_packages_info
2477 done
2478 echo "$pkgs packages in the repository."
2479 echo ""
2480 ;;
2481 new-tree)
2482 # Just create a few directories and generate an empty receipt to prepare
2483 # the creation of a new package.
2485 get_tazwok_config
2486 check_for_package_on_cmdline
2487 if [ -d $WOK/$PACKAGE ]; then
2488 echo -e "\n$PACKAGE package tree already exists.\n" >&2
2489 exit 1
2490 fi
2491 echo "Creating : $WOK/$PACKAGE"
2492 mkdir $WOK/$PACKAGE
2493 cd $WOK/$PACKAGE
2494 echo -n "Preparing the receipt..."
2496 # Default receipt begin.
2498 echo "# SliTaz package receipt." > receipt
2499 echo "" >> receipt
2500 echo "PACKAGE=\"$PACKAGE\"" >> receipt
2501 # Finish the empty receipt.
2502 cat >> receipt << "EOF"
2503 VERSION=""
2504 CATEGORY=""
2505 SHORT_DESC=""
2506 MAINTAINER=""
2507 DEPENDS=""
2508 TARBALL="$PACKAGE-$VERSION.tar.gz"
2509 WEB_SITE=""
2510 WGET_URL=""
2512 # Rules to configure and make the package.
2513 compile_rules()
2515 cd $src
2516 ./configure \
2517 --prefix=/usr \
2518 --infodir=/usr/share/info \
2519 --mandir=/usr/share/man \
2520 $CONFIGURE_ARGS &&
2521 make -j 4 && make DESTDIR=$PWD/_pkg install
2524 # Rules to gen a SliTaz package suitable for Tazpkg.
2525 genpkg_rules()
2527 mkdir -p $fs/usr
2528 cp -a $_pkg/usr/bin $fs/usr
2531 EOF
2533 # Default receipt end.
2535 status
2536 # Interactive mode, asking and seding.
2537 if [ "$3" = "--interactive" ]; then
2538 echo "Entering into interactive mode..."
2539 echo "================================================================================"
2540 echo "Package : $PACKAGE"
2541 # Version.
2542 echo -n "Version : " ; read anser
2543 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
2544 # Category.
2545 echo -n "Category : " ; read anser
2546 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
2547 # Short description.
2548 echo -n "Short desc : " ; read anser
2549 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
2550 # Maintainer.
2551 echo -n "Maintainer : " ; read anser
2552 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
2553 # Web site.
2554 echo -n "Web site : " ; read anser
2555 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
2556 echo ""
2557 # Wget URL.
2558 echo "Wget URL to download source tarball."
2559 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
2560 echo -n "Wget url : " ; read anser
2561 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
2562 # Ask for a stuff dir.
2563 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
2564 if [ "$anser" = "y" ]; then
2565 echo -n "Creating the stuff directory..."
2566 mkdir stuff && status
2567 fi
2568 # Ask for a description file.
2569 echo -n "Are you going to write a description ? (y/N) : " ; read anser
2570 if [ "$anser" = "y" ]; then
2571 echo -n "Creating the description.txt file..."
2572 echo "" > description.txt && status
2573 fi
2574 echo "================================================================================"
2575 echo ""
2576 fi
2577 ;;
2578 remove)
2579 # Remove a package from the wok.
2581 get_tazwok_config
2582 check_for_package_on_cmdline
2583 echo ""
2584 echo -n "Please confirm deletion (y/N) : "; read anser
2585 if [ "$anser" = "y" ]; then
2586 echo -n "Removing $PACKAGE..."
2587 rm -rf $WOK/$PACKAGE && status
2588 echo ""
2589 fi
2590 ;;
2591 hgup)
2592 # Pull and update a Hg wok.
2593 get_tazwok_config
2594 if ls -l $WOK/.hg/hgrc | grep -q "root"; then
2595 check_root
2596 fi
2597 cd $WOK
2598 hg pull && hg update
2599 ;;
2600 maintainers)
2601 get_tazwok_config
2602 echo ""
2603 echo "List of maintainers for: $WOK"
2604 echo "================================================================================"
2605 touch /tmp/slitaz-maintainers
2606 for pkg in $WOK/*
2607 do
2608 . $pkg/receipt
2609 if ! grep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
2610 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
2611 echo "$MAINTAINER"
2612 fi
2613 done
2614 echo "================================================================================"
2615 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
2616 echo ""
2617 # Remove tmp files
2618 rm -f /tmp/slitaz-maintainers
2619 ;;
2620 maintained-by)
2621 # Search for packages maintained by a contributor.
2622 get_tazwok_config
2623 if [ ! -n "$2" ]; then
2624 echo "Specify a name or email of a maintainer." >&2
2625 exit 1
2626 fi
2627 echo "Maintainer packages"
2628 echo "================================================================================"
2629 for pkg in $WOK/*
2630 do
2631 . $pkg/receipt
2632 if echo "$MAINTAINER" | grep -q "$2"; then
2633 echo "$PACKAGE"
2634 packages=$(($PACKAGEs+1))
2635 fi
2636 done
2637 echo "================================================================================"
2638 echo "Packages maintained by $2: $PACKAGEs"
2639 echo ""
2640 ;;
2641 check-src)
2642 # Verify if upstream package is still available
2644 get_tazwok_config
2645 check_for_package_on_cmdline
2646 check_for_receipt
2647 source_receipt
2648 check_src()
2650 for url in $@; do
2651 busybox wget -s $url 2>/dev/null && break
2652 done
2654 if [ "$WGET_URL" ];then
2655 echo -n "$PACKAGE : "
2656 check_src $WGET_URL
2657 status
2658 else
2659 echo "No tarball to check for $PACKAGE"
2660 fi
2661 ;;
2662 get-src)
2663 check_root
2664 get_options_list="target"
2665 get_tazwok_config
2666 check_for_package_on_cmdline
2667 check_for_receipt
2668 source_receipt
2669 if [ "$WGET_URL" ];then
2670 source_lib report
2671 report start
2672 check_for_tarball
2673 else
2674 echo "No tarball to download for $PACKAGE"
2675 fi
2676 ;;
2677 check-commit)
2678 check_root
2679 get_tazwok_config
2680 source_lib report
2681 report start
2682 mkdir -p $tmp
2683 check_for_commit
2684 gen_cook_list
2685 ;;
2686 cook-commit)
2687 check_root
2688 get_tazwok_config
2689 source_lib report
2690 report start
2691 mkdir -p $tmp
2692 check_for_commit
2693 # 2) update cook-database (actually complete regeneration)
2694 dbtype=wok
2695 mode=gen
2696 files_list="$dep_db $wan_db $PACKAGE_REPOSITORY/cookorder.txt"
2697 gen_db
2698 # 3) check cooklist
2699 # 3.1) rename pkgs with wanted variable to wanted pkg
2700 gen_cook_list
2701 cook_list
2702 ;;
2703 cook-all)
2704 check_root
2705 get_tazwok_config
2706 source_lib report
2707 report start
2708 mkdir -p $tmp
2709 # 2) update cook-database (actually complete regeneration)
2710 dbtype=wok
2711 mode=gen
2712 files_list="$dep_db $wan_db $PACKAGE_REPOSITORY/cookorder.txt"
2713 gen_db
2714 # Add all packages, without toolchain, in cooklist.
2715 # Recook toolchain need to be coded.
2716 echo -n "" > $PACKAGES_REPOSITORY/cooklist
2717 for pkg in $(cd $WOK && echo *); do
2718 echo $pkg >> $PACKAGES_REPOSITORY/cooklist
2719 done
2720 for pkg in $(scan gcc --look_for=all --with_wanted --with_args); do
2721 sed "/^$pkg$/d" -i $PACKAGES_REPOSITORY/cooklist
2722 done
2723 sort_cooklist
2724 cook_list
2725 ;;
2726 gen-wok-db)
2727 check_root
2728 get_tazwok_config
2729 source_lib report
2730 report start
2731 mkdir $tmp
2732 dbtype=wok
2733 mode=gen
2734 files_list="$dep_db $wan_db $PACKAGE_REPOSITORY/cookorder.txt"
2735 gen_db
2736 ;;
2737 report)
2738 check_root
2739 get_tazwok_config
2740 cd $PACKAGES_REPOSITORY
2741 for i in commit genpkglist cooklist incoming broken blocked; do
2742 if [ -s $i ]; then
2743 echo -e "\n********************* $i *********************\n$(cat $i)\n*********************"
2744 fi
2745 done
2746 ;;
2747 check-incoming)
2748 check_root
2749 get_tazwok_config
2750 source_lib report
2751 report start
2752 mkdir $tmp
2753 check_for_incoming
2754 ;;
2755 remove-old)
2756 check_root
2757 get_tazwok_config
2758 source_lib report
2759 report start
2760 mkdir $tmp
2761 remove_old_packages
2762 ;;
2763 chroot)
2764 check_root
2765 get_tazwok_config
2766 # Merge this and the other chroot function ?.
2767 if [ -f /usr/bin/tazchroot ]; then
2768 cd $LOCAL_REPOSITORY
2769 [ ! -f tazchroot.conf ] && configure_tazchroot
2770 tazchroot
2771 else
2772 echo "The packages tazchroot need to be installed" >&2
2773 exit 1
2774 fi
2775 ;;
2776 cook-toolchain)
2777 check_root
2778 get_tazwok_config
2779 echo -n "" > $PACKAGES_REPOSITORY/broken
2780 if [ -f /usr/bin/tazchroot ]; then
2781 cd $LOCAL_REPOSITORY
2782 [ ! -f tazchroot.conf ] && configure_tazchroot
2783 tazchroot cook-toolchain
2784 # Buggy : chroot can be elsewhere.
2785 rm -r $LOCAL_REPOSITORY/chroot
2786 # /!\ to be writed :
2787 # next rm chroot and plan cook-all by pushing all packages
2788 # in cooklist.
2789 else
2790 echo "The packages tazchroot need to be installed" >&2
2791 exit 1
2792 fi
2793 ;;
2794 usage|*)
2795 # Print usage also for all unknown commands.
2797 usage
2798 ;;
2799 esac
2801 [ -d "$tmp" ] && rm -r $tmp
2802 report stop 2>/dev/null || exit 0