tazwok view tazwok @ rev 136

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