tazwok view tazwok @ rev 35

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