tazwok view tazwok @ rev 124

log compile_rules and genpkg_rules output
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Apr 07 08:37:14 2009 +0000 (2009-04-07)
parents 10ae7d406b96
children d88dec86b2ec
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 packages to build a 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 - doesn't scan 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 directory 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 2>&1 | tee compile_rules.log
340 # Exit if compilation failed so the binary package
341 # is not generated when using the cook command.
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 2>&1 | tee genpkg_rules.log
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 status
538 echo -n "Updating receipt sizes..."
539 sed -i s/^PACKED_SIZE.*$// receipt
540 sed -i s/^UNPACKED_SIZE.*$// receipt
541 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
542 sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
543 status
544 if [ -n "$EXTRAVERSION" ]; then
545 echo -n "Updating receipt EXTRAVERSION..."
546 sed -i s/^EXTRAVERSION.*$// receipt
547 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
548 status
549 fi
550 echo -n "Creating full cpio archive... "
551 find . -print | cpio -o -H newc > $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
552 status
553 # Restore package tree incase we want to browse it.
554 echo -n "Restoring original package tree... "
555 zcat fs.cpio.gz | cpio -id
556 rm fs.cpio.gz && cd ..
557 # Log process.
558 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
559 echo "================================================================================"
560 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
561 echo "Size : `du -sh $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
562 echo ""
563 }
565 # Optional text packages list for gen-list.
566 gen_textlist()
567 {
568 rm -f packages.desc packages.equiv
569 DATE=`date +%Y-%m-%d\ \%H:%M:%S`
570 echo -n "Creating the text packages list... "
571 cat >> packages.txt << _EOT_
572 # SliTaz GNU/Linux - Packages list
573 #
574 # Packages : _packages_
575 # Date : $DATE
576 #
577 _EOT_
578 for pkg in $WOK/*
579 do
580 PROVIDE=""
581 PACKAGE=""
582 PACKED_SIZE=""
583 if [ -f $pkg/taz/*/receipt ]; then
584 . $pkg/taz/*/receipt
585 else
586 . $pkg/receipt
587 fi
588 cat >> packages.txt << _EOT_
590 $PACKAGE
591 $VERSION
592 $SHORT_DESC
593 _EOT_
594 if [ -n "$PACKED_SIZE" ]; then
595 cat >> packages.txt << _EOT_
596 $PACKED_SIZE ($UNPACKED_SIZE installed)
597 _EOT_
598 fi
599 # Packages.desc is used by Tazpkgbox <tree>.
600 echo "$PACKAGE | $VERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> packages.desc
601 # Packages.equiv is used by tazpkg install to check depends
602 touch packages.equiv
603 for i in $PROVIDE; do
604 DEST=""
605 echo $i | grep -q : && DEST="${i#*:}:"
606 if grep -qs ^${i%:*}= packages.equiv; then
607 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" packages.equiv
608 else
609 echo "${i%:*}=$DEST$PACKAGE" >> packages.equiv
610 fi
611 done
612 packages=$(($packages+1))
613 done && status
614 echo -n "Creating the text files list... "
615 for pkg in $WOK/*
616 do
617 if [ -f $pkg/taz/*/files.list ]; then
618 . $pkg/taz/*/receipt
619 ( echo "$PACKAGE"; cat $pkg/taz/*/files.list ) | awk '
620 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }'
621 else
622 echo "No files_list in $pkg" 1>&2
623 fi
624 done | lzma e files.list.lzma -si && status
625 sed -i s/"_packages_"/"$packages"/ packages.txt
626 }
628 # Return the date of the last commit in seconds since Jan 1 1970
629 hgdate()
630 {
631 local pkg
632 local date
633 local mon
634 # Default date is Jan 1 1970
635 [ -d $WOK/.hg -a -x /usr/bin/hg ] || { echo "010100001970"; return; }
636 pkg=$(basename $1)
637 # Get date for last commit
638 date="$( cd $WOK; hg log $(find $pkg/receipt $pkg/stuff -type f \
639 2> /dev/null) | grep date: | head -1 | cut -c 6-)"
640 [ -n "$date" ] || { echo "010100001970"; return; }
641 case "$(echo $date | awk '{ print $2 }')" in
642 Jan) mon="01";; Feb) mon="02";; Mar) mon="03";; Apr) mon="04";;
643 May) mon="05";; Jun) mon="06";; Jul) mon="07";; Aug) mon="08";;
644 Sep) mon="09";; Oct) mon="10";; Nov) mon="11";; Dec) mon="12";;
645 esac
646 # Reformat, don't mind about TZ: we look for days or months delta
647 echo $date | sed "s|[^ ]* [^ ]* \\(.*\\) \\(.*\\):\\(.*\\):\\(.*\\) \\(.*\\) .*|$mon\1\2\3\5|"
648 }
650 # List packages providing a virtual package
651 whoprovide()
652 {
653 local i;
654 for i in $(grep -l PROVIDE $WOK/*/receipt); do
655 . $i
656 case " $PROVIDE " in
657 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
658 esac
659 done
660 }
662 ###################
663 # Tazwok commands #
664 ###################
666 case "$COMMAND" in
667 stats)
668 # Tazwok general statistics from the config file the wok.
669 #
670 echo ""
671 echo -e "\033[1mTazwok configuration statistics\033[0m
672 ================================================================================
673 Wok directory : $WOK
674 Packages repository : $PACKAGES_REPOSITORY
675 Sources repository : $SOURCES_REPOSITORY
676 Packages in the wok : `ls -1 $WOK | wc -l`
677 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
678 ================================================================================"
679 echo ""
680 ;;
681 build-depends)
682 # List dependancies to rebuild wok
683 cd $WOK
684 ALL_DEPS="slitaz-toolchain"
685 echo $ALL_DEPS
686 for pkg in $(ls $2)
687 do
688 [ -f $pkg/receipt ] || continue
689 BUILD_DEPENDS=""
690 . $pkg/receipt
691 for i in $BUILD_DEPENDS; do
692 case " $ALL_DEPS " in
693 *\ $i\ *);;
694 *) ALL_DEPS="$ALL_DEPS $i"
695 echo $i;;
696 esac
697 done
698 done
699 ;;
700 check-depends)
701 # Check package depends
702 echo ""
703 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
704 ================================================================================"
705 TMPDIR=/tmp/tazwok$$
706 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
708 # Build ALL_DEPENDS variable
709 scan_dep()
710 {
711 local i
712 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
713 for i in $DEPENDS ; do
714 case " $ALL_DEPENDS " in
715 *\ $i\ *) continue;;
716 esac
717 [ -d $WOK/$i ] || {
718 ALL_DEPENDS="$ALL_DEPENDS$i "
719 continue
720 }
721 . $WOK/$i/receipt
722 scan_dep
723 done
724 }
726 # Check for ELF file
727 is_elf()
728 {
729 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" \
730 = "ELF" ]
731 }
733 # Print shared library dependencies
734 ldd()
735 {
736 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1
737 }
739 mkdir $TMPDIR
740 cd $TMPDIR
741 for i in /var/lib/tazpkg/files.list.lzma \
742 /var/lib/tazpkg/undigest/*/files.list.lzma ; do
743 [ -f $i ] && lzma d $i -so >> files.list
744 done
745 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
746 tazpkg extract $pkg > /dev/null 2>&1
747 . */receipt
748 ALL_DEPENDS="$DEFAULT_DEPENDS "
749 scan_dep
750 find */fs -type f | while read file ; do
751 is_elf $file || continue
752 case "$file" in
753 *.o|*.ko|*.ko.gz) continue;;
754 esac
755 ldd $file | while read lib rem; do
756 case "$lib" in
757 linux-gate.so*|ld-*.so|*/ld-*.so)
758 continue;;
759 esac
760 for dep in $(grep $lib files.list | cut -d: -f1); do
761 case " $ALL_DEPENDS " in
762 *\ $dep\ *) continue 2;;
763 esac
764 done
765 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
766 done
767 done
768 rm -rf */
769 done
770 cd /tmp
771 rm -rf $TMPDIR
772 ;;
773 check)
774 # Check wok consistancy
775 echo ""
776 echo -e "\033[1mWok and packages checking\033[0m
777 ================================================================================"
778 cd $WOK
779 for pkg in $(ls)
780 do
781 [ -f $pkg/receipt ] || continue
782 PACKAGE=""
783 VERSION=""
784 EXTRAVERSION=""
785 CATEGORY=""
786 SHORT_DESC=""
787 MAINTAINER=""
788 WEB_SITE=""
789 WGET_URL=""
790 DEPENDS=""
791 BUILD_DEPENDS=""
792 WANTED=""
793 PACKED_SIZE=""
794 UNPACKED_SIZE=""
795 . $pkg/receipt
796 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg"
797 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION"
798 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE"
799 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE"
800 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION"
801 if [ -n "$WANTED" ]; then
802 if [ ! -f $WANTED/receipt ]; then
803 echo "Package $PACKAGE wants unknown $WANTED package"
804 else
805 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
806 if [ "$VERSION" = "$WANTED" ]; then
807 # BASEVERSION is computed in receipt
808 grep -q '_pkg=' $pkg/receipt &&
809 BASEVERSION=$VERSION
810 fi
811 if [ "$VERSION" != "$BASEVERSION" ]; then
812 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)"
813 fi
814 fi
815 fi
817 if [ -n "$CATEGORY" ]; then
818 case " $(echo $CATEGORIES) " in
819 *\ $CATEGORY\ *);;
820 *) echo "Package $PACKAGE has an invalid CATEGORY";;
821 esac
822 else
823 echo"Package $PACKAGE has no CATEGORY"
824 fi
825 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC"
826 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER"
827 case "$WGET_URL" in
828 ftp*|http*) wget -s $WGET_URL 2> /dev/null ||
829 echo "Package $PACKAGE has a wrong WGET_URL";;
830 '') ;;
831 *) echo "Package $PACKAGE has an invalid WGET_URL";;
832 esac
833 case "$WEB_SITE" in
834 ftp*|http*) wget -s $WEB_SITE 2> /dev/null ||
835 echo "Package $PACKAGE has a wrong WEB_SITE";;
836 '') echo "Package $PACKAGE has no WEB_SITE";;
837 *) echo "Package $PACKAGE has an invalid WEB_SITE";;
838 esac
839 case "$MAINTAINER" in
840 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER";;
841 esac
842 case "$MAINTAINER" in
843 *@*);;
844 *) echo "Package $PACKAGE MAINTAINER is not an email address";;
845 esac
846 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n"
847 for i in $DEPENDS; do
848 [ -d $i ] && continue
849 [ -n "$(whoprovide $i)" ] && continue
850 echo -e "$MSG $i"
851 MSG=""
852 done
853 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n"
854 for i in $BUILD_DEPENDS; do
855 [ -d $i ] && continue
856 [ -n "$(whoprovide $i)" ] && continue
857 echo -e "$MSG $i"
858 MSG=""
859 done
860 MSG="Dependencies loop between $PACKAGE and :\n"
861 ALL_DEPS=""
862 check_for_deps_loop $PACKAGE $DEPENDS
863 done
864 ;;
865 cmp|compare)
866 # Compare the wok and packages repository to help with maintaining
867 # a mirror.
868 echo ""
869 echo -e "\033[1mWok and packages comparison\033[0m
870 ================================================================================"
871 for pkg in $WOK/*
872 do
873 WANTED=""
874 . $pkg/receipt
875 echo "$PACKAGE-$VERSION.tazpkg" >> /tmp/wok.list.$$
876 tpkg="$(ls $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg 2> /dev/null | head -1)"
877 if [ -z "$tpkg" ]; then
878 echo "Missing package: $PACKAGE ($VERSION)"
879 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
880 elif [ -f $pkg/taz/*/receipt -a ! -f $pkg/taz/*/md5sum ]; then
881 echo "Obsolete package: $PACKAGE ($VERSION)"
882 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
883 elif [ $pkg/receipt -nt $tpkg ]; then
884 echo "Refresh package: $PACKAGE ($VERSION)"
885 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
886 else
887 srcdate=$(hgdate $pkg)
888 pkgdate=$(date -u -r $tpkg '+%m%d%H%M%Y')
889 if [ $(date -d $pkgdate +%s) -lt $(date -d $srcdate +%s) ]; then
890 echo "Rebuild package: $PACKAGE ($VERSION) cooked $(date -d $pkgdate "+%x %X"), modified $(date -d $srcdate "+%x %X")"
891 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
892 else
893 continue
894 fi
895 fi
896 if [ "$2" = "--cook" ]; then
897 if [ -n "$WANTED" -a ! -d $WOK/$WANTED/taz ]; then
898 yes '' | tazwok cook $WANTED
899 fi
900 yes '' | tazwok cook $PACKAGE
901 fi
902 done
903 for pkg in `cd $PACKAGES_REPOSITORY && ls *.tazpkg`
904 do
905 # grep $pkg in /tmp/wok.list.$$
906 # may include EXTRAVERSION or computed VERSION
907 for i in $(grep ^${pkg%-*} /tmp/wok.list.$$); do
908 case "$pkg" in
909 ${i%.tazpkg}*.tazpkg) continue 2;;
910 esac
911 done
912 # Not found
913 echo $pkg >> /tmp/pkgs.old.$$
914 if [ "$2" = "--remove" ]; then
915 echo "Removing package: $pkg"
916 rm $PACKAGES_REPOSITORY/$pkg
917 else
918 echo "Old package: $pkg"
919 fi
920 done
921 cd /tmp
922 echo "================================================================================"
923 echo "Wok: `cat wok.list.$$ | wc -l` - \
924 Cooked: `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l` - \
925 Missing: `cat pkgs.missing.$$ 2>/dev/null | wc -l` - \
926 Old: `cat pkgs.old.$$ 2>/dev/null | wc -l`"
927 echo ""
928 rm -f wok.list.$$ pkgs.old.$$ pkgs.missing.$$
929 ;;
930 list)
931 # List packages in wok directory. User can specify a category
932 #
933 if [ "$2" = "category" ]; then
934 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
935 exit 0
936 fi
937 # Check for an asked category.
938 if [ -n "$2" ]; then
939 ASKED_CATEGORY=$2
940 echo ""
941 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
942 echo "================================================================================"
943 for pkg in $WOK/*
944 do
945 . $pkg/receipt
946 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
947 echo -n "$PACKAGE"
948 echo -e "\033[28G $VERSION"
949 packages=$(($packages+1))
950 fi
951 done
952 echo "================================================================================"
953 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
954 else
955 # By default list all packages and version.
956 echo ""
957 echo -e "\033[1mList of packages in the wok\033[0m"
958 echo "================================================================================"
959 for pkg in $WOK/*
960 do
961 . $pkg/receipt
962 echo -n "$PACKAGE"
963 echo -en "\033[28G $VERSION"
964 echo -e "\033[42G $CATEGORY"
965 packages=$(($packages+1))
966 done
967 echo "================================================================================"
968 echo -e "$packages packages available in the wok.\n"
969 fi
970 ;;
971 info)
972 # Information about a package.
973 #
974 check_for_package_on_cmdline
975 check_for_receipt
976 . $WOK/$PACKAGE/receipt
977 echo ""
978 echo -e "\033[1mTazwok package information\033[0m
979 ================================================================================
980 Package : $PACKAGE
981 Version : $VERSION
982 Category : $CATEGORY
983 Short desc : $SHORT_DESC
984 Maintainer : $MAINTAINER"
985 if [ ! "$WEB_SITE" = "" ]; then
986 echo "Web site : $WEB_SITE"
987 fi
988 if [ ! "$DEPENDS" = "" ]; then
989 echo "Depends : $DEPENDS"
990 fi
991 if [ ! "$WANTED" = "" ]; then
992 echo "Wanted src : $WANTED"
993 fi
994 echo "================================================================================"
995 echo ""
997 ;;
998 check-log)
999 # We just cat the file log to view process info.
1001 if [ ! -f "$LOG" ]; then
1002 echo -e "\nNo process log found. The package is probably not cooked.\n"
1003 exit 0
1004 else
1005 echo ""
1006 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
1007 echo "================================================================================"
1008 cat $LOG
1009 echo "================================================================================"
1010 echo ""
1011 fi
1012 ;;
1013 search)
1014 # Search for a package by pattern or name.
1016 if [ -z "$2" ]; then
1017 echo -e "\nPlease specify a pattern or a package name to search."
1018 echo -e "Example : 'tazwok search gcc'.\n"
1019 exit 0
1020 fi
1021 echo ""
1022 echo -e "\033[1mSearch result for :\033[0m $2"
1023 echo "================================================================================"
1024 list=`ls -1 $WOK | grep $2`
1025 for pkg in $list
1026 do
1027 . $WOK/$pkg/receipt
1028 echo -n "$PACKAGE "
1029 echo -en "\033[24G $VERSION"
1030 echo -e "\033[42G $CATEGORY"
1031 packages=$(($packages+1))
1032 done
1033 echo "================================================================================"
1034 echo "$packages packages found for : $2"
1035 echo ""
1036 ;;
1037 compile)
1038 # Configure and make a package with the receipt.
1040 compile_package
1041 ;;
1042 genpkg)
1043 # Generate a package.
1045 gen_package
1046 ;;
1047 cook)
1048 # Compile and generate a package. Just execute tazwok with
1049 # the good commands.
1051 check_root
1052 compile_package
1053 gen_package
1054 ;;
1055 cook-list)
1056 # Cook all packages listed in a file. The path to the cooklist must
1057 # be specified on the cmdline.
1059 check_root
1060 check_for_list
1061 for pkg in $LIST
1062 do
1063 tazwok compile $pkg
1064 tazwok genpkg $pkg
1065 done
1066 ;;
1067 clean)
1068 # Clean up a package work directory.
1070 check_for_package_on_cmdline
1071 check_for_receipt
1072 . $RECEIPT
1073 cd $WOK/$PACKAGE
1074 echo ""
1075 echo "Cleaning $PACKAGE..."
1076 echo "================================================================================"
1077 # Check for clean_wok function.
1078 if grep -q ^clean_wok $RECEIPT; then
1079 clean_wok
1080 fi
1081 # Remove taz/ and source tree if exists.
1082 if [ -d "taz" ]; then
1083 echo -n "Removing taz files..."
1084 rm -rf taz
1085 status
1086 fi
1087 for i in $PACKAGE-$VERSION $SOURCE-$VERSION ; do
1088 [ -e "$i" ] || continue
1089 echo -n "Removing source files..."
1090 if [ -L $i ]; then
1091 target=$(readlink $i)
1092 [ -d "$target" ] && case "$target" in
1093 /*|.|./*|..|../*);;
1094 *) rm -rf $target;;
1095 esac
1096 fi
1097 rm -rf $i
1098 status
1099 done
1100 # Remove an eventual $PACKAGE-build directory.
1101 if [ -d "$PACKAGE-build" ]; then
1102 echo -n "Removing build tree..."
1103 rm -rf $PACKAGE-build && status
1104 fi
1105 # Remove process log file.
1106 if [ -f "process.log" ]; then
1107 echo -n "Removing process log file..."
1108 rm process.log && status
1109 echo "================================================================================"
1110 fi
1111 echo "$PACKAGE is clean. You can cook it again..."
1112 echo ""
1113 ;;
1114 gen-clean-wok)
1115 # Generate a clean wok from the current wok by copying all receipts
1116 # and stuff directory.
1118 if [ -z "$2" ]; then
1119 echo -e "\nPlease specify the destination for the new clean wok.\n"
1120 exit 0
1121 else
1122 dest=$2
1123 mkdir -p $dest
1124 fi
1125 echo "New wok is going to : $dest"
1126 for pkg in `ls -1 $WOK`
1127 do
1128 echo "----"
1129 echo -n "Preparing $pkg..."
1130 mkdir -p $dest/$pkg
1131 status
1132 echo -n "Copying the receipt..."
1133 cp -a $WOK/$pkg/receipt $dest/$pkg
1134 status
1135 if [ -d "$WOK/$pkg/stuff" ]; then
1136 echo -n "Copying all the stuff directory..."
1137 cp -a $WOK/$pkg/stuff $dest/$pkg
1138 status
1139 fi
1140 done
1141 echo "================================================================================"
1142 echo "Clean wok generated in : $dest"
1143 echo "Packages cleaned : `ls -1 $dest | wc -l`"
1144 echo ""
1145 ;;
1146 clean-wok)
1147 # Clean all packages in the work directory
1149 for pkg in `ls -1 $WOK`
1150 do
1151 tazwok clean $pkg
1152 done
1153 echo "================================================================================"
1154 echo "`ls -1 $WOK | wc -l` packages cleaned."
1155 echo ""
1156 ;;
1157 gen-list)
1158 # Sed is used to remove all the .tazpkg extensions from the
1159 # packages.list. The directory to move in by default is the repository
1160 # if $2 is not empty cd into $2. A text packages list can also be gen
1161 # with the option --text.
1163 fakewok=""
1164 if [ "$2" == "--text" ]; then
1165 textlist="yes"
1166 if [ "$3" == "--fakewok" ]; then
1167 WOK=/tmp/fakewok-$$
1168 fakewok="$WOK"
1169 mkdir -p $WOK
1170 for i in $PACKAGES_REPOSITORY/*.tazpkg; do
1171 (cd $WOK; cpio -i receipt files.list 2>/dev/null) < $i
1172 . $WOK/receipt
1173 mkdir -p $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
1174 mv $WOK/receipt $WOK/files.list \
1175 $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
1176 ln $WOK/$PACKAGE/taz/$PACKAGE-$VERSION/receipt $WOK/$PACKAGE
1177 done
1178 fi
1179 elif [ -z "$2" ]; then
1180 PACKAGES_REPOSITORY=$PACKAGES_REPOSITORY
1181 else
1182 if [ -d "$2" ]; then
1183 PACKAGES_REPOSITORY=$2
1184 else
1185 echo -e "\nUnable to find directory : $2\n"
1186 exit 0
1187 fi
1188 fi
1189 cd $PACKAGES_REPOSITORY
1190 # Remove old packages.list and md5sum, they will soon be rebuilt.
1191 rm -f packages.list packages.md5 packages.txt
1192 echo ""
1193 echo -e "\033[1mGenerating packages lists\033[0m"
1194 echo "================================================================================"
1195 echo -n "Repository path : $PACKAGES_REPOSITORY" && status
1196 # Generate packages.txt
1197 if [ "$textlist" == "yes" ]; then
1198 gen_textlist
1199 [ "$fakewok" == "" ] || rm -rf $fakewok
1200 fi
1201 echo -n "Creating the raw packages list... "
1202 ls -1 *.tazpkg > /tmp/packages.list
1203 sed -i s/'.tazpkg'/''/ /tmp/packages.list
1204 status
1205 echo -n "Building the md5sum for all packages... "
1206 md5sum *.tazpkg > packages.md5
1207 status
1208 mv /tmp/packages.list $PACKAGES_REPOSITORY
1209 echo "================================================================================"
1210 pkgs=`cat $PACKAGES_REPOSITORY/packages.list | wc -l`
1211 echo "$pkgs packages in the repository."
1212 echo ""
1213 ;;
1214 new-tree)
1215 # Just create a few directories and generate an empty receipt to prepare
1216 # the creation of a new package.
1218 check_for_package_on_cmdline
1219 if [ -d $WOK/$PACKAGE ]; then
1220 echo -e "\n$PACKAGE package tree already exists.\n"
1221 exit 0
1222 fi
1223 echo "Creating : $WOK/$PACKAGE"
1224 mkdir $WOK/$PACKAGE
1225 cd $WOK/$PACKAGE
1226 echo -n "Preparing the receipt..."
1228 # Default receipt begin.
1230 echo "# SliTaz package receipt." > receipt
1231 echo "" >> receipt
1232 echo "PACKAGE=\"$PACKAGE\"" >> receipt
1233 # Finish the empty receipt.
1234 cat >> receipt << "EOF"
1235 VERSION=""
1236 CATEGORY=""
1237 SHORT_DESC=""
1238 MAINTAINER=""
1239 DEPENDS=""
1240 TARBALL="$PACKAGE-$VERSION.tar.gz"
1241 WEB_SITE=""
1242 WGET_URL=""
1244 # Rules to configure and make the package.
1245 compile_rules()
1247 cd $src
1248 ./configure \
1249 --prefix=/usr \
1250 --infodir=/usr/share/info \
1251 --mandir=/usr/share/man \
1252 $CONFIGURE_ARGS &&
1253 make && make DESTDIR=$PWD/_pkg install
1256 # Rules to gen a SliTaz package suitable for Tazpkg.
1257 genpkg_rules()
1259 mkdir -p $fs/usr
1260 cp -a $_pkg/usr/bin $fs/usr
1263 EOF
1265 # Default receipt end.
1267 status
1268 # Interactive mode, asking and seding.
1269 if [ "$3" = "--interactive" ]; then
1270 echo "Entering in interactive mode..."
1271 echo "================================================================================"
1272 echo "Package : $PACKAGE"
1273 # Version.
1274 echo -n "Version : " ; read anser
1275 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
1276 # Category.
1277 echo -n "Category : " ; read anser
1278 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
1279 # Short description.
1280 echo -n "Short desc : " ; read anser
1281 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
1282 # Maintainer.
1283 echo -n "Maintainer : " ; read anser
1284 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
1285 # Web site.
1286 echo -n "Web site : " ; read anser
1287 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
1288 echo ""
1289 # Wget URL.
1290 echo "Wget URL to download source tarball."
1291 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
1292 echo -n "Wget url : " ; read anser
1293 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
1294 # Ask for a stuff dir.
1295 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
1296 if [ "$anser" = "y" ]; then
1297 echo -n "Creating the stuff directory..."
1298 mkdir stuff && status
1299 fi
1300 # Ask for a description file.
1301 echo -n "Are you going to write a description ? (y/N) : " ; read anser
1302 if [ "$anser" = "y" ]; then
1303 echo -n "Creating the description.txt file..."
1304 echo "" > description.txt && status
1305 fi
1306 echo "================================================================================"
1307 echo ""
1308 fi
1309 ;;
1310 remove)
1311 # Remove a package from the wok.
1313 check_for_package_on_cmdline
1314 echo ""
1315 echo -n "Please confirm deletion (y/N) : "; read anser
1316 if [ "$anser" = "y" ]; then
1317 echo -n "Removing $PACKAGE..."
1318 rm -rf $WOK/$PACKAGE && status
1319 echo ""
1320 fi
1321 ;;
1322 hgup)
1323 # Pull and update an Hg wok.
1324 if ls -l $WOK/.hg/hgrc | grep -q "root"; then
1325 check_root
1326 fi
1327 cd $WOK
1328 hg pull && hg update ;;
1329 maintainers)
1330 echo ""
1331 echo "List of maintainers for: $WOK"
1332 echo "================================================================================"
1333 touch /tmp/slitaz-maintainers
1334 for pkg in $WOK/*
1335 do
1336 . $pkg/receipt
1337 if ! grep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
1338 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
1339 echo "$MAINTAINER"
1340 fi
1341 done
1342 echo "================================================================================"
1343 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
1344 echo ""
1345 # Remove tmp files
1346 rm -f /tmp/slitaz-maintainers ;;
1347 maintained-by)
1348 # Search for packages maintained by a packagers.
1349 if [ ! -n "$2" ]; then
1350 echo "Specify a name or mail of a maintainer."
1351 exit 0
1352 fi
1353 echo "Maintainer packages"
1354 echo "================================================================================"
1355 for pkg in $WOK/*
1356 do
1357 . $pkg/receipt
1358 if echo "$MAINTAINER" | grep -q "$2"; then
1359 echo "$PACKAGE"
1360 packages=$(($packages+1))
1361 fi
1362 done
1363 echo "================================================================================"
1364 echo "Packages maintained by $1: $packages"
1365 echo "" ;;
1366 usage|*)
1367 # Print usage also for all unknown commands.
1369 usage
1370 ;;
1371 esac
1373 exit 0