tazwok view tazwok @ rev 129

check-depends: fix virtual packages check
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Apr 11 16:07:42 2009 +0000 (2009-04-11)
parents 80593ffbf3cf
children 770760bb3d44
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
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
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 $SUGGESTED ; 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 DEPENDS=""
722 SUGGESTED=""
723 . $WOK/$i/receipt
724 scan_dep
725 done
726 }
728 # Check for ELF file
729 is_elf()
730 {
731 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" \
732 = "ELF" ]
733 }
735 # Print shared library dependencies
736 ldd()
737 {
738 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1
739 }
741 mkdir $TMPDIR
742 cd $TMPDIR
743 for i in /var/lib/tazpkg/files.list.lzma \
744 /var/lib/tazpkg/undigest/*/files.list.lzma ; do
745 [ -f $i ] && lzma d $i -so >> files.list
746 done
747 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
748 tazpkg extract $pkg > /dev/null 2>&1
749 . */receipt
750 ALL_DEPENDS="$DEFAULT_DEPENDS "
751 scan_dep
752 find */fs -type f | while read file ; do
753 is_elf $file || continue
754 case "$file" in
755 *.o|*.ko|*.ko.gz) continue;;
756 esac
757 ldd $file | while read lib rem; do
758 case "$lib" in
759 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
760 continue;;
761 esac
762 for dep in $(grep $lib files.list | cut -d: -f1); do
763 case " $ALL_DEPENDS " in
764 *\ $dep\ *) continue 2;;
765 esac
766 for vdep in $(grep $dep /var/lib/tazpkg/packages.equiv | cut -d= -f1); do
767 case " $ALL_DEPENDS " in
768 *\ $vdep\ *) continue 3;;
769 esac
770 done
771 done
772 [ -n "$dep" ] || dep="UNKNOWN"
773 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
774 done
775 done
776 rm -rf */
777 done
778 cd /tmp
779 rm -rf $TMPDIR
780 ;;
781 check)
782 # Check wok consistancy
783 echo ""
784 echo -e "\033[1mWok and packages checking\033[0m
785 ================================================================================"
786 cd $WOK
787 for pkg in $(ls)
788 do
789 [ -f $pkg/receipt ] || continue
790 PACKAGE=""
791 VERSION=""
792 EXTRAVERSION=""
793 CATEGORY=""
794 SHORT_DESC=""
795 MAINTAINER=""
796 WEB_SITE=""
797 WGET_URL=""
798 DEPENDS=""
799 BUILD_DEPENDS=""
800 WANTED=""
801 PACKED_SIZE=""
802 UNPACKED_SIZE=""
803 . $pkg/receipt
804 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg"
805 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION"
806 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE"
807 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE"
808 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION"
809 if [ -n "$WANTED" ]; then
810 if [ ! -f $WANTED/receipt ]; then
811 echo "Package $PACKAGE wants unknown $WANTED package"
812 else
813 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
814 if [ "$VERSION" = "$WANTED" ]; then
815 # BASEVERSION is computed in receipt
816 grep -q '_pkg=' $pkg/receipt &&
817 BASEVERSION=$VERSION
818 fi
819 if [ "$VERSION" != "$BASEVERSION" ]; then
820 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)"
821 fi
822 fi
823 fi
825 if [ -n "$CATEGORY" ]; then
826 case " $(echo $CATEGORIES) " in
827 *\ $CATEGORY\ *);;
828 *) echo "Package $PACKAGE has an invalid CATEGORY";;
829 esac
830 else
831 echo"Package $PACKAGE has no CATEGORY"
832 fi
833 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC"
834 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER"
835 case "$WGET_URL" in
836 ftp*|http*) wget -s $WGET_URL 2> /dev/null ||
837 echo "Package $PACKAGE has a wrong WGET_URL";;
838 '') ;;
839 *) echo "Package $PACKAGE has an invalid WGET_URL";;
840 esac
841 case "$WEB_SITE" in
842 ftp*|http*);;
843 '') echo "Package $PACKAGE has no WEB_SITE";;
844 *) echo "Package $PACKAGE has an invalid WEB_SITE";;
845 esac
846 case "$MAINTAINER" in
847 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER";;
848 esac
849 case "$MAINTAINER" in
850 *@*);;
851 *) echo "Package $PACKAGE MAINTAINER is not an email address";;
852 esac
853 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n"
854 for i in $DEPENDS; do
855 [ -d $i ] && continue
856 [ -n "$(whoprovide $i)" ] && continue
857 echo -e "$MSG $i"
858 MSG=""
859 done
860 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n"
861 for i in $BUILD_DEPENDS; do
862 [ -d $i ] && continue
863 [ -n "$(whoprovide $i)" ] && continue
864 echo -e "$MSG $i"
865 MSG=""
866 done
867 MSG="Dependencies loop between $PACKAGE and :\n"
868 ALL_DEPS=""
869 check_for_deps_loop $PACKAGE $DEPENDS
870 done
871 ;;
872 cmp|compare)
873 # Compare the wok and packages repository to help with maintaining
874 # a mirror.
875 echo ""
876 echo -e "\033[1mWok and packages comparison\033[0m
877 ================================================================================"
878 for pkg in $WOK/*
879 do
880 WANTED=""
881 . $pkg/receipt
882 echo "$PACKAGE-$VERSION.tazpkg" >> /tmp/wok.list.$$
883 tpkg="$(ls $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg 2> /dev/null | head -1)"
884 if [ -z "$tpkg" ]; then
885 echo "Missing package: $PACKAGE ($VERSION)"
886 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
887 elif [ -f $pkg/taz/*/receipt -a ! -f $pkg/taz/*/md5sum ]; then
888 echo "Obsolete package: $PACKAGE ($VERSION)"
889 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
890 elif [ $pkg/receipt -nt $tpkg ]; then
891 echo "Refresh package: $PACKAGE ($VERSION)"
892 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
893 else
894 srcdate=$(hgdate $pkg)
895 pkgdate=$(date -u -r $tpkg '+%m%d%H%M%Y')
896 if [ $(date -d $pkgdate +%s) -lt $(date -d $srcdate +%s) ]; then
897 echo "Rebuild package: $PACKAGE ($VERSION) cooked $(date -d $pkgdate "+%x %X"), modified $(date -d $srcdate "+%x %X")"
898 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
899 else
900 continue
901 fi
902 fi
903 if [ "$2" = "--cook" ]; then
904 if [ -n "$WANTED" -a ! -d $WOK/$WANTED/taz ]; then
905 yes '' | tazwok cook $WANTED
906 fi
907 yes '' | tazwok cook $PACKAGE
908 fi
909 done
910 for pkg in `cd $PACKAGES_REPOSITORY && ls *.tazpkg`
911 do
912 # grep $pkg in /tmp/wok.list.$$
913 # may include EXTRAVERSION or computed VERSION
914 for i in $(grep ^${pkg%-*} /tmp/wok.list.$$); do
915 case "$pkg" in
916 ${i%.tazpkg}*.tazpkg) continue 2;;
917 esac
918 done
919 # Not found
920 echo $pkg >> /tmp/pkgs.old.$$
921 if [ "$2" = "--remove" ]; then
922 echo "Removing package: $pkg"
923 rm $PACKAGES_REPOSITORY/$pkg
924 else
925 echo "Old package: $pkg"
926 fi
927 done
928 cd /tmp
929 echo "================================================================================"
930 echo "Wok: `cat wok.list.$$ | wc -l` - \
931 Cooked: `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l` - \
932 Missing: `cat pkgs.missing.$$ 2>/dev/null | wc -l` - \
933 Old: `cat pkgs.old.$$ 2>/dev/null | wc -l`"
934 echo ""
935 rm -f wok.list.$$ pkgs.old.$$ pkgs.missing.$$
936 ;;
937 list)
938 # List packages in wok directory. User can specify a category
939 #
940 if [ "$2" = "category" ]; then
941 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
942 exit 0
943 fi
944 # Check for an asked category.
945 if [ -n "$2" ]; then
946 ASKED_CATEGORY=$2
947 echo ""
948 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
949 echo "================================================================================"
950 for pkg in $WOK/*
951 do
952 . $pkg/receipt
953 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
954 echo -n "$PACKAGE"
955 echo -e "\033[28G $VERSION"
956 packages=$(($packages+1))
957 fi
958 done
959 echo "================================================================================"
960 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
961 else
962 # By default list all packages and version.
963 echo ""
964 echo -e "\033[1mList of packages in the wok\033[0m"
965 echo "================================================================================"
966 for pkg in $WOK/*
967 do
968 . $pkg/receipt
969 echo -n "$PACKAGE"
970 echo -en "\033[28G $VERSION"
971 echo -e "\033[42G $CATEGORY"
972 packages=$(($packages+1))
973 done
974 echo "================================================================================"
975 echo -e "$packages packages available in the wok.\n"
976 fi
977 ;;
978 info)
979 # Information about a package.
980 #
981 check_for_package_on_cmdline
982 check_for_receipt
983 . $WOK/$PACKAGE/receipt
984 echo ""
985 echo -e "\033[1mTazwok package information\033[0m
986 ================================================================================
987 Package : $PACKAGE
988 Version : $VERSION
989 Category : $CATEGORY
990 Short desc : $SHORT_DESC
991 Maintainer : $MAINTAINER"
992 if [ ! "$WEB_SITE" = "" ]; then
993 echo "Web site : $WEB_SITE"
994 fi
995 if [ ! "$DEPENDS" = "" ]; then
996 echo "Depends : $DEPENDS"
997 fi
998 if [ ! "$WANTED" = "" ]; then
999 echo "Wanted src : $WANTED"
1000 fi
1001 echo "================================================================================"
1002 echo ""
1004 ;;
1005 check-log)
1006 # We just cat the file log to view process info.
1008 if [ ! -f "$LOG" ]; then
1009 echo -e "\nNo process log found. The package is probably not cooked.\n"
1010 exit 0
1011 else
1012 echo ""
1013 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
1014 echo "================================================================================"
1015 cat $LOG
1016 echo "================================================================================"
1017 echo ""
1018 fi
1019 ;;
1020 search)
1021 # Search for a package by pattern or name.
1023 if [ -z "$2" ]; then
1024 echo -e "\nPlease specify a pattern or a package name to search."
1025 echo -e "Example : 'tazwok search gcc'.\n"
1026 exit 0
1027 fi
1028 echo ""
1029 echo -e "\033[1mSearch result for :\033[0m $2"
1030 echo "================================================================================"
1031 list=`ls -1 $WOK | grep $2`
1032 for pkg in $list
1033 do
1034 . $WOK/$pkg/receipt
1035 echo -n "$PACKAGE "
1036 echo -en "\033[24G $VERSION"
1037 echo -e "\033[42G $CATEGORY"
1038 packages=$(($packages+1))
1039 done
1040 echo "================================================================================"
1041 echo "$packages packages found for : $2"
1042 echo ""
1043 ;;
1044 compile)
1045 # Configure and make a package with the receipt.
1047 compile_package
1048 ;;
1049 genpkg)
1050 # Generate a package.
1052 gen_package
1053 ;;
1054 cook)
1055 # Compile and generate a package. Just execute tazwok with
1056 # the good commands.
1058 check_root
1059 compile_package
1060 gen_package
1061 ;;
1062 cook-list)
1063 # Cook all packages listed in a file. The path to the cooklist must
1064 # be specified on the cmdline.
1066 check_root
1067 check_for_list
1068 for pkg in $LIST
1069 do
1070 tazwok compile $pkg
1071 tazwok genpkg $pkg
1072 done
1073 ;;
1074 clean)
1075 # Clean up a package work directory.
1077 check_for_package_on_cmdline
1078 check_for_receipt
1079 . $RECEIPT
1080 cd $WOK/$PACKAGE
1081 echo ""
1082 echo "Cleaning $PACKAGE..."
1083 echo "================================================================================"
1084 # Check for clean_wok function.
1085 if grep -q ^clean_wok $RECEIPT; then
1086 clean_wok
1087 fi
1088 # Remove taz/ and source tree if exists.
1089 if [ -d "taz" ]; then
1090 echo -n "Removing taz files..."
1091 rm -rf taz
1092 status
1093 fi
1094 for i in $PACKAGE-$VERSION $SOURCE-$VERSION ; do
1095 [ -e "$i" ] || continue
1096 echo -n "Removing source files..."
1097 if [ -L $i ]; then
1098 target=$(readlink $i)
1099 [ -d "$target" ] && case "$target" in
1100 /*|.|./*|..|../*);;
1101 *) rm -rf $target;;
1102 esac
1103 fi
1104 rm -rf $i
1105 status
1106 done
1107 # Remove an eventual $PACKAGE-build directory.
1108 if [ -d "$PACKAGE-build" ]; then
1109 echo -n "Removing build tree..."
1110 rm -rf $PACKAGE-build && status
1111 fi
1112 # Remove process log file.
1113 if [ -f "process.log" ]; then
1114 echo -n "Removing process log file..."
1115 rm process.log && status
1116 echo "================================================================================"
1117 fi
1118 echo "$PACKAGE is clean. You can cook it again..."
1119 echo ""
1120 ;;
1121 gen-clean-wok)
1122 # Generate a clean wok from the current wok by copying all receipts
1123 # and stuff directory.
1125 if [ -z "$2" ]; then
1126 echo -e "\nPlease specify the destination for the new clean wok.\n"
1127 exit 0
1128 else
1129 dest=$2
1130 mkdir -p $dest
1131 fi
1132 echo "New wok is going to : $dest"
1133 for pkg in `ls -1 $WOK`
1134 do
1135 echo "----"
1136 echo -n "Preparing $pkg..."
1137 mkdir -p $dest/$pkg
1138 status
1139 echo -n "Copying the receipt..."
1140 cp -a $WOK/$pkg/receipt $dest/$pkg
1141 status
1142 if [ -d "$WOK/$pkg/stuff" ]; then
1143 echo -n "Copying all the stuff directory..."
1144 cp -a $WOK/$pkg/stuff $dest/$pkg
1145 status
1146 fi
1147 done
1148 echo "================================================================================"
1149 echo "Clean wok generated in : $dest"
1150 echo "Packages cleaned : `ls -1 $dest | wc -l`"
1151 echo ""
1152 ;;
1153 clean-wok)
1154 # Clean all packages in the work directory
1156 for pkg in `ls -1 $WOK`
1157 do
1158 tazwok clean $pkg
1159 done
1160 echo "================================================================================"
1161 echo "`ls -1 $WOK | wc -l` packages cleaned."
1162 echo ""
1163 ;;
1164 gen-list)
1165 # Sed is used to remove all the .tazpkg extensions from the
1166 # packages.list. The directory to move in by default is the repository
1167 # if $2 is not empty cd into $2. A text packages list can also be gen
1168 # with the option --text.
1170 fakewok=""
1171 if [ "$2" == "--text" ]; then
1172 textlist="yes"
1173 if [ "$3" == "--fakewok" ]; then
1174 WOK=/tmp/fakewok-$$
1175 fakewok="$WOK"
1176 mkdir -p $WOK
1177 for i in $PACKAGES_REPOSITORY/*.tazpkg; do
1178 (cd $WOK; cpio -i receipt files.list 2>/dev/null) < $i
1179 . $WOK/receipt
1180 mkdir -p $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
1181 mv $WOK/receipt $WOK/files.list \
1182 $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
1183 ln $WOK/$PACKAGE/taz/$PACKAGE-$VERSION/receipt $WOK/$PACKAGE
1184 done
1185 fi
1186 elif [ -z "$2" ]; then
1187 PACKAGES_REPOSITORY=$PACKAGES_REPOSITORY
1188 else
1189 if [ -d "$2" ]; then
1190 PACKAGES_REPOSITORY=$2
1191 else
1192 echo -e "\nUnable to find directory : $2\n"
1193 exit 0
1194 fi
1195 fi
1196 cd $PACKAGES_REPOSITORY
1197 # Remove old packages.list and md5sum, they will soon be rebuilt.
1198 rm -f packages.list packages.md5 packages.txt
1199 echo ""
1200 echo -e "\033[1mGenerating packages lists\033[0m"
1201 echo "================================================================================"
1202 echo -n "Repository path : $PACKAGES_REPOSITORY" && status
1203 # Generate packages.txt
1204 if [ "$textlist" == "yes" ]; then
1205 gen_textlist
1206 [ "$fakewok" == "" ] || rm -rf $fakewok
1207 fi
1208 echo -n "Creating the raw packages list... "
1209 ls -1 *.tazpkg > /tmp/packages.list
1210 sed -i s/'.tazpkg'/''/ /tmp/packages.list
1211 status
1212 echo -n "Building the md5sum for all packages... "
1213 md5sum *.tazpkg > packages.md5
1214 status
1215 mv /tmp/packages.list $PACKAGES_REPOSITORY
1216 echo "================================================================================"
1217 pkgs=`cat $PACKAGES_REPOSITORY/packages.list | wc -l`
1218 echo "$pkgs packages in the repository."
1219 echo ""
1220 ;;
1221 new-tree)
1222 # Just create a few directories and generate an empty receipt to prepare
1223 # the creation of a new package.
1225 check_for_package_on_cmdline
1226 if [ -d $WOK/$PACKAGE ]; then
1227 echo -e "\n$PACKAGE package tree already exists.\n"
1228 exit 0
1229 fi
1230 echo "Creating : $WOK/$PACKAGE"
1231 mkdir $WOK/$PACKAGE
1232 cd $WOK/$PACKAGE
1233 echo -n "Preparing the receipt..."
1235 # Default receipt begin.
1237 echo "# SliTaz package receipt." > receipt
1238 echo "" >> receipt
1239 echo "PACKAGE=\"$PACKAGE\"" >> receipt
1240 # Finish the empty receipt.
1241 cat >> receipt << "EOF"
1242 VERSION=""
1243 CATEGORY=""
1244 SHORT_DESC=""
1245 MAINTAINER=""
1246 DEPENDS=""
1247 TARBALL="$PACKAGE-$VERSION.tar.gz"
1248 WEB_SITE=""
1249 WGET_URL=""
1251 # Rules to configure and make the package.
1252 compile_rules()
1254 cd $src
1255 ./configure \
1256 --prefix=/usr \
1257 --infodir=/usr/share/info \
1258 --mandir=/usr/share/man \
1259 $CONFIGURE_ARGS &&
1260 make && make DESTDIR=$PWD/_pkg install
1263 # Rules to gen a SliTaz package suitable for Tazpkg.
1264 genpkg_rules()
1266 mkdir -p $fs/usr
1267 cp -a $_pkg/usr/bin $fs/usr
1270 EOF
1272 # Default receipt end.
1274 status
1275 # Interactive mode, asking and seding.
1276 if [ "$3" = "--interactive" ]; then
1277 echo "Entering in interactive mode..."
1278 echo "================================================================================"
1279 echo "Package : $PACKAGE"
1280 # Version.
1281 echo -n "Version : " ; read anser
1282 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
1283 # Category.
1284 echo -n "Category : " ; read anser
1285 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
1286 # Short description.
1287 echo -n "Short desc : " ; read anser
1288 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
1289 # Maintainer.
1290 echo -n "Maintainer : " ; read anser
1291 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
1292 # Web site.
1293 echo -n "Web site : " ; read anser
1294 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
1295 echo ""
1296 # Wget URL.
1297 echo "Wget URL to download source tarball."
1298 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
1299 echo -n "Wget url : " ; read anser
1300 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
1301 # Ask for a stuff dir.
1302 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
1303 if [ "$anser" = "y" ]; then
1304 echo -n "Creating the stuff directory..."
1305 mkdir stuff && status
1306 fi
1307 # Ask for a description file.
1308 echo -n "Are you going to write a description ? (y/N) : " ; read anser
1309 if [ "$anser" = "y" ]; then
1310 echo -n "Creating the description.txt file..."
1311 echo "" > description.txt && status
1312 fi
1313 echo "================================================================================"
1314 echo ""
1315 fi
1316 ;;
1317 remove)
1318 # Remove a package from the wok.
1320 check_for_package_on_cmdline
1321 echo ""
1322 echo -n "Please confirm deletion (y/N) : "; read anser
1323 if [ "$anser" = "y" ]; then
1324 echo -n "Removing $PACKAGE..."
1325 rm -rf $WOK/$PACKAGE && status
1326 echo ""
1327 fi
1328 ;;
1329 hgup)
1330 # Pull and update an Hg wok.
1331 if ls -l $WOK/.hg/hgrc | grep -q "root"; then
1332 check_root
1333 fi
1334 cd $WOK
1335 hg pull && hg update ;;
1336 maintainers)
1337 echo ""
1338 echo "List of maintainers for: $WOK"
1339 echo "================================================================================"
1340 touch /tmp/slitaz-maintainers
1341 for pkg in $WOK/*
1342 do
1343 . $pkg/receipt
1344 if ! grep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
1345 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
1346 echo "$MAINTAINER"
1347 fi
1348 done
1349 echo "================================================================================"
1350 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
1351 echo ""
1352 # Remove tmp files
1353 rm -f /tmp/slitaz-maintainers ;;
1354 maintained-by)
1355 # Search for packages maintained by a packagers.
1356 if [ ! -n "$2" ]; then
1357 echo "Specify a name or mail of a maintainer."
1358 exit 0
1359 fi
1360 echo "Maintainer packages"
1361 echo "================================================================================"
1362 for pkg in $WOK/*
1363 do
1364 . $pkg/receipt
1365 if echo "$MAINTAINER" | grep -q "$2"; then
1366 echo "$PACKAGE"
1367 packages=$(($packages+1))
1368 fi
1369 done
1370 echo "================================================================================"
1371 echo "Packages maintained by $1: $packages"
1372 echo "" ;;
1373 usage|*)
1374 # Print usage also for all unknown commands.
1376 usage
1377 ;;
1378 esac
1380 exit 0