tazwok view tazwok @ rev 161

Added tag 3.1 for changeset 3a48fb61c93d
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Feb 02 15:21:14 2010 +0100 (2010-02-02)
parents efa7df06bf04
children 05bf754a184d
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-2009 SliTaz - GNU General Public License.
10 #
11 VERSION=3.1
13 ####################
14 # Tazwok variables #
15 ####################
17 # Packages categories
18 #
19 # We may move this to a centralized config for Tazwok, Tazpkg and Tazbb.
20 # /var/lib/tazpkg/categories ?
21 #
22 CATEGORIES="
23 base-system
24 x-window
25 utilities
26 network
27 graphics
28 multimedia
29 office
30 development
31 system-tools
32 security
33 games
34 misc
35 meta
36 non-free"
38 # Use words rather than numbers in the code.
39 COMMAND=$1
40 PACKAGE=$2
41 LIST=$2
43 LOCALSTATE=/var/lib/tazpkg
44 INSTALLED=$LOCALSTATE/installed
46 # Include config file or exit if no file found.
47 if [ -f "./tazwok.conf" ]; then
48 . ./tazwok.conf
49 elif [ -f "/etc/tazwok.conf" ]; then
50 . /etc/tazwok.conf
51 else
52 echo -e "\nUnable to find the configuration file : /etc/tazwok.conf"
53 echo -e "Please read the Tazwok documentation.\n"
54 exit 0
55 fi
57 # Create Taz wok needed directories if user is root.
58 if test $(id -u) = 0 ; then
59 # Check for the wok directory.
60 if [ ! -d "$WOK" ]; then
61 echo "Creating the wok directory..."
62 mkdir -p $WOK
63 chmod 777 $WOK
64 fi
65 # Check for the packages repository.
66 if [ ! -d "$PACKAGES_REPOSITORY" ]; then
67 echo "Creating the packages repository..."
68 mkdir -p $PACKAGES_REPOSITORY
69 fi
70 # Check for the sources repository.
71 if [ ! -d "$SOURCES_REPOSITORY" ]; then
72 echo "Creating the sources repository..."
73 mkdir -p $SOURCES_REPOSITORY
74 fi
75 fi
77 # The path to the most important file used by Tazwok.
78 # The receipt is used to compile the source code and
79 # generate suitable packages for Tazpkg.
80 RECEIPT="$WOK/$PACKAGE/receipt"
82 # The path to the process log file.
83 LOG="$WOK/$PACKAGE/process.log"
85 ####################
86 # Tazwok functions #
87 ####################
89 # Print the usage (English).
90 usage ()
91 {
92 echo -e "\nSliTaz sources compiler and packages generator - Version: $VERSION\n
93 \033[1mUsage: \033[0m `basename $0` [command] [package|list|category|dir|id] [--option]
94 \033[1mCommands: \033[0m\n
95 usage Print this short usage.
96 stats Print Tazwok statistics from the config file and the wok.
97 edit Edit a package receipt in the current wok.
98 build-depends Generate a list of packages to build a wok.
99 cmp|compare Compare the wok and the cooked pkgs (--remove old pkgs).
100 list List all packages in the wok tree or by category.
101 info Get information about a package in the wok.
102 check Check every receipt for common errors.
103 check-log Check the process log file of a package.
104 check-depends Check every receipt for DEPENDS - doesn't scan ELF files.
105 check-src Check upstream tarball for package in the wok.
106 search Search for a package in the wok by pattern or name.
107 compile Configure and build a package using the receipt rules.
108 genpkg Generate a suitable package for Tazpkg with the rules.
109 cook Compile and generate a package directly.
110 cook-list Cook all packages specified in the list by order.
111 clean Clean all generated files in the package tree.
112 new-tree Prepare a new package tree and receipt (--interactive).
113 gen-list Generate a packages list for a repository (--text).
114 gen-clean-wok Gen a clean wok in a dir ('clean-wok' cleans current wok).
115 remove Remove a package from the wok.
116 hgup Pull and update a wok under Hg.
117 maintainers List all maintainers in the wok.
118 maintained-by List packages maintained by a contributor.\n"
119 }
121 # Status function.
122 status()
123 {
124 local CHECK=$?
125 echo -en "\\033[70G[ "
126 if [ $CHECK = 0 ]; then
127 echo -en "\\033[1;33mOK"
128 else
129 echo -en "\\033[1;31mFailed"
130 fi
131 echo -e "\\033[0;39m ]"
132 }
134 # Check if user is root.
135 check_root()
136 {
137 if test $(id -u) != 0 ; then
138 echo -e "\nYou must be root to run `basename $0` with this option."
139 echo -e "Please type 'su' and root password to become super-user.\n"
140 exit 0
141 fi
142 }
144 # Check for a package name on cmdline.
145 check_for_package_on_cmdline()
146 {
147 if [ -z "$PACKAGE" ]; then
148 echo -e "\nYou must specify a package name on the command line."
149 echo -e "Example : tazwok $COMMAND package\n"
150 exit 0
151 fi
152 }
154 # Check for the receipt of a package used to cook.
155 check_for_receipt()
156 {
157 if [ ! -f "$RECEIPT" ]; then
158 echo -e "\nUnable to find the receipt : $RECEIPT\n"
159 exit 0
160 fi
161 }
163 # Check for a specified file list on cmdline.
164 check_for_list()
165 {
166 if [ -z "$LIST" ]; then
167 echo -e "\nPlease specify the path to the list of packages to cook.\n"
168 exit 0
169 fi
170 # Check if the list of packages exists.
171 if [ -f "$LIST" ]; then
172 LIST=`cat $LIST`
173 else
174 echo -e "\nUnable to find $LIST packages list.\n"
175 exit 0
176 fi
177 }
179 # Check for the wanted package if specified in WANTED
180 # receipt variable. Set the $src/$_pkg variable to help compiling
181 # and generating packages.
182 check_for_wanted()
183 {
184 if [ ! "$WANTED" = "" ]; then
185 echo -n "Checking for the wanted package..."
186 if [ ! -d "$WOK/$WANTED" ]; then
187 echo -e "\nWanted package is missing in the work directory.\n"
188 exit 0
189 fi
190 # Checking for buildtree of Wanted package
191 if [ ! -d "$WOK/$WANTED/taz" ]; then
192 echo -e "\n\nSource files of wanted package is missing in the work directory."
193 echo -n "Would you like to build the missing package (y/N) ? " ; read anser
194 if [ "$anser" == "y" ]; then
195 tazwok cook $WANTED
196 else
197 echo -e "\nWanted package source tree is missing in the work directory.\n"
198 exit 0
199 fi
200 fi
201 status
202 # Set wanted src path.
203 src=$WOK/$WANTED/$WANTED-$VERSION
204 _pkg=$src/_pkg
205 fi
206 }
209 # Check for build dependencies, notify user and install if specified.
210 check_for_build_depends()
211 {
212 echo "Checking for build dependencies..."
213 for pkg in $BUILD_DEPENDS
214 do
215 if [ ! -d "$INSTALLED/$pkg" ]; then
216 MISSING_PACKAGE=$pkg
217 fi
218 done
219 if [ ! "$MISSING_PACKAGE" = "" ]; then
220 echo "================================================================================"
221 for pkg in $BUILD_DEPENDS
222 do
223 if [ ! -d "$INSTALLED/$pkg" ]; then
224 MISSING_PACKAGE=$pkg
225 echo "Missing : $pkg"
226 fi
227 done
228 echo "================================================================================"
229 echo "You can continue, exit or install missing dependencies."
230 echo -n "Install, continue or exit (install/y/N) ? "; read anser
231 case $anser in
232 install)
233 for pkg in $BUILD_DEPENDS
234 do
235 if [ ! -d "$INSTALLED/$pkg" ]; then
236 tazpkg get-install $pkg
237 fi
238 done ;;
239 y|yes)
240 ;;
241 *)
242 exit 0 ;;
243 esac
244 fi
245 }
247 # Check for loop in deps tree.
248 check_for_deps_loop()
249 {
250 local list
251 local pkg
252 local deps
253 pkg=$1
254 shift
255 [ -n "$1" ] || return
256 list=""
257 # Filter out already processed deps
258 for i in $@; do
259 case " $ALL_DEPS" in
260 *\ $i\ *);;
261 *) list="$list $i";;
262 esac
263 done
264 ALL_DEPS="$ALL_DEPS$list "
265 for i in $list; do
266 [ -f $i/receipt ] || continue
267 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
268 case " $deps " in
269 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
270 *) check_for_deps_loop $pkg $deps;;
271 esac
272 done
273 }
275 download()
276 {
277 for file in $@; do
278 wget $file && break
279 done
280 }
282 # Configure and make a package with the receipt.
283 compile_package()
284 {
285 check_for_package_on_cmdline
286 # Include the receipt to get all needed variables and functions
287 # and cd into the work directory to start the work.
288 check_for_receipt
289 . $RECEIPT
290 # Log the package name and date.
291 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
292 echo "package $PACKAGE (compile)" >> $LOG
293 # Set wanted $src variable to help compiling.
294 if [ ! "$SOURCE" = "" ]; then
295 src=$WOK/$PACKAGE/$SOURCE-$VERSION
296 else
297 src=$WOK/$PACKAGE/$PACKAGE-$VERSION
298 fi
299 check_for_build_depends
300 check_for_wanted
301 echo ""
302 echo "Starting to cook $PACKAGE..."
303 echo "================================================================================"
304 # Check for src tarball and wget if needed.
305 if [ ! "$WGET_URL" = "" ]; then
306 echo "Checking for source tarball... "
307 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
308 cd $SOURCES_REPOSITORY
309 download $WGET_URL
310 #wget $WGET_URL
311 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
312 echo "Download failed, try with mirror copy... "
313 file=$(basename $WGET_URL)
314 download http://mirror.slitaz.org/sources/packages/${file:0:1}/$file
315 fi
316 # Exit if download failed to avoid errors.
317 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
318 echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n"
319 exit 1
320 fi
321 else
322 echo -n "Source tarball exit... "
323 status
324 fi
325 # Untaring source if necessary. We don't need to extract source if
326 # the package is built with a wanted source package.
327 if [ "$WANTED" = "" ]; then
328 if [ ! -d $src ]; then
329 # Log process.
330 echo "untaring $TARBALL" >> $LOG
331 echo -n "Untaring $TARBALL... "
332 case "$TARBALL" in
333 *zip|*xpi) ( cd $WOK/$PACKAGE; unzip -o $SOURCES_REPOSITORY/$TARBALL );;
334 *bz2) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE;;
335 *tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE;;
336 *Z) tar xZf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE;;
337 *) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $WOK/$PACKAGE;;
338 esac
339 status
340 # Permissions settings
341 chown -R root.root $WOK/$PACKAGE/$PACKAGE-* 2>/dev/null
342 chown -R root.root $WOK/$PACKAGE/$SOURCE-* 2>/dev/null
343 else
344 echo -n "Source directory exit... " && status
345 fi
346 fi
347 fi
348 cd $WOK/$PACKAGE
349 # Log and execute compile_rules function if it exists, to configure and
350 # make the package if it exists.
351 if grep -q ^compile_rules $RECEIPT; then
352 echo "executing compile_rules" >> $LOG
353 compile_rules
354 # Exit if compilation failed so the binary package
355 # is not generated when using the cook command.
356 local CHECK=$?
357 if [ $CHECK = 0 ]; then
358 echo "================================================================================"
359 echo "$PACKAGE compiled on : `date +%Y%m%d\ \%H:%M:%S`"
360 echo ""
361 echo "compilation done : `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
363 else
364 echo "================================================================================"
365 echo "Compilation failed. Please read the compiler output."
366 echo "" && exit 1
367 fi
368 else
369 echo "no compile_rules" >> $LOG
370 echo -e "No compile rules for $PACKAGE...\n"
371 fi
372 }
374 # Regenerate every package that wants a PACKAGE compiled
375 refresh_packages_from_compile()
376 {
377 # make tazwok genpkg happy
378 mkdir $WOK/$PACKAGE/taz
379 for i in $( grep -l "^WANTED=\"$PACKAGE\"" $WOK/*/receipt) ; do
380 tazwok genpkg $(basename $(dirname $i))
381 done
382 # Still needs tazwok genpkg for this package
383 rm -rf $WOK/$PACKAGE/taz
384 }
386 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
387 # so some packages need to copy these files with the receipt and genpkg_rules.
388 # This function is executed by gen_package when 'tazwok genpkg'.
389 copy_generic_files()
390 {
391 # In most cases, locales are in $_pkg/usr/share/locale so we copy files
392 # using generic variables and $LOCALE from Tazwok config file.
393 if [ ! "$LOCALE" = "" ]; then
394 if [ -d "$_pkg/usr/share/locale" ]; then
395 for i in $LOCALE
396 do
397 if [ -d "$_pkg/usr/share/locale/$i" ]; then
398 mkdir -p $fs/usr/share/locale
399 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
400 fi
401 done
402 fi
403 fi
404 # Pixmaps (PNG or/and XPM only). Some icons/images can be added through
405 # genpkg_rules and generic copy can be disabled with GENERIC_PIXMAPS="no"
406 # in pkg receipt.
407 if [ ! "$GENERIC_PIXMAPS" = "no" ]; then
408 if [ -d "$_pkg/usr/share/pixmaps" ]; then
409 mkdir -p $fs/usr/share/pixmaps
410 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
411 $fs/usr/share/pixmaps 2>/dev/null
412 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
413 $fs/usr/share/pixmaps 2>/dev/null
414 fi
415 # Custom or homemade PNG pixmap can be in stuff.
416 if [ -f "stuff/$PACKAGE.png" ]; then
417 mkdir -p $fs/usr/share/pixmaps
418 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
419 fi
420 fi
421 # Desktop entry (.desktop).
422 if [ -d "$_pkg/usr/share/applications" ]; then
423 cp -a $_pkg/usr/share/applications $fs/usr/share
424 fi
425 # Homemade desktop file(s) can be in stuff.
426 if [ -d "stuff/applications" ]; then
427 mkdir -p $fs/usr/share
428 cp -a stuff/applications $fs/usr/share
429 fi
430 if [ -f "stuff/$PACKAGE.desktop" ]; then
431 mkdir -p $fs/usr/share/applications
432 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
433 fi
434 }
436 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
437 strip_package()
438 {
439 echo -n "Executing strip on all files..."
440 # Binaries.
441 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
442 do
443 if [ -d "$dir" ]; then
444 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
445 fi
446 done
447 # Libraries.
448 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
449 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
450 status
451 }
453 # Check FSH in a slitaz package (Path: /:/usr)
454 check_fsh()
455 {
456 cd $WOK/$PACKAGE/taz/*/fs
457 [ -n "$FSH" ] || FSH="bin boot dev etc home init lib media mnt proc \
458 root sbin share sys tmp usr var vz usr/bin usr/games usr/include usr/lib \
459 usr/local usr/sbin usr/share usr/src"
460 for i in `ls -d * usr/* 2>/dev/null`
461 do
462 if ! echo $FSH | grep -q $i; then
463 echo "Wrong path: /$i"
464 error=1
465 fi
466 done
467 if [ "$error" = "1" ]; then
468 cat << _EOT_
470 Package will install files in a non standard directory and won't be generated.
471 You may have a wrong copy path in genpkg_rules or need to add some options to
472 configure in compile_rules. Some valid options for SliTaz (Linux FSH):
474 --prefix=/usr
475 --sysconfdir=/etc
476 --libexecdir=/usr/lib/(pkgname)
477 --localstatedir=/var
478 --mandir=/usr/share/man
479 --infodir=/usr/share/info
481 For more information please read SliTaz docs and run: ./configure --help
482 ================================================================================
483 $PACKAGE package generation aborted.
485 _EOT_
486 # Dont generate a corrupted package.
487 cd $WOK/$PACKAGE && rm -rf taz
488 exit 1
489 fi
490 echo ""
491 }
493 # Create a package tree and build the gziped cpio archive
494 # to make a SliTaz (.tazpkg) package.
495 gen_package()
496 {
497 check_root
498 check_for_package_on_cmdline
499 check_for_receipt
500 EXTRAVERSION=""
501 . $RECEIPT
502 # May compute VERSION
503 if grep -q ^get_version $RECEIPT; then
504 get_version
505 fi
506 check_for_wanted
507 cd $WOK/$PACKAGE
508 # Remove old Tazwok package files.
509 if [ -d "taz" ]; then
510 rm -rf taz
511 fi
512 # Create the package tree and set useful variables.
513 mkdir -p taz/$PACKAGE-$VERSION/fs
514 fs=taz/$PACKAGE-$VERSION/fs
515 # Set $src for standard package and $_pkg variables.
516 if [ "$WANTED" = "" ]; then
517 src=$WOK/$PACKAGE/$PACKAGE-$VERSION
518 _pkg=$src/_pkg
519 fi
520 if [ ! "$SOURCE" = "" ]; then
521 src=$WOK/$PACKAGE/$SOURCE-$VERSION
522 _pkg=$src/_pkg
523 fi
524 cd $WOK/$PACKAGE
525 # Execute genpkg_rules, check package and copy generic files to build
526 # the package.
527 echo ""
528 echo "Building $PACKAGE with the receipt..."
529 echo "================================================================================"
530 if grep -q ^genpkg_rules $RECEIPT; then
531 # Log process.
532 echo "executing genpkg_rules" >> $LOG
533 genpkg_rules
534 check_fsh
535 cd $WOK/$PACKAGE
536 # Skip generic files for packages with a WANTED variable
537 # (dev and splited pkgs).
538 if [ "$WANTED" = "" ]; then
539 copy_generic_files
540 fi
541 strip_package
542 else
543 echo "No package rules to gen $PACKAGE..."
544 exit 1
545 fi
546 # Copy the receipt and description (if exists) into the binary package tree.
547 cd $WOK/$PACKAGE
548 echo -n "Copying the receipt..."
549 cp receipt taz/$PACKAGE-$VERSION
550 status
551 if grep -q ^get_version $RECEIPT; then
552 echo -n "Updating version in receipt..."
553 sed -i "s/^VERSION=.*/VERSION=\"$VERSION\"/" \
554 taz/$PACKAGE-$VERSION/receipt
555 status
556 fi
557 if [ -f "description.txt" ]; then
558 echo -n "Copying the description file..."
559 cp description.txt taz/$PACKAGE-$VERSION
560 status
561 fi
562 # Create the files.list by redirecting find output.
563 echo -n "Creating the list of files..."
564 cd taz/$PACKAGE-$VERSION
565 LAST_FILE=""
566 ( find fs -print; echo ) | while read file; do
567 if [ "$LAST_FILE" != "" ]; then
568 case "$file" in
569 $LAST_FILE/*)
570 case "$(ls -ld "$LAST_FILE")" in
571 drwxr-xr-x\ *\ root\ *\ root\ *);;
572 *) echo ${LAST_FILE#fs};;
573 esac;;
574 *) echo ${LAST_FILE#fs};;
575 esac
576 fi
577 LAST_FILE="$file"
578 done > files.list
579 status
580 if [ -z "$EXTRAVERSION" ]; then
581 case "$PACKAGE" in
582 linux*);;
583 *) EXTRAVERSION="$(grep '/lib/modules/.*-slitaz/' files.list |\
584 head -1 | sed 's|/lib/modules/\(.*\)-slitaz/.*|_\1|')";;
585 esac
586 fi
587 rm -f $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
588 echo -n "Creating md5sum of files..."
589 while read file; do
590 [ -L "fs$file" ] && continue
591 [ -f "fs$file" ] || continue
592 md5sum "fs$file" | sed 's/ fs/ /'
593 done < files.list > md5sum
594 #[ -s md5sum ] || rm -f md5sum
595 status
596 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
597 2> /dev/null | awk '{ sz=$1 } END { print sz }')
598 # Build cpio archives. Find, cpio and gzip the fs, finish by
599 # removing the fs tree.
600 echo -n "Compressing the fs... "
601 find fs -print | cpio -o -H newc | case "$PACKAGE-$COMPRESSION" in
602 tazpkg-lzma) gzip > fs.cpio.gz;;
603 *-lzma) lzma e fs.cpio.lzma -si;;
604 *) gzip > fs.cpio.gz;;
605 esac && rm -rf fs
606 PACKED_SIZE=$(du -chs fs.cpio.* receipt files.list md5sum \
607 description.txt 2> /dev/null | awk '{ sz=$1 } END { print sz }')
608 status
609 echo -n "Updating receipt sizes..."
610 sed -i '/^PACKED_SIZE/d' receipt
611 sed -i '/^UNPACKED_SIZE/d' receipt
612 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
613 sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
614 status
615 if [ -n "$EXTRAVERSION" ]; then
616 echo -n "Updating receipt EXTRAVERSION..."
617 sed -i s/^EXTRAVERSION.*$// receipt
618 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
619 status
620 fi
621 echo -n "Creating full cpio archive... "
622 find . -print | cpio -o -H newc > $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
623 status
624 # Restore package tree in case we want to browse it.
625 echo -n "Restoring original package tree... "
626 ( zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma ) | cpio -id
627 rm fs.cpio.* && cd ..
628 # Log process.
629 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
630 echo "================================================================================"
631 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
632 echo "Size : `du -sh $PACKAGES_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
633 echo ""
634 }
636 # Optional text packages list for gen-list.
637 gen_textlist()
638 {
639 rm -f packages.desc packages.equiv
640 DATE=`date +%Y-%m-%d\ \%H:%M:%S`
641 echo -n "Creating the text packages list... "
642 cat >> packages.txt << _EOT_
643 # SliTaz GNU/Linux - Packages list
644 #
645 # Packages : _packages_
646 # Date : $DATE
647 #
648 _EOT_
649 for pkg in $WOK/*
650 do
651 PROVIDE=""
652 PACKAGE=""
653 PACKED_SIZE=""
654 if [ -f $pkg/taz/*/receipt ]; then
655 . $pkg/taz/*/receipt
656 else
657 . $pkg/receipt
658 fi
659 cat >> packages.txt << _EOT_
661 $PACKAGE
662 $VERSION
663 $SHORT_DESC
664 _EOT_
665 if [ -n "$PACKED_SIZE" ]; then
666 cat >> packages.txt << _EOT_
667 $PACKED_SIZE ($UNPACKED_SIZE installed)
668 _EOT_
669 fi
670 # Packages.desc is used by Tazpkgbox <tree>.
671 echo "$PACKAGE | $VERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> packages.desc
672 # Packages.equiv is used by tazpkg install to check depends
673 touch packages.equiv
674 for i in $PROVIDE; do
675 DEST=""
676 echo $i | grep -q : && DEST="${i#*:}:"
677 if grep -qs ^${i%:*}= packages.equiv; then
678 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" packages.equiv
679 else
680 echo "${i%:*}=$DEST$PACKAGE" >> packages.equiv
681 fi
682 done
683 packages=$(($packages+1))
684 done && status
685 echo -n "Creating the text files list... "
686 for pkg in $WOK/*
687 do
688 if [ -f $pkg/taz/*/files.list ]; then
689 . $pkg/taz/*/receipt
690 ( echo "$PACKAGE"; cat $pkg/taz/*/files.list ) | awk '
691 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }'
692 else
693 echo "No files_list in $pkg" 1>&2
694 fi
695 done | lzma e files.list.lzma -si && status
696 sed -i s/"_packages_"/"$packages"/ packages.txt
697 }
699 # Return the date of the last commit in seconds since Jan 1 1970
700 hgdate()
701 {
702 local pkg
703 local date
704 local mon
705 # Default date is Jan 1 1970
706 [ -d $WOK/.hg -a -x /usr/bin/hg ] || { echo "010100001970"; return; }
707 pkg=$(basename $1)
708 # Get date for last commit
709 date="$( cd $WOK; hg log $(find $pkg/receipt $pkg/stuff -type f \
710 2> /dev/null) | grep date: | head -1 | cut -c 6-)"
711 [ -n "$date" ] || { echo "010100001970"; return; }
712 case "$(echo $date | awk '{ print $2 }')" in
713 Jan) mon="01";; Feb) mon="02";; Mar) mon="03";; Apr) mon="04";;
714 May) mon="05";; Jun) mon="06";; Jul) mon="07";; Aug) mon="08";;
715 Sep) mon="09";; Oct) mon="10";; Nov) mon="11";; Dec) mon="12";;
716 esac
717 # Reformat, don't mind about TZ: we look for days or months delta
718 echo $date | sed "s|[^ ]* [^ ]* \\(.*\\) \\(.*\\):\\(.*\\):\\(.*\\) \\(.*\\) .*|$mon\1\2\3\5|"
719 }
721 # List packages providing a virtual package
722 whoprovide()
723 {
724 local i;
725 for i in $(grep -l PROVIDE $WOK/*/receipt); do
726 . $i
727 case " $PROVIDE " in
728 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
729 esac
730 done
731 }
733 ###################
734 # Tazwok commands #
735 ###################
737 case "$COMMAND" in
738 stats)
739 # Tazwok general statistics from the config file the wok.
740 #
741 echo ""
742 echo -e "\033[1mTazwok configuration statistics\033[0m
743 ================================================================================
744 Wok directory : $WOK
745 Packages repository : $PACKAGES_REPOSITORY
746 Sources repository : $SOURCES_REPOSITORY
747 Packages in the wok : `ls -1 $WOK | wc -l`
748 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
749 ================================================================================"
750 echo "" ;;
751 edit)
752 check_for_package_on_cmdline
753 check_for_receipt
754 $EDITOR $WOK/$PACKAGE/receipt ;;
755 build-depends)
756 # List dependancies to rebuild wok
757 cd $WOK
758 ALL_DEPS="slitaz-toolchain"
759 echo $ALL_DEPS
760 for pkg in $(ls $2)
761 do
762 [ -f $pkg/receipt ] || continue
763 BUILD_DEPENDS=""
764 . $pkg/receipt
765 for i in $BUILD_DEPENDS; do
766 case " $ALL_DEPS " in
767 *\ $i\ *);;
768 *) ALL_DEPS="$ALL_DEPS $i"
769 echo $i;;
770 esac
771 done
772 done
773 ;;
774 check-depends)
775 # Check package depends
776 echo ""
777 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
778 ================================================================================"
779 TMPDIR=/tmp/tazwok$$
780 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
782 # Build ALL_DEPENDS variable
783 scan_dep()
784 {
785 local i
786 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
787 for i in $DEPENDS $SUGGESTED ; do
788 case " $ALL_DEPENDS " in
789 *\ $i\ *) continue;;
790 esac
791 [ -d $WOK/$i ] || {
792 ALL_DEPENDS="$ALL_DEPENDS$i "
793 continue
794 }
795 DEPENDS=""
796 SUGGESTED=""
797 . $WOK/$i/receipt
798 scan_dep
799 done
800 }
802 # Check for ELF file
803 is_elf()
804 {
805 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" \
806 = "ELF" ]
807 }
809 # Print shared library dependencies
810 ldd()
811 {
812 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
813 }
815 mkdir $TMPDIR
816 cd $TMPDIR
817 for i in $LOCALSTATE/files.list.lzma \
818 $LOCALSTATE/undigest/*/files.list.lzma ; do
819 [ -f $i ] && lzma d $i -so >> files.list
820 done
821 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
822 tazpkg extract $pkg > /dev/null 2>&1
823 . */receipt
824 ALL_DEPENDS="$DEFAULT_DEPENDS "
825 scan_dep
826 find */fs -type f | while read file ; do
827 is_elf $file || continue
828 case "$file" in
829 *.o|*.ko|*.ko.gz) continue;;
830 esac
831 ldd $file | while read lib rem; do
832 case "$lib" in
833 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
834 continue;;
835 esac
836 for dep in $(grep $lib files.list | cut -d: -f1); do
837 case " $ALL_DEPENDS " in
838 *\ $dep\ *) continue 2;;
839 esac
840 for vdep in $(grep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
841 case " $ALL_DEPENDS " in
842 *\ $vdep\ *) continue 3;;
843 esac
844 done
845 done
846 [ -n "$dep" ] || dep="UNKNOWN"
847 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
848 done
849 done
850 rm -rf */
851 done
852 cd /tmp
853 rm -rf $TMPDIR
854 ;;
855 check)
856 # Check wok consistency
857 echo ""
858 echo -e "\033[1mWok and packages checking\033[0m
859 ================================================================================"
860 cd $WOK
861 for pkg in $(ls)
862 do
863 [ -f $pkg/receipt ] || continue
864 PACKAGE=""
865 VERSION=""
866 EXTRAVERSION=""
867 CATEGORY=""
868 SHORT_DESC=""
869 MAINTAINER=""
870 WEB_SITE=""
871 WGET_URL=""
872 DEPENDS=""
873 BUILD_DEPENDS=""
874 WANTED=""
875 PACKED_SIZE=""
876 UNPACKED_SIZE=""
877 . $pkg/receipt
878 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg"
879 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION"
880 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE"
881 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE"
882 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION"
883 if [ -n "$WANTED" ]; then
884 if [ ! -f $WANTED/receipt ]; then
885 echo "Package $PACKAGE wants unknown $WANTED package"
886 else
887 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
888 if [ "$VERSION" = "$WANTED" ]; then
889 # BASEVERSION is computed in receipt
890 grep -q '_pkg=' $pkg/receipt &&
891 BASEVERSION=$VERSION
892 fi
893 if [ "$VERSION" != "$BASEVERSION" ]; then
894 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)"
895 fi
896 fi
897 fi
899 if [ -n "$CATEGORY" ]; then
900 case " $(echo $CATEGORIES) " in
901 *\ $CATEGORY\ *);;
902 *) echo "Package $PACKAGE has an invalid CATEGORY";;
903 esac
904 else
905 echo"Package $PACKAGE has no CATEGORY"
906 fi
907 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC"
908 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER"
909 case "$WGET_URL" in
910 ftp*|http*) wget -s $WGET_URL 2> /dev/null ||
911 echo "Package $PACKAGE has a wrong WGET_URL";;
912 '') ;;
913 *) echo "Package $PACKAGE has an invalid WGET_URL";;
914 esac
915 case "$WEB_SITE" in
916 ftp*|http*);;
917 '') echo "Package $PACKAGE has no WEB_SITE";;
918 *) echo "Package $PACKAGE has an invalid WEB_SITE";;
919 esac
920 case "$MAINTAINER" in
921 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER";;
922 esac
923 case "$MAINTAINER" in
924 *@*);;
925 *) echo "Package $PACKAGE MAINTAINER is not an email address";;
926 esac
927 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n"
928 for i in $DEPENDS; do
929 [ -d $i ] && continue
930 [ -n "$(whoprovide $i)" ] && continue
931 echo -e "$MSG $i"
932 MSG=""
933 done
934 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n"
935 for i in $BUILD_DEPENDS; do
936 [ -d $i ] && continue
937 [ -n "$(whoprovide $i)" ] && continue
938 echo -e "$MSG $i"
939 MSG=""
940 done
941 MSG="Dependencies loop between $PACKAGE and :\n"
942 ALL_DEPS=""
943 check_for_deps_loop $PACKAGE $DEPENDS
944 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
945 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
946 echo "$pkg should be rebuilt after $i installation"
947 done
948 done
949 ;;
950 cmp|compare)
951 # Compare the wok and packages repository to help with maintaining
952 # a mirror.
953 echo ""
954 echo -e "\033[1mWok and packages comparison\033[0m
955 ================================================================================"
956 for pkg in $WOK/*
957 do
958 WANTED=""
959 . $pkg/receipt
960 echo "$PACKAGE-$VERSION.tazpkg" >> /tmp/wok.list.$$
961 tpkg="$(ls $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg 2> /dev/null | head -1)"
962 if [ -z "$tpkg" ]; then
963 echo "Missing package: $PACKAGE ($VERSION)"
964 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
965 elif [ -f $pkg/taz/*/receipt -a ! -f $pkg/taz/*/md5sum ]; then
966 echo "Obsolete package: $PACKAGE ($VERSION)"
967 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
968 elif [ $pkg/receipt -nt $tpkg ]; then
969 echo "Refresh package: $PACKAGE ($VERSION)"
970 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
971 else
972 srcdate=$(hgdate $pkg)
973 pkgdate=$(date -u -r $tpkg '+%m%d%H%M%Y')
974 if [ $(date -d $pkgdate +%s) -lt $(date -d $srcdate +%s) ]; then
975 echo "Rebuild package: $PACKAGE ($VERSION) cooked $(date -d $pkgdate "+%x %X"), modified $(date -d $srcdate "+%x %X")"
976 echo "$PACKAGE" >> /tmp/pkgs.missing.$$
977 else
978 continue
979 fi
980 fi
981 if [ "$2" = "--cook" ]; then
982 if [ -n "$WANTED" -a ! -d $WOK/$WANTED/taz ]; then
983 yes '' | tazwok cook $WANTED
984 fi
985 yes '' | tazwok cook $PACKAGE
986 fi
987 done
988 for pkg in `cd $PACKAGES_REPOSITORY && ls *.tazpkg`
989 do
990 # grep $pkg in /tmp/wok.list.$$
991 # may include EXTRAVERSION or computed VERSION
992 for i in $(grep ^${pkg%-*} /tmp/wok.list.$$); do
993 case "$pkg" in
994 ${i%.tazpkg}*.tazpkg) continue 2;;
995 esac
996 done
997 # Not found
998 echo $pkg >> /tmp/pkgs.old.$$
999 if [ "$2" = "--remove" ]; then
1000 echo "Removing package: $pkg"
1001 rm $PACKAGES_REPOSITORY/$pkg
1002 else
1003 echo "Old package: $pkg"
1004 fi
1005 done
1006 cd /tmp
1007 echo "================================================================================"
1008 echo "Wok: `cat wok.list.$$ | wc -l` - \
1009 Cooked: `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l` - \
1010 Missing: `cat pkgs.missing.$$ 2>/dev/null | wc -l` - \
1011 Old: `cat pkgs.old.$$ 2>/dev/null | wc -l`"
1012 echo ""
1013 rm -f wok.list.$$ pkgs.old.$$ pkgs.missing.$$
1014 ;;
1015 list)
1016 # List packages in wok directory. User can specify a category
1018 if [ "$2" = "category" ]; then
1019 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
1020 exit 0
1021 fi
1022 # Check for an asked category.
1023 if [ -n "$2" ]; then
1024 ASKED_CATEGORY=$2
1025 echo ""
1026 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
1027 echo "================================================================================"
1028 for pkg in $WOK/*
1029 do
1030 . $pkg/receipt
1031 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
1032 echo -n "$PACKAGE"
1033 echo -e "\033[28G $VERSION"
1034 packages=$(($packages+1))
1035 fi
1036 done
1037 echo "================================================================================"
1038 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
1039 else
1040 # By default list all packages and version.
1041 echo ""
1042 echo -e "\033[1mList of packages in the wok\033[0m"
1043 echo "================================================================================"
1044 for pkg in $WOK/*
1045 do
1046 . $pkg/receipt
1047 echo -n "$PACKAGE"
1048 echo -en "\033[28G $VERSION"
1049 echo -e "\033[42G $CATEGORY"
1050 packages=$(($packages+1))
1051 done
1052 echo "================================================================================"
1053 echo -e "$packages packages available in the wok.\n"
1054 fi
1055 ;;
1056 info)
1057 # Information about a package.
1059 check_for_package_on_cmdline
1060 check_for_receipt
1061 . $WOK/$PACKAGE/receipt
1062 echo ""
1063 echo -e "\033[1mTazwok package information\033[0m
1064 ================================================================================
1065 Package : $PACKAGE
1066 Version : $VERSION
1067 Category : $CATEGORY
1068 Short desc : $SHORT_DESC
1069 Maintainer : $MAINTAINER"
1070 if [ ! "$WEB_SITE" = "" ]; then
1071 echo "Web site : $WEB_SITE"
1072 fi
1073 if [ ! "$DEPENDS" = "" ]; then
1074 echo "Depends : $DEPENDS"
1075 fi
1076 if [ ! "$WANTED" = "" ]; then
1077 echo "Wanted src : $WANTED"
1078 fi
1079 echo "================================================================================"
1080 echo ""
1082 ;;
1083 check-log)
1084 # We just cat the file log to view process info.
1086 if [ ! -f "$LOG" ]; then
1087 echo -e "\nNo process log found. The package is probably not cooked.\n"
1088 exit 0
1089 else
1090 echo ""
1091 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
1092 echo "================================================================================"
1093 cat $LOG
1094 echo "================================================================================"
1095 echo ""
1096 fi
1097 ;;
1098 search)
1099 # Search for a package by pattern or name.
1101 if [ -z "$2" ]; then
1102 echo -e "\nPlease specify a pattern or a package name to search."
1103 echo -e "Example : 'tazwok search gcc'.\n"
1104 exit 0
1105 fi
1106 echo ""
1107 echo -e "\033[1mSearch result for :\033[0m $2"
1108 echo "================================================================================"
1109 list=`ls -1 $WOK | grep $2`
1110 for pkg in $list
1111 do
1112 . $WOK/$pkg/receipt
1113 echo -n "$PACKAGE "
1114 echo -en "\033[24G $VERSION"
1115 echo -e "\033[42G $CATEGORY"
1116 packages=$(($packages+1))
1117 done
1118 echo "================================================================================"
1119 echo "$packages packages found for : $2"
1120 echo ""
1121 ;;
1122 compile)
1123 # Configure and make a package with the receipt.
1125 compile_package
1126 ;;
1127 genpkg)
1128 # Generate a package.
1130 gen_package
1131 ;;
1132 cook)
1133 # Compile and generate a package. Just execute tazwok with
1134 # the good commands.
1136 check_root
1137 compile_package
1138 refresh_packages_from_compile
1139 gen_package
1140 ;;
1141 cook-list)
1142 # Cook all packages listed in a file. The path to the cooklist must
1143 # be specified on the cmdline.
1145 check_root
1146 check_for_list
1147 for pkg in $LIST
1148 do
1149 tazwok cook $pkg
1150 done
1151 ;;
1152 clean)
1153 # Clean up a package work directory.
1155 check_for_package_on_cmdline
1156 check_for_receipt
1157 . $RECEIPT
1158 cd $WOK/$PACKAGE
1159 echo ""
1160 echo "Cleaning $PACKAGE..."
1161 echo "================================================================================"
1162 # Check for clean_wok function.
1163 if grep -q ^clean_wok $RECEIPT; then
1164 clean_wok
1165 fi
1166 # Remove taz/ and source tree if exists.
1167 if [ -d "taz" ]; then
1168 echo -n "Removing taz files..."
1169 rm -rf taz
1170 status
1171 fi
1172 for i in $PACKAGE-$VERSION $SOURCE-$VERSION ; do
1173 [ -e "$i" ] || continue
1174 echo -n "Removing source files..."
1175 if [ -L $i ]; then
1176 target=$(readlink $i)
1177 [ -d "$target" ] && case "$target" in
1178 /*|.|./*|..|../*);;
1179 *) rm -rf $target;;
1180 esac
1181 fi
1182 rm -rf $i
1183 status
1184 done
1185 # Remove an eventual $PACKAGE-build directory.
1186 if [ -d "$PACKAGE-build" ]; then
1187 echo -n "Removing build tree..."
1188 rm -rf $PACKAGE-build && status
1189 fi
1190 # Remove process log file.
1191 if [ -f "process.log" ]; then
1192 echo -n "Removing process log file..."
1193 rm process.log && status
1194 echo "================================================================================"
1195 fi
1196 echo "$PACKAGE is clean. You can cook it again..."
1197 echo ""
1198 ;;
1199 gen-clean-wok)
1200 # Generate a clean wok from the current wok by copying all receipts
1201 # and stuff directory.
1203 if [ -z "$2" ]; then
1204 echo -e "\nPlease specify the destination for the new clean wok.\n"
1205 exit 0
1206 else
1207 dest=$2
1208 mkdir -p $dest
1209 fi
1210 echo "New wok is going to : $dest"
1211 for pkg in `ls -1 $WOK`
1212 do
1213 echo "----"
1214 echo -n "Preparing $pkg..."
1215 mkdir -p $dest/$pkg
1216 status
1217 echo -n "Copying the receipt..."
1218 cp -a $WOK/$pkg/receipt $dest/$pkg
1219 status
1220 if [ -d "$WOK/$pkg/stuff" ]; then
1221 echo -n "Copying all the stuff directory..."
1222 cp -a $WOK/$pkg/stuff $dest/$pkg
1223 status
1224 fi
1225 done
1226 echo "================================================================================"
1227 echo "Clean wok generated in : $dest"
1228 echo "Packages cleaned : `ls -1 $dest | wc -l`"
1229 echo ""
1230 ;;
1231 clean-wok)
1232 # Clean all packages in the work directory
1234 for pkg in `ls -1 $WOK`
1235 do
1236 tazwok clean $pkg
1237 done
1238 echo "================================================================================"
1239 echo "`ls -1 $WOK | wc -l` packages cleaned."
1240 echo ""
1241 ;;
1242 gen-list)
1243 # Sed is used to remove all the .tazpkg extensions from the
1244 # packages.list. The directory to move in by default is the repository
1245 # if $2 is not empty cd into $2. A text packages list can also be gen
1246 # with the option --text.
1248 fakewok=""
1249 if [ "$2" == "--text" ]; then
1250 textlist="yes"
1251 if [ "$3" == "--fakewok" ]; then
1252 WOK=/tmp/fakewok-$$
1253 fakewok="$WOK"
1254 mkdir -p $WOK
1255 for i in $PACKAGES_REPOSITORY/*.tazpkg; do
1256 (cd $WOK; cpio -i receipt files.list 2>/dev/null) < $i
1257 . $WOK/receipt
1258 mkdir -p $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
1259 mv $WOK/receipt $WOK/files.list \
1260 $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
1261 ln $WOK/$PACKAGE/taz/$PACKAGE-$VERSION/receipt $WOK/$PACKAGE
1262 done
1263 fi
1264 elif [ -z "$2" ]; then
1265 PACKAGES_REPOSITORY=$PACKAGES_REPOSITORY
1266 else
1267 if [ -d "$2" ]; then
1268 PACKAGES_REPOSITORY=$2
1269 else
1270 echo -e "\nUnable to find directory : $2\n"
1271 exit 0
1272 fi
1273 fi
1274 cd $PACKAGES_REPOSITORY
1275 # Remove old packages.list and md5sum, they will soon be rebuilt.
1276 rm -f packages.list packages.md5 packages.txt
1277 echo ""
1278 echo -e "\033[1mGenerating packages lists\033[0m"
1279 echo "================================================================================"
1280 echo -n "Repository path : $PACKAGES_REPOSITORY" && status
1281 # Generate packages.txt
1282 if [ "$textlist" == "yes" ]; then
1283 gen_textlist
1284 [ "$fakewok" == "" ] || rm -rf $fakewok
1285 fi
1286 echo -n "Creating the raw packages list... "
1287 ls -1 *.tazpkg > /tmp/packages.list
1288 sed -i s/'.tazpkg'/''/ /tmp/packages.list
1289 status
1290 echo -n "Building the md5sum for all packages... "
1291 md5sum *.tazpkg > packages.md5
1292 status
1293 mv /tmp/packages.list $PACKAGES_REPOSITORY
1294 echo "================================================================================"
1295 pkgs=`cat $PACKAGES_REPOSITORY/packages.list | wc -l`
1296 echo "$pkgs packages in the repository."
1297 echo ""
1298 ;;
1299 new-tree)
1300 # Just create a few directories and generate an empty receipt to prepare
1301 # the creation of a new package.
1303 check_for_package_on_cmdline
1304 if [ -d $WOK/$PACKAGE ]; then
1305 echo -e "\n$PACKAGE package tree already exists.\n"
1306 exit 0
1307 fi
1308 echo "Creating : $WOK/$PACKAGE"
1309 mkdir $WOK/$PACKAGE
1310 cd $WOK/$PACKAGE
1311 echo -n "Preparing the receipt..."
1313 # Default receipt begin.
1315 echo "# SliTaz package receipt." > receipt
1316 echo "" >> receipt
1317 echo "PACKAGE=\"$PACKAGE\"" >> receipt
1318 # Finish the empty receipt.
1319 cat >> receipt << "EOF"
1320 VERSION=""
1321 CATEGORY=""
1322 SHORT_DESC=""
1323 MAINTAINER=""
1324 DEPENDS=""
1325 TARBALL="$PACKAGE-$VERSION.tar.gz"
1326 WEB_SITE=""
1327 WGET_URL=""
1329 # Rules to configure and make the package.
1330 compile_rules()
1332 cd $src
1333 ./configure \
1334 --prefix=/usr \
1335 --infodir=/usr/share/info \
1336 --mandir=/usr/share/man \
1337 $CONFIGURE_ARGS &&
1338 make && make DESTDIR=$PWD/_pkg install
1341 # Rules to gen a SliTaz package suitable for Tazpkg.
1342 genpkg_rules()
1344 mkdir -p $fs/usr
1345 cp -a $_pkg/usr/bin $fs/usr
1348 EOF
1350 # Default receipt end.
1352 status
1353 # Interactive mode, asking and seding.
1354 if [ "$3" = "--interactive" ]; then
1355 echo "Entering into interactive mode..."
1356 echo "================================================================================"
1357 echo "Package : $PACKAGE"
1358 # Version.
1359 echo -n "Version : " ; read anser
1360 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
1361 # Category.
1362 echo -n "Category : " ; read anser
1363 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
1364 # Short description.
1365 echo -n "Short desc : " ; read anser
1366 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
1367 # Maintainer.
1368 echo -n "Maintainer : " ; read anser
1369 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
1370 # Web site.
1371 echo -n "Web site : " ; read anser
1372 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
1373 echo ""
1374 # Wget URL.
1375 echo "Wget URL to download source tarball."
1376 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
1377 echo -n "Wget url : " ; read anser
1378 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
1379 # Ask for a stuff dir.
1380 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
1381 if [ "$anser" = "y" ]; then
1382 echo -n "Creating the stuff directory..."
1383 mkdir stuff && status
1384 fi
1385 # Ask for a description file.
1386 echo -n "Are you going to write a description ? (y/N) : " ; read anser
1387 if [ "$anser" = "y" ]; then
1388 echo -n "Creating the description.txt file..."
1389 echo "" > description.txt && status
1390 fi
1391 echo "================================================================================"
1392 echo ""
1393 fi
1394 ;;
1395 remove)
1396 # Remove a package from the wok.
1398 check_for_package_on_cmdline
1399 echo ""
1400 echo -n "Please confirm deletion (y/N) : "; read anser
1401 if [ "$anser" = "y" ]; then
1402 echo -n "Removing $PACKAGE..."
1403 rm -rf $WOK/$PACKAGE && status
1404 echo ""
1405 fi
1406 ;;
1407 hgup)
1408 # Pull and update an Hg wok.
1409 if ls -l $WOK/.hg/hgrc | grep -q "root"; then
1410 check_root
1411 fi
1412 cd $WOK
1413 hg pull && hg update ;;
1414 maintainers)
1415 echo ""
1416 echo "List of maintainers for: $WOK"
1417 echo "================================================================================"
1418 touch /tmp/slitaz-maintainers
1419 for pkg in $WOK/*
1420 do
1421 . $pkg/receipt
1422 if ! grep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
1423 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
1424 echo "$MAINTAINER"
1425 fi
1426 done
1427 echo "================================================================================"
1428 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
1429 echo ""
1430 # Remove tmp files
1431 rm -f /tmp/slitaz-maintainers ;;
1432 maintained-by)
1433 # Search for packages maintained by a packagers.
1434 if [ ! -n "$2" ]; then
1435 echo "Specify a name or email of a maintainer."
1436 exit 0
1437 fi
1438 echo "Maintainer packages"
1439 echo "================================================================================"
1440 for pkg in $WOK/*
1441 do
1442 . $pkg/receipt
1443 if echo "$MAINTAINER" | grep -q "$2"; then
1444 echo "$PACKAGE"
1445 packages=$(($packages+1))
1446 fi
1447 done
1448 echo "================================================================================"
1449 echo "Packages maintained by $2: $packages"
1450 echo "" ;;
1451 check-src)
1452 # Verify if upstream package is still available
1454 check_for_package_on_cmdline
1455 check_for_receipt
1456 . $WOK/$PACKAGE/receipt
1457 check_src()
1459 for url in $@; do
1460 wget -s $url 2>/dev/null && break
1461 done
1463 if [ ! -z "$WGET_URL" ];then
1464 echo -n "$PACKAGE : "
1465 check_src $WGET_URL
1466 status
1467 else
1468 echo "No tarball to check for $PACKAGE"
1469 fi
1470 ;;
1471 usage|*)
1472 # Print usage also for all unknown commands.
1474 usage
1475 ;;
1476 esac
1478 exit 0