tazwok view tazwok @ rev 40

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