tazwok view tazwok @ rev 144

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