tazwok view tazwok @ rev 138

tazwok: regen add packages depending on compile_rules
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Jun 29 11:49:34 2009 +0200 (2009-06-29)
parents 711dd1c7d1c6
children b07f8b1c7002
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
354 for i in $( grep -l "WANTED=\"$PACKAGE\"" $WOK/*/receipt) ; do
355 tazwok genpkg $(basename $(dirname $i))
356 done
357 else
358 echo "================================================================================"
359 echo "Compilation failed. Please read the compilator output."
360 echo "" && exit 1
361 fi
362 else
363 echo "no compile_rules" >> $LOG
364 echo -e "No compile rules for $PACKAGE...\n"
365 fi
366 }
368 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
369 # so some packages need to copy these files with the receipt and genpkg_rules.
370 # This function is executed by gen_package when 'tazwok genpkg'.
371 copy_generic_files()
372 {
373 # In most cases, locales are in $_pkg/usr/share/locale so we copy files
374 # using generic variables and $LOCALE from Tazwok config file.
375 if [ ! "$LOCALE" = "" ]; then
376 if [ -d "$_pkg/usr/share/locale" ]; then
377 for i in $LOCALE
378 do
379 if [ -d "$_pkg/usr/share/locale/$i" ]; then
380 mkdir -p $fs/usr/share/locale
381 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
382 fi
383 done
384 fi
385 fi
386 # Pixmaps (PNG or/and XPM only). Some icons/images can be added through
387 # genpkg_rules and generic copy can be disabled with GENERIC_PIXMAPS="no"
388 # in pkg receipt.
389 if [ ! "$GENERIC_PIXMAPS" = "no" ]; then
390 if [ -d "$_pkg/usr/share/pixmaps" ]; then
391 mkdir -p $fs/usr/share/pixmaps
392 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
393 $fs/usr/share/pixmaps 2>/dev/null
394 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
395 $fs/usr/share/pixmaps 2>/dev/null
396 fi
397 # Custom or homemade PNG pixmap can be in stuff.
398 if [ -f "stuff/$PACKAGE.png" ]; then
399 mkdir -p $fs/usr/share/pixmaps
400 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
401 fi
402 fi
403 # Desktop entry (.desktop).
404 if [ -d "$_pkg/usr/share/applications" ]; then
405 cp -a $_pkg/usr/share/applications $fs/usr/share
406 fi
407 # Homemade desktop file(s) can be in stuff.
408 if [ -d "stuff/applications" ]; then
409 mkdir -p $fs/usr/share
410 cp -a stuff/applications $fs/usr/share
411 fi
412 if [ -f "stuff/$PACKAGE.desktop" ]; then
413 mkdir -p $fs/usr/share/applications
414 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
415 fi
416 }
418 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
419 strip_package()
420 {
421 echo -n "Executing strip on all files..."
422 # Binaries.
423 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
424 do
425 if [ -d "$dir" ]; then
426 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
427 fi
428 done
429 # Libraries.
430 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
431 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
432 status
433 }
435 # Check FSH in a slitaz package (Path: /:/usr)
436 check_fsh()
437 {
438 cd $WOK/$PACKAGE/taz/*/fs
439 for i in `ls -d * usr/* 2>/dev/null`
440 do
441 if ! echo $FSH | grep -q $i; then
442 echo "Wrong path: /$i"
443 error=1
444 fi
445 done
446 if [ "$error" = "1" ]; then
447 cat << _EOT_
449 Package will install files in a non standard directory and want be generated.
450 You may have a wrong copy path in genpkg_rules or must add some options to
451 configure in compile_rules. Some valid options for SliTaz (Linux FSH):
453 --prefix=/usr
454 --sysconfdir=/etc
455 --libexecdir=/usr/lib/(pkgname)
456 --localstatedir=/var
457 --mandir=/usr/share/man
458 --infodir=/usr/share/info
460 For more information please read SliTaz doc and run: ./configure --help
461 ================================================================================
462 $PACKAGE package generation aborted.
464 _EOT_
465 # Dont generate a corrupted package.
466 cd $WOK/$PACKAGE && rm -rf taz
467 exit 1
468 fi
469 echo ""
470 }
472 # Create a package tree and build the gziped cpio archive
473 # to make a SliTaz (.tazpkg) package.
474 gen_package()
475 {
476 check_root
477 check_for_package_on_cmdline
478 check_for_receipt
479 EXTRAVERSION=""
480 . $RECEIPT
481 # May compute VERSION
482 if grep -q ^get_version $RECEIPT; then
483 get_version
484 fi
485 check_for_wanted
486 cd $WOK/$PACKAGE
487 # Remove old Tazwok package files.
488 if [ -d "taz" ]; then
489 rm -rf taz
490 fi
491 # Create the package tree and set useful variables.
492 mkdir -p taz/$PACKAGE-$VERSION/fs
493 fs=taz/$PACKAGE-$VERSION/fs
494 # Set $src for standard package and $_pkg variables.
495 if [ "$WANTED" = "" ]; then
496 src=$WOK/$PACKAGE/$PACKAGE-$VERSION
497 _pkg=$src/_pkg
498 fi
499 if [ ! "$SOURCE" = "" ]; then
500 src=$WOK/$PACKAGE/$SOURCE-$VERSION
501 _pkg=$src/_pkg
502 fi
503 cd $WOK/$PACKAGE
504 # Execute genpkg_rules, check package and copy generic files to build
505 # the package.
506 echo ""
507 echo "Building $PACKAGE with the receipt..."
508 echo "================================================================================"
509 if grep -q ^genpkg_rules $RECEIPT; then
510 # Log process.
511 echo "executing genpkg_rules" >> $LOG
512 genpkg_rules
513 check_fsh
514 cd $WOK/$PACKAGE
515 # Skip generic files for packages with a WANTED variable
516 # (dev and splited pkgs).
517 if [ ! "$WANTED" = "" ]; then
518 continue
519 else
520 copy_generic_files
521 fi
522 strip_package
523 else
524 echo "No package rules to gen $PACKAGE..."
525 exit 1
526 fi
527 # Copy the receipt and description (if exists) in the binary package tree.
528 cd $WOK/$PACKAGE
529 echo -n "Copying the receipt..."
530 cp receipt taz/$PACKAGE-$VERSION
531 status
532 if grep -q ^get_version $RECEIPT; then
533 echo -n "Update version in receipt..."
534 sed -i "s/^VERSION=.*/VERSION=\"$VERSION\"/" \
535 taz/$PACKAGE-$VERSION/receipt
536 status
537 fi
538 if [ -f "description.txt" ]; then
539 echo -n "Copying the description file..."
540 cp description.txt taz/$PACKAGE-$VERSION
541 status
542 fi
543 # Create the files.list by redirecting find output.
544 echo -n "Creating the list of files..."
545 cd taz/$PACKAGE-$VERSION
546 LAST_FILE=""
547 ( find fs -print; echo ) | while read file; do
548 if [ "$LAST_FILE" != "" ]; then
549 case "$file" in
550 $LAST_FILE/*)
551 case "$(ls -ld "$LAST_FILE")" in
552 drwxr-xr-x\ *\ root\ *\ root\ *);;
553 *) echo ${LAST_FILE#fs};;
554 esac;;
555 *) echo ${LAST_FILE#fs};;
556 esac
557 fi
558 LAST_FILE="$file"
559 done > files.list
560 status
561 if [ -z "$EXTRAVERSION" ]; then
562 case "$PACKAGE" in
563 linux*);;
564 *) EXTRAVERSION="$(grep '/lib/modules/.*-slitaz/' files.list |\
565 head -1 | sed 's|/lib/modules/\(.*\)-slitaz/.*|_\1|')";;
566 esac
567 fi
568 rm -f $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
569 echo -n "Creating md5sum of files..."
570 while read file; do
571 [ -L "fs$file" ] && continue
572 [ -f "fs$file" ] || continue
573 md5sum "fs$file" | sed 's/ fs/ /'
574 done < files.list > md5sum
575 #[ -s md5sum ] || rm -f md5sum
576 status
577 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
578 2> /dev/null | awk '{ sz=$1 } END { print sz }')
579 # Build cpio archives. Find, cpio and gzip the fs, finish by
580 # removing the fs tree.
581 echo -n "Compressing the fs... "
582 find fs -print | cpio -o -H newc | gzip > fs.cpio.gz && rm -rf fs
583 PACKED_SIZE=$(du -chs fs.cpio.gz receipt files.list md5sum \
584 description.txt 2> /dev/null | awk '{ sz=$1 } END { print sz }')
585 status
586 echo -n "Updating receipt sizes..."
587 sed -i '/^PACKED_SIZE/d' receipt
588 sed -i '/^UNPACKED_SIZE/d' receipt
589 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
590 sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
591 status
592 if [ -n "$EXTRAVERSION" ]; then
593 echo -n "Updating receipt EXTRAVERSION..."
594 sed -i s/^EXTRAVERSION.*$// receipt
595 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
596 status
597 fi
598 echo -n "Creating full cpio archive... "
599 find . -print | cpio -o -H newc > $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
600 status
601 # Restore package tree incase we want to browse it.
602 echo -n "Restoring original package tree... "
603 zcat fs.cpio.gz | cpio -id
604 rm fs.cpio.gz && cd ..
605 # Log process.
606 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
607 echo "================================================================================"
608 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
609 echo "Size : `du -sh $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
610 echo ""
611 }
613 # Optional text packages list for gen-list.
614 gen_textlist()
615 {
616 rm -f packages.desc packages.equiv
617 DATE=`date +%Y-%m-%d\ \%H:%M:%S`
618 echo -n "Creating the text packages list... "
619 cat >> packages.txt << _EOT_
620 # SliTaz GNU/Linux - Packages list
621 #
622 # Packages : _packages_
623 # Date : $DATE
624 #
625 _EOT_
626 for pkg in $WOK/*
627 do
628 PROVIDE=""
629 PACKAGE=""
630 PACKED_SIZE=""
631 if [ -f $pkg/taz/*/receipt ]; then
632 . $pkg/taz/*/receipt
633 else
634 . $pkg/receipt
635 fi
636 cat >> packages.txt << _EOT_
638 $PACKAGE
639 $VERSION
640 $SHORT_DESC
641 _EOT_
642 if [ -n "$PACKED_SIZE" ]; then
643 cat >> packages.txt << _EOT_
644 $PACKED_SIZE ($UNPACKED_SIZE installed)
645 _EOT_
646 fi
647 # Packages.desc is used by Tazpkgbox <tree>.
648 echo "$PACKAGE | $VERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> packages.desc
649 # Packages.equiv is used by tazpkg install to check depends
650 touch packages.equiv
651 for i in $PROVIDE; do
652 DEST=""
653 echo $i | grep -q : && DEST="${i#*:}:"
654 if grep -qs ^${i%:*}= packages.equiv; then
655 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" packages.equiv
656 else
657 echo "${i%:*}=$DEST$PACKAGE" >> packages.equiv
658 fi
659 done
660 packages=$(($packages+1))
661 done && status
662 echo -n "Creating the text files list... "
663 for pkg in $WOK/*
664 do
665 if [ -f $pkg/taz/*/files.list ]; then
666 . $pkg/taz/*/receipt
667 ( echo "$PACKAGE"; cat $pkg/taz/*/files.list ) | awk '
668 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }'
669 else
670 echo "No files_list in $pkg" 1>&2
671 fi
672 done | lzma e files.list.lzma -si && status
673 sed -i s/"_packages_"/"$packages"/ packages.txt
674 }
676 # Return the date of the last commit in seconds since Jan 1 1970
677 hgdate()
678 {
679 local pkg
680 local date
681 local mon
682 # Default date is Jan 1 1970
683 [ -d $WOK/.hg -a -x /usr/bin/hg ] || { echo "010100001970"; return; }
684 pkg=$(basename $1)
685 # Get date for last commit
686 date="$( cd $WOK; hg log $(find $pkg/receipt $pkg/stuff -type f \
687 2> /dev/null) | grep date: | head -1 | cut -c 6-)"
688 [ -n "$date" ] || { echo "010100001970"; return; }
689 case "$(echo $date | awk '{ print $2 }')" in
690 Jan) mon="01";; Feb) mon="02";; Mar) mon="03";; Apr) mon="04";;
691 May) mon="05";; Jun) mon="06";; Jul) mon="07";; Aug) mon="08";;
692 Sep) mon="09";; Oct) mon="10";; Nov) mon="11";; Dec) mon="12";;
693 esac
694 # Reformat, don't mind about TZ: we look for days or months delta
695 echo $date | sed "s|[^ ]* [^ ]* \\(.*\\) \\(.*\\):\\(.*\\):\\(.*\\) \\(.*\\) .*|$mon\1\2\3\5|"
696 }
698 # List packages providing a virtual package
699 whoprovide()
700 {
701 local i;
702 for i in $(grep -l PROVIDE $WOK/*/receipt); do
703 . $i
704 case " $PROVIDE " in
705 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
706 esac
707 done
708 }
710 ###################
711 # Tazwok commands #
712 ###################
714 case "$COMMAND" in
715 stats)
716 # Tazwok general statistics from the config file the wok.
717 #
718 echo ""
719 echo -e "\033[1mTazwok configuration statistics\033[0m
720 ================================================================================
721 Wok directory : $WOK
722 Packages repository : $PACKAGES_REPOSITORY
723 Sources repository : $SOURCES_REPOSITORY
724 Packages in the wok : `ls -1 $WOK | wc -l`
725 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
726 ================================================================================"
727 echo "" ;;
728 edit)
729 check_for_package_on_cmdline
730 check_for_receipt
731 $EDITOR $WOK/$PACKAGE/receipt ;;
732 build-depends)
733 # List dependancies to rebuild wok
734 cd $WOK
735 ALL_DEPS="slitaz-toolchain"
736 echo $ALL_DEPS
737 for pkg in $(ls $2)
738 do
739 [ -f $pkg/receipt ] || continue
740 BUILD_DEPENDS=""
741 . $pkg/receipt
742 for i in $BUILD_DEPENDS; do
743 case " $ALL_DEPS " in
744 *\ $i\ *);;
745 *) ALL_DEPS="$ALL_DEPS $i"
746 echo $i;;
747 esac
748 done
749 done
750 ;;
751 check-depends)
752 # Check package depends
753 echo ""
754 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
755 ================================================================================"
756 TMPDIR=/tmp/tazwok$$
757 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
759 # Build ALL_DEPENDS variable
760 scan_dep()
761 {
762 local i
763 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
764 for i in $DEPENDS $SUGGESTED ; do
765 case " $ALL_DEPENDS " in
766 *\ $i\ *) continue;;
767 esac
768 [ -d $WOK/$i ] || {
769 ALL_DEPENDS="$ALL_DEPENDS$i "
770 continue
771 }
772 DEPENDS=""
773 SUGGESTED=""
774 . $WOK/$i/receipt
775 scan_dep
776 done
777 }
779 # Check for ELF file
780 is_elf()
781 {
782 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" \
783 = "ELF" ]
784 }
786 # Print shared library dependencies
787 ldd()
788 {
789 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
790 }
792 mkdir $TMPDIR
793 cd $TMPDIR
794 for i in /var/lib/tazpkg/files.list.lzma \
795 /var/lib/tazpkg/undigest/*/files.list.lzma ; do
796 [ -f $i ] && lzma d $i -so >> files.list
797 done
798 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
799 tazpkg extract $pkg > /dev/null 2>&1
800 . */receipt
801 ALL_DEPENDS="$DEFAULT_DEPENDS "
802 scan_dep
803 find */fs -type f | while read file ; do
804 is_elf $file || continue
805 case "$file" in
806 *.o|*.ko|*.ko.gz) continue;;
807 esac
808 ldd $file | while read lib rem; do
809 case "$lib" in
810 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
811 continue;;
812 esac
813 for dep in $(grep $lib files.list | cut -d: -f1); do
814 case " $ALL_DEPENDS " in
815 *\ $dep\ *) continue 2;;
816 esac
817 for vdep in $(grep $dep /var/lib/tazpkg/packages.equiv | cut -d= -f1); do
818 case " $ALL_DEPENDS " in
819 *\ $vdep\ *) continue 3;;
820 esac
821 done
822 done
823 [ -n "$dep" ] || dep="UNKNOWN"
824 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
825 done
826 done
827 rm -rf */
828 done
829 cd /tmp
830 rm -rf $TMPDIR
831 ;;
832 check)
833 # Check wok consistancy
834 echo ""
835 echo -e "\033[1mWok and packages checking\033[0m
836 ================================================================================"
837 cd $WOK
838 for pkg in $(ls)
839 do
840 [ -f $pkg/receipt ] || continue
841 PACKAGE=""
842 VERSION=""
843 EXTRAVERSION=""
844 CATEGORY=""
845 SHORT_DESC=""
846 MAINTAINER=""
847 WEB_SITE=""
848 WGET_URL=""
849 DEPENDS=""
850 BUILD_DEPENDS=""
851 WANTED=""
852 PACKED_SIZE=""
853 UNPACKED_SIZE=""
854 . $pkg/receipt
855 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg"
856 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION"
857 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE"
858 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE"
859 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION"
860 if [ -n "$WANTED" ]; then
861 if [ ! -f $WANTED/receipt ]; then
862 echo "Package $PACKAGE wants unknown $WANTED package"
863 else
864 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
865 if [ "$VERSION" = "$WANTED" ]; then
866 # BASEVERSION is computed in receipt
867 grep -q '_pkg=' $pkg/receipt &&
868 BASEVERSION=$VERSION
869 fi
870 if [ "$VERSION" != "$BASEVERSION" ]; then
871 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)"
872 fi
873 fi
874 fi
876 if [ -n "$CATEGORY" ]; then
877 case " $(echo $CATEGORIES) " in
878 *\ $CATEGORY\ *);;
879 *) echo "Package $PACKAGE has an invalid CATEGORY";;
880 esac
881 else
882 echo"Package $PACKAGE has no CATEGORY"
883 fi
884 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC"
885 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER"
886 case "$WGET_URL" in
887 ftp*|http*) wget -s $WGET_URL 2> /dev/null ||
888 echo "Package $PACKAGE has a wrong WGET_URL";;
889 '') ;;
890 *) echo "Package $PACKAGE has an invalid WGET_URL";;
891 esac
892 case "$WEB_SITE" in
893 ftp*|http*);;
894 '') echo "Package $PACKAGE has no WEB_SITE";;
895 *) echo "Package $PACKAGE has an invalid WEB_SITE";;
896 esac
897 case "$MAINTAINER" in
898 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER";;
899 esac
900 case "$MAINTAINER" in
901 *@*);;
902 *) echo "Package $PACKAGE MAINTAINER is not an email address";;
903 esac
904 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n"
905 for i in $DEPENDS; do
906 [ -d $i ] && continue
907 [ -n "$(whoprovide $i)" ] && continue
908 echo -e "$MSG $i"
909 MSG=""
910 done
911 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n"
912 for i in $BUILD_DEPENDS; do
913 [ -d $i ] && continue
914 [ -n "$(whoprovide $i)" ] && continue
915 echo -e "$MSG $i"
916 MSG=""
917 done
918 MSG="Dependencies loop between $PACKAGE and :\n"
919 ALL_DEPS=""
920 check_for_deps_loop $PACKAGE $DEPENDS
921 done
922 ;;
923 cmp|compare)
924 # Compare the wok and packages repository to help with maintaining
925 # a mirror.
926 echo ""
927 echo -e "\033[1mWok and packages comparison\033[0m
928 ================================================================================"
929 for pkg in $WOK/*
930 do
931 WANTED=""
932 . $pkg/receipt
933 echo "$PACKAGE-$VERSION.tazpkg" >> /tmp/wok.list.$$
934 tpkg="$(ls $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg 2> /dev/null | head -1)"
935 if [ -z "$tpkg" ]; then
936 echo "Missing package: $PACKAGE ($VERSION)"
937 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
938 elif [ -f $pkg/taz/*/receipt -a ! -f $pkg/taz/*/md5sum ]; then
939 echo "Obsolete package: $PACKAGE ($VERSION)"
940 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
941 elif [ $pkg/receipt -nt $tpkg ]; then
942 echo "Refresh package: $PACKAGE ($VERSION)"
943 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
944 else
945 srcdate=$(hgdate $pkg)
946 pkgdate=$(date -u -r $tpkg '+%m%d%H%M%Y')
947 if [ $(date -d $pkgdate +%s) -lt $(date -d $srcdate +%s) ]; then
948 echo "Rebuild package: $PACKAGE ($VERSION) cooked $(date -d $pkgdate "+%x %X"), modified $(date -d $srcdate "+%x %X")"
949 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
950 else
951 continue
952 fi
953 fi
954 if [ "$2" = "--cook" ]; then
955 if [ -n "$WANTED" -a ! -d $WOK/$WANTED/taz ]; then
956 yes '' | tazwok cook $WANTED
957 fi
958 yes '' | tazwok cook $PACKAGE
959 fi
960 done
961 for pkg in `cd $PACKAGES_REPOSITORY && ls *.tazpkg`
962 do
963 # grep $pkg in /tmp/wok.list.$$
964 # may include EXTRAVERSION or computed VERSION
965 for i in $(grep ^${pkg%-*} /tmp/wok.list.$$); do
966 case "$pkg" in
967 ${i%.tazpkg}*.tazpkg) continue 2;;
968 esac
969 done
970 # Not found
971 echo $pkg >> /tmp/pkgs.old.$$
972 if [ "$2" = "--remove" ]; then
973 echo "Removing package: $pkg"
974 rm $PACKAGES_REPOSITORY/$pkg
975 else
976 echo "Old package: $pkg"
977 fi
978 done
979 cd /tmp
980 echo "================================================================================"
981 echo "Wok: `cat wok.list.$$ | wc -l` - \
982 Cooked: `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l` - \
983 Missing: `cat pkgs.missing.$$ 2>/dev/null | wc -l` - \
984 Old: `cat pkgs.old.$$ 2>/dev/null | wc -l`"
985 echo ""
986 rm -f wok.list.$$ pkgs.old.$$ pkgs.missing.$$
987 ;;
988 list)
989 # List packages in wok directory. User can specify a category
990 #
991 if [ "$2" = "category" ]; then
992 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
993 exit 0
994 fi
995 # Check for an asked category.
996 if [ -n "$2" ]; then
997 ASKED_CATEGORY=$2
998 echo ""
999 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
1000 echo "================================================================================"
1001 for pkg in $WOK/*
1002 do
1003 . $pkg/receipt
1004 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
1005 echo -n "$PACKAGE"
1006 echo -e "\033[28G $VERSION"
1007 packages=$(($packages+1))
1008 fi
1009 done
1010 echo "================================================================================"
1011 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
1012 else
1013 # By default list all packages and version.
1014 echo ""
1015 echo -e "\033[1mList of packages in the wok\033[0m"
1016 echo "================================================================================"
1017 for pkg in $WOK/*
1018 do
1019 . $pkg/receipt
1020 echo -n "$PACKAGE"
1021 echo -en "\033[28G $VERSION"
1022 echo -e "\033[42G $CATEGORY"
1023 packages=$(($packages+1))
1024 done
1025 echo "================================================================================"
1026 echo -e "$packages packages available in the wok.\n"
1027 fi
1028 ;;
1029 info)
1030 # Information about a package.
1032 check_for_package_on_cmdline
1033 check_for_receipt
1034 . $WOK/$PACKAGE/receipt
1035 echo ""
1036 echo -e "\033[1mTazwok package information\033[0m
1037 ================================================================================
1038 Package : $PACKAGE
1039 Version : $VERSION
1040 Category : $CATEGORY
1041 Short desc : $SHORT_DESC
1042 Maintainer : $MAINTAINER"
1043 if [ ! "$WEB_SITE" = "" ]; then
1044 echo "Web site : $WEB_SITE"
1045 fi
1046 if [ ! "$DEPENDS" = "" ]; then
1047 echo "Depends : $DEPENDS"
1048 fi
1049 if [ ! "$WANTED" = "" ]; then
1050 echo "Wanted src : $WANTED"
1051 fi
1052 echo "================================================================================"
1053 echo ""
1055 ;;
1056 check-log)
1057 # We just cat the file log to view process info.
1059 if [ ! -f "$LOG" ]; then
1060 echo -e "\nNo process log found. The package is probably not cooked.\n"
1061 exit 0
1062 else
1063 echo ""
1064 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
1065 echo "================================================================================"
1066 cat $LOG
1067 echo "================================================================================"
1068 echo ""
1069 fi
1070 ;;
1071 search)
1072 # Search for a package by pattern or name.
1074 if [ -z "$2" ]; then
1075 echo -e "\nPlease specify a pattern or a package name to search."
1076 echo -e "Example : 'tazwok search gcc'.\n"
1077 exit 0
1078 fi
1079 echo ""
1080 echo -e "\033[1mSearch result for :\033[0m $2"
1081 echo "================================================================================"
1082 list=`ls -1 $WOK | grep $2`
1083 for pkg in $list
1084 do
1085 . $WOK/$pkg/receipt
1086 echo -n "$PACKAGE "
1087 echo -en "\033[24G $VERSION"
1088 echo -e "\033[42G $CATEGORY"
1089 packages=$(($packages+1))
1090 done
1091 echo "================================================================================"
1092 echo "$packages packages found for : $2"
1093 echo ""
1094 ;;
1095 compile)
1096 # Configure and make a package with the receipt.
1098 compile_package
1099 ;;
1100 genpkg)
1101 # Generate a package.
1103 gen_package
1104 ;;
1105 cook)
1106 # Compile and generate a package. Just execute tazwok with
1107 # the good commands.
1109 check_root
1110 compile_package
1111 gen_package
1112 ;;
1113 cook-list)
1114 # Cook all packages listed in a file. The path to the cooklist must
1115 # be specified on the cmdline.
1117 check_root
1118 check_for_list
1119 for pkg in $LIST
1120 do
1121 tazwok compile $pkg
1122 tazwok genpkg $pkg
1123 done
1124 ;;
1125 clean)
1126 # Clean up a package work directory.
1128 check_for_package_on_cmdline
1129 check_for_receipt
1130 . $RECEIPT
1131 cd $WOK/$PACKAGE
1132 echo ""
1133 echo "Cleaning $PACKAGE..."
1134 echo "================================================================================"
1135 # Check for clean_wok function.
1136 if grep -q ^clean_wok $RECEIPT; then
1137 clean_wok
1138 fi
1139 # Remove taz/ and source tree if exists.
1140 if [ -d "taz" ]; then
1141 echo -n "Removing taz files..."
1142 rm -rf taz
1143 status
1144 fi
1145 for i in $PACKAGE-$VERSION $SOURCE-$VERSION ; do
1146 [ -e "$i" ] || continue
1147 echo -n "Removing source files..."
1148 if [ -L $i ]; then
1149 target=$(readlink $i)
1150 [ -d "$target" ] && case "$target" in
1151 /*|.|./*|..|../*);;
1152 *) rm -rf $target;;
1153 esac
1154 fi
1155 rm -rf $i
1156 status
1157 done
1158 # Remove an eventual $PACKAGE-build directory.
1159 if [ -d "$PACKAGE-build" ]; then
1160 echo -n "Removing build tree..."
1161 rm -rf $PACKAGE-build && status
1162 fi
1163 # Remove process log file.
1164 if [ -f "process.log" ]; then
1165 echo -n "Removing process log file..."
1166 rm process.log && status
1167 echo "================================================================================"
1168 fi
1169 echo "$PACKAGE is clean. You can cook it again..."
1170 echo ""
1171 ;;
1172 gen-clean-wok)
1173 # Generate a clean wok from the current wok by copying all receipts
1174 # and stuff directory.
1176 if [ -z "$2" ]; then
1177 echo -e "\nPlease specify the destination for the new clean wok.\n"
1178 exit 0
1179 else
1180 dest=$2
1181 mkdir -p $dest
1182 fi
1183 echo "New wok is going to : $dest"
1184 for pkg in `ls -1 $WOK`
1185 do
1186 echo "----"
1187 echo -n "Preparing $pkg..."
1188 mkdir -p $dest/$pkg
1189 status
1190 echo -n "Copying the receipt..."
1191 cp -a $WOK/$pkg/receipt $dest/$pkg
1192 status
1193 if [ -d "$WOK/$pkg/stuff" ]; then
1194 echo -n "Copying all the stuff directory..."
1195 cp -a $WOK/$pkg/stuff $dest/$pkg
1196 status
1197 fi
1198 done
1199 echo "================================================================================"
1200 echo "Clean wok generated in : $dest"
1201 echo "Packages cleaned : `ls -1 $dest | wc -l`"
1202 echo ""
1203 ;;
1204 clean-wok)
1205 # Clean all packages in the work directory
1207 for pkg in `ls -1 $WOK`
1208 do
1209 tazwok clean $pkg
1210 done
1211 echo "================================================================================"
1212 echo "`ls -1 $WOK | wc -l` packages cleaned."
1213 echo ""
1214 ;;
1215 gen-list)
1216 # Sed is used to remove all the .tazpkg extensions from the
1217 # packages.list. The directory to move in by default is the repository
1218 # if $2 is not empty cd into $2. A text packages list can also be gen
1219 # with the option --text.
1221 fakewok=""
1222 if [ "$2" == "--text" ]; then
1223 textlist="yes"
1224 if [ "$3" == "--fakewok" ]; then
1225 WOK=/tmp/fakewok-$$
1226 fakewok="$WOK"
1227 mkdir -p $WOK
1228 for i in $PACKAGES_REPOSITORY/*.tazpkg; do
1229 (cd $WOK; cpio -i receipt files.list 2>/dev/null) < $i
1230 . $WOK/receipt
1231 mkdir -p $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
1232 mv $WOK/receipt $WOK/files.list \
1233 $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
1234 ln $WOK/$PACKAGE/taz/$PACKAGE-$VERSION/receipt $WOK/$PACKAGE
1235 done
1236 fi
1237 elif [ -z "$2" ]; then
1238 PACKAGES_REPOSITORY=$PACKAGES_REPOSITORY
1239 else
1240 if [ -d "$2" ]; then
1241 PACKAGES_REPOSITORY=$2
1242 else
1243 echo -e "\nUnable to find directory : $2\n"
1244 exit 0
1245 fi
1246 fi
1247 cd $PACKAGES_REPOSITORY
1248 # Remove old packages.list and md5sum, they will soon be rebuilt.
1249 rm -f packages.list packages.md5 packages.txt
1250 echo ""
1251 echo -e "\033[1mGenerating packages lists\033[0m"
1252 echo "================================================================================"
1253 echo -n "Repository path : $PACKAGES_REPOSITORY" && status
1254 # Generate packages.txt
1255 if [ "$textlist" == "yes" ]; then
1256 gen_textlist
1257 [ "$fakewok" == "" ] || rm -rf $fakewok
1258 fi
1259 echo -n "Creating the raw packages list... "
1260 ls -1 *.tazpkg > /tmp/packages.list
1261 sed -i s/'.tazpkg'/''/ /tmp/packages.list
1262 status
1263 echo -n "Building the md5sum for all packages... "
1264 md5sum *.tazpkg > packages.md5
1265 status
1266 mv /tmp/packages.list $PACKAGES_REPOSITORY
1267 echo "================================================================================"
1268 pkgs=`cat $PACKAGES_REPOSITORY/packages.list | wc -l`
1269 echo "$pkgs packages in the repository."
1270 echo ""
1271 ;;
1272 new-tree)
1273 # Just create a few directories and generate an empty receipt to prepare
1274 # the creation of a new package.
1276 check_for_package_on_cmdline
1277 if [ -d $WOK/$PACKAGE ]; then
1278 echo -e "\n$PACKAGE package tree already exists.\n"
1279 exit 0
1280 fi
1281 echo "Creating : $WOK/$PACKAGE"
1282 mkdir $WOK/$PACKAGE
1283 cd $WOK/$PACKAGE
1284 echo -n "Preparing the receipt..."
1286 # Default receipt begin.
1288 echo "# SliTaz package receipt." > receipt
1289 echo "" >> receipt
1290 echo "PACKAGE=\"$PACKAGE\"" >> receipt
1291 # Finish the empty receipt.
1292 cat >> receipt << "EOF"
1293 VERSION=""
1294 CATEGORY=""
1295 SHORT_DESC=""
1296 MAINTAINER=""
1297 DEPENDS=""
1298 TARBALL="$PACKAGE-$VERSION.tar.gz"
1299 WEB_SITE=""
1300 WGET_URL=""
1302 # Rules to configure and make the package.
1303 compile_rules()
1305 cd $src
1306 ./configure \
1307 --prefix=/usr \
1308 --infodir=/usr/share/info \
1309 --mandir=/usr/share/man \
1310 $CONFIGURE_ARGS &&
1311 make && make DESTDIR=$PWD/_pkg install
1314 # Rules to gen a SliTaz package suitable for Tazpkg.
1315 genpkg_rules()
1317 mkdir -p $fs/usr
1318 cp -a $_pkg/usr/bin $fs/usr
1321 EOF
1323 # Default receipt end.
1325 status
1326 # Interactive mode, asking and seding.
1327 if [ "$3" = "--interactive" ]; then
1328 echo "Entering in interactive mode..."
1329 echo "================================================================================"
1330 echo "Package : $PACKAGE"
1331 # Version.
1332 echo -n "Version : " ; read anser
1333 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
1334 # Category.
1335 echo -n "Category : " ; read anser
1336 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
1337 # Short description.
1338 echo -n "Short desc : " ; read anser
1339 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
1340 # Maintainer.
1341 echo -n "Maintainer : " ; read anser
1342 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
1343 # Web site.
1344 echo -n "Web site : " ; read anser
1345 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
1346 echo ""
1347 # Wget URL.
1348 echo "Wget URL to download source tarball."
1349 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
1350 echo -n "Wget url : " ; read anser
1351 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
1352 # Ask for a stuff dir.
1353 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
1354 if [ "$anser" = "y" ]; then
1355 echo -n "Creating the stuff directory..."
1356 mkdir stuff && status
1357 fi
1358 # Ask for a description file.
1359 echo -n "Are you going to write a description ? (y/N) : " ; read anser
1360 if [ "$anser" = "y" ]; then
1361 echo -n "Creating the description.txt file..."
1362 echo "" > description.txt && status
1363 fi
1364 echo "================================================================================"
1365 echo ""
1366 fi
1367 ;;
1368 remove)
1369 # Remove a package from the wok.
1371 check_for_package_on_cmdline
1372 echo ""
1373 echo -n "Please confirm deletion (y/N) : "; read anser
1374 if [ "$anser" = "y" ]; then
1375 echo -n "Removing $PACKAGE..."
1376 rm -rf $WOK/$PACKAGE && status
1377 echo ""
1378 fi
1379 ;;
1380 hgup)
1381 # Pull and update an Hg wok.
1382 if ls -l $WOK/.hg/hgrc | grep -q "root"; then
1383 check_root
1384 fi
1385 cd $WOK
1386 hg pull && hg update ;;
1387 maintainers)
1388 echo ""
1389 echo "List of maintainers for: $WOK"
1390 echo "================================================================================"
1391 touch /tmp/slitaz-maintainers
1392 for pkg in $WOK/*
1393 do
1394 . $pkg/receipt
1395 if ! grep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
1396 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
1397 echo "$MAINTAINER"
1398 fi
1399 done
1400 echo "================================================================================"
1401 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
1402 echo ""
1403 # Remove tmp files
1404 rm -f /tmp/slitaz-maintainers ;;
1405 maintained-by)
1406 # Search for packages maintained by a packagers.
1407 if [ ! -n "$2" ]; then
1408 echo "Specify a name or mail of a maintainer."
1409 exit 0
1410 fi
1411 echo "Maintainer packages"
1412 echo "================================================================================"
1413 for pkg in $WOK/*
1414 do
1415 . $pkg/receipt
1416 if echo "$MAINTAINER" | grep -q "$2"; then
1417 echo "$PACKAGE"
1418 packages=$(($packages+1))
1419 fi
1420 done
1421 echo "================================================================================"
1422 echo "Packages maintained by $2: $packages"
1423 echo "" ;;
1424 usage|*)
1425 # Print usage also for all unknown commands.
1427 usage
1428 ;;
1429 esac
1431 exit 0