tazwok view tazwok @ rev 32

They can be multiple desktop files in stuff/
author Christophe Lincoln <pankso@slitaz.org>
date Thu Feb 07 11:39:52 2008 +0100 (2008-02-07)
parents ea4c836f2a68
children 0338f2ec63d2
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 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 [ -f "stuff/$PACKAGE.desktop" ]; then
327 mkdir -p $fs/usr/share/applications
328 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
329 cp -a stuff/$PACKAGE-*.desktop $fs/usr/share/applications
330 fi
331 }
333 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
334 strip_package()
335 {
336 echo -n "Executing strip on all files..."
337 # Binaries.
338 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
339 do
340 if [ -d "$dir" ]; then
341 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
342 fi
343 done
344 # Libraries.
345 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
346 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
347 status
348 }
350 # Creat a package tree and build the gziped cpio archive
351 # to make a SliTaz (.tazpkg) package.
352 gen_package()
353 {
354 check_root
355 check_for_package_on_cmdline
356 check_for_receipt
357 . $RECEIPT
358 check_for_wanted
359 cd $WOK/$PACKAGE
360 # Remove old Tazwok package files.
361 if [ -d "taz" ]; then
362 rm -rf taz
363 rm -f $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
364 fi
365 # Creat the package tree and set usful variables.
366 mkdir -p taz/$PACKAGE-$VERSION/fs
367 fs=taz/$PACKAGE-$VERSION/fs
368 # Set $src for standards package and $_pkg variables.
369 if [ "$WANTED" = "" ]; then
370 src=$WOK/$PACKAGE/$PACKAGE-$VERSION
371 _pkg=$src/_pkg
372 fi
373 if [ ! "$SOURCE" = "" ]; then
374 src=$WOK/$PACKAGE/$SOURCE-$VERSION
375 _pkg=$src/_pkg
376 fi
377 cd $WOK/$PACKAGE
378 # Execute genpkg_rules and copy generic files to build the package.
379 echo ""
380 echo "Bulding $PACKAGE with the receipt..."
381 echo "================================================================================"
382 if grep -q ^genpkg_rules $RECEIPT; then
383 # Log process.
384 echo "executing genpkg_rules" >> $LOG
385 genpkg_rules
386 cd $WOK/$PACKAGE
387 # Skip generic files for packages with a WANTED variable
388 # (dev and splited pkgs).
389 if [ ! "$WANTED" = "" ]; then
390 continue
391 else
392 copy_generic_files
393 fi
394 strip_package
395 else
396 echo "No package rules to gen $PACKAGE..."
397 exit 1
398 fi
399 # Copy the receipt and description (if exist) in the binary package tree.
400 cd $WOK/$PACKAGE
401 echo -n "Copying the receipt..."
402 cp receipt taz/$PACKAGE-$VERSION
403 status
404 if [ -f "description.txt" ]; then
405 echo -n "Copying the description file..."
406 cp description.txt taz/$PACKAGE-$VERSION
407 status
408 fi
409 # Creat the files.list by redirecting find outpout.
410 echo -n "Creating the list of files..."
411 cd taz/$PACKAGE-$VERSION
412 LAST_FILE=""
413 ( find fs -print; echo ) | while read file; do
414 if [ "$LAST_FILE" != "" ]; then
415 case "$file" in
416 $LAST_FILE/*)
417 case "$(ls -ld "$LAST_FILE")" in
418 drwxr-xr-x\ *\ root\ *\ root\ *);;
419 *) echo ${LAST_FILE#fs};;
420 esac;;
421 *) echo ${LAST_FILE#fs};;
422 esac
423 fi
424 LAST_FILE="$file"
425 done > files.list
426 status
427 # Build cpio archives. Find, cpio and gzip the fs, finish by
428 # removing the fs tree.
429 echo -n "Compressing the fs... "
430 find fs -print | cpio -o -H newc | gzip > fs.cpio.gz && rm -rf fs
431 echo -n "Creating full cpio archive... "
432 find . -print | cpio -o -H newc > $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
433 # Restore package tree in case we want to browse it.
434 echo -n "Restoring original package tree... "
435 zcat fs.cpio.gz | cpio -id
436 rm fs.cpio.gz && cd ..
437 # Log process.
438 echo "$PACKAGE-$VERSION.tazpkg (done)" >> $LOG
439 echo "================================================================================"
440 echo "Package $PACKAGE ($VERSION) generated."
441 echo "Size : `du -sh $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg`"
442 echo ""
443 }
445 # Optional text packages list for gen-list.
446 gen_textlist()
447 {
448 DATE=`date +%Y-%m-%d\ \%H:%M:%S`
449 echo -n "Creating the text packages list... "
450 cat >> packages.txt << _EOT_
451 # SliTaz GNU/Linux - Packages list
452 #
453 # Packages : _packages_
454 # Date : $DATE
455 #
456 _EOT_
457 for pkg in $WOK/*
458 do
459 . $pkg/receipt
460 cat >> packages.txt << _EOT_
462 $PACKAGE
463 $VERSION
464 $SHORT_DESC
465 _EOT_
466 packages=$(($packages+1))
467 done && status
468 sed -i s/"_packages_"/"$packages"/ packages.txt
469 }
471 ###################
472 # Tazwok commands #
473 ###################
475 case "$COMMAND" in
476 stats)
477 # Tazwok general statistics from the config file the wok.
478 #
479 echo ""
480 echo -e "\033[1mTazwok configuration statistics\033[0m
481 ================================================================================
482 Wok directory : $WOK
483 Packages repository : $PACKAGES_REPOSITORY
484 Sources repository : $SOURCES_REPOSITORY
485 Packages in the wok : `ls -1 $WOK | wc -l`
486 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
487 ================================================================================"
488 echo ""
489 ;;
490 list)
491 # List packages in wok directory. User can specifiy a category
492 #
493 if [ "$2" = "category" ]; then
494 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
495 exit 0
496 fi
497 # Check for an asked category.
498 if [ -n "$2" ]; then
499 ASKED_CATEGORY=$2
500 echo ""
501 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
502 echo "================================================================================"
503 for pkg in $WOK/*
504 do
505 . $pkg/receipt
506 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
507 echo -n "$PACKAGE"
508 echo -e "\033[28G $VERSION"
509 packages=$(($packages+1))
510 fi
511 done
512 echo "================================================================================"
513 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
514 else
515 # By default list all packages and version.
516 echo ""
517 echo -e "\033[1mList of packages in the wok\033[0m"
518 echo "================================================================================"
519 for pkg in $WOK/*
520 do
521 . $pkg/receipt
522 echo -n "$PACKAGE"
523 echo -en "\033[28G $VERSION"
524 echo -e "\033[42G $CATEGORY"
525 packages=$(($packages+1))
526 done
527 echo "================================================================================"
528 echo -e "$packages packages avalaible in the wok.\n"
529 fi
530 ;;
531 info)
532 # Informations about package.
533 #
534 check_for_package_on_cmdline
535 check_for_receipt
536 . $WOK/$PACKAGE/receipt
537 echo ""
538 echo -e "\033[1mTazwok package informations\033[0m
539 ================================================================================
540 Package : $PACKAGE
541 Version : $VERSION
542 Category : $CATEGORY
543 Short desc : $SHORT_DESC
544 Maintainer : $MAINTAINER"
545 if [ ! "$WEB_SITE" = "" ]; then
546 echo "Web site : $WEB_SITE"
547 fi
548 if [ ! "$DEPENDS" = "" ]; then
549 echo "Depends : $DEPENDS"
550 fi
551 if [ ! "$WANTED" = "" ]; then
552 echo "Wanted src : $WANTED"
553 fi
554 echo "================================================================================"
555 echo ""
557 ;;
558 check-log)
559 # We just cat the file log to view process info.
560 #
561 if [ ! -f "$LOG" ]; then
562 echo -e "\nNo process log found. The package is probably not cook.\n"
563 exit 0
564 else
565 echo ""
566 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
567 echo "================================================================================"
568 cat $LOG
569 echo "================================================================================"
570 echo ""
571 fi
572 ;;
573 search)
574 # Search for a package by pattern or name.
575 #
576 if [ -z "$2" ]; then
577 echo -e "\nPlease specify a pattern or a package name to search."
578 echo -e "Example : 'tazwok search gcc'.\n"
579 exit 0
580 fi
581 echo ""
582 echo -e "\033[1mSearch result for :\033[0m $2"
583 echo "================================================================================"
584 list=`ls -1 $WOK | grep $2`
585 for pkg in $list
586 do
587 . $WOK/$pkg/receipt
588 echo -n "$PACKAGE "
589 echo -en "\033[24G $VERSION"
590 echo -e "\033[42G $CATEGORY"
591 packages=$(($packages+1))
592 done
593 echo "================================================================================"
594 echo "$packages packages found for : $2"
595 echo ""
596 ;;
597 compile)
598 # Configure and make a package with the receipt.
599 #
600 compile_package
601 ;;
602 genpkg)
603 # Generate a package
604 #
605 gen_package
606 ;;
607 cook)
608 # Compile and generate a package. Just execute tazwok with
609 # the good commands.
610 #
611 check_root
612 compile_package
613 gen_package
614 ;;
615 cook-list)
616 # Cook all packages listed in a file. The path to the cooklist must
617 # be specified on the cmdline.
618 #
619 check_root
620 check_for_list
621 for pkg in $LIST
622 do
623 tazwok compile $pkg
624 tazwok genpkg $pkg
625 done
626 ;;
627 clean)
628 # Clean up a package work directory.
629 #
630 check_for_package_on_cmdline
631 check_for_receipt
632 . $RECEIPT
633 cd $WOK/$PACKAGE
634 echo ""
635 echo "Cleaning $PACKAGE..."
636 echo "================================================================================"
637 # Check for clean_wok function.
638 if grep -q ^clean_wok $RECEIPT; then
639 clean_wok
640 fi
641 # Remove taz/ and source tree if exist.
642 if [ -d "taz" ]; then
643 echo -n "Removing taz files..."
644 rm -rf taz && status
645 fi
646 if [ -d "$PACKAGE-$VERSION" ]; then
647 echo -n "Removing source files..."
648 rm -rf $PACKAGE-$VERSION && status
649 fi
650 if [ -d "$SOURCE-$VERSION" ]; then
651 echo -n "Removing source files..."
652 rm -rf $SOURCE-$VERSION && status
653 fi
654 # Remove an envental $PACKAGE-build directory.
655 if [ -d "$PACKAGE-build" ]; then
656 echo -n "Removing build tree..."
657 rm -rf $PACKAGE-build && status
658 fi
659 # Remove process log file.
660 if [ -f "process.log" ]; then
661 echo -n "Removing process log file..."
662 rm process.log && status
663 echo "================================================================================"
664 fi
665 echo "$PACKAGE is clean. You can cook it again..."
666 echo ""
667 ;;
668 gen-clean-wok)
669 # Generate a clean wok from the current wok by copying all receipt
670 # and stuff directory.
671 #
672 if [ -z "$2" ]; then
673 echo -e "\nPlease specify the destination for the new clean wok.\n"
674 exit 0
675 else
676 dest=$2
677 mkdir -p $dest
678 fi
679 echo "New wok is going to : $dest"
680 for pkg in `ls -1 $WOK`
681 do
682 echo "----"
683 echo -n "Preparing $pkg..."
684 mkdir -p $dest/$pkg
685 status
686 echo -n "Copying the receipt..."
687 cp -a $WOK/$pkg/receipt $dest/$pkg
688 status
689 if [ -d "$WOK/$pkg/stuff" ]; then
690 echo -n "Copying all the stuff directory..."
691 cp -a $WOK/$pkg/stuff $dest/$pkg
692 status
693 fi
694 done
695 echo "================================================================================"
696 echo "Clean wok generated in : $dest"
697 echo "Packages cleaned : `ls -1 $dest | wc -l`"
698 echo ""
699 ;;
700 clean-wok)
701 # Clean all packages in the work directory
702 #
703 for pkg in `ls -1 $WOK`
704 do
705 tazwok clean $pkg
706 done
707 echo "================================================================================"
708 echo "`ls -1 $WOK | wc -l` packages cleaned."
709 echo ""
710 ;;
711 gen-list)
712 # Sed is used to remove all the .tazpkg extensions from the
713 # packages.list. The directory to move in by default is the repository
714 # if $2 is not empty cd into $2. A text packages list can also be gen
715 # with the option --text.
716 #
717 if [ "$2" == "--text" ]; then
718 textlist="yes"
719 elif [ -z "$2" ]; then
720 PACKAGES_REPOSITORY=$PACKAGES_REPOSITORY
721 else
722 if [ -d "$2" ]; then
723 PACKAGES_REPOSITORY=$2
724 else
725 echo -e "\nUnable to find directory : $2\n"
726 exit 0
727 fi
728 fi
729 cd $PACKAGES_REPOSITORY
730 # Remove old packages.list and md5sum, it well be soon rebuild.
731 rm -f packages.list packages.md5 packages.txt
732 echo ""
733 echo -e "\033[1mGenerating packages lists\033[0m"
734 echo "================================================================================"
735 echo -n "Repository path : $PACKAGES_REPOSITORY" && status
736 # Gen packages.txt
737 if [ "$textlist" == "yes" ]; then
738 gen_textlist
739 fi
740 echo -n "Creating the raw packages list... "
741 ls -1 *.tazpkg > /tmp/packages.list
742 sed -i s/'.tazpkg'/''/ /tmp/packages.list
743 status
744 echo -n "Building the md5sum for all packages... "
745 md5sum * > packages.md5
746 status
747 mv /tmp/packages.list $PACKAGES_REPOSITORY
748 echo "================================================================================"
749 pkgs=`cat $PACKAGES_REPOSITORY/packages.list | wc -l`
750 echo "$pkgs packages in the repository."
751 echo ""
752 ;;
753 new-tree)
754 # Just creat a few directories and gen a empty receipt to prepare
755 # the creation of a new package.
756 #
757 check_for_package_on_cmdline
758 if [ -d $WOK/$PACKAGE ]; then
759 echo -e "\n$PACKAGE package tree already exist.\n"
760 exit 0
761 fi
762 echo "Creating : $WOK/$PACKAGE"
763 mkdir $WOK/$PACKAGE
764 cd $WOK/$PACKAGE
765 echo -n "Preparing the receipt..."
766 #
767 # Default receipt begin.
768 #
769 echo "# SliTaz package receipt." > receipt
770 echo "" >> receipt
771 echo "PACKAGE=\"$PACKAGE\"" >> receipt
772 # Finish the empty receipt.
773 cat >> receipt << "EOF"
774 VERSION=""
775 CATEGORY=""
776 SHORT_DESC=""
777 MAINTAINER=""
778 DEPENDS=""
779 TARBALL="$PACKAGE-$VERSION.tar.gz"
780 WEB_SITE=""
781 WGET_URL=""
783 # Rules to configure and make the package.
784 compile_rules()
785 {
786 cd $src
787 ./configure --prefix=/usr --infodir=/usr/share/info \
788 --mandir=/usr/share/man $CONFIGURE_ARGS
789 make
790 make DESTDIR=$PWD/_pkg install
791 }
793 # Rules to gen a SliTaz package suitable for Tazpkg.
794 genpkg_rules()
795 {
796 mkdir -p $fs/usr
797 cp -a $_pkg/usr/bin $fs/usr
798 strip -s $fs/usr/bin/*
799 }
801 EOF
802 #
803 # Default receipt end.
804 #
805 status
806 # Interactive mode, asking and seding.
807 if [ "$3" = "--interactive" ]; then
808 echo "Entering in interactive mode..."
809 echo "================================================================================"
810 echo "Package : $PACKAGE"
811 # Version.
812 echo -n "Version : " ; read anser
813 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
814 # Category.
815 echo -n "Category : " ; read anser
816 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
817 # Short description.
818 echo -n "Short desc : " ; read anser
819 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
820 # Maintainer.
821 echo -n "Maintainer : " ; read anser
822 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
823 # Web site.
824 echo -n "Web site : " ; read anser
825 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
826 echo ""
827 # Wget URL.
828 echo "Wget URL to download source tarball."
829 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
830 echo -n "Wget url : " ; read anser
831 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
832 # Ask for a stuff dir.
833 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
834 if [ "$anser" = "y" ]; then
835 echo -n "Creating the stuff directory..."
836 mkdir stuff && status
837 fi
838 # Ask for a description file.
839 echo -n "Are you going to write a description ? (y/N) : " ; read anser
840 if [ "$anser" = "y" ]; then
841 echo -n "Creating the description.txt file..."
842 echo "" > description.txt && status
843 fi
844 echo "================================================================================"
845 echo ""
846 fi
847 ;;
848 remove)
849 # Remove a package from the wok.
850 #
851 check_for_package_on_cmdline
852 echo ""
853 echo -n "Removing $PACKAGE..."
854 rm -rf $WOK/$PACKAGE && status
855 echo ""
856 ;;
857 usage|*)
858 # Print usage also for all unknow commands.
859 #
860 usage
861 ;;
862 esac
864 exit 0