tazwok view tazwok @ rev 89

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