tazwok view tazwok @ rev 234

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