tazwok view tazwok @ rev 185

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