tazwok view tazwok @ rev 140

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