tazwok view tazwok @ rev 133

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