tazwok view tazwok @ rev 25

Strip generated packages automaticly
author Christophe Lincoln <pankso@slitaz.org>
date Tue Feb 05 00:27:57 2008 +0100 (2008-02-05)
parents 47584d26ad16
children f0821ee32fd3
line source
1 #!/bin/sh
2 # Tazwok - SliTaz source compiler and binary packages generator/cooker.
3 #
4 # Tazwok can compile source package and creat binary packages suitable for
5 # Tazpkg (Tiny Autonomus zone package manager). You can build individuals
6 # package or a list a 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-2008 SliTaz - GNU General Public License.
10 #
11 VERSION=1.3.1
13 ####################
14 # Tazwok variables #
15 ####################
17 # Packages categories.
18 CATEGORIES="
19 base-system
20 utilities
21 network
22 graphics
23 multimedia
24 office
25 development
26 system-tools
27 security
28 meta"
30 # Use words rater than numbers in the code.
31 COMMAND=$1
32 PACKAGE=$2
33 LIST=$2
35 # Include config file or exit if any file found.
36 if [ -f "/etc/tazwok.conf" ]; then
37 . /etc/tazwok.conf
38 else
39 echo -e "\nUnable to find the configuration file : /etc/tazwok.conf"
40 echo -e "Please read the Tazwok documentation.\n"
41 exit 0
42 fi
44 # Creat Taz wok needed directories if user is root.
45 if test $(id -u) = 0 ; then
46 # Check for the wok directory.
47 if [ ! -d "$WOK" ]; then
48 echo "Creating the wok directory..."
49 mkdir -p $WOK
50 chmod 777 $WOK
51 fi
52 # Check for the packages repository.
53 if [ ! -d "$PACKAGES_REPOSITORY" ]; then
54 echo "Creating the packages repository..."
55 mkdir -p $PACKAGES_REPOSITORY
56 fi
57 # Check for the sources repository.
58 if [ ! -d "$SOURCES_REPOSITORY" ]; then
59 echo "Creating the sources repository..."
60 mkdir -p $SOURCES_REPOSITORY
61 fi
62 fi
64 # The path to the most important file used by Tazwok.
65 # The receipt is used to compile the source code and
66 # gen suitables packages for Tazpkg.
67 RECEIPT="$WOK/$PACKAGE/receipt"
69 # The path to the process log file.
70 LOG="$WOK/$PACKAGE/process.log"
72 ####################
73 # Tazwok functions #
74 ####################
76 # Print the usage (English).
77 usage ()
78 {
79 echo -e "\nSliTaz sources compiler and packages generator - Version: $VERSION\n
80 \033[1mUsage: \033[0m `basename $0` [command] [package|list|category|dir] [--option]
81 \033[1mCommands: \033[0m\n
82 usage Print this short usage.
83 stats Print Tazwok statistics from the config file and the wok.
84 list List all packages in the wok tree or by category.
85 info Get informations about a package in the wok.
86 check-log Check the process log file of a package.
87 search Search for a package in the wok by pattern or name.
88 compile Configure and build the package using the receipt rules.
89 genpkg Generate a suitable package for Tazpkg with the rules.
90 cook Compile and generate a package directly.
91 cook-list Cook all packages specified in the list by order.
92 clean Clean all generated files in the package tree.
93 new-tree Prepare a new package tree and receipt (--interactive).
94 gen-list Generate a packages.list and md5sum for a repository.
95 gen-clean-wok Gen a clean wok in a dir ('clean-wok' cleans current wok).
96 remove Remove a package from the wok.\n"
97 }
99 # Status function.
100 status()
101 {
102 local CHECK=$?
103 echo -en "\\033[70G[ "
104 if [ $CHECK = 0 ]; then
105 echo -en "\\033[1;33mOK"
106 else
107 echo -en "\\033[1;31mFailed"
108 fi
109 echo -e "\\033[0;39m ]"
110 }
112 # Check if user is root.
113 check_root()
114 {
115 if test $(id -u) != 0 ; then
116 echo -e "\nYou must be root to run `basename $0` with this option."
117 echo -e "Please type 'su' and root password to become super-user.\n"
118 exit 0
119 fi
120 }
122 # Check for a package name on cmdline.
123 check_for_package_on_cmdline()
124 {
125 if [ -z "$PACKAGE" ]; then
126 echo -e "\nYou must specify a package name on the command line."
127 echo -e "Example : tazwok $COMMAND package\n"
128 exit 0
129 fi
130 }
132 # Check for the receipt of a package used to cook.
133 check_for_receipt()
134 {
135 if [ ! -f "$RECEIPT" ]; then
136 echo -e "\nUnable to find the receipt : $RECEIPT\n"
137 exit 0
138 fi
139 }
141 # Check for a specified file list on cmdline.
142 check_for_list()
143 {
144 if [ -z "$LIST" ]; then
145 echo -e "\nPlease specify the path to the list of packages to cook.\n"
146 exit 0
147 fi
148 # Check if the list of packages exist.
149 if [ -f "$LIST" ]; then
150 LIST=`cat $LIST`
151 else
152 echo -e "\nUnable to find $LIST packages list.\n"
153 exit 0
154 fi
155 }
157 # Check for the wanted package if specified in WANTED
158 # receipt variable. Set the $src/$_pkg variable to help compiling
159 # and generating packages.
160 check_for_wanted()
161 {
162 if [ ! "$WANTED" = "" ]; then
163 echo -n "Checking for the wanted package..."
164 if [ ! -d "$WOK/$WANTED" ]; then
165 echo -e "\nWanted package is missing in the work directory.\n"
166 exit 0
167 fi
168 status
169 # Set wanted src path.
170 src=$WOK/$WANTED/$WANTED-$VERSION
171 _pkg=$src/_pkg
172 fi
173 }
175 # Check for build dependencies and notify user.
176 check_for_build_depends()
177 {
178 echo "Checking for build dependencies..."
179 for pkg in $BUILD_DEPENDS
180 do
181 if [ ! -d "/var/lib/tazpkg/installed/$pkg" ]; then
182 MISSING_PACKAGE=$pkg
183 fi
184 done
185 if [ ! "$MISSING_PACKAGE" = "" ]; then
186 echo "================================================================================"
187 for pkg in $BUILD_DEPENDS
188 do
189 if [ ! -d "/var/lib/tazpkg/installed/$pkg" ]; then
190 MISSING_PACKAGE=$pkg
191 echo "Missing : $pkg"
192 fi
193 done
194 echo "================================================================================"
195 echo "You can continue or exit to install missing dependencies."
196 echo -n "Continue or exit (y/N) ? "; read anser
197 if [ "$anser" == "y" ]; then
198 continue
199 else
200 exit 0
201 fi
202 fi
203 }
205 # Configure and make a package with the receipt.
206 compile_package()
207 {
208 check_for_package_on_cmdline
209 # Include the receipt to get all needed variables and functions
210 # and cd into the work directory to start the work.
211 check_for_receipt
212 . $RECEIPT
213 # Log the package name and date.
214 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
215 echo "package $PACKAGE (compile)" >> $LOG
216 # Set wanted $src variable to help compiling.
217 if [ ! "$SOURCE" = "" ]; then
218 src=$WOK/$PACKAGE/$SOURCE-$VERSION
219 else
220 src=$WOK/$PACKAGE/$PACKAGE-$VERSION
221 fi
222 check_for_build_depends
223 check_for_wanted
224 echo ""
225 echo "Starting to cook $PACKAGE..."
226 echo "================================================================================"
227 # Check for src tarball and wget if needed.
228 if [ ! "$TARBALL" = "" ]; then
229 echo "Checking for source tarball... "
230 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
231 cd $SOURCES_REPOSITORY
232 wget $WGET_URL
233 # Exit if download failed to avoid errors.
234 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
235 echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n"
236 exit 1
237 fi
238 else
239 echo -n "Source tarball exit... "
240 status
241 fi
242 # Untaring source if necessary. We dont need to extract source if
243 # the package is build with a wanted source package.
244 if [ "$WANTED" = "" ]; then
245 if [ ! -d $src ]; then
246 # Log process.
247 echo "untaring $TARBALL" >> $LOG
248 echo -n "Untaring $TARBALL... "
249 if [ "`basename $TARBALL | grep tar.bz2`" ]; then
250 tar xjf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE
251 else
252 tar xzf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE
253 fi
254 status
255 else
256 echo -n "Source direcory exit... " && status
257 fi
258 fi
259 fi
260 cd $WOK/$PACKAGE
261 # Log and execute compile_rules function if it exist, to configure and
262 # make the package if it exist.
263 if [ `cat $RECEIPT | grep compile_rules` ]; then
264 echo "executing compile_rules" >> $LOG
265 compile_rules
266 # Exit if compilation failed so the binary package
267 # is not generated when using the cook comand.
268 local CHECK=$?
269 if [ $CHECK = 0 ]; then
270 echo "================================================================================"
271 echo "$PACKAGE compiled on : `date +%Y%m%d\ \%H:%M:%S`"
272 echo ""
273 echo "compilation done : `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
274 else
275 echo "================================================================================"
276 echo "Compilation failed. Please read the compilator output."
277 echo "" && exit 1
278 fi
279 else
280 echo "no compile_rules" >> $LOG
281 echo -e "No compile rules for $PACKAGE...\n"
282 fi
283 }
285 # Copy all generic files (locale, pixmaps, .desktop). We use standard path,
286 # so some packages need to copy these files with the receipt and genpkg_rules.
287 # This function is executed by gen_package when 'tazwok genpkg'.
288 copy_generic_files()
289 {
290 # In most case locale are in $_pkg/usr/share/locale so we copy files
291 # using generic variables and $LOCALE from Tazwok config file.
292 if [ ! "$LOCALE" = "" ]; then
293 if [ -d "$_pkg/usr/share/locale" ]; then
294 mkdir -p $fs/usr/share/locale
295 for i in $LOCALE
296 do
297 cp -a $_pkg/usr/share/locale/$i \
298 $fs/usr/share/locale 2>/dev/null
299 done
300 fi
301 fi
302 # Pixmaps. Some icons/images can be add trough genpkg_rules and
303 # generic copy can be disable with GENERIC_PIXMAPS="no" in pkg receipt.
304 if [ ! "$GENERIC_PIXMAPS" = "no" ]; then
305 if [ -d "$_pkg/usr/share/pixmaps" ]; then
306 mkdir -p $fs/usr/share/pixmaps
307 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.* \
308 $fs/usr/share/pixmaps 2>/dev/null
309 fi
310 # Custom or home made PNG pixmap can be in stuff.
311 if [ -f "stuff/$PACKAGE.png" ]; then
312 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
313 fi
314 fi
315 # Desktop entry (.desktop).
316 if [ -d "$_pkg/usr/share/applications" ]; then
317 cp -a $_pkg/usr/share/applications $fs/usr/share
318 fi
319 # Home made desktop file can be in stuff.
320 if [ -f "stuff/$PACKAGE.desktop" ]; then
321 mkdir -p $fs/usr/share/applications
322 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
323 fi
324 }
326 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
327 strip_package()
328 {
329 echo -n "Executing strip on all files..."
330 # Binaries.
331 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
332 do
333 if [ -d "$dir" ]; then
334 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
335 fi
336 done
337 # Libraries.
338 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
339 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
340 status
341 }
343 # Creat a package tree and build the gziped cpio archive
344 # to make a SliTaz (.tazpkg) package.
345 gen_package()
346 {
347 check_root
348 check_for_package_on_cmdline
349 check_for_receipt
350 . $RECEIPT
351 check_for_wanted
352 cd $WOK/$PACKAGE
353 # Remove old Tazwok package files.
354 if [ -d "taz" ]; then
355 rm -rf taz
356 rm -f $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
357 fi
358 # Creat the package tree and set usful variables.
359 mkdir -p taz/$PACKAGE-$VERSION/fs
360 fs=taz/$PACKAGE-$VERSION/fs
361 # Set $src for standards package and $_pkg variables.
362 if [ "$WANTED" = "" ]; then
363 src=$WOK/$PACKAGE/$PACKAGE-$VERSION
364 _pkg=$src/_pkg
365 fi
366 if [ ! "$SOURCE" = "" ]; then
367 src=$WOK/$PACKAGE/$SOURCE-$VERSION
368 _pkg=$src/_pkg
369 fi
370 cd $WOK/$PACKAGE
371 # Execute genpkg_rules and copy generic files to build the package.
372 echo ""
373 echo "Bulding $PACKAGE with the receipt..."
374 echo "================================================================================"
375 if [ `cat $RECEIPT | grep ^genpkg_rules` ]; then
376 # Log process.
377 echo "executing genpkg_rules" >> $LOG
378 genpkg_rules
379 cd $WOK/$PACKAGE
380 # Skip generic files for packages with a WANTED variable
381 # (dev and splited pkgs).
382 if [ ! "$WANTED" = "" ]; then
383 continue
384 else
385 copy_generic_files
386 fi
387 strip_package
388 else
389 echo "No package rules to gen $PACKAGE..."
390 exit 1
391 fi
392 # Copy the receipt and description (if exist) in the binary package tree.
393 cd $WOK/$PACKAGE
394 echo -n "Copying the receipt..."
395 cp receipt taz/$PACKAGE-$VERSION
396 status
397 if [ -f "description.txt" ]; then
398 echo -n "Copying the description file..."
399 cp description.txt taz/$PACKAGE-$VERSION
400 status
401 fi
402 # Creat the files.list by redirecting find outpout.
403 echo -n "Creating the list of files..."
404 cd taz/$PACKAGE-$VERSION
405 LAST_FILE=""
406 ( find fs -print; echo ) | while read file; do
407 if [ "$LAST_FILE" != "" ]; then
408 case "$file" in
409 $LAST_FILE/*)
410 case "$(ls -ld "$LAST_FILE")" in
411 drwxr-xr-x\ *\ root\ *\ root\ *);;
412 *) echo ${LAST_FILE#fs};;
413 esac;;
414 *) echo ${LAST_FILE#fs};;
415 esac
416 fi
417 LAST_FILE="$file"
418 done > files.list
419 status
420 # Build cpio archives. Find, cpio and gzip the fs, finish by
421 # removing the fs tree.
422 echo -n "Compressing the fs... "
423 find fs -print | cpio -o -H newc | gzip > fs.cpio.gz && rm -rf fs
424 echo -n "Creating full cpio archive... "
425 find . -print | cpio -o -H newc > $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
426 # Restore package tree in case we want to browse it.
427 echo -n "Restoring original package tree... "
428 zcat fs.cpio.gz | cpio -id
429 rm fs.cpio.gz && cd ..
430 # Log process.
431 echo "$PACKAGE-$VERSION.tazpkg (done)" >> $LOG
432 echo "================================================================================"
433 echo "Package $PACKAGE ($VERSION) generated."
434 echo "Size : `du -sh $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg`"
435 echo ""
436 }
438 ###################
439 # Tazwok commands #
440 ###################
442 case "$COMMAND" in
443 stats)
444 # Tazwok general statistics from the config file the wok.
445 #
446 echo ""
447 echo -e "\033[1mTazwok configuration statistics\033[0m
448 ================================================================================
449 Wok directory : $WOK
450 Packages repository : $PACKAGES_REPOSITORY
451 Sources repository : $SOURCES_REPOSITORY
452 Packages in the wok : `ls -1 $WOK | wc -l`
453 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
454 ================================================================================"
455 echo ""
456 ;;
457 list)
458 # List packages in wok directory. User can specifiy a category
459 #
460 if [ "$2" = "category" ]; then
461 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
462 exit 0
463 fi
464 # Check for an asked category.
465 if [ -n "$2" ]; then
466 ASKED_CATEGORY=$2
467 echo ""
468 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
469 echo "================================================================================"
470 for pkg in $WOK/*
471 do
472 . $pkg/receipt
473 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
474 echo -n "$PACKAGE"
475 echo -e "\033[24G $VERSION"
476 packages=$(($packages+1))
477 fi
478 done
479 echo "================================================================================"
480 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
481 else
482 # By default list all packages and version.
483 echo ""
484 echo -e "\033[1mList of packages in the wok\033[0m"
485 echo "================================================================================"
486 for pkg in $WOK/*
487 do
488 . $pkg/receipt
489 echo -n "$PACKAGE"
490 echo -en "\033[24G $VERSION"
491 echo -e "\033[42G $CATEGORY"
492 packages=$(($packages+1))
493 done
494 echo "================================================================================"
495 echo -e "$packages packages avalaible in the wok.\n"
496 fi
497 ;;
498 info)
499 # Informations about package.
500 #
501 check_for_package_on_cmdline
502 check_for_receipt
503 . $WOK/$PACKAGE/receipt
504 echo ""
505 echo -e "\033[1mTazwok package informations\033[0m
506 ================================================================================
507 Package : $PACKAGE
508 Version : $VERSION
509 Category : $CATEGORY
510 Short desc : $SHORT_DESC
511 Maintainer : $MAINTAINER"
512 if [ ! "$WEB_SITE" = "" ]; then
513 echo "Web site : $WEB_SITE"
514 fi
515 if [ ! "$DEPENDS" = "" ]; then
516 echo "Depends : $DEPENDS"
517 fi
518 if [ ! "$WANTED" = "" ]; then
519 echo "Wanted src : $WANTED"
520 fi
521 echo "================================================================================"
522 echo ""
524 ;;
525 check-log)
526 # We just cat the file log to view process info.
527 #
528 if [ ! -f "$LOG" ]; then
529 echo -e "\nNo process log found. The package is probably not cook.\n"
530 exit 0
531 else
532 echo ""
533 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
534 echo "================================================================================"
535 cat $LOG
536 echo "================================================================================"
537 echo ""
538 fi
539 ;;
540 search)
541 # Search for a package by pattern or name.
542 #
543 if [ -z "$2" ]; then
544 echo -e "\nPlease specify a pattern or a package name to search."
545 echo -e "Example : 'tazwok search gcc'.\n"
546 exit 0
547 fi
548 echo ""
549 echo -e "\033[1mSearch result for :\033[0m $2"
550 echo "================================================================================"
551 list=`ls -1 $WOK | grep $2`
552 for pkg in $list
553 do
554 . $WOK/$pkg/receipt
555 echo -n "$PACKAGE "
556 echo -en "\033[24G $VERSION"
557 echo -e "\033[42G $CATEGORY"
558 packages=$(($packages+1))
559 done
560 echo "================================================================================"
561 echo "$packages packages found for : $2"
562 echo ""
563 ;;
564 compile)
565 # Configure and make a package with the receipt.
566 #
567 compile_package
568 ;;
569 genpkg)
570 # Generate a package
571 #
572 gen_package
573 ;;
574 cook)
575 # Compile and generate a package. Just execute tazwok with
576 # the good commands.
577 #
578 check_root
579 compile_package
580 gen_package
581 ;;
582 cook-list)
583 # Cook all packages listed in a file. The path to the cooklist must
584 # be specified on the cmdline.
585 #
586 check_root
587 check_for_list
588 for pkg in $LIST
589 do
590 tazwok compile $pkg
591 tazwok genpkg $pkg
592 done
593 ;;
594 clean)
595 # Clean up a package work directory.
596 #
597 check_for_package_on_cmdline
598 check_for_receipt
599 . $RECEIPT
600 cd $WOK/$PACKAGE
601 echo ""
602 echo "Cleaning $PACKAGE..."
603 echo "================================================================================"
604 if [ -d "taz" ]; then
605 echo -n "Removing taz files..."
606 rm -rf taz && status
607 fi
608 # Remove source tree if exist.
609 if [ -d "$PACKAGE-$VERSION" ]; then
610 echo -n "Removing source files..."
611 rm -rf $PACKAGE-$VERSION && status
612 fi
613 if [ -d "$SOURCE-$VERSION" ]; then
614 echo -n "Removing source files..."
615 rm -rf $SOURCE-$VERSION && status
616 fi
617 # Remove an envental $PACKAGE-build directory.
618 if [ -d "$PACKAGE-build" ]; then
619 echo -n "Removing build tree..."
620 rm -rf $PACKAGE-build && status
621 fi
622 # Remove process log file.
623 if [ -f "process.log" ]; then
624 echo -n "Removing process log file..."
625 rm process.log && status
626 fi
627 echo "$PACKAGE is clean. You can cook it again..."
628 echo ""
629 ;;
630 gen-clean-wok)
631 # Generate a clean wok from the current wok by copying all receipt
632 # and stuff directory.
633 #
634 if [ -z "$2" ]; then
635 echo -e "\nPlease specify the destination for the new clean wok.\n"
636 exit 0
637 else
638 dest=$2
639 mkdir -p $dest
640 fi
641 echo "New wok is going to : $dest"
642 for pkg in `ls -1 $WOK`
643 do
644 echo "----"
645 echo -n "Preparing $pkg..."
646 mkdir -p $dest/$pkg
647 status
648 echo -n "Copying the receipt..."
649 cp -a $WOK/$pkg/receipt $dest/$pkg
650 status
651 if [ -d "$WOK/$pkg/stuff" ]; then
652 echo -n "Copying all the stuff directory..."
653 cp -a $WOK/$pkg/stuff $dest/$pkg
654 status
655 fi
656 done
657 echo "================================================================================"
658 echo "Clean wok generated in : $dest"
659 echo "Packages cleaned : `ls -1 $dest | wc -l`"
660 echo ""
661 ;;
662 clean-wok)
663 # Clean all packages in the work directory
664 #
665 for pkg in `ls -1 $WOK`
666 do
667 tazwok clean $pkg
668 done
669 echo "================================================================================"
670 echo "`ls -1 $WOK | wc -l` packages cleaned."
671 echo ""
672 ;;
673 gen-list)
674 # cd in the directory to creat a packages.list and the md5sum file.
675 # Sed is used to remove all the .tazpkg extensions from the
676 # packages.list. The directory to move in by default is the repository
677 # if $3 is not empty cd into $3.
678 #
679 if [ -z "$2" ]; then
680 PACKAGES_REPOSITORY=$PACKAGES_REPOSITORY
681 else
682 if [ -d "$2" ]; then
683 PACKAGES_REPOSITORY=$2
684 else
685 echo -e "\nUnable to find directory : $2\n"
686 exit 0
687 fi
688 fi
689 cd $PACKAGES_REPOSITORY
690 # Remove old packages.list and md5sum, it well be soon rebuild.
691 rm -f packages.list packages.md5
692 echo ""
693 echo "Repository path : $PACKAGES_REPOSITORY"
694 echo -n "Creating the packages list... "
695 ls -1 *.tazpkg > /tmp/packages.list
696 sed -i s/'.tazpkg'/''/ /tmp/packages.list
697 status
698 echo -n "Building the md5sum for all packages... "
699 md5sum * > packages.md5
700 status
701 mv /tmp/packages.list $PACKAGES_REPOSITORY
702 echo "================================================================================"
703 pkgs=`cat $PACKAGES_REPOSITORY/packages.list | wc -l`
704 echo "$pkgs packages in the repository."
705 echo ""
706 ;;
707 new-tree)
708 # Just creat a few directories and gen a empty receipt to prepare
709 # the creation of a new package.
710 #
711 check_for_package_on_cmdline
712 if [ -d $WOK/$PACKAGE ]; then
713 echo -e "\n$PACKAGE package tree already exist.\n"
714 exit 0
715 fi
716 echo "Creating : $WOK/$PACKAGE"
717 mkdir $WOK/$PACKAGE
718 cd $WOK/$PACKAGE
719 echo -n "Preparing the receipt..."
720 #
721 # Default receipt begin.
722 #
723 echo "# SliTaz package receipt." > receipt
724 echo "" >> receipt
725 echo "PACKAGE=\"$PACKAGE\"" >> receipt
726 # Finish the empty receipt.
727 cat >> receipt << "EOF"
728 VERSION=""
729 CATEGORY=""
730 SHORT_DESC=""
731 MAINTAINER=""
732 DEPENDS=""
733 TARBALL="$PACKAGE-$VERSION.tar.gz"
734 WEB_SITE=""
735 WGET_URL=""
737 # Rules to configure and make the package.
738 compile_rules()
739 {
740 cd $src
741 ./configure --prefix=/usr --infodir=/usr/share/info \
742 --mandir=/usr/share/man $CONFIGURE_ARGS
743 make
744 make DESTDIR=$PWD/_pkg install
745 }
747 # Rules to gen a SliTaz package suitable for Tazpkg.
748 genpkg_rules()
749 {
750 mkdir -p $fs/usr
751 cp -a $_pkg/usr/bin $fs/usr
752 strip -s $fs/usr/bin/*
753 }
755 EOF
756 #
757 # Default receipt end.
758 #
759 status
760 # Interactive mode, asking and seding.
761 if [ "$3" = "--interactive" ]; then
762 echo "Entering in interactive mode..."
763 echo "================================================================================"
764 echo "Package : $PACKAGE"
765 # Version.
766 echo -n "Version : " ; read anser
767 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
768 # Category.
769 echo -n "Category : " ; read anser
770 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
771 # Short description.
772 echo -n "Short desc : " ; read anser
773 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
774 # Maintainer.
775 echo -n "Maintainer : " ; read anser
776 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
777 # Web site.
778 echo -n "Web site : " ; read anser
779 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
780 echo ""
781 # Wget URL.
782 echo "Wget URL to download source tarball."
783 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
784 echo -n "Wget url : " ; read anser
785 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
786 # Ask for a stuff dir.
787 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
788 if [ "$anser" = "y" ]; then
789 echo -n "Creating the stuff directory..."
790 mkdir stuff && status
791 fi
792 # Ask for a description file.
793 echo -n "Are you going to write a description ? (y/N) : " ; read anser
794 if [ "$anser" = "y" ]; then
795 echo -n "Creating the description.txt file..."
796 echo "" > description.txt && status
797 fi
798 echo "================================================================================"
799 echo ""
800 fi
801 ;;
802 remove)
803 # Remove a package from the wok.
804 #
805 check_for_package_on_cmdline
806 echo ""
807 echo -n "Removing $PACKAGE..."
808 rm -rf $WOK/$PACKAGE && status
809 echo ""
810 ;;
811 usage|*)
812 # Print usage also for all unknow commands.
813 #
814 usage
815 ;;
816 esac
818 exit 0