tazwok view tazwok @ rev 119

Add check-depends
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Mar 11 11:00:50 2009 +0000 (2009-03-11)
parents 3fa6decf700e
children 1803f2206ec5
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 #
11 VERSION=2.2
13 ####################
14 # Tazwok variables #
15 ####################
17 # Packages categories.
18 CATEGORIES="
19 base-system
20 x-window
21 utilities
22 network
23 graphics
24 multimedia
25 office
26 development
27 system-tools
28 security
29 games
30 misc
31 meta
32 non-free"
34 # Use words rather than numbers in the code.
35 COMMAND=$1
36 PACKAGE=$2
37 LIST=$2
39 # Include config file or exit if no file found.
40 if [ -f "./tazwok.conf" ]; then
41 . ./tazwok.conf
42 elif [ -f "/etc/tazwok.conf" ]; then
43 . /etc/tazwok.conf
44 else
45 echo -e "\nUnable to find the configuration file : /etc/tazwok.conf"
46 echo -e "Please read the Tazwok documentation.\n"
47 exit 0
48 fi
50 # Create Taz wok needed directories if user is root.
51 if test $(id -u) = 0 ; then
52 # Check for the wok directory.
53 if [ ! -d "$WOK" ]; then
54 echo "Creating the wok directory..."
55 mkdir -p $WOK
56 chmod 777 $WOK
57 fi
58 # Check for the packages repository.
59 if [ ! -d "$PACKAGES_REPOSITORY" ]; then
60 echo "Creating the packages repository..."
61 mkdir -p $PACKAGES_REPOSITORY
62 fi
63 # Check for the sources repository.
64 if [ ! -d "$SOURCES_REPOSITORY" ]; then
65 echo "Creating the sources repository..."
66 mkdir -p $SOURCES_REPOSITORY
67 fi
68 fi
70 # The path to the most important file used by Tazwok.
71 # The receipt is used to compile the source code and
72 # generate suitable packages for Tazpkg.
73 RECEIPT="$WOK/$PACKAGE/receipt"
75 # The path to the process log file.
76 LOG="$WOK/$PACKAGE/process.log"
78 ####################
79 # Tazwok functions #
80 ####################
82 # Print the usage (English).
83 usage ()
84 {
85 echo -e "\nSliTaz sources compiler and packages generator - Version: $VERSION\n
86 \033[1mUsage: \033[0m `basename $0` [command] [package|list|category|dir|id] [--option]
87 \033[1mCommands: \033[0m\n
88 usage Print this short usage.
89 stats Print Tazwok statistics from the config file and the wok.
90 build-depends Generate a list of package to build wok.
91 cmp|compare Compare the wok and the cooked pkgs (--remove old pkgs).
92 list List all packages in the wok tree or by category.
93 info Get information about a package in the wok.
94 check Check every receipt for common errors.
95 check-log Check the process log file of a package.
96 check-depends Check every receipt for DEPENDS misses scanning ELF files
97 search Search for a package in the wok by pattern or name.
98 compile Configure and build a package using the receipt rules.
99 genpkg Generate a suitable package for Tazpkg with the rules.
100 cook Compile and generate a package directly.
101 cook-list Cook all packages specified in the list by order.
102 clean Clean all generated files in the package tree.
103 new-tree Prepare a new package tree and receipt (--interactive).
104 gen-list Generate a packages list for a repository (--text).
105 gen-clean-wok Gen a clean wok in a dir ('clean-wok' cleans current wok).
106 remove Remove a package from the wok.
107 hgup Pull and update a wok under Hg.
108 maintainers List all maintainers in the wok.
109 maintained-by List packages maintained by a contributor\n"
110 }
112 # Status function.
113 status()
114 {
115 local CHECK=$?
116 echo -en "\\033[70G[ "
117 if [ $CHECK = 0 ]; then
118 echo -en "\\033[1;33mOK"
119 else
120 echo -en "\\033[1;31mFailed"
121 fi
122 echo -e "\\033[0;39m ]"
123 }
125 # Check if user is root.
126 check_root()
127 {
128 if test $(id -u) != 0 ; then
129 echo -e "\nYou must be root to run `basename $0` with this option."
130 echo -e "Please type 'su' and root password to become super-user.\n"
131 exit 0
132 fi
133 }
135 # Check for a package name on cmdline.
136 check_for_package_on_cmdline()
137 {
138 if [ -z "$PACKAGE" ]; then
139 echo -e "\nYou must specify a package name on the command line."
140 echo -e "Example : tazwok $COMMAND package\n"
141 exit 0
142 fi
143 }
145 # Check for the receipt of a package used to cook.
146 check_for_receipt()
147 {
148 if [ ! -f "$RECEIPT" ]; then
149 echo -e "\nUnable to find the receipt : $RECEIPT\n"
150 exit 0
151 fi
152 }
154 # Check for a specified file list on cmdline.
155 check_for_list()
156 {
157 if [ -z "$LIST" ]; then
158 echo -e "\nPlease specify the path to the list of packages to cook.\n"
159 exit 0
160 fi
161 # Check if the list of packages exists.
162 if [ -f "$LIST" ]; then
163 LIST=`cat $LIST`
164 else
165 echo -e "\nUnable to find $LIST packages list.\n"
166 exit 0
167 fi
168 }
170 # Check for the wanted package if specified in WANTED
171 # receipt variable. Set the $src/$_pkg variable to help compiling
172 # and generating packages.
173 check_for_wanted()
174 {
175 if [ ! "$WANTED" = "" ]; then
176 echo -n "Checking for the wanted package..."
177 if [ ! -d "$WOK/$WANTED" ]; then
178 echo -e "\nWanted package is missing in the work directory.\n"
179 exit 0
180 fi
181 # Checking for buildtree of Wanted package
182 if [ ! -d "$WOK/$WANTED/taz" ]; then
183 echo -e "\n\nSource files of wanted package is missing in the work directory."
184 echo -n "Would you like to build the missing package (y/N) ? " ; read anser
185 if [ "$anser" == "y" ]; then
186 tazwok cook $WANTED
187 else
188 echo -e "\nWanted package source tree is missing in the work directory.\n"
189 exit 0
190 fi
191 fi
192 status
193 # Set wanted src path.
194 src=$WOK/$WANTED/$WANTED-$VERSION
195 _pkg=$src/_pkg
196 fi
197 }
200 # Check for build dependencies, notify user and install if specified.
201 check_for_build_depends()
202 {
203 echo "Checking for build dependencies..."
204 for pkg in $BUILD_DEPENDS
205 do
206 if [ ! -d "/var/lib/tazpkg/installed/$pkg" ]; then
207 MISSING_PACKAGE=$pkg
208 fi
209 done
210 if [ ! "$MISSING_PACKAGE" = "" ]; then
211 echo "================================================================================"
212 for pkg in $BUILD_DEPENDS
213 do
214 if [ ! -d "/var/lib/tazpkg/installed/$pkg" ]; then
215 MISSING_PACKAGE=$pkg
216 echo "Missing : $pkg"
217 fi
218 done
219 echo "================================================================================"
220 echo "You can continue, exit or install missing dependencies."
221 echo -n "Install, continue or exit (install/y/N) ? "; read anser
222 case $anser in
223 install)
224 for pkg in $BUILD_DEPENDS
225 do
226 if [ ! -d "/var/lib/tazpkg/installed/$pkg" ]; then
227 tazpkg get-install $pkg
228 fi
229 done ;;
230 y|yes)
231 continue ;;
232 *)
233 exit 0 ;;
234 esac
235 fi
236 }
238 # Check for loop in deps tree.
239 check_for_deps_loop()
240 {
241 local list
242 local pkg
243 local deps
244 pkg=$1
245 shift
246 [ -n "$1" ] || return
247 list=""
248 # Filter out already processed deps
249 for i in $@; do
250 case " $ALL_DEPS" in
251 *\ $i\ *);;
252 *) list="$list $i";;
253 esac
254 done
255 ALL_DEPS="$ALL_DEPS$list "
256 for i in $list; do
257 [ -f $i/receipt ] || continue
258 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
259 case " $deps " in
260 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
261 *) check_for_deps_loop $pkg $deps;;
262 esac
263 done
264 }
266 download()
267 {
268 for file in $@; do
269 wget $file && break
270 done
271 }
273 # Configure and make a package with the receipt.
274 compile_package()
275 {
276 check_for_package_on_cmdline
277 # Include the receipt to get all needed variables and functions
278 # and cd into the work directory to start the work.
279 check_for_receipt
280 . $RECEIPT
281 # Log the package name and date.
282 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
283 echo "package $PACKAGE (compile)" >> $LOG
284 # Set wanted $src variable to help compiling.
285 if [ ! "$SOURCE" = "" ]; then
286 src=$WOK/$PACKAGE/$SOURCE-$VERSION
287 else
288 src=$WOK/$PACKAGE/$PACKAGE-$VERSION
289 fi
290 check_for_build_depends
291 check_for_wanted
292 echo ""
293 echo "Starting to cook $PACKAGE..."
294 echo "================================================================================"
295 # Check for src tarball and wget if needed.
296 if [ ! "$WGET_URL" = "" ]; then
297 echo "Checking for source tarball... "
298 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
299 cd $SOURCES_REPOSITORY
300 download $WGET_URL
301 #wget $WGET_URL
302 # Exit if download failed to avoid errors.
303 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
304 echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n"
305 exit 1
306 fi
307 else
308 echo -n "Source tarball exit... "
309 status
310 fi
311 # Untaring source if necessary. We don't need to extract source if
312 # the package is built with a wanted source package.
313 if [ "$WANTED" = "" ]; then
314 if [ ! -d $src ]; then
315 # Log process.
316 echo "untaring $TARBALL" >> $LOG
317 echo -n "Untaring $TARBALL... "
318 case "$TARBALL" in
319 *zip) ( cd $WOK/$PACKAGE; unzip -o $SOURCES_REPOSITORY/$TARBALL );;
320 *bz2) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE;;
321 *tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE;;
322 *Z) tar xZf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE;;
323 *) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE;;
324 esac
325 status
326 # Permissions settings
327 chown -R root.root $WOK/$PACKAGE/$PACKAGE-* 2>/dev/null
328 chown -R root.root $WOK/$PACKAGE/$SOURCE-* 2>/dev/null
329 else
330 echo -n "Source direcory exit... " && status
331 fi
332 fi
333 fi
334 cd $WOK/$PACKAGE
335 # Log and execute compile_rules function if it exists, to configure and
336 # make the package if it exists.
337 if grep -q ^compile_rules $RECEIPT; then
338 echo "executing compile_rules" >> $LOG
339 compile_rules
340 # Exit if compilation failed so the binary package
341 # is not generated when using the cook comand.
342 local CHECK=$?
343 if [ $CHECK = 0 ]; then
344 echo "================================================================================"
345 echo "$PACKAGE compiled on : `date +%Y%m%d\ \%H:%M:%S`"
346 echo ""
347 echo "compilation done : `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
348 else
349 echo "================================================================================"
350 echo "Compilation failed. Please read the compilator output."
351 echo "" && exit 1
352 fi
353 else
354 echo "no compile_rules" >> $LOG
355 echo -e "No compile rules for $PACKAGE...\n"
356 fi
357 }
359 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
360 # so some packages need to copy these files with the receipt and genpkg_rules.
361 # This function is executed by gen_package when 'tazwok genpkg'.
362 copy_generic_files()
363 {
364 # In most cases, locales are in $_pkg/usr/share/locale so we copy files
365 # using generic variables and $LOCALE from Tazwok config file.
366 if [ ! "$LOCALE" = "" ]; then
367 if [ -d "$_pkg/usr/share/locale" ]; then
368 for i in $LOCALE
369 do
370 if [ -d "$_pkg/usr/share/locale/$i" ]; then
371 mkdir -p $fs/usr/share/locale
372 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
373 fi
374 done
375 fi
376 fi
377 # Pixmaps (PNG or/and XPM only). Some icons/images can be added through
378 # genpkg_rules and generic copy can be disabled with GENERIC_PIXMAPS="no"
379 # in pkg receipt.
380 if [ ! "$GENERIC_PIXMAPS" = "no" ]; then
381 if [ -d "$_pkg/usr/share/pixmaps" ]; then
382 mkdir -p $fs/usr/share/pixmaps
383 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
384 $fs/usr/share/pixmaps 2>/dev/null
385 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
386 $fs/usr/share/pixmaps 2>/dev/null
387 fi
388 # Custom or homemade PNG pixmap can be in stuff.
389 if [ -f "stuff/$PACKAGE.png" ]; then
390 mkdir -p $fs/usr/share/pixmaps
391 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
392 fi
393 fi
394 # Desktop entry (.desktop).
395 if [ -d "$_pkg/usr/share/applications" ]; then
396 cp -a $_pkg/usr/share/applications $fs/usr/share
397 fi
398 # Homemade desktop file(s) can be in stuff.
399 if [ -d "stuff/applications" ]; then
400 mkdir -p $fs/usr/share
401 cp -a stuff/applications $fs/usr/share
402 fi
403 if [ -f "stuff/$PACKAGE.desktop" ]; then
404 mkdir -p $fs/usr/share/applications
405 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
406 fi
407 }
409 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
410 strip_package()
411 {
412 echo -n "Executing strip on all files..."
413 # Binaries.
414 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
415 do
416 if [ -d "$dir" ]; then
417 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
418 fi
419 done
420 # Libraries.
421 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
422 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
423 status
424 }
426 # Create a package tree and build the gziped cpio archive
427 # to make a SliTaz (.tazpkg) package.
428 gen_package()
429 {
430 check_root
431 check_for_package_on_cmdline
432 check_for_receipt
433 EXTRAVERSION=""
434 . $RECEIPT
435 # May compute VERSION
436 if grep -q ^get_version $RECEIPT; then
437 get_version
438 fi
439 check_for_wanted
440 cd $WOK/$PACKAGE
441 # Remove old Tazwok package files.
442 if [ -d "taz" ]; then
443 rm -rf taz
444 fi
445 # Create the package tree and set useful variables.
446 mkdir -p taz/$PACKAGE-$VERSION/fs
447 fs=taz/$PACKAGE-$VERSION/fs
448 # Set $src for standard package and $_pkg variables.
449 if [ "$WANTED" = "" ]; then
450 src=$WOK/$PACKAGE/$PACKAGE-$VERSION
451 _pkg=$src/_pkg
452 fi
453 if [ ! "$SOURCE" = "" ]; then
454 src=$WOK/$PACKAGE/$SOURCE-$VERSION
455 _pkg=$src/_pkg
456 fi
457 cd $WOK/$PACKAGE
458 # Execute genpkg_rules and copy generic files to build the package.
459 echo ""
460 echo "Building $PACKAGE with the receipt..."
461 echo "================================================================================"
462 if grep -q ^genpkg_rules $RECEIPT; then
463 # Log process.
464 echo "executing genpkg_rules" >> $LOG
465 genpkg_rules
466 cd $WOK/$PACKAGE
467 # Skip generic files for packages with a WANTED variable
468 # (dev and splited pkgs).
469 if [ ! "$WANTED" = "" ]; then
470 continue
471 else
472 copy_generic_files
473 fi
474 strip_package
475 else
476 echo "No package rules to gen $PACKAGE..."
477 exit 1
478 fi
479 # Copy the receipt and description (if exists) in the binary package tree.
480 cd $WOK/$PACKAGE
481 echo -n "Copying the receipt..."
482 cp receipt taz/$PACKAGE-$VERSION
483 status
484 if grep -q ^get_version $RECEIPT; then
485 echo -n "Update version in receipt..."
486 sed -i "s/^VERSION=.*/VERSION=\"$VERSION\"/" \
487 taz/$PACKAGE-$VERSION/receipt
488 status
489 fi
490 if [ -f "description.txt" ]; then
491 echo -n "Copying the description file..."
492 cp description.txt taz/$PACKAGE-$VERSION
493 status
494 fi
495 # Create the files.list by redirecting find output.
496 echo -n "Creating the list of files..."
497 cd taz/$PACKAGE-$VERSION
498 LAST_FILE=""
499 ( find fs -print; echo ) | while read file; do
500 if [ "$LAST_FILE" != "" ]; then
501 case "$file" in
502 $LAST_FILE/*)
503 case "$(ls -ld "$LAST_FILE")" in
504 drwxr-xr-x\ *\ root\ *\ root\ *);;
505 *) echo ${LAST_FILE#fs};;
506 esac;;
507 *) echo ${LAST_FILE#fs};;
508 esac
509 fi
510 LAST_FILE="$file"
511 done > files.list
512 status
513 if [ -z "$EXTRAVERSION" ]; then
514 case "$PACKAGE" in
515 linux*);;
516 *) EXTRAVERSION="$(grep '/lib/modules/.*-slitaz/' files.list |\
517 head -1 | sed 's|/lib/modules/\(.*\)-slitaz/.*|_\1|')";;
518 esac
519 fi
520 rm -f $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
521 echo -n "Creating md5sum of files..."
522 while read file; do
523 [ -L "fs$file" ] && continue
524 [ -f "fs$file" ] || continue
525 md5sum "fs$file" | sed 's/ fs/ /'
526 done < files.list > md5sum
527 #[ -s md5sum ] || rm -f md5sum
528 status
529 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
530 2> /dev/null | awk '{ sz=$1 } END { print sz }')
531 # Build cpio archives. Find, cpio and gzip the fs, finish by
532 # removing the fs tree.
533 echo -n "Compressing the fs... "
534 find fs -print | cpio -o -H newc | gzip > fs.cpio.gz && rm -rf fs
535 PACKED_SIZE=$(du -chs fs.cpio.gz receipt files.list md5sum \
536 description.txt 2> /dev/null | awk '{ sz=$1 } END { print sz }')
537 echo -n "Undating receipt sizes..."
538 sed -i s/^PACKED_SIZE.*$// receipt
539 sed -i s/^UNPACKED_SIZE.*$// receipt
540 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
541 sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
542 status
543 if [ -n "$EXTRAVERSION" ]; then
544 echo -n "Undating receipt EXTRAVERSION..."
545 sed -i s/^EXTRAVERSION.*$// receipt
546 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
547 status
548 fi
549 echo -n "Creating full cpio archive... "
550 find . -print | cpio -o -H newc > $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
551 # Restore package tree incase we want to browse it.
552 echo -n "Restoring original package tree... "
553 zcat fs.cpio.gz | cpio -id
554 rm fs.cpio.gz && cd ..
555 # Log process.
556 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
557 echo "================================================================================"
558 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
559 echo "Size : `du -sh $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
560 echo ""
561 }
563 # Optional text packages list for gen-list.
564 gen_textlist()
565 {
566 rm -f packages.desc packages.equiv
567 DATE=`date +%Y-%m-%d\ \%H:%M:%S`
568 echo -n "Creating the text packages list... "
569 cat >> packages.txt << _EOT_
570 # SliTaz GNU/Linux - Packages list
571 #
572 # Packages : _packages_
573 # Date : $DATE
574 #
575 _EOT_
576 for pkg in $WOK/*
577 do
578 PROVIDE=""
579 PACKAGE=""
580 PACKED_SIZE=""
581 if [ -f $pkg/taz/*/receipt ]; then
582 . $pkg/taz/*/receipt
583 else
584 . $pkg/receipt
585 fi
586 cat >> packages.txt << _EOT_
588 $PACKAGE
589 $VERSION
590 $SHORT_DESC
591 _EOT_
592 if [ -n "$PACKED_SIZE" ]; then
593 cat >> packages.txt << _EOT_
594 $PACKED_SIZE ($UNPACKED_SIZE installed)
595 _EOT_
596 fi
597 # packages.desc is used by Tazpkgbox <tree>.
598 echo "$PACKAGE | $VERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> packages.desc
599 # packages.equiv is used by tazpkg install to check depends
600 touch packages.equiv
601 for i in $PROVIDE; do
602 DEST=""
603 echo $i | grep -q : && DEST="${i#*:}:"
604 if grep -qs ^${i%:*}= packages.equiv; then
605 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" packages.equiv
606 else
607 echo "${i%:*}=$DEST$PACKAGE" >> packages.equiv
608 fi
609 done
610 packages=$(($packages+1))
611 done && status
612 echo -n "Creating the text files list... "
613 for pkg in $WOK/*
614 do
615 if [ -f $pkg/taz/*/files.list ]; then
616 . $pkg/taz/*/receipt
617 ( echo "$PACKAGE"; cat $pkg/taz/*/files.list ) | awk '
618 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }'
619 else
620 echo "No files_list in $pkg" 1>&2
621 fi
622 done | lzma e files.list.lzma -si && status
623 sed -i s/"_packages_"/"$packages"/ packages.txt
624 }
626 # Return the date of the last commit in seconds since Jan 1 1970
627 hgdate()
628 {
629 local pkg
630 local date
631 local mon
632 # Default date is Jan 1 1970
633 [ -d $WOK/.hg -a -x /usr/bin/hg ] || { echo "010100001970"; return; }
634 pkg=$(basename $1)
635 # Get date for last commit
636 date="$( cd $WOK; hg log $(find $pkg/receipt $pkg/stuff -type f \
637 2> /dev/null) | grep date: | head -1 | cut -c 6-)"
638 [ -n "$date" ] || { echo "010100001970"; return; }
639 case "$(echo $date | awk '{ print $2 }')" in
640 Jan) mon="01";; Feb) mon="02";; Mar) mon="03";; Apr) mon="04";;
641 May) mon="05";; Jun) mon="06";; Jul) mon="07";; Aug) mon="08";;
642 Sep) mon="09";; Oct) mon="10";; Nov) mon="11";; Dec) mon="12";;
643 esac
644 # Reformat, don't mind about TZ: we look for days or months delta
645 echo $date | sed "s|[^ ]* [^ ]* \\(.*\\) \\(.*\\):\\(.*\\):\\(.*\\) \\(.*\\) .*|$mon\1\2\3\5|"
646 }
648 # List packages providing a virtual package
649 whoprovide()
650 {
651 local i;
652 for i in $(grep -l PROVIDE $WOK/*/receipt); do
653 . $i
654 case " $PROVIDE " in
655 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
656 esac
657 done
658 }
660 ###################
661 # Tazwok commands #
662 ###################
664 case "$COMMAND" in
665 stats)
666 # Tazwok general statistics from the config file the wok.
667 #
668 echo ""
669 echo -e "\033[1mTazwok configuration statistics\033[0m
670 ================================================================================
671 Wok directory : $WOK
672 Packages repository : $PACKAGES_REPOSITORY
673 Sources repository : $SOURCES_REPOSITORY
674 Packages in the wok : `ls -1 $WOK | wc -l`
675 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
676 ================================================================================"
677 echo ""
678 ;;
679 build-depends)
680 # List dependancies to rebuild wok
681 cd $WOK
682 ALL_DEPS="slitaz-toolchain"
683 echo $ALL_DEPS
684 for pkg in $(ls $2)
685 do
686 [ -f $pkg/receipt ] || continue
687 BUILD_DEPENDS=""
688 . $pkg/receipt
689 for i in $BUILD_DEPENDS; do
690 case " $ALL_DEPS " in
691 *\ $i\ *);;
692 *) ALL_DEPS="$ALL_DEPS $i"
693 echo $i;;
694 esac
695 done
696 done
697 ;;
698 check-depends)
699 # Check package depends
700 echo ""
701 echo -e "\033[1mCheck every receipt for DEPENDS misses scanning ELF files\033[0m
702 ================================================================================"
703 TMPDIR=/tmp/tazwok$$
704 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
706 # Build ALL_DEPENDS variable
707 scan_dep()
708 {
709 local i
710 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
711 for i in $DEPENDS ; do
712 case " $ALL_DEPENDS " in
713 *\ $i\ *) continue;;
714 esac
715 [ -d $WOK/$i ] || continue
716 . $WOK/$i/receipt
717 scan_dep
718 done
719 }
721 # Check for ELF file
722 is_elf()
723 {
724 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" \
725 = "ELF" ]
726 }
728 # Print shared library dependencies
729 ldd()
730 {
731 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1
732 }
734 mkdir $TMPDIR
735 cd $TMPDIR
736 for i in /var/lib/tazpkg/files.list.lzma \
737 /var/lib/tazpkg/undigest/*/files.list.lzma ; do
738 [ -f $i ] && lzma d $i -so >> files.list
739 done
740 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
741 tazpkg extract $pkg > /dev/null 2>&1
742 . */receipt
743 ALL_DEPENDS="$DEFAULT_DEPENDS "
744 scan_dep
745 find */fs -type f | while read file ; do
746 is_elf $file || continue
747 case "$file" in
748 *.o|*.ko|*.ko.gz) continue;;
749 esac
750 ldd $file | while read lib rem; do
751 case "$lib" in
752 linux-gate.so*|ld-*.so|*/ld-*.so)
753 continue;;
754 esac
755 for dep in $(grep $lib files.list | cut -d: -f1); do
756 case " $ALL_DEPENDS " in
757 *\ $dep\ *) continue 2;;
758 esac
759 done
760 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
761 done
762 done
763 rm -rf */
764 done
765 cd /tmp
766 rm -rf $TMPDIR
767 ;;
768 check)
769 # Check wok consistancy
770 echo ""
771 echo -e "\033[1mWok and packages checking\033[0m
772 ================================================================================"
773 cd $WOK
774 for pkg in $(ls)
775 do
776 [ -f $pkg/receipt ] || continue
777 PACKAGE=""
778 VERSION=""
779 EXTRAVERSION=""
780 CATEGORY=""
781 SHORT_DESC=""
782 MAINTAINER=""
783 WEB_SITE=""
784 DEPENDS=""
785 BUILD_DEPENDS=""
786 WANTED=""
787 PACKED_SIZE=""
788 UNPACKED_SIZE=""
789 . $pkg/receipt
790 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg"
791 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION"
792 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE"
793 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE"
794 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION"
795 if [ -n "$WANTED" ]; then
796 if [ ! -f $WANTED/receipt ]; then
797 echo "Package $PACKAGE want unknown $WANTED package"
798 else
799 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
800 if [ "$VERSION" = "$WANTED" ]; then
801 # BASEVERSION is computed in receipt
802 grep -q '_pkg=' $pkg/receipt &&
803 BASEVERSION=$VERSION
804 fi
805 if [ "$VERSION" != "$BASEVERSION" ]; then
806 echo "Package $PACKAGE ($VERSION) want $WANTED ($BASEVERSION)"
807 fi
808 fi
809 fi
811 if [ -n "$CATEGORY" ]; then
812 case " $(echo $CATEGORIES) " in
813 *\ $CATEGORY\ *);;
814 *) echo "Package $PACKAGE has an invalid CATEGORY";;
815 esac
816 else
817 echo"Package $PACKAGE has no CATEGORY"
818 fi
819 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC"
820 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER"
821 case "$WEB_SITE" in
822 ftp*|http*);;
823 '') echo "Package $PACKAGE has no WEB_SITE";;
824 *) echo "Package $PACKAGE has an invalid WEB_SITE";;
825 esac
826 case "$MAINTAINER" in
827 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER";;
828 esac
829 case "$MAINTAINER" in
830 *@*);;
831 *) echo "Package $PACKAGE MAINTAINER is not an email address";;
832 esac
833 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n"
834 for i in $DEPENDS; do
835 [ -d $i ] && continue
836 [ -n "$(whoprovide $i)" ] && continue
837 echo -e "$MSG $i"
838 MSG=""
839 done
840 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n"
841 for i in $BUILD_DEPENDS; do
842 [ -d $i ] && continue
843 [ -n "$(whoprovide $i)" ] && continue
844 echo -e "$MSG $i"
845 MSG=""
846 done
847 MSG="Dependencies loop between $PACKAGE and :\n"
848 ALL_DEPS=""
849 check_for_deps_loop $PACKAGE $DEPENDS
850 done
851 ;;
852 cmp|compare)
853 # Compare the wok and packages repository to help with maintaining
854 # a mirror.
855 echo ""
856 echo -e "\033[1mWok and packages comparison\033[0m
857 ================================================================================"
858 for pkg in $WOK/*
859 do
860 WANTED=""
861 . $pkg/receipt
862 echo "$PACKAGE-$VERSION.tazpkg" >> /tmp/wok.list.$$
863 tpkg="$(ls $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg 2> /dev/null | head -1)"
864 if [ -z "$tpkg" ]; then
865 echo "Missing package: $PACKAGE ($VERSION)"
866 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
867 elif [ -f $pkg/taz/*/receipt -a ! -f $pkg/taz/*/md5sum ]; then
868 echo "Obsolete package: $PACKAGE ($VERSION)"
869 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
870 elif [ $pkg/receipt -nt $tpkg ]; then
871 echo "Refresh package: $PACKAGE ($VERSION)"
872 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
873 else
874 srcdate=$(hgdate $pkg)
875 pkgdate=$(date -u -r $tpkg '+%m%d%H%M%Y')
876 if [ $(date -d $pkgdate +%s) -lt $(date -d $srcdate +%s) ]; then
877 echo "Rebuild package: $PACKAGE ($VERSION) cooked $(date -d $pkgdate "+%x %X"), modified $(date -d $srcdate "+%x %X")"
878 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
879 else
880 continue
881 fi
882 fi
883 if [ "$2" = "--cook" ]; then
884 if [ -n "$WANTED" -a ! -d $WOK/$WANTED/taz ]; then
885 yes '' | tazwok cook $WANTED
886 fi
887 yes '' | tazwok cook $PACKAGE
888 fi
889 done
890 for pkg in `cd $PACKAGES_REPOSITORY && ls *.tazpkg`
891 do
892 # grep $pkg in /tmp/wok.list.$$
893 # may include EXTRAVERSION or computed VERSION
894 for i in $(grep ^${pkg%-*} /tmp/wok.list.$$); do
895 case "$pkg" in
896 ${i%.tazpkg}*.tazpkg) continue 2;;
897 esac
898 done
899 # Not found
900 echo $pkg >> /tmp/pkgs.old.$$
901 if [ "$2" = "--remove" ]; then
902 echo "Removing package: $pkg"
903 rm $PACKAGES_REPOSITORY/$pkg
904 else
905 echo "Old package: $pkg"
906 fi
907 done
908 cd /tmp
909 echo "================================================================================"
910 echo "Wok: `cat wok.list.$$ | wc -l` - \
911 Cooked: `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l` - \
912 Missing: `cat pkgs.missing.$$ 2>/dev/null | wc -l` - \
913 Old: `cat pkgs.old.$$ 2>/dev/null | wc -l`"
914 echo ""
915 rm -f wok.list.$$ pkgs.old.$$ pkgs.missing.$$
916 ;;
917 list)
918 # List packages in wok directory. User can specifiy a category
919 #
920 if [ "$2" = "category" ]; then
921 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
922 exit 0
923 fi
924 # Check for an asked category.
925 if [ -n "$2" ]; then
926 ASKED_CATEGORY=$2
927 echo ""
928 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
929 echo "================================================================================"
930 for pkg in $WOK/*
931 do
932 . $pkg/receipt
933 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
934 echo -n "$PACKAGE"
935 echo -e "\033[28G $VERSION"
936 packages=$(($packages+1))
937 fi
938 done
939 echo "================================================================================"
940 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
941 else
942 # By default list all packages and version.
943 echo ""
944 echo -e "\033[1mList of packages in the wok\033[0m"
945 echo "================================================================================"
946 for pkg in $WOK/*
947 do
948 . $pkg/receipt
949 echo -n "$PACKAGE"
950 echo -en "\033[28G $VERSION"
951 echo -e "\033[42G $CATEGORY"
952 packages=$(($packages+1))
953 done
954 echo "================================================================================"
955 echo -e "$packages packages available in the wok.\n"
956 fi
957 ;;
958 info)
959 # Information about a package.
960 #
961 check_for_package_on_cmdline
962 check_for_receipt
963 . $WOK/$PACKAGE/receipt
964 echo ""
965 echo -e "\033[1mTazwok package information\033[0m
966 ================================================================================
967 Package : $PACKAGE
968 Version : $VERSION
969 Category : $CATEGORY
970 Short desc : $SHORT_DESC
971 Maintainer : $MAINTAINER"
972 if [ ! "$WEB_SITE" = "" ]; then
973 echo "Web site : $WEB_SITE"
974 fi
975 if [ ! "$DEPENDS" = "" ]; then
976 echo "Depends : $DEPENDS"
977 fi
978 if [ ! "$WANTED" = "" ]; then
979 echo "Wanted src : $WANTED"
980 fi
981 echo "================================================================================"
982 echo ""
984 ;;
985 check-log)
986 # We just cat the file log to view process info.
987 #
988 if [ ! -f "$LOG" ]; then
989 echo -e "\nNo process log found. The package is probably not cooked.\n"
990 exit 0
991 else
992 echo ""
993 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
994 echo "================================================================================"
995 cat $LOG
996 echo "================================================================================"
997 echo ""
998 fi
999 ;;
1000 search)
1001 # Search for a package by pattern or name.
1003 if [ -z "$2" ]; then
1004 echo -e "\nPlease specify a pattern or a package name to search."
1005 echo -e "Example : 'tazwok search gcc'.\n"
1006 exit 0
1007 fi
1008 echo ""
1009 echo -e "\033[1mSearch result for :\033[0m $2"
1010 echo "================================================================================"
1011 list=`ls -1 $WOK | grep $2`
1012 for pkg in $list
1013 do
1014 . $WOK/$pkg/receipt
1015 echo -n "$PACKAGE "
1016 echo -en "\033[24G $VERSION"
1017 echo -e "\033[42G $CATEGORY"
1018 packages=$(($packages+1))
1019 done
1020 echo "================================================================================"
1021 echo "$packages packages found for : $2"
1022 echo ""
1023 ;;
1024 compile)
1025 # Configure and make a package with the receipt.
1027 compile_package
1028 ;;
1029 genpkg)
1030 # Generate a package
1032 gen_package
1033 ;;
1034 cook)
1035 # Compile and generate a package. Just execute tazwok with
1036 # the good commands.
1038 check_root
1039 compile_package
1040 gen_package
1041 ;;
1042 cook-list)
1043 # Cook all packages listed in a file. The path to the cooklist must
1044 # be specified on the cmdline.
1046 check_root
1047 check_for_list
1048 for pkg in $LIST
1049 do
1050 tazwok compile $pkg
1051 tazwok genpkg $pkg
1052 done
1053 ;;
1054 clean)
1055 # Clean up a package work directory.
1057 check_for_package_on_cmdline
1058 check_for_receipt
1059 . $RECEIPT
1060 cd $WOK/$PACKAGE
1061 echo ""
1062 echo "Cleaning $PACKAGE..."
1063 echo "================================================================================"
1064 # Check for clean_wok function.
1065 if grep -q ^clean_wok $RECEIPT; then
1066 clean_wok
1067 fi
1068 # Remove taz/ and source tree if exists.
1069 if [ -d "taz" ]; then
1070 echo -n "Removing taz files..."
1071 rm -rf taz
1072 status
1073 fi
1074 for i in $PACKAGE-$VERSION $SOURCE-$VERSION ; do
1075 [ -e "$i" ] || continue
1076 echo -n "Removing source files..."
1077 if [ -L $i ]; then
1078 target=$(readlink $i)
1079 [ -d "$target" ] && case "$target" in
1080 /*|.|./*|..|../*);;
1081 *) rm -rf $target;;
1082 esac
1083 fi
1084 rm -rf $i
1085 status
1086 done
1087 # Remove an envental $PACKAGE-build directory.
1088 if [ -d "$PACKAGE-build" ]; then
1089 echo -n "Removing build tree..."
1090 rm -rf $PACKAGE-build && status
1091 fi
1092 # Remove process log file.
1093 if [ -f "process.log" ]; then
1094 echo -n "Removing process log file..."
1095 rm process.log && status
1096 echo "================================================================================"
1097 fi
1098 echo "$PACKAGE is clean. You can cook it again..."
1099 echo ""
1100 ;;
1101 gen-clean-wok)
1102 # Generate a clean wok from the current wok by copying all receipt
1103 # and stuff directory.
1105 if [ -z "$2" ]; then
1106 echo -e "\nPlease specify the destination for the new clean wok.\n"
1107 exit 0
1108 else
1109 dest=$2
1110 mkdir -p $dest
1111 fi
1112 echo "New wok is going to : $dest"
1113 for pkg in `ls -1 $WOK`
1114 do
1115 echo "----"
1116 echo -n "Preparing $pkg..."
1117 mkdir -p $dest/$pkg
1118 status
1119 echo -n "Copying the receipt..."
1120 cp -a $WOK/$pkg/receipt $dest/$pkg
1121 status
1122 if [ -d "$WOK/$pkg/stuff" ]; then
1123 echo -n "Copying all the stuff directory..."
1124 cp -a $WOK/$pkg/stuff $dest/$pkg
1125 status
1126 fi
1127 done
1128 echo "================================================================================"
1129 echo "Clean wok generated in : $dest"
1130 echo "Packages cleaned : `ls -1 $dest | wc -l`"
1131 echo ""
1132 ;;
1133 clean-wok)
1134 # Clean all packages in the work directory
1136 for pkg in `ls -1 $WOK`
1137 do
1138 tazwok clean $pkg
1139 done
1140 echo "================================================================================"
1141 echo "`ls -1 $WOK | wc -l` packages cleaned."
1142 echo ""
1143 ;;
1144 gen-list)
1145 # Sed is used to remove all the .tazpkg extensions from the
1146 # packages.list. The directory to move in by default is the repository
1147 # if $2 is not empty cd into $2. A text packages list can also be gen
1148 # with the option --text.
1150 fakewok=""
1151 if [ "$2" == "--text" ]; then
1152 textlist="yes"
1153 if [ "$3" == "--fakewok" ]; then
1154 WOK=/tmp/fakewok-$$
1155 fakewok="$WOK"
1156 mkdir -p $WOK
1157 for i in $PACKAGES_REPOSITORY/*.tazpkg; do
1158 (cd $WOK; cpio -i receipt files.list 2>/dev/null) < $i
1159 . $WOK/receipt
1160 mkdir -p $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
1161 mv $WOK/receipt $WOK/files.list \
1162 $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
1163 ln $WOK/$PACKAGE/taz/$PACKAGE-$VERSION/receipt $WOK/$PACKAGE
1164 done
1165 fi
1166 elif [ -z "$2" ]; then
1167 PACKAGES_REPOSITORY=$PACKAGES_REPOSITORY
1168 else
1169 if [ -d "$2" ]; then
1170 PACKAGES_REPOSITORY=$2
1171 else
1172 echo -e "\nUnable to find directory : $2\n"
1173 exit 0
1174 fi
1175 fi
1176 cd $PACKAGES_REPOSITORY
1177 # Remove old packages.list and md5sum, they will soon be rebuilt.
1178 rm -f packages.list packages.md5 packages.txt
1179 echo ""
1180 echo -e "\033[1mGenerating packages lists\033[0m"
1181 echo "================================================================================"
1182 echo -n "Repository path : $PACKAGES_REPOSITORY" && status
1183 # Generate packages.txt
1184 if [ "$textlist" == "yes" ]; then
1185 gen_textlist
1186 [ "$fakewok" == "" ] || rm -rf $fakewok
1187 fi
1188 echo -n "Creating the raw packages list... "
1189 ls -1 *.tazpkg > /tmp/packages.list
1190 sed -i s/'.tazpkg'/''/ /tmp/packages.list
1191 status
1192 echo -n "Building the md5sum for all packages... "
1193 md5sum *.tazpkg > packages.md5
1194 status
1195 mv /tmp/packages.list $PACKAGES_REPOSITORY
1196 echo "================================================================================"
1197 pkgs=`cat $PACKAGES_REPOSITORY/packages.list | wc -l`
1198 echo "$pkgs packages in the repository."
1199 echo ""
1200 ;;
1201 new-tree)
1202 # Just create a few directories and generate an empty receipt to prepare
1203 # the creation of a new package.
1205 check_for_package_on_cmdline
1206 if [ -d $WOK/$PACKAGE ]; then
1207 echo -e "\n$PACKAGE package tree already exists.\n"
1208 exit 0
1209 fi
1210 echo "Creating : $WOK/$PACKAGE"
1211 mkdir $WOK/$PACKAGE
1212 cd $WOK/$PACKAGE
1213 echo -n "Preparing the receipt..."
1215 # Default receipt begin.
1217 echo "# SliTaz package receipt." > receipt
1218 echo "" >> receipt
1219 echo "PACKAGE=\"$PACKAGE\"" >> receipt
1220 # Finish the empty receipt.
1221 cat >> receipt << "EOF"
1222 VERSION=""
1223 CATEGORY=""
1224 SHORT_DESC=""
1225 MAINTAINER=""
1226 DEPENDS=""
1227 TARBALL="$PACKAGE-$VERSION.tar.gz"
1228 WEB_SITE=""
1229 WGET_URL=""
1231 # Rules to configure and make the package.
1232 compile_rules()
1234 cd $src
1235 ./configure \
1236 --prefix=/usr \
1237 --infodir=/usr/share/info \
1238 --mandir=/usr/share/man \
1239 $CONFIGURE_ARGS &&
1240 make && make DESTDIR=$PWD/_pkg install
1243 # Rules to gen a SliTaz package suitable for Tazpkg.
1244 genpkg_rules()
1246 mkdir -p $fs/usr
1247 cp -a $_pkg/usr/bin $fs/usr
1250 EOF
1252 # Default receipt end.
1254 status
1255 # Interactive mode, asking and seding.
1256 if [ "$3" = "--interactive" ]; then
1257 echo "Entering in interactive mode..."
1258 echo "================================================================================"
1259 echo "Package : $PACKAGE"
1260 # Version.
1261 echo -n "Version : " ; read anser
1262 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
1263 # Category.
1264 echo -n "Category : " ; read anser
1265 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
1266 # Short description.
1267 echo -n "Short desc : " ; read anser
1268 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
1269 # Maintainer.
1270 echo -n "Maintainer : " ; read anser
1271 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
1272 # Web site.
1273 echo -n "Web site : " ; read anser
1274 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
1275 echo ""
1276 # Wget URL.
1277 echo "Wget URL to download source tarball."
1278 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
1279 echo -n "Wget url : " ; read anser
1280 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
1281 # Ask for a stuff dir.
1282 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
1283 if [ "$anser" = "y" ]; then
1284 echo -n "Creating the stuff directory..."
1285 mkdir stuff && status
1286 fi
1287 # Ask for a description file.
1288 echo -n "Are you going to write a description ? (y/N) : " ; read anser
1289 if [ "$anser" = "y" ]; then
1290 echo -n "Creating the description.txt file..."
1291 echo "" > description.txt && status
1292 fi
1293 echo "================================================================================"
1294 echo ""
1295 fi
1296 ;;
1297 remove)
1298 # Remove a package from the wok.
1300 check_for_package_on_cmdline
1301 echo ""
1302 echo -n "Please confirm deletion (y/N) : "; read anser
1303 if [ "$anser" = "y" ]; then
1304 echo -n "Removing $PACKAGE..."
1305 rm -rf $WOK/$PACKAGE && status
1306 echo ""
1307 fi
1308 ;;
1309 hgup)
1310 # Pull and update an Hg wok.
1311 if ls -l $WOK/.hg/hgrc | grep -q "root"; then
1312 check_root
1313 fi
1314 cd $WOK
1315 hg pull && hg update ;;
1316 maintainers)
1317 echo ""
1318 echo "List of maintainers for: $WOK"
1319 echo "================================================================================"
1320 touch /tmp/slitaz-maintainers
1321 for pkg in $WOK/*
1322 do
1323 . $pkg/receipt
1324 if ! grep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
1325 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
1326 echo "$MAINTAINER"
1327 fi
1328 done
1329 echo "================================================================================"
1330 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
1331 echo ""
1332 # Remove tmp files
1333 rm -f /tmp/slitaz-maintainers ;;
1334 maintained-by)
1335 # Search for packages maintained by a packagers.
1336 if [ ! -n "$2" ]; then
1337 echo "Specify a name or mail of a maintainer."
1338 exit 0
1339 fi
1340 echo "Maintainer packages"
1341 echo "================================================================================"
1342 for pkg in $WOK/*
1343 do
1344 . $pkg/receipt
1345 if echo "$MAINTAINER" | grep -q "$2"; then
1346 echo "$PACKAGE"
1347 packages=$(($packages+1))
1348 fi
1349 done
1350 echo "================================================================================"
1351 echo "Packages maintained by $1: $packages"
1352 echo "" ;;
1353 usage|*)
1354 # Print usage also for all unknown commands.
1356 usage
1357 ;;
1358 esac
1360 exit 0