tazwok view tazwok @ rev 70

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