tazwok view tazwok @ rev 87

Update default receipt
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Aug 26 15:43:25 2008 +0000 (2008-08-26)
parents 75b508daa737
children 07f7cadc87e1
line source
1 #!/bin/sh
2 # Tazwok - SliTaz source compiler and binary packages generator/cooker.
3 #
4 # Tazwok can compile source packages and create binary packages suitable for
5 # Tazpkg (Tiny Autonomous zone package manager). You can build individual
6 # packages or a list of 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=2.0
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 rather than numbers in the code.
34 COMMAND=$1
35 PACKAGE=$2
36 LIST=$2
38 # Include config file or exit if no file found.
39 if [ -f "./tazwok.conf" ]; then
40 . ./tazwok.conf
41 elif [ -f "/etc/tazwok.conf" ]; then
42 . /etc/tazwok.conf
43 else
44 echo -e "\nUnable to find the configuration file : /etc/tazwok.conf"
45 echo -e "Please read the Tazwok documentation.\n"
46 exit 0
47 fi
49 # Create Taz wok needed directories if user is root.
50 if test $(id -u) = 0 ; then
51 # Check for the wok directory.
52 if [ ! -d "$WOK" ]; then
53 echo "Creating the wok directory..."
54 mkdir -p $WOK
55 chmod 777 $WOK
56 fi
57 # Check for the packages repository.
58 if [ ! -d "$PACKAGES_REPOSITORY" ]; then
59 echo "Creating the packages repository..."
60 mkdir -p $PACKAGES_REPOSITORY
61 fi
62 # Check for the sources repository.
63 if [ ! -d "$SOURCES_REPOSITORY" ]; then
64 echo "Creating the sources repository..."
65 mkdir -p $SOURCES_REPOSITORY
66 fi
67 fi
69 # The path to the most important file used by Tazwok.
70 # The receipt is used to compile the source code and
71 # generate suitable packages for Tazpkg.
72 RECEIPT="$WOK/$PACKAGE/receipt"
74 # The path to the process log file.
75 LOG="$WOK/$PACKAGE/process.log"
77 ####################
78 # Tazwok functions #
79 ####################
81 # Print the usage (English).
82 usage ()
83 {
84 echo -e "\nSliTaz sources compiler and packages generator - Version: $VERSION\n
85 \033[1mUsage: \033[0m `basename $0` [command] [package|list|category|dir] [--option]
86 \033[1mCommands: \033[0m\n
87 usage Print this short usage.
88 stats Print Tazwok statistics from the config file and the wok.
89 cmp|compare Compare the wok and the cooked pkgs (--remove old pkgs).
90 list List all packages in the wok tree or by category.
91 info Get information 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 a 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 list 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 exists.
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 # Check for loop in deps tree.
232 check_for_deps_loop()
233 {
234 local list
235 local pkg
236 local deps
237 pkg=$1
238 shift
239 [ -n "$1" ] || return
240 list=""
241 # Filter out already processed deps
242 for i in $@; do
243 case " $ALL_DEPS" in
244 *\ $i\ *);;
245 *) list="$list $i";;
246 esac
247 done
248 ALL_DEPS="$ALL_DEPS$list "
249 for i in $list; do
250 [ -f $i/receipt ] || continue
251 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
252 case " $deps " in
253 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
254 *) check_for_deps_loop $pkg $deps;;
255 esac
256 done
257 }
259 download()
260 {
261 for file in $@; do
262 wget $file && break
263 done
264 }
266 # Configure and make a package with the receipt.
267 compile_package()
268 {
269 check_for_package_on_cmdline
270 # Include the receipt to get all needed variables and functions
271 # and cd into the work directory to start the work.
272 check_for_receipt
273 . $RECEIPT
274 # Log the package name and date.
275 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
276 echo "package $PACKAGE (compile)" >> $LOG
277 # Set wanted $src variable to help compiling.
278 if [ ! "$SOURCE" = "" ]; then
279 src=$WOK/$PACKAGE/$SOURCE-$VERSION
280 else
281 src=$WOK/$PACKAGE/$PACKAGE-$VERSION
282 fi
283 check_for_build_depends
284 check_for_wanted
285 echo ""
286 echo "Starting to cook $PACKAGE..."
287 echo "================================================================================"
288 # Check for src tarball and wget if needed.
289 if [ ! "$WGET_URL" = "" ]; then
290 echo "Checking for source tarball... "
291 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
292 cd $SOURCES_REPOSITORY
293 download $WGET_URL
294 #wget $WGET_URL
295 # Exit if download failed to avoid errors.
296 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
297 echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n"
298 exit 1
299 fi
300 else
301 echo -n "Source tarball exit... "
302 status
303 fi
304 # Untaring source if necessary. We don't need to extract source if
305 # the package is built with a wanted source package.
306 if [ "$WANTED" = "" ]; then
307 if [ ! -d $src ]; then
308 # Log process.
309 echo "untaring $TARBALL" >> $LOG
310 echo -n "Untaring $TARBALL... "
311 case "$TARBALL" in
312 *zip) ( cd $WOK/$PACKAGE; unzip $SOURCES_REPOSITORY/$TARBALL );;
313 *bz2) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE;;
314 *tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE;;
315 *) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE;;
316 esac
317 status
318 # Permissions settings
319 chown -R root.root $WOK/$PACKAGE/$PACKAGE-* 2>/dev/null
320 chown -R root.root $WOK/$PACKAGE/$SOURCE-* 2>/dev/null
321 else
322 echo -n "Source direcory exit... " && status
323 fi
324 fi
325 fi
326 cd $WOK/$PACKAGE
327 # Log and execute compile_rules function if it exists, to configure and
328 # make the package if it exists.
329 if grep -q ^compile_rules $RECEIPT; then
330 echo "executing compile_rules" >> $LOG
331 compile_rules
332 # Exit if compilation failed so the binary package
333 # is not generated when using the cook comand.
334 local CHECK=$?
335 if [ $CHECK = 0 ]; then
336 echo "================================================================================"
337 echo "$PACKAGE compiled on : `date +%Y%m%d\ \%H:%M:%S`"
338 echo ""
339 echo "compilation done : `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
340 else
341 echo "================================================================================"
342 echo "Compilation failed. Please read the compilator output."
343 echo "" && exit 1
344 fi
345 else
346 echo "no compile_rules" >> $LOG
347 echo -e "No compile rules for $PACKAGE...\n"
348 fi
349 }
351 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
352 # so some packages need to copy these files with the receipt and genpkg_rules.
353 # This function is executed by gen_package when 'tazwok genpkg'.
354 copy_generic_files()
355 {
356 # In most cases, locales are in $_pkg/usr/share/locale so we copy files
357 # using generic variables and $LOCALE from Tazwok config file.
358 if [ ! "$LOCALE" = "" ]; then
359 if [ -d "$_pkg/usr/share/locale" ]; then
360 for i in $LOCALE
361 do
362 if [ -d "$_pkg/usr/share/locale/$i" ]; then
363 mkdir -p $fs/usr/share/locale
364 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
365 fi
366 done
367 fi
368 fi
369 # Pixmaps (PNG or/and XPM only). Some icons/images can be added through
370 # genpkg_rules and generic copy can be disabled with GENERIC_PIXMAPS="no"
371 # in pkg receipt.
372 if [ ! "$GENERIC_PIXMAPS" = "no" ]; then
373 if [ -d "$_pkg/usr/share/pixmaps" ]; then
374 mkdir -p $fs/usr/share/pixmaps
375 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
376 $fs/usr/share/pixmaps 2>/dev/null
377 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
378 $fs/usr/share/pixmaps 2>/dev/null
379 fi
380 # Custom or homemade PNG pixmap can be in stuff.
381 if [ -f "stuff/$PACKAGE.png" ]; then
382 mkdir -p $fs/usr/share/pixmaps
383 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
384 fi
385 fi
386 # Desktop entry (.desktop).
387 if [ -d "$_pkg/usr/share/applications" ]; then
388 cp -a $_pkg/usr/share/applications $fs/usr/share
389 fi
390 # Homemade desktop file(s) can be in stuff.
391 if [ -d "stuff/applications" ]; then
392 mkdir -p $fs/usr/share
393 cp -a stuff/applications $fs/usr/share
394 fi
395 if [ -f "stuff/$PACKAGE.desktop" ]; then
396 mkdir -p $fs/usr/share/applications
397 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
398 fi
399 }
401 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
402 strip_package()
403 {
404 echo -n "Executing strip on all files..."
405 # Binaries.
406 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
407 do
408 if [ -d "$dir" ]; then
409 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
410 fi
411 done
412 # Libraries.
413 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
414 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
415 status
416 }
418 # Create a package tree and build the gziped cpio archive
419 # to make a SliTaz (.tazpkg) package.
420 gen_package()
421 {
422 check_root
423 check_for_package_on_cmdline
424 check_for_receipt
425 EXTRAVERSION=""
426 . $RECEIPT
427 # May compute VERSION
428 if grep -q ^get_version $RECEIPT; then
429 get_version
430 fi
431 check_for_wanted
432 cd $WOK/$PACKAGE
433 # Remove old Tazwok package files.
434 if [ -d "taz" ]; then
435 rm -rf taz
436 fi
437 # Create the package tree and set useful variables.
438 mkdir -p taz/$PACKAGE-$VERSION/fs
439 fs=taz/$PACKAGE-$VERSION/fs
440 # Set $src for standard package and $_pkg variables.
441 if [ "$WANTED" = "" ]; then
442 src=$WOK/$PACKAGE/$PACKAGE-$VERSION
443 _pkg=$src/_pkg
444 fi
445 if [ ! "$SOURCE" = "" ]; then
446 src=$WOK/$PACKAGE/$SOURCE-$VERSION
447 _pkg=$src/_pkg
448 fi
449 cd $WOK/$PACKAGE
450 # Execute genpkg_rules and copy generic files to build the package.
451 echo ""
452 echo "Building $PACKAGE with the receipt..."
453 echo "================================================================================"
454 if grep -q ^genpkg_rules $RECEIPT; then
455 # Log process.
456 echo "executing genpkg_rules" >> $LOG
457 genpkg_rules
458 cd $WOK/$PACKAGE
459 # Skip generic files for packages with a WANTED variable
460 # (dev and splited pkgs).
461 if [ ! "$WANTED" = "" ]; then
462 continue
463 else
464 copy_generic_files
465 fi
466 strip_package
467 else
468 echo "No package rules to gen $PACKAGE..."
469 exit 1
470 fi
471 # Copy the receipt and description (if exists) in the binary package tree.
472 cd $WOK/$PACKAGE
473 echo -n "Copying the receipt..."
474 cp receipt taz/$PACKAGE-$VERSION
475 status
476 if [ -f "description.txt" ]; then
477 echo -n "Copying the description file..."
478 cp description.txt taz/$PACKAGE-$VERSION
479 status
480 fi
481 # Create the files.list by redirecting find output.
482 echo -n "Creating the list of files..."
483 cd taz/$PACKAGE-$VERSION
484 LAST_FILE=""
485 ( find fs -print; echo ) | while read file; do
486 if [ "$LAST_FILE" != "" ]; then
487 case "$file" in
488 $LAST_FILE/*)
489 case "$(ls -ld "$LAST_FILE")" in
490 drwxr-xr-x\ *\ root\ *\ root\ *);;
491 *) echo ${LAST_FILE#fs};;
492 esac;;
493 *) echo ${LAST_FILE#fs};;
494 esac
495 fi
496 LAST_FILE="$file"
497 done > files.list
498 status
499 if [ -z "$EXTRAVERSION" ]; then
500 case "$PACKAGE" in
501 linux*);;
502 *) EXTRAVERSION="$(grep '/lib/modules/.*-slitaz/' files.list |\
503 head -1 | sed 's|/lib/modules/\(.*\)-slitaz/.*|_\1|')";;
504 esac
505 fi
506 rm -f $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
507 echo -n "Creating md5sum of files..."
508 while read file; do
509 [ -L "fs$file" ] && continue
510 [ -f "fs$file" ] || continue
511 md5sum "fs$file" | sed 's/ fs/ /'
512 done < files.list > md5sum
513 status
514 [ -s md5sum ] || rm -f md5sum
515 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
516 2> /dev/null | awk '{ sz=$1 } END { print sz }')
517 # Build cpio archives. Find, cpio and gzip the fs, finish by
518 # removing the fs tree.
519 echo -n "Compressing the fs... "
520 find fs -print | cpio -o -H newc | gzip > fs.cpio.gz && rm -rf fs
521 PACKED_SIZE=$(du -chs fs.cpio.gz receipt files.list md5sum \
522 description.txt 2> /dev/null | awk '{ sz=$1 } END { print sz }')
523 echo -n "Undating receipt sizes..."
524 sed -i s/^PACKED_SIZE.*$// receipt
525 sed -i s/^UNPACKED_SIZE.*$// receipt
526 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
527 sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
528 status
529 if [ -n "$EXTRAVERSION" ]; then
530 echo -n "Undating receipt EXTRAVERSION..."
531 sed -i s/^EXTRAVERSION.*$// receipt
532 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
533 status
534 fi
535 echo -n "Creating full cpio archive... "
536 find . -print | cpio -o -H newc > $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
537 # Restore package tree incase we want to browse it.
538 echo -n "Restoring original package tree... "
539 zcat fs.cpio.gz | cpio -id
540 rm fs.cpio.gz && cd ..
541 # Log process.
542 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
543 echo "================================================================================"
544 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
545 echo "Size : `du -sh $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
546 echo ""
547 }
549 # Optional text packages list for gen-list.
550 gen_textlist()
551 {
552 rm -f packages.desc
553 DATE=`date +%Y-%m-%d\ \%H:%M:%S`
554 echo -n "Creating the text packages list... "
555 cat >> packages.txt << _EOT_
556 # SliTaz GNU/Linux - Packages list
557 #
558 # Packages : _packages_
559 # Date : $DATE
560 #
561 _EOT_
562 for pkg in $WOK/*
563 do
564 PACKAGE=""
565 PACKED_SIZE=""
566 if [ -f $pkg/taz/*/receipt ]; then
567 . $pkg/taz/*/receipt
568 else
569 . $pkg/receipt
570 fi
571 cat >> packages.txt << _EOT_
573 $PACKAGE
574 $VERSION
575 $SHORT_DESC
576 _EOT_
577 if [ -n "$PACKED_SIZE" ]; then
578 cat >> packages.txt << _EOT_
579 $PACKED_SIZE ($UNPACKED_SIZE installed)
580 _EOT_
581 fi
582 # packages.desc is used by Tazpkgbox <tree>.
583 echo "$PACKAGE | $VERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> packages.desc
584 packages=$(($packages+1))
585 done && status
586 echo -n "Creating the text files list... "
587 for pkg in $WOK/*
588 do
589 if [ -f $pkg/taz/*/files.list ]; then
590 . $pkg/taz/*/receipt
591 ( echo "$PACKAGE"; cat $pkg/taz/*/files.list ) | awk '
592 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }'
593 else
594 echo "No files_list in $pkg" 1>&2
595 fi
596 done | lzma e files.list.lzma -si && status
597 sed -i s/"_packages_"/"$packages"/ packages.txt
598 }
600 ###################
601 # Tazwok commands #
602 ###################
604 case "$COMMAND" in
605 stats)
606 # Tazwok general statistics from the config file the wok.
607 #
608 echo ""
609 echo -e "\033[1mTazwok configuration statistics\033[0m
610 ================================================================================
611 Wok directory : $WOK
612 Packages repository : $PACKAGES_REPOSITORY
613 Sources repository : $SOURCES_REPOSITORY
614 Packages in the wok : `ls -1 $WOK | wc -l`
615 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
616 ================================================================================"
617 echo ""
618 ;;
619 check)
620 # Check wok consistancy
621 echo ""
622 echo -e "\033[1mWok and packages checking\033[0m
623 ================================================================================"
624 cd $WOK
625 for pkg in $(ls)
626 do
627 [ -f $pkg/receipt ] || continue
628 PACKAGE=""
629 VERSION=""
630 CATEGORY=""
631 SHORT_DESC=""
632 MAINTAINER=""
633 WEB_SITE=""
634 DEPENDS=""
635 . $pkg/receipt
636 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg"
637 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION"
638 [ -n "$CATEGORY" ] || echo "Package $PACKAGE has no CATEGORY"
639 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC"
640 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER"
641 [ -n "$WEB_SITE" ] || echo "Package $PACKAGE has no WEB_SITE"
642 case "$MAINTAINER" in
643 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER";;
644 esac
645 case "$MAINTAINER" in
646 *@*);;
647 *) echo "Package $PACKAGE MAINTAINER is not an email address";;
648 esac
649 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n"
650 for i in $DEPENDS; do
651 [ -d $i ] && continue
652 echo -e "$MSG $i"
653 MSG=""
654 done
655 MSG="Dependencies loop between $PACKAGE and :\n"
656 ALL_DEPS=""
657 check_for_deps_loop $PACKAGE $DEPENDS
658 done
659 ;;
660 cmp|compare)
661 # Compare the wok and packages repository to help with maintaining
662 # a mirror.
663 echo ""
664 echo -e "\033[1mWok and packages comparison\033[0m
665 ================================================================================"
666 for pkg in $WOK/*
667 do
668 . $pkg/receipt
669 echo "$PACKAGE-$VERSION.tazpkg" >> /tmp/wok.list
670 if [ -z "$(ls $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg 2> /dev/null)" ]; then
671 echo "Missing package: $PACKAGE ($VERSION)"
672 echo "$PACKAGE" >> /tmp/pkgs.missing
673 fi
674 done
675 for pkg in `cd $PACKAGES_REPOSITORY && ls *.tazpkg`
676 do
677 # grep $pkg in /tmp/wok.list, may include EXTRAVERSION
678 for i in $(grep ^${pkg%_*} /tmp/wok.list); do
679 case "$pkg" in
680 ${i%.tazpkg}*.tazpkg) continue 2;;
681 esac
682 done
683 # Not found
684 echo $pkg >> /tmp/pkgs.old
685 if [ "$2" = "--remove" ]; then
686 echo "Removing package: $pkg"
687 rm $PACKAGES_REPOSITORY/$pkg
688 else
689 echo "Old package: $pkg"
690 fi
691 done
692 cd /tmp
693 echo "================================================================================"
694 echo "Wok: `cat wok.list | wc -l` - \
695 Cooked: `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l` - \
696 Missing: `cat pkgs.missing 2>/dev/null | wc -l` - \
697 Old: `cat pkgs.old 2>/dev/null | wc -l`"
698 echo ""
699 rm -f wok.list pkgs.old pkgs.missing
700 ;;
701 list)
702 # List packages in wok directory. User can specifiy a category
703 #
704 if [ "$2" = "category" ]; then
705 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
706 exit 0
707 fi
708 # Check for an asked category.
709 if [ -n "$2" ]; then
710 ASKED_CATEGORY=$2
711 echo ""
712 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
713 echo "================================================================================"
714 for pkg in $WOK/*
715 do
716 . $pkg/receipt
717 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
718 echo -n "$PACKAGE"
719 echo -e "\033[28G $VERSION"
720 packages=$(($packages+1))
721 fi
722 done
723 echo "================================================================================"
724 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
725 else
726 # By default list all packages and version.
727 echo ""
728 echo -e "\033[1mList of packages in the wok\033[0m"
729 echo "================================================================================"
730 for pkg in $WOK/*
731 do
732 . $pkg/receipt
733 echo -n "$PACKAGE"
734 echo -en "\033[28G $VERSION"
735 echo -e "\033[42G $CATEGORY"
736 packages=$(($packages+1))
737 done
738 echo "================================================================================"
739 echo -e "$packages packages available in the wok.\n"
740 fi
741 ;;
742 info)
743 # Information about a package.
744 #
745 check_for_package_on_cmdline
746 check_for_receipt
747 . $WOK/$PACKAGE/receipt
748 echo ""
749 echo -e "\033[1mTazwok package information\033[0m
750 ================================================================================
751 Package : $PACKAGE
752 Version : $VERSION
753 Category : $CATEGORY
754 Short desc : $SHORT_DESC
755 Maintainer : $MAINTAINER"
756 if [ ! "$WEB_SITE" = "" ]; then
757 echo "Web site : $WEB_SITE"
758 fi
759 if [ ! "$DEPENDS" = "" ]; then
760 echo "Depends : $DEPENDS"
761 fi
762 if [ ! "$WANTED" = "" ]; then
763 echo "Wanted src : $WANTED"
764 fi
765 echo "================================================================================"
766 echo ""
768 ;;
769 check-log)
770 # We just cat the file log to view process info.
771 #
772 if [ ! -f "$LOG" ]; then
773 echo -e "\nNo process log found. The package is probably not cooked.\n"
774 exit 0
775 else
776 echo ""
777 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
778 echo "================================================================================"
779 cat $LOG
780 echo "================================================================================"
781 echo ""
782 fi
783 ;;
784 search)
785 # Search for a package by pattern or name.
786 #
787 if [ -z "$2" ]; then
788 echo -e "\nPlease specify a pattern or a package name to search."
789 echo -e "Example : 'tazwok search gcc'.\n"
790 exit 0
791 fi
792 echo ""
793 echo -e "\033[1mSearch result for :\033[0m $2"
794 echo "================================================================================"
795 list=`ls -1 $WOK | grep $2`
796 for pkg in $list
797 do
798 . $WOK/$pkg/receipt
799 echo -n "$PACKAGE "
800 echo -en "\033[24G $VERSION"
801 echo -e "\033[42G $CATEGORY"
802 packages=$(($packages+1))
803 done
804 echo "================================================================================"
805 echo "$packages packages found for : $2"
806 echo ""
807 ;;
808 compile)
809 # Configure and make a package with the receipt.
810 #
811 compile_package
812 ;;
813 genpkg)
814 # Generate a package
815 #
816 gen_package
817 ;;
818 cook)
819 # Compile and generate a package. Just execute tazwok with
820 # the good commands.
821 #
822 check_root
823 compile_package
824 gen_package
825 ;;
826 cook-list)
827 # Cook all packages listed in a file. The path to the cooklist must
828 # be specified on the cmdline.
829 #
830 check_root
831 check_for_list
832 for pkg in $LIST
833 do
834 tazwok compile $pkg
835 tazwok genpkg $pkg
836 done
837 ;;
838 clean)
839 # Clean up a package work directory.
840 #
841 check_for_package_on_cmdline
842 check_for_receipt
843 . $RECEIPT
844 cd $WOK/$PACKAGE
845 echo ""
846 echo "Cleaning $PACKAGE..."
847 echo "================================================================================"
848 # Check for clean_wok function.
849 if grep -q ^clean_wok $RECEIPT; then
850 clean_wok
851 fi
852 # Remove taz/ and source tree if exists.
853 if [ -d "taz" ]; then
854 echo -n "Removing taz files..."
855 rm -rf taz && status
856 fi
857 if [ -d "$PACKAGE-$VERSION" ]; then
858 echo -n "Removing source files..."
859 rm -rf $PACKAGE-$VERSION && status
860 fi
861 if [ -d "$SOURCE-$VERSION" ]; then
862 echo -n "Removing source files..."
863 rm -rf $SOURCE-$VERSION && status
864 fi
865 # Remove an envental $PACKAGE-build directory.
866 if [ -d "$PACKAGE-build" ]; then
867 echo -n "Removing build tree..."
868 rm -rf $PACKAGE-build && status
869 fi
870 # Remove process log file.
871 if [ -f "process.log" ]; then
872 echo -n "Removing process log file..."
873 rm process.log && status
874 echo "================================================================================"
875 fi
876 echo "$PACKAGE is clean. You can cook it again..."
877 echo ""
878 ;;
879 gen-clean-wok)
880 # Generate a clean wok from the current wok by copying all receipt
881 # and stuff directory.
882 #
883 if [ -z "$2" ]; then
884 echo -e "\nPlease specify the destination for the new clean wok.\n"
885 exit 0
886 else
887 dest=$2
888 mkdir -p $dest
889 fi
890 echo "New wok is going to : $dest"
891 for pkg in `ls -1 $WOK`
892 do
893 echo "----"
894 echo -n "Preparing $pkg..."
895 mkdir -p $dest/$pkg
896 status
897 echo -n "Copying the receipt..."
898 cp -a $WOK/$pkg/receipt $dest/$pkg
899 status
900 if [ -d "$WOK/$pkg/stuff" ]; then
901 echo -n "Copying all the stuff directory..."
902 cp -a $WOK/$pkg/stuff $dest/$pkg
903 status
904 fi
905 done
906 echo "================================================================================"
907 echo "Clean wok generated in : $dest"
908 echo "Packages cleaned : `ls -1 $dest | wc -l`"
909 echo ""
910 ;;
911 clean-wok)
912 # Clean all packages in the work directory
913 #
914 for pkg in `ls -1 $WOK`
915 do
916 tazwok clean $pkg
917 done
918 echo "================================================================================"
919 echo "`ls -1 $WOK | wc -l` packages cleaned."
920 echo ""
921 ;;
922 gen-list)
923 # Sed is used to remove all the .tazpkg extensions from the
924 # packages.list. The directory to move in by default is the repository
925 # if $2 is not empty cd into $2. A text packages list can also be gen
926 # with the option --text.
927 #
928 if [ "$2" == "--text" ]; then
929 textlist="yes"
930 elif [ -z "$2" ]; then
931 PACKAGES_REPOSITORY=$PACKAGES_REPOSITORY
932 else
933 if [ -d "$2" ]; then
934 PACKAGES_REPOSITORY=$2
935 else
936 echo -e "\nUnable to find directory : $2\n"
937 exit 0
938 fi
939 fi
940 cd $PACKAGES_REPOSITORY
941 # Remove old packages.list and md5sum, they will soon be rebuilt.
942 rm -f packages.list packages.md5 packages.txt
943 echo ""
944 echo -e "\033[1mGenerating packages lists\033[0m"
945 echo "================================================================================"
946 echo -n "Repository path : $PACKAGES_REPOSITORY" && status
947 # Generate packages.txt
948 if [ "$textlist" == "yes" ]; then
949 gen_textlist
950 fi
951 echo -n "Creating the raw packages list... "
952 ls -1 *.tazpkg > /tmp/packages.list
953 sed -i s/'.tazpkg'/''/ /tmp/packages.list
954 status
955 echo -n "Building the md5sum for all packages... "
956 md5sum * > packages.md5
957 status
958 mv /tmp/packages.list $PACKAGES_REPOSITORY
959 echo "================================================================================"
960 pkgs=`cat $PACKAGES_REPOSITORY/packages.list | wc -l`
961 echo "$pkgs packages in the repository."
962 echo ""
963 ;;
964 new-tree)
965 # Just create a few directories and generate an empty receipt to prepare
966 # the creation of a new package.
967 #
968 check_for_package_on_cmdline
969 if [ -d $WOK/$PACKAGE ]; then
970 echo -e "\n$PACKAGE package tree already exists.\n"
971 exit 0
972 fi
973 echo "Creating : $WOK/$PACKAGE"
974 mkdir $WOK/$PACKAGE
975 cd $WOK/$PACKAGE
976 echo -n "Preparing the receipt..."
977 #
978 # Default receipt begin.
979 #
980 echo "# SliTaz package receipt." > receipt
981 echo "" >> receipt
982 echo "PACKAGE=\"$PACKAGE\"" >> receipt
983 # Finish the empty receipt.
984 cat >> receipt << "EOF"
985 VERSION=""
986 CATEGORY=""
987 SHORT_DESC=""
988 MAINTAINER=""
989 DEPENDS=""
990 TARBALL="$PACKAGE-$VERSION.tar.gz"
991 WEB_SITE=""
992 WGET_URL=""
994 # Rules to configure and make the package.
995 compile_rules()
996 {
997 cd $src
998 ./configure --prefix=/usr --infodir=/usr/share/info \
999 --mandir=/usr/share/man $CONFIGURE_ARGS && \
1000 make && make DESTDIR=$PWD/_pkg install
1003 # Rules to gen a SliTaz package suitable for Tazpkg.
1004 genpkg_rules()
1006 mkdir -p $fs/usr
1007 cp -a $_pkg/usr/bin $fs/usr
1010 EOF
1012 # Default receipt end.
1014 status
1015 # Interactive mode, asking and seding.
1016 if [ "$3" = "--interactive" ]; then
1017 echo "Entering in interactive mode..."
1018 echo "================================================================================"
1019 echo "Package : $PACKAGE"
1020 # Version.
1021 echo -n "Version : " ; read anser
1022 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
1023 # Category.
1024 echo -n "Category : " ; read anser
1025 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
1026 # Short description.
1027 echo -n "Short desc : " ; read anser
1028 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
1029 # Maintainer.
1030 echo -n "Maintainer : " ; read anser
1031 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
1032 # Web site.
1033 echo -n "Web site : " ; read anser
1034 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
1035 echo ""
1036 # Wget URL.
1037 echo "Wget URL to download source tarball."
1038 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
1039 echo -n "Wget url : " ; read anser
1040 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
1041 # Ask for a stuff dir.
1042 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
1043 if [ "$anser" = "y" ]; then
1044 echo -n "Creating the stuff directory..."
1045 mkdir stuff && status
1046 fi
1047 # Ask for a description file.
1048 echo -n "Are you going to write a description ? (y/N) : " ; read anser
1049 if [ "$anser" = "y" ]; then
1050 echo -n "Creating the description.txt file..."
1051 echo "" > description.txt && status
1052 fi
1053 echo "================================================================================"
1054 echo ""
1055 fi
1056 ;;
1057 remove)
1058 # Remove a package from the wok.
1060 check_for_package_on_cmdline
1061 echo ""
1062 echo -n "Please confirm deletion (y/N) : "; read anser
1063 if [ "$anser" = "y" ]; then
1064 echo -n "Removing $PACKAGE..."
1065 rm -rf $WOK/$PACKAGE && status
1066 echo ""
1067 fi
1068 ;;
1069 usage|*)
1070 # Print usage also for all unknown commands.
1072 usage
1073 ;;
1074 esac
1076 exit 0