tazwok view tazwok @ rev 135

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