tazwok view tazwok @ rev 42

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