tazwok view tazwok @ rev 48

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