tazwok view tazwok @ rev 50

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