tazwok view tazwok @ rev 33

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