tazwok view tazwok @ rev 72

Put EXTRAVERSION into receipt
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Jun 28 10:01:59 2008 +0000 (2008-06-28)
parents 7e213a12d8ca
children b82d34244ec4
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 "fs$file" ] && continue
470 [ -f "fs$file" ] || continue
471 md5sum "fs$file" | sed 's/ fs/ /'
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 if [ -n "$EXTRAVERSION" ]; then
487 echo -n "Undating receipt EXTRAVERSION..."
488 sed -i s/^EXTRAVERSION.*$// receipt
489 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
490 status
491 fi
492 echo -n "Creating full cpio archive... "
493 find . -print | cpio -o -H newc > $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
494 # Restore package tree in case we want to browse it.
495 echo -n "Restoring original package tree... "
496 zcat fs.cpio.gz | cpio -id
497 rm fs.cpio.gz && cd ..
498 # Log process.
499 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
500 echo "================================================================================"
501 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
502 echo "Size : `du -sh $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
503 echo ""
504 }
506 # Optional text packages list for gen-list.
507 gen_textlist()
508 {
509 rm -f packages.desc
510 DATE=`date +%Y-%m-%d\ \%H:%M:%S`
511 echo -n "Creating the text packages list... "
512 cat >> packages.txt << _EOT_
513 # SliTaz GNU/Linux - Packages list
514 #
515 # Packages : _packages_
516 # Date : $DATE
517 #
518 _EOT_
519 for pkg in $WOK/*
520 do
521 PACKAGE=""
522 PACKED_SIZE=""
523 if [ -f $pkg/taz/*/receipt ]; then
524 . $pkg/taz/*/receipt
525 else
526 . $pkg/receipt
527 fi
528 cat >> packages.txt << _EOT_
530 $PACKAGE
531 $VERSION
532 $SHORT_DESC
533 _EOT_
534 if [ -n "$PACKED_SIZE" ]; then
535 cat >> packages.txt << _EOT_
536 $PACKED_SIZE ($UNPACKED_SIZE installed)
537 _EOT_
538 fi
539 # packages.desv is used by Tazpkgbox <tree>.
540 echo "$PACKAGE | $VERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> packages.desc
541 packages=$(($packages+1))
542 done && status
543 echo -n "Creating the text files list... "
544 for pkg in $WOK/*
545 do
546 if [ -f $pkg/taz/*/files.list ]; then
547 . $pkg/taz/*/receipt
548 ( echo "$PACKAGE"; cat $pkg/taz/*/files.list ) | awk '
549 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }'
550 else
551 echo "No files_list in $pkg" 1>&2
552 fi
553 done | lzma e files.list.lzma -si && status
554 sed -i s/"_packages_"/"$packages"/ packages.txt
555 }
557 ###################
558 # Tazwok commands #
559 ###################
561 case "$COMMAND" in
562 stats)
563 # Tazwok general statistics from the config file the wok.
564 #
565 echo ""
566 echo -e "\033[1mTazwok configuration statistics\033[0m
567 ================================================================================
568 Wok directory : $WOK
569 Packages repository : $PACKAGES_REPOSITORY
570 Sources repository : $SOURCES_REPOSITORY
571 Packages in the wok : `ls -1 $WOK | wc -l`
572 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
573 ================================================================================"
574 echo ""
575 ;;
576 cmp|compare)
577 # Compare the wok and packages repository to help maintaining
578 # a mirror.
579 echo ""
580 echo -e "\033[1mWok and packages comparaison\033[0m
581 ================================================================================"
582 for pkg in $WOK/*
583 do
584 . $pkg/receipt
585 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" >> /tmp/wok.list
586 if [ ! -f $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg ]; then
587 echo "Missing package: $PACKAGE ($VERSION$EXTRAVERSION)"
588 echo "$PACKAGE" >> /tmp/pkgs.missing
589 fi
590 done
591 for pkg in `cd $PACKAGES_REPOSITORY && ls *.tazpkg`
592 do
593 if ! grep -q ^$pkg /tmp/wok.list; then
594 echo $pkg >> /tmp/pkgs.old
595 if [ "$2" = "--remove" ]; then
596 echo "Removing package: $pkg"
597 rm $PACKAGES_REPOSITORY/$pkg
598 else
599 echo "Old package: $pkg"
600 fi
601 fi
602 done
603 cd /tmp
604 echo "================================================================================"
605 echo "Wok: `cat wok.list | wc -l` - \
606 Cooked: `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l` - \
607 Missing: `cat pkgs.missing 2>/dev/null | wc -l` - \
608 Old: `cat pkgs.old 2>/dev/null | wc -l`"
609 echo ""
610 rm -f wok.list pkgs.old pkgs.missing
611 ;;
612 list)
613 # List packages in wok directory. User can specifiy a category
614 #
615 if [ "$2" = "category" ]; then
616 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
617 exit 0
618 fi
619 # Check for an asked category.
620 if [ -n "$2" ]; then
621 ASKED_CATEGORY=$2
622 echo ""
623 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
624 echo "================================================================================"
625 for pkg in $WOK/*
626 do
627 . $pkg/receipt
628 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
629 echo -n "$PACKAGE"
630 echo -e "\033[28G $VERSION"
631 packages=$(($packages+1))
632 fi
633 done
634 echo "================================================================================"
635 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
636 else
637 # By default list all packages and version.
638 echo ""
639 echo -e "\033[1mList of packages in the wok\033[0m"
640 echo "================================================================================"
641 for pkg in $WOK/*
642 do
643 . $pkg/receipt
644 echo -n "$PACKAGE"
645 echo -en "\033[28G $VERSION"
646 echo -e "\033[42G $CATEGORY"
647 packages=$(($packages+1))
648 done
649 echo "================================================================================"
650 echo -e "$packages packages avalaible in the wok.\n"
651 fi
652 ;;
653 info)
654 # Informations about package.
655 #
656 check_for_package_on_cmdline
657 check_for_receipt
658 . $WOK/$PACKAGE/receipt
659 echo ""
660 echo -e "\033[1mTazwok package informations\033[0m
661 ================================================================================
662 Package : $PACKAGE
663 Version : $VERSION
664 Category : $CATEGORY
665 Short desc : $SHORT_DESC
666 Maintainer : $MAINTAINER"
667 if [ ! "$WEB_SITE" = "" ]; then
668 echo "Web site : $WEB_SITE"
669 fi
670 if [ ! "$DEPENDS" = "" ]; then
671 echo "Depends : $DEPENDS"
672 fi
673 if [ ! "$WANTED" = "" ]; then
674 echo "Wanted src : $WANTED"
675 fi
676 echo "================================================================================"
677 echo ""
679 ;;
680 check-log)
681 # We just cat the file log to view process info.
682 #
683 if [ ! -f "$LOG" ]; then
684 echo -e "\nNo process log found. The package is probably not cook.\n"
685 exit 0
686 else
687 echo ""
688 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
689 echo "================================================================================"
690 cat $LOG
691 echo "================================================================================"
692 echo ""
693 fi
694 ;;
695 search)
696 # Search for a package by pattern or name.
697 #
698 if [ -z "$2" ]; then
699 echo -e "\nPlease specify a pattern or a package name to search."
700 echo -e "Example : 'tazwok search gcc'.\n"
701 exit 0
702 fi
703 echo ""
704 echo -e "\033[1mSearch result for :\033[0m $2"
705 echo "================================================================================"
706 list=`ls -1 $WOK | grep $2`
707 for pkg in $list
708 do
709 . $WOK/$pkg/receipt
710 echo -n "$PACKAGE "
711 echo -en "\033[24G $VERSION"
712 echo -e "\033[42G $CATEGORY"
713 packages=$(($packages+1))
714 done
715 echo "================================================================================"
716 echo "$packages packages found for : $2"
717 echo ""
718 ;;
719 compile)
720 # Configure and make a package with the receipt.
721 #
722 compile_package
723 ;;
724 genpkg)
725 # Generate a package
726 #
727 gen_package
728 ;;
729 cook)
730 # Compile and generate a package. Just execute tazwok with
731 # the good commands.
732 #
733 check_root
734 compile_package
735 gen_package
736 ;;
737 cook-list)
738 # Cook all packages listed in a file. The path to the cooklist must
739 # be specified on the cmdline.
740 #
741 check_root
742 check_for_list
743 for pkg in $LIST
744 do
745 tazwok compile $pkg
746 tazwok genpkg $pkg
747 done
748 ;;
749 clean)
750 # Clean up a package work directory.
751 #
752 check_for_package_on_cmdline
753 check_for_receipt
754 . $RECEIPT
755 cd $WOK/$PACKAGE
756 echo ""
757 echo "Cleaning $PACKAGE..."
758 echo "================================================================================"
759 # Check for clean_wok function.
760 if grep -q ^clean_wok $RECEIPT; then
761 clean_wok
762 fi
763 # Remove taz/ and source tree if exist.
764 if [ -d "taz" ]; then
765 echo -n "Removing taz files..."
766 rm -rf taz && status
767 fi
768 if [ -d "$PACKAGE-$VERSION" ]; then
769 echo -n "Removing source files..."
770 rm -rf $PACKAGE-$VERSION && status
771 fi
772 if [ -d "$SOURCE-$VERSION" ]; then
773 echo -n "Removing source files..."
774 rm -rf $SOURCE-$VERSION && status
775 fi
776 # Remove an envental $PACKAGE-build directory.
777 if [ -d "$PACKAGE-build" ]; then
778 echo -n "Removing build tree..."
779 rm -rf $PACKAGE-build && status
780 fi
781 # Remove process log file.
782 if [ -f "process.log" ]; then
783 echo -n "Removing process log file..."
784 rm process.log && status
785 echo "================================================================================"
786 fi
787 echo "$PACKAGE is clean. You can cook it again..."
788 echo ""
789 ;;
790 gen-clean-wok)
791 # Generate a clean wok from the current wok by copying all receipt
792 # and stuff directory.
793 #
794 if [ -z "$2" ]; then
795 echo -e "\nPlease specify the destination for the new clean wok.\n"
796 exit 0
797 else
798 dest=$2
799 mkdir -p $dest
800 fi
801 echo "New wok is going to : $dest"
802 for pkg in `ls -1 $WOK`
803 do
804 echo "----"
805 echo -n "Preparing $pkg..."
806 mkdir -p $dest/$pkg
807 status
808 echo -n "Copying the receipt..."
809 cp -a $WOK/$pkg/receipt $dest/$pkg
810 status
811 if [ -d "$WOK/$pkg/stuff" ]; then
812 echo -n "Copying all the stuff directory..."
813 cp -a $WOK/$pkg/stuff $dest/$pkg
814 status
815 fi
816 done
817 echo "================================================================================"
818 echo "Clean wok generated in : $dest"
819 echo "Packages cleaned : `ls -1 $dest | wc -l`"
820 echo ""
821 ;;
822 clean-wok)
823 # Clean all packages in the work directory
824 #
825 for pkg in `ls -1 $WOK`
826 do
827 tazwok clean $pkg
828 done
829 echo "================================================================================"
830 echo "`ls -1 $WOK | wc -l` packages cleaned."
831 echo ""
832 ;;
833 gen-list)
834 # Sed is used to remove all the .tazpkg extensions from the
835 # packages.list. The directory to move in by default is the repository
836 # if $2 is not empty cd into $2. A text packages list can also be gen
837 # with the option --text.
838 #
839 if [ "$2" == "--text" ]; then
840 textlist="yes"
841 elif [ -z "$2" ]; then
842 PACKAGES_REPOSITORY=$PACKAGES_REPOSITORY
843 else
844 if [ -d "$2" ]; then
845 PACKAGES_REPOSITORY=$2
846 else
847 echo -e "\nUnable to find directory : $2\n"
848 exit 0
849 fi
850 fi
851 cd $PACKAGES_REPOSITORY
852 # Remove old packages.list and md5sum, it well be soon rebuild.
853 rm -f packages.list packages.md5 packages.txt
854 echo ""
855 echo -e "\033[1mGenerating packages lists\033[0m"
856 echo "================================================================================"
857 echo -n "Repository path : $PACKAGES_REPOSITORY" && status
858 # Gen packages.txt
859 if [ "$textlist" == "yes" ]; then
860 gen_textlist
861 fi
862 echo -n "Creating the raw packages list... "
863 ls -1 *.tazpkg > /tmp/packages.list
864 sed -i s/'.tazpkg'/''/ /tmp/packages.list
865 status
866 echo -n "Building the md5sum for all packages... "
867 md5sum * > packages.md5
868 status
869 mv /tmp/packages.list $PACKAGES_REPOSITORY
870 echo "================================================================================"
871 pkgs=`cat $PACKAGES_REPOSITORY/packages.list | wc -l`
872 echo "$pkgs packages in the repository."
873 echo ""
874 ;;
875 new-tree)
876 # Just creat a few directories and gen a empty receipt to prepare
877 # the creation of a new package.
878 #
879 check_for_package_on_cmdline
880 if [ -d $WOK/$PACKAGE ]; then
881 echo -e "\n$PACKAGE package tree already exist.\n"
882 exit 0
883 fi
884 echo "Creating : $WOK/$PACKAGE"
885 mkdir $WOK/$PACKAGE
886 cd $WOK/$PACKAGE
887 echo -n "Preparing the receipt..."
888 #
889 # Default receipt begin.
890 #
891 echo "# SliTaz package receipt." > receipt
892 echo "" >> receipt
893 echo "PACKAGE=\"$PACKAGE\"" >> receipt
894 # Finish the empty receipt.
895 cat >> receipt << "EOF"
896 VERSION=""
897 CATEGORY=""
898 SHORT_DESC=""
899 MAINTAINER=""
900 DEPENDS=""
901 TARBALL="$PACKAGE-$VERSION.tar.gz"
902 WEB_SITE=""
903 WGET_URL=""
905 # Rules to configure and make the package.
906 compile_rules()
907 {
908 cd $src
909 ./configure --prefix=/usr --infodir=/usr/share/info \
910 --mandir=/usr/share/man $CONFIGURE_ARGS
911 make
912 make DESTDIR=$PWD/_pkg install
913 }
915 # Rules to gen a SliTaz package suitable for Tazpkg.
916 genpkg_rules()
917 {
918 mkdir -p $fs/usr
919 cp -a $_pkg/usr/bin $fs/usr
920 strip -s $fs/usr/bin/*
921 }
923 EOF
924 #
925 # Default receipt end.
926 #
927 status
928 # Interactive mode, asking and seding.
929 if [ "$3" = "--interactive" ]; then
930 echo "Entering in interactive mode..."
931 echo "================================================================================"
932 echo "Package : $PACKAGE"
933 # Version.
934 echo -n "Version : " ; read anser
935 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
936 # Category.
937 echo -n "Category : " ; read anser
938 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
939 # Short description.
940 echo -n "Short desc : " ; read anser
941 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
942 # Maintainer.
943 echo -n "Maintainer : " ; read anser
944 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
945 # Web site.
946 echo -n "Web site : " ; read anser
947 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
948 echo ""
949 # Wget URL.
950 echo "Wget URL to download source tarball."
951 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
952 echo -n "Wget url : " ; read anser
953 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
954 # Ask for a stuff dir.
955 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
956 if [ "$anser" = "y" ]; then
957 echo -n "Creating the stuff directory..."
958 mkdir stuff && status
959 fi
960 # Ask for a description file.
961 echo -n "Are you going to write a description ? (y/N) : " ; read anser
962 if [ "$anser" = "y" ]; then
963 echo -n "Creating the description.txt file..."
964 echo "" > description.txt && status
965 fi
966 echo "================================================================================"
967 echo ""
968 fi
969 ;;
970 remove)
971 # Remove a package from the wok.
972 #
973 check_for_package_on_cmdline
974 echo ""
975 echo -n "Removing $PACKAGE..."
976 rm -rf $WOK/$PACKAGE && status
977 echo ""
978 ;;
979 usage|*)
980 # Print usage also for all unknow commands.
981 #
982 usage
983 ;;
984 esac
986 exit 0