tazwok view tazwok @ rev 28

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