tazwok view tazwok @ rev 149

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