tazwok view tazwok @ rev 39

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