tazpkg view tazpkg @ rev 202

Install non-free depends via get-*
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Nov 17 16:06:36 2008 +0000 (2008-11-17)
parents 50bdf9ad81ce
children bdc5253ca4a8
line source
1 #!/bin/sh
2 # Tazpkg - Tiny autonomus zone packages manager.
3 #
4 # This is a lightwight packages manager for *.tazpkg files, all written in
5 # SHell script. It works well with Busybox ash shell and bash. Tazpkg lets you
6 # list, install, remove, download or get information about a package. You can
7 # use 'tazpkg usage' to get a list of commands with short descriptions. Tazpkg
8 # also resolves dependencies and can upgrade packages from a mirror.
9 #
10 # (C) 2007-2008 SliTaz - GNU General Public License v3.
11 #
12 # Authors : Christophe Lincoln <pankso@slitaz.org>
13 # Pascal Bellard <pascal.bellard@slitaz.org>
14 # Eric Joseph-Alexandre <erjo@slitaz.org>
15 #
16 VERSION=2.5.2
18 ####################
19 # Script variables #
20 ####################
22 # Packages categories.
23 CATEGORIES="
24 base-system
25 x-window
26 utilities
27 network
28 graphics
29 multimedia
30 office
31 development
32 system-tools
33 security
34 games
35 misc
36 meta
37 non-free"
39 # Initialize some variables to use words
40 # rather than numbers for functions and actions.
41 COMMAND=$1
42 if [ -f "$2" ]; then
43 # Set pkg basename for install, extract
44 PACKAGE=$(basename ${2%.tazpkg} 2>/dev/null)
45 else
46 # Pkg name for remove, search and all other cmds
47 PACKAGE=${2%.tazpkg}
48 fi
49 PACKAGE_FILE=$2
50 TARGET_DIR=$3
51 TOP_DIR=`pwd`
52 TMP_DIR=/tmp/tazpkg-$$-$RANDOM
54 # Path to tazpkg used dir and configuration files
55 LOCALSTATE=/var/lib/tazpkg
56 INSTALLED=$LOCALSTATE/installed
57 CACHE_DIR=/var/cache/tazpkg
58 MIRROR=$LOCALSTATE/mirror
59 BLOCKED=$LOCALSTATE/blocked-packages.list
60 DEFAULT_MIRROR="http://mirror.slitaz.org/packages/`cat /etc/slitaz-release`/"
61 INSTALL_LIST=""
62 LOG=/var/log/tazpkg.log
64 # Bold red warning for upgrade.
65 WARNING="\\033[1;31mWARNING\\033[0;39m"
67 # Check if the directories and files used by Tazpkg
68 # exist. If not and user is root we create them.
69 if test $(id -u) = 0 ; then
70 if [ ! -d "$CACHE_DIR" ]; then
71 mkdir -p $CACHE_DIR
72 fi
73 if [ ! -d "$INSTALLED" ]; then
74 mkdir -p $INSTALLED
75 fi
76 if [ ! -f "$LOCALSTATE/mirror" ]; then
77 echo "$DEFAULT_MIRROR" > $LOCALSTATE/mirror
78 fi
79 fi
81 ####################
82 # Script functions #
83 ####################
85 # Print the usage.
86 usage ()
87 {
88 echo -e "SliTaz package manager - Version: $VERSION\n
89 \033[1mUsage:\033[0m tazpkg [command] [package|dir|pattern|list|cat|--opt] [dir|--opt]
90 tazpkg shell\n
91 \033[1mCommands: \033[0m
92 usage Print this short usage.
93 bugs Show known bugs in packages
94 list List installed packages on the system by category or all.
95 xhtml-list Create a xHTML list of installed packges.
96 list-mirror List all available packages on the mirror (--diff for new).
97 info Print information about a package.
98 desc Print description of a package (if it exists).
99 list-files List the files installed with a package.
100 list-config List the configuration files.
101 search Search for a package by pattern or name (options: -i|-l|-m).
102 search-file Search for file(s) in all installed packages files.
103 install Install a local (*.tazpkg) package (--forced to force).
104 install-list Install all packages from a list of packages.
105 remove Remove the specified package and all installed files.
106 extract Extract a (*.tazpkg) package into a directory.
107 pack Pack an unpacked or prepared package tree.
108 recharge Recharge your packages.list from the mirror.
109 repack Create a package archive from an installed package.
110 repack-config Create a package archive with configuration files.
111 upgrade Upgrade all installed and listed packages on the mirror.
112 block|unblock Block an installed package version or unblock it for upgrade.
113 get Download a package into the current directory.
114 get-install Download and install a package from the mirror.
115 get-install-list Download and install a list of packages from the mirror.
116 check Verify consistency of installed packages.
117 add-flavor Install the flavor list of packages.
118 install-flavor Install the flavor list of packages and remove other ones.
119 set-release Change release and update packages
120 clean-cache Clean all packages downloaded in cache directory.
121 setup-mirror Change the mirror url configuration.
122 list-undigest List undigest mirrors.
123 remove-undigest Remove an undigest mirror.
124 add-undigest Add an undigest mirror.
125 setup-undigest Update an undigest mirror.
126 reconfigure Replay post install script from package."
127 }
129 # Status function with color (supported by Ash).
130 status()
131 {
132 local CHECK=$?
133 echo -en "\\033[70G[ "
134 if [ $CHECK = 0 ]; then
135 echo -en "\\033[1;33mOK"
136 else
137 echo -en "\\033[1;31mFailed"
138 fi
139 echo -e "\\033[0;39m ]"
140 return $CHECK
141 }
143 # Check if user is root to install, or remove packages.
144 check_root()
145 {
146 if test $(id -u) != 0 ; then
147 echo -e "\nYou must be root to run `basename $0` with this option."
148 echo -e "Please use 'su' and root password to become super-user.\n"
149 exit 0
150 fi
151 }
153 # Check for a package name on cmdline.
154 check_for_package_on_cmdline()
155 {
156 if [ -z "$PACKAGE" ]; then
157 echo -e "\nPlease specify a package name on the command line.\n"
158 exit 0
159 fi
160 }
162 # Check if the package (*.tazpkg) exist before installing or extracting.
163 check_for_package_file()
164 {
165 if [ ! -f "$PACKAGE_FILE" ]; then
166 echo -e "
167 Unable to find : $PACKAGE_FILE\n"
168 exit 0
169 fi
170 }
172 # Check for the receipt of an installed package.
173 check_for_receipt()
174 {
175 if [ ! -f "$INSTALLED/$PACKAGE/receipt" ]; then
176 echo -e "\nUnable to find the receipt : $INSTALLED/$PACKAGE/receipt\n"
177 exit 0
178 fi
179 }
181 # Get package name in a directory
182 package_fullname_in_dir()
183 {
184 [ -f $2$1/receipt ] || return
185 EXTRAVERSION=""
186 . $2$1/receipt
187 echo $PACKAGE-$VERSION$EXTRAVERSION
188 }
190 # Get package name that is already installed.
191 get_installed_package_pathname()
192 {
193 for i in $2$INSTALLED/${1%%-*}*; do
194 [ -d $i ] || continue
195 if [ "$1" = "$(package_fullname_in_dir $i $2)" ]; then
196 echo $i
197 return
198 fi
199 done
200 }
202 # Check if a package is already installed.
203 check_for_installed_package()
204 {
205 if [ -n "$(get_installed_package_pathname $PACKAGE $1)" ]; then
206 echo -e "
207 $PACKAGE is already installed. You can use the --forced option to force
208 installation or remove it and reinstall.\n"
209 exit 0
210 fi
211 }
213 # Check for packages.list to download and install packages.
214 check_for_packages_list()
215 {
216 if [ ! -f "$LOCALSTATE/packages.list" ]; then
217 if test $(id -u) = 0 ; then
218 tazpkg recharge
219 else
220 echo -e "
221 Unable to find the list : $LOCALSTATE/packages.list\n
222 You should probably run 'tazpkg recharge' as root to get the latest list of
223 packages available on the mirror.\n"
224 exit 0
225 fi
226 fi
227 }
229 # Get package filename available on the mirror
230 get_package_filename()
231 {
232 local pkg
233 pkg=$(grep -A 1 -sh "^$1$" $LOCALSTATE/packages.txt \
234 $LOCALSTATE/undigest/*/packages.txt | tail -1)
235 pkg=$(echo $pkg)
236 [ -n "$pkg" ] && pkg=$(grep -sh "^$1-$pkg" \
237 $LOCALSTATE/packages.list \
238 $LOCALSTATE/undigest/*/packages.list | head -1)
239 [ -n "$pkg" ] || pkg=$(grep -sh "^$1-[0-9]" \
240 $LOCALSTATE/packages.list \
241 $LOCALSTATE/undigest/*/packages.list | head -1)
242 [ -n "$pkg" ] || pkg=$(grep -sh "^$1-.[\.0-9]" \
243 $LOCALSTATE/packages.list \
244 $LOCALSTATE/undigest/*/packages.list | head -1)
245 echo $pkg
246 }
248 # Check for a package in packages.list. Used by get and get-install to grep
249 # package basename.
250 check_for_package_in_list()
251 {
252 local filename
253 local check_only
254 check_only="$1"
255 filename=$(get_package_filename $PACKAGE)
256 if [ -n "$filename" ]; then
257 PACKAGE=$filename
258 else
259 echo -e "\nUnable to find : $PACKAGE in the mirrored packages list.\n"
260 [ -n "$check_only" ] && return 1
261 exit 0
262 fi
263 }
265 # Log this activity
266 log()
267 {
268 [ -e $LOG ] || touch $LOG
269 DATE=`date +'%F %T'`
270 [ -w $LOG ] &&
271 echo "$DATE - $1 - $PACKAGE ($VERSION$EXTRAVERSION)" >> $LOG
272 }
274 # Download a file from this mirror
275 download_from()
276 {
277 local i
278 local mirrors
279 mirrors="$1"
280 shift
281 for i in $mirrors; do
282 case "$i" in
283 http://*|ftp://*) wget -c $i$@ && break;;
284 *) cp $i/$1 . && break;;
285 esac
286 done
287 }
289 # Download a file trying all mirrors
290 download()
291 {
292 local i
293 for i in $(cat $MIRROR $LOCALSTATE/undigest/*/mirror 2> /dev/null); do
294 download_from "$i" "$@" && break
295 done
296 }
298 # Extract a package with cpio and gzip.
299 extract_package()
300 {
301 echo -n "Extracting $PACKAGE... "
302 cpio -id < $PACKAGE.tazpkg && rm -f $PACKAGE.tazpkg
303 gzip -d fs.cpio.gz
304 echo -n "Extracting the pseudo fs... "
305 cpio -id < fs.cpio && rm fs.cpio
306 }
308 # This function installs a package in the rootfs.
309 install_package()
310 {
311 ROOT=$1
312 if [ -n "$ROOT" ]; then
313 # Get absolute path
314 ROOT=$(cd $ROOT; pwd)
315 fi
316 (
317 # Create package path early to avoid dependencies loop
318 mkdir -p $TMP_DIR
319 ( cd $TMP_DIR ; cpio -i receipt > /dev/null) < $PACKAGE_FILE
320 . $TMP_DIR/receipt
321 rm -rf $TMP_DIR
322 # Make the installed package data dir to store
323 # the receipt and the files list.
324 mkdir -p $ROOT$INSTALLED/$PACKAGE
325 sed -i "/ $(basename $PACKAGE_FILE)$/d" \
326 $ROOT$LOCALSTATE/installed.md5 2> /dev/null
327 cd $(dirname $PACKAGE_FILE)
328 md5sum $(basename $PACKAGE_FILE) >> $ROOT$LOCALSTATE/installed.md5
329 )
330 # Resolve package deps.
331 check_for_deps $ROOT
332 if [ ! "$MISSING_PACKAGE" = "" ]; then
333 install_deps $ROOT
334 fi
335 mkdir -p $TMP_DIR
336 [ -n "$INSTALL_LIST" ] && echo "$PACKAGE_FILE" >> $INSTALL_LIST-processed
337 echo ""
338 echo -e "\033[1mInstallation of :\033[0m $PACKAGE"
339 echo "================================================================================"
340 echo -n "Copying $PACKAGE... "
341 cp $PACKAGE_FILE $TMP_DIR
342 status
343 cd $TMP_DIR
344 extract_package
345 SELF_INSTALL=0
346 EXTRAVERSION=""
347 CONFIG_FILES=""
348 # Include temporary receipt to get the right variables.
349 . $PWD/receipt
350 if [ $SELF_INSTALL -ne 0 -a -n "$ROOT" ]; then
351 echo -n "Checking post install dependencies... "
352 [ -f $INSTALLED/$PACKAGE/receipt ]
353 if ! status; then
354 echo "Please run 'tazpkg install $PACKAGE_FILE' in / and retry."
355 cd .. && rm -rf $TMP_DIR
356 exit 1
357 fi
358 fi
359 # Remember modified packages
360 for i in $(grep -v '\[' files.list); do
361 [ -e "$ROOT$i" ] || continue
362 [ -d "$ROOT$i" ] && continue
363 for j in $(grep -l "^$i$" $ROOT$INSTALLED/*/files.list); do
364 [ "$j" = "$ROOT$INSTALLED/$PACKAGE/files.list" ] && continue
365 grep -qs ^$PACKAGE$ $(dirname $j)/modifiers && continue
366 if [ -s "$(dirname $j)/volatile.cpio.gz" ]; then
367 # We can modify backed up files
368 zcat $(dirname $j)/volatile.cpio.gz | \
369 cpio -t 2> /dev/null | \
370 grep -q "^${i#/}$" && continue
371 fi
372 echo "$PACKAGE" >> $(dirname $j)/modifiers
373 done
374 done
375 cp receipt files.list $ROOT$INSTALLED/$PACKAGE
376 # Copy the description if found.
377 if [ -f "description.txt" ]; then
378 cp description.txt $ROOT$INSTALLED/$PACKAGE
379 fi
380 # Copy the md5sum if found.
381 if [ -f "md5sum" ]; then
382 cp md5sum $ROOT$INSTALLED/$PACKAGE
383 fi
384 # Pre install commands.
385 if grep -q ^pre_install $ROOT$INSTALLED/$PACKAGE/receipt; then
386 pre_install $ROOT
387 fi
388 if [ -n "$CONFIG_FILES" ]; then
389 # save 'official' configuration files
390 echo -n "Save configuration files for $PACKAGE... "
391 for i in $CONFIG_FILES; do
392 ( cd fs ; find ${i#/} -type f )
393 done | ( cd fs ; cpio -o -H newc | gzip -9 ) > \
394 $ROOT$INSTALLED/$PACKAGE/volatile.cpio.gz
395 # keep user configuration files
396 for i in $CONFIG_FILES; do
397 ( cd fs ; find ${i#/} -type f )
398 done | while read i; do
399 [ -e $ROOT/$i ] || continue
400 cp -a $ROOT/$i fs/$i
401 done
402 status
403 fi
404 echo -n "Installing $PACKAGE... "
405 cp -a fs/* $ROOT/
406 status
407 # Remove the temporary random directory.
408 echo -n "Removing all tmp files... "
409 cd .. && rm -rf $TMP_DIR
410 status
411 # Post install commands.
412 if grep -q ^post_install $ROOT$INSTALLED/$PACKAGE/receipt; then
413 post_install $ROOT
414 fi
415 cd $TOP_DIR
416 echo "================================================================================"
417 echo "$PACKAGE ($VERSION$EXTRAVERSION) is installed."
418 echo ""
419 # Log this activity
420 [ -n "$ROOT" ] || log Installed
422 }
424 # Check for loop in deps tree.
425 check_for_deps_loop()
426 {
427 local list
428 local pkg
429 local deps
430 pkg=$1
431 shift
432 [ -n "$1" ] || return
433 list=""
434 # Filter out already processed deps
435 for i in $@; do
436 case " $ALL_DEPS" in
437 *\ $i\ *);;
438 *) list="$list $i";;
439 esac
440 done
441 ALL_DEPS="$ALL_DEPS$list "
442 for i in $list; do
443 [ -f $i/receipt ] || continue
444 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
445 case " $deps " in
446 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
447 *) check_for_deps_loop $pkg $deps;;
448 esac
449 done
450 }
452 # get package from packages.equiv
453 equivalent_pkg()
454 {
455 for i in $(grep -s "^$1=" $2$LOCALSTATE/packages.equiv | sed "s/^$1=//"); do
456 if echo $i | grep -q : ; then
457 # format 'alternative:newname'
458 # if alternative is installed then substitute newname
459 if [ -f $2$INSTALLED/${i%:*}/receipt ]; then
460 # substitute package dependancy
461 echo ${i#*:}
462 return
463 fi
464 else
465 # if alternative is installed then nothing to install
466 if [ -f $2$INSTALLED/$i/receipt ]; then
467 # substitute installed package
468 echo $i
469 return
470 fi
471 fi
472 done
473 # if not found in packages.equiv then no substitution
474 echo $1
475 }
477 # Check for missing deps listed in a receipt packages.
478 check_for_deps()
479 {
480 local saved;
481 saved=$PACKAGE
482 mkdir -p $TMP_DIR
483 ( cd $TMP_DIR ; cpio -i receipt > /dev/null ) < $PACKAGE_FILE
484 . $TMP_DIR/receipt
485 PACKAGE=$saved
486 rm -rf $TMP_DIR
487 for pkgorg in $DEPENDS
488 do
489 i=$(equivalent_pkg $pkgorg $1)
490 if [ ! -d "$1$INSTALLED/$i" ]; then
491 MISSING_PACKAGE=$i
492 deps=$(($deps+1))
493 elif [ ! -f "$1$INSTALLED/$i/receipt" ]; then
494 echo -e "$WARNING Dependency loop between $PACKAGE and $i."
495 fi
496 done
497 if [ ! "$MISSING_PACKAGE" = "" ]; then
498 echo -e "\033[1mTracking dependencies for :\033[0m $PACKAGE"
499 echo "================================================================================"
500 for pkgorg in $DEPENDS
501 do
502 i=$(equivalent_pkg $pkgorg $1)
503 if [ ! -d "$1$INSTALLED/$i" ]; then
504 MISSING_PACKAGE=$i
505 echo "Missing : $MISSING_PACKAGE"
506 fi
507 done
508 echo "================================================================================"
509 echo "$deps missing package(s) to install."
510 fi
511 }
513 # Install all missing deps. First ask user then install all missing deps
514 # from local dir, cdrom, media or from the mirror. In case we want to
515 # install packages from local, we need a packages.list to find the version.
516 install_deps()
517 {
518 local root
519 root=""
520 [ -n "$1" ] && root="--root=$1"
521 echo ""
522 echo -n "Install all missing dependencies (y/N) ? "; read anser
523 echo ""
524 if [ "$anser" = "y" ]; then
525 for pkgorg in $DEPENDS
526 do
527 pkg=$(equivalent_pkg $pkgorg $1)
528 if [ ! -d "$1$INSTALLED/$pkg" ]; then
529 local list
530 list="$INSTALL_LIST"
531 [ -n "$list" ] || list="$TOP_DIR/packages.list"
532 # We can install packages from a local dir by greping
533 # the TAZPKG_BASENAME in the local packages.list.
534 found=0
535 if [ -f "$list" ]; then
536 echo "Checking if $pkg exist in local list... "
537 mkdir $TMP_DIR
538 for i in $pkg-*.tazpkg; do
539 [ -f $i ] || continue
540 ( cd $TMP_DIR ; cpio -i receipt > /dev/null) < $i
541 [ "$(. $TMP_DIR/receipt; echo $PACKAGE)" = "$pkg" ] || continue
542 if grep -q ^$(package_fullname_in_dir $TMP_DIR).tazpkg$ $list
543 then
544 found=1
545 tazpkg install $i $root --list=$list
546 break
547 fi
548 done
549 rm -rf $TMP_DIR
550 fi
551 # Install deps from the mirror.
552 if [ $found -eq 0 ]; then
553 if [ ! -f "$LOCALSTATE/packages.list" ]; then
554 tazpkg recharge
555 fi
556 tazpkg get-install $pkg $root
557 fi
558 fi
559 done
560 else
561 echo -e "\nLeaving dependencies for $PACKAGE unsolved."
562 echo -e "The package is installed but will probably not work.\n"
563 fi
564 }
566 # xHTML packages list header.
567 xhtml_header()
568 {
569 cat > $XHTML_LIST << _EOT_
570 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
571 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
572 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
573 <head>
574 <title>Installed packages list</title>
575 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
576 <meta name="modified" content="$DATE" />
577 <meta name="generator" content="Tazpkg" />
578 <style type="text/css"><!--
579 body { font: 12px sans-serif, vernada, arial; margin: 0; }
580 #header { background: #f0ba08; color: black; height: 50px;
581 border-top: 1px solid black; border-bottom: 1px solid black; }
582 #content { margin: 0px 50px 26px 50px; }
583 #footer { border-top: 1px solid black; padding-top: 10px;}
584 h1 { margin: 14px 0px 0px 16px; }
585 pre { padding-left: 5px; }
586 hr { color: white; background: white; height: 1px; border: 0; }
587 --></style>
588 </head>
589 <body bgcolor="#ffffff">
590 <div id="header">
591 <h1><font color="#3e1220">Installed packages list</font></h1>
592 </div>
593 <hr />
594 <!-- Start content -->
595 <div id="content">
597 <p>
598 _packages_ packages installed - List generated on : $DATE
599 <p>
601 _EOT_
602 }
604 # xHTML content with packages info.
605 xhtml_pkg_info()
606 {
607 cat >> $XHTML_LIST << _EOT_
608 <h3>$PACKAGE</h3>
609 <pre>
610 Version : $VERSION$EXTRAVERSION
611 Short desc : $SHORT_DESC
612 Web site : <a href="$WEB_SITE">$WEB_SITE</a>
613 </pre>
615 _EOT_
616 }
618 # xHTML packages list footer.
619 xhtml_footer()
620 {
621 cat >> $XHTML_LIST << _EOT_
622 <hr />
623 <p id="footer">
624 $packages packages installed - List generated on : $DATE
625 </p>
627 <!-- End content -->
628 </div>
629 </body>
630 </html>
631 _EOT_
632 }
634 # Search pattern in installed packages.
635 search_in_installed_packages()
636 {
637 echo "Installed packages"
638 echo "================================================================================"
639 list=`ls -1 $INSTALLED | grep -i "$PATTERN"`
640 for pkg in $list
641 do
642 EXTRAVERSION=""
643 [ -f $INSTALLED/$pkg/receipt ] || continue
644 . $INSTALLED/$pkg/receipt
645 echo -n "$PACKAGE "
646 echo -en "\033[24G $VERSION$EXTRAVERSION"
647 echo -e "\033[42G $CATEGORY"
648 packages=$(($packages+1))
649 done
650 # Set correct ending messages.
651 if [ "$packages" = "" ]; then
652 echo "0 installed packages found for : $PATTERN"
653 echo ""
654 else
655 echo "================================================================================"
656 echo "$packages installed package(s) found for : $PATTERN"
657 echo ""
658 fi
659 }
661 # Search in packages.list for available pkgs.
662 search_in_packages_list()
663 {
664 echo "Available packages name-version"
665 echo "================================================================================"
666 packages=0
667 for i in $LOCALSTATE/packages.list $LOCALSTATE/undigest/*/packages.list; do
668 grep -is "$PATTERN" $i
669 packages=$(($packages + `grep -is "$PATTERN" $i | wc -l`))
670 done
671 if [ ! -f "$LOCALSTATE/packages.list" ]; then
672 echo -e "
673 No 'packages.list' found to check for mirrored packages. For more results,
674 please run 'tazpkg recharge' once as root before searching.\n"
675 fi
676 if [ "$packages" = "0" ]; then
677 echo "0 available packages found for : $PATTERN"
678 echo ""
679 else
680 echo "================================================================================"
681 echo "$packages available package(s) found for : $PATTERN"
682 echo ""
683 fi
684 }
686 # search --mirror: Search in packages.txt for available pkgs and give more
687 # info than --list or default.
688 search_in_packages_txt()
689 {
690 echo "Matching packages name with version and desc"
691 echo "================================================================================"
692 packages=0
693 for i in $LOCALSTATE/packages.txt $LOCALSTATE/undigest/*/packages.txt; do
694 grep -is -A 2 "^$PATTERN" $i
695 packages=$(($packages + `grep -is "^$PATTERN" $i | wc -l`))
696 done
697 if [ ! -f "$LOCALSTATE/packages.txt" ]; then
698 echo -e "
699 No 'packages.txt' found to check for mirrored packages. For more results,
700 please run 'tazpkg recharge' once as root before searching.\n"
701 fi
702 if [ "$packages" = "0" ]; then
703 echo "0 available packages found for : $PATTERN"
704 echo ""
705 else
706 echo "================================================================================"
707 echo "$packages available package(s) found for : $PATTERN"
708 echo ""
709 fi
710 }
712 # Install package-list from a flavor
713 install_flavor()
714 {
715 check_root
716 FLAVOR=$1
717 ARG=$2
718 mkdir -p $TMP_DIR
719 [ -f $FLAVOR.flavor ] && cp $FLAVOR.flavor $TMP_DIR
720 cd $TMP_DIR
721 if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
722 zcat $FLAVOR.flavor | cpio -i 2>/dev/null
723 while read file; do
724 for pkg in $(ls -d $INSTALLED/${file%%-*}*); do
725 [ -f $pkg/receipt ] || continue
726 EXTRAVERSION=""
727 . $pkg/receipt
728 [ "$PACKAGE-$VERSION$EXTRAVERSION" = "$file" ] && break
729 done
730 [ "$PACKAGE-$VERSION$EXTRAVERSION" = "$file" ] && continue
731 cd $CACHE_DIR
732 download $file.tazpkg
733 cd $TMP_DIR
734 tazpkg install $CACHE_DIR/$file.tazpkg --forced
735 done < $FLAVOR.pkglist
736 [ -f $FLAVOR.nonfree ] && while read pkg; do
737 [ -d $INSTALLED/$pkg ] || continue
738 [ -d $INSTALLED/get-$pkg ] && tazpkg get-install get-$pkg
739 get-$pkg
740 done < $FLAVOR.nonfree
741 [ "$ARG" == "--purge" ] && for pkg in $(ls $INSTALLED); do
742 [ -f $INSTALLED/$pkg/receipt ] || continue
743 EXTRAVERSION=""
744 . $INSTALLED/$pkg/receipt
745 grep -q ^$PACKAGE-$VERSION$EXTRAVERSION$ $FLAVOR.pkglist && continue
746 grep -qs ^$PACKAGE$ $FLAVOR.nonfree && continue
747 tazpkg remove $PACKAGE
748 done
749 else
750 echo "Can't find flavor $FLAVOR Abort."
751 fi
752 cd $TOP_DIR
753 rm -rf $TMP_DIR
754 }
756 # Update mirror urls
757 setup_mirror()
758 {
759 # Backup old list.
760 if [ -f "$1/mirror" ]; then
761 cp -f $1/mirror $1/mirror.bak
762 fi
763 echo ""
764 echo -e "\033[1mCurrent mirror(s)\033[0m"
765 echo "================================================================================"
766 echo " `cat $1/mirror 2> /dev/null`"
767 echo "
768 Please enter URL of the new mirror (http, ftp or local path). You must specify
769 the complete address to the directory of the packages and packages.list file."
770 echo ""
771 echo -n "New mirror(s) URL : "
772 NEW_MIRROR_URL=$2
773 if [ -n "$NEW_MIRROR_URL" ]; then
774 echo $NEW_MIRROR_URL
775 else
776 read NEW_MIRROR_URL
777 fi
778 if [ "$NEW_MIRROR_URL" = "" ]; then
779 echo "Nothing has been changed."
780 else
781 echo "Setting mirror(s) to : $NEW_MIRROR_URL"
782 rm -f $1/mirror
783 for i in $NEW_MIRROR_URL; do
784 echo "$i" >> $1/mirror
785 done
786 fi
787 echo ""
788 }
790 ###################
791 # Tazpkg commands #
792 ###################
794 case "$COMMAND" in
795 list)
796 # List all installed packages or a specific category.
797 #
798 if [ "$2" = "blocked" ]; then
799 echo ""
800 echo -e "\033[1mBlocked packages\033[0m"
801 echo "================================================================================"
802 if [ -s "$BLOCKED" ];then
803 cat $BLOCKED
804 echo ""
805 else
806 echo -e "No blocked packages found.\n"
807 fi
808 exit 0
809 fi
810 # Display the list of categories.
811 if [ "$2" = "cat" -o "$2" = "categories" ]; then
812 echo ""
813 echo -e "\033[1mPackages categories :\033[0m"
814 echo "================================================================================"
815 for i in $CATEGORIES
816 do
817 echo $i
818 categories=$(($categories+1))
819 done
820 echo "================================================================================"
821 echo "$categories categories"
822 echo ""
823 exit 0
824 fi
825 # Check for an asked category.
826 if [ -n "$2" ]; then
827 ASKED_CATEGORY=$2
828 echo ""
829 echo -e "\033[1mInstalled packages of category :\033[0m $ASKED_CATEGORY"
830 echo "================================================================================"
831 for pkg in $INSTALLED/*
832 do
833 [ -f $pkg/receipt ] || continue
834 EXTRAVERSION=""
835 . $pkg/receipt
836 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
837 echo -n "$PACKAGE"
838 echo -e "\033[24G $VERSION$EXTRAVERSION"
839 packages=$(($packages+1))
840 fi
841 done
842 echo "================================================================================"
843 echo -e "$packages packages installed of category $ASKED_CATEGORY."
844 echo ""
845 else
846 # By default list all packages and versions.
847 echo ""
848 echo -e "\033[1mList of all installed packages\033[0m"
849 echo "================================================================================"
850 for pkg in $INSTALLED/*
851 do
852 [ -f $pkg/receipt ] || continue
853 EXTRAVERSION=""
854 . $pkg/receipt
855 echo -n "$PACKAGE"
856 echo -en "\033[24G $VERSION$EXTRAVERSION"
857 echo -e "\033[42G $CATEGORY"
858 packages=$(($packages+1))
859 done
860 echo "================================================================================"
861 echo "$packages packages installed."
862 echo ""
863 fi
864 ;;
865 xhtml-list)
866 # Get info in receipts and build list.
867 DATE=`date +%Y-%m-%d\ \%H:%M:%S`
868 if [ -n "$2" ]; then
869 XHTML_LIST=$2
870 else
871 XHTML_LIST=installed-packages.html
872 fi
873 echo ""
874 echo -e "\033[1mCreating xHTML list of installed packages\033[0m"
875 echo "================================================================================"
876 echo -n "Generating xHTML header..."
877 xhtml_header
878 status
879 # Packages
880 echo -n "Creating packages information..."
881 for pkg in $INSTALLED/*
882 do
883 [ -f $pkg/receipt ] || continue
884 EXTRAVERSION=""
885 . $pkg/receipt
886 xhtml_pkg_info
887 packages=$(($packages+1))
888 done
889 status
890 echo -n "Generating xHTML footer..."
891 xhtml_footer
892 status
893 # sed pkgs nb in header.
894 sed -i s/'_packages_'/"$packages"/ $XHTML_LIST
895 echo "================================================================================"
896 echo "$XHTML_LIST created - $packages packages."
897 echo ""
898 ;;
899 list-mirror)
900 # List all available packages on the mirror. Option --diff display
901 # last mirrored packages diff (see recharge).
902 check_for_packages_list
903 case $2 in
904 --diff)
905 if [ -f "$LOCALSTATE/packages.diff" ]; then
906 echo ""
907 echo -e "\033[1mMirrored packages diff\033[0m"
908 echo "================================================================================"
909 cat $LOCALSTATE/packages.diff
910 echo "================================================================================"
911 pkgs=`cat $LOCALSTATE/packages.diff | wc -l`
912 echo "$pkgs new packages listed on the mirror."
913 echo ""
914 else
915 echo -e "\nUnable to list anything, no packages.diff found."
916 echo -e "Recharge your current list to create a first diff.\n"
917 fi && exit 0 ;;
918 --text|--txt)
919 echo ""
920 echo -e "\033[1mList of available packages on the mirror\033[0m"
921 echo "================================================================================"
922 cat $LOCALSTATE/packages.txt ;;
923 --raw|*)
924 echo ""
925 echo -e "\033[1mList of available packages on the mirror\033[0m"
926 echo "================================================================================"
927 cat $LOCALSTATE/packages.list ;;
928 esac
929 echo "================================================================================"
930 pkgs=`cat $LOCALSTATE/packages.list | wc -l`
931 echo "$pkgs packages in the last recharged list."
932 echo ""
933 ;;
934 list-files)
935 # List files installed with the package.
936 #
937 check_for_package_on_cmdline
938 check_for_receipt
939 echo ""
940 echo -e "\033[1mInstalled files with :\033[0m $PACKAGE"
941 echo "================================================================================"
942 cat $INSTALLED/$PACKAGE/files.list | sort
943 echo "================================================================================"
944 files=`cat $INSTALLED/$PACKAGE/files.list | wc -l`
945 echo "$files files installed with $PACKAGE."
946 echo ""
947 ;;
948 info)
949 # Information about package.
950 #
951 check_for_package_on_cmdline
952 check_for_receipt
953 EXTRAVERSION=""
954 . $INSTALLED/$PACKAGE/receipt
955 echo ""
956 echo -e "\033[1mTazpkg information\033[0m
957 ================================================================================
958 Package : $PACKAGE
959 Version : $VERSION$EXTRAVERSION
960 Category : $CATEGORY
961 Short desc : $SHORT_DESC
962 Maintainer : $MAINTAINER"
963 if [ ! "$DEPENDS" = "" ]; then
964 echo -e "Depends : $DEPENDS"
965 fi
966 if [ ! "$SUGGESTED" = "" ]; then
967 echo -e "Suggested : $SUGGESTED"
968 fi
969 if [ ! "$BUILD_DEPENDS" = "" ]; then
970 echo -e "Build deps : $BUILD_DEPENDS"
971 fi
972 if [ ! "$WANTED" = "" ]; then
973 echo -e "Wanted src : $WANTED"
974 fi
975 if [ ! "$WEB_SITE" = "" ]; then
976 echo -e "Web site : $WEB_SITE"
977 fi
978 echo "================================================================================"
979 echo ""
980 ;;
981 desc)
982 # Display package description.txt if available.
983 if [ -f "$INSTALLED/$PACKAGE/description.txt" ]; then
984 echo ""
985 echo -e "\033[1mDescription of :\033[0m $PACKAGE"
986 echo "================================================================================"
987 cat $INSTALLED/$PACKAGE/description.txt
988 echo "================================================================================"
989 echo ""
990 else
991 echo -e "\nSorry, no description available for this package.\n"
992 fi
993 ;;
994 search)
995 # Search for a package by pattern or name.
996 #
997 PATTERN="$2"
998 if [ -z "$PATTERN" ]; then
999 echo -e "\nPlease specify a pattern or package name to search for."
1000 echo -e "Example : 'tazpkg search paint'.\n"
1001 exit 0
1002 fi
1003 echo ""
1004 echo -e "\033[1mSearch result for :\033[0m $PATTERN"
1005 echo ""
1006 # Default is to search in installed pkgs and the raw list.
1007 case $3 in
1008 -i|--installed)
1009 search_in_installed_packages ;;
1010 -l|--list)
1011 search_in_packages_list ;;
1012 -m|--mirror)
1013 search_in_packages_txt ;;
1014 *)
1015 search_in_installed_packages
1016 search_in_packages_list ;;
1017 esac
1018 ;;
1019 search-file)
1020 # Search for a file by pattern or name in all files.list.
1022 if [ -z "$2" ]; then
1023 echo -e "\nPlease specify a pattern or file name to search for."
1024 echo -e "Example : 'tazpkg search-file libnss'. \n"
1025 exit 0
1026 fi
1027 echo ""
1028 echo -e "\033[1mSearch result for file :\033[0m $2"
1029 echo "================================================================================"
1031 if [ "$3" == "--mirror" ]; then
1033 match=0
1034 for i in $LOCALSTATE/files.list.lzma \
1035 $LOCALSTATE/undigest/*/files.list.lzma; do
1036 [ -f $i ] || continue
1037 unlzma -c $i | grep -- ".*:.*$2" | awk '
1038 BEGIN { last="" }
1040 pkg=substr($0,0,index($0,":")-1);
1041 file=substr($0,index($0,":")+2);
1042 if (last != pkg) {
1043 last = pkg;
1044 printf("\n%c[1mPackage %s :%c[0m\n",27,pkg,27);
1046 printf("%s\n",file);
1047 }'
1048 match=$(($match + `unlzma -c $i | grep -- ".*:.*$2" | wc -l`))
1049 done
1051 else
1053 # Check all pkg files.list in search match with specify the package
1054 # name and the full path to the file(s).
1055 for pkg in $INSTALLED/*
1056 do
1057 if grep -qs "$2" $pkg/files.list; then
1058 . $pkg/receipt
1059 echo ""
1060 echo -e "\033[1mPackage $PACKAGE :\033[0m"
1061 grep "$2" $pkg/files.list
1062 files=`grep $2 $pkg/files.list | wc -l`
1063 match=$(($match+$files))
1064 fi
1065 done
1067 fi
1069 if [ "$match" = "" ]; then
1070 echo "0 file found for : $2"
1071 echo ""
1072 else
1073 echo ""
1074 echo "================================================================================"
1075 echo "$match file(s) found for : $2"
1076 echo ""
1077 fi
1078 ;;
1079 install)
1080 # Install .tazpkg packages.
1082 check_root
1083 check_for_package_on_cmdline
1084 check_for_package_file
1085 # Check if forced install.
1086 DO_CHECK="yes"
1087 ROOT=""
1088 while [ -n "$3" ]; do
1089 case "$3" in
1090 --forced)
1091 DO_CHECK="no"
1092 ;;
1093 --root=*)
1094 ROOT="${3#--root=}"
1095 ;;
1096 --list=*)
1097 INSTALL_LIST="${3#--list=}"
1098 ;;
1099 *) shift 2
1100 echo -e "\nUnknown option $*.\n"
1101 exit 1
1102 ;;
1103 esac
1104 shift
1105 done
1106 if [ "$DO_CHECK" = "yes" ]; then
1107 check_for_installed_package $ROOT
1108 fi
1109 install_package $ROOT
1110 ;;
1111 install-list|get-install-list)
1112 # Install a set of packages from a list.
1114 check_root
1115 if [ -z "$2" ]; then
1116 echo -e "
1117 Please change directory (cd) to the packages repository, and specify the
1118 list of packages to install. Example : tazpkg install-list packages.list\n"
1119 exit 0
1120 fi
1121 # Check if the packages list exist.
1122 if [ ! -f "$2" ]; then
1123 echo "Unable to find : $2"
1124 exit 0
1125 else
1126 LIST=`cat $2`
1127 fi
1129 # Remember processed list
1130 export INSTALL_LIST="$2"
1132 # Set $COMMAND and install all packages.
1133 if [ "$1" = "get-install-list" ]; then
1134 COMMAND=get-install
1135 else
1136 COMMAND=install
1137 fi
1138 touch $2-processed
1139 for pkg in $LIST
1140 do
1141 grep -qs ^$pkg$ $2-processed && continue
1142 tazpkg $COMMAND $pkg --list=$2 "$3" "$4" "$5"
1143 done
1144 rm -f $2-processed
1145 ;;
1146 add-flavor)
1147 # Install a set of packages from a flavor.
1149 install_flavor $2
1150 ;;
1151 install-flavor)
1152 # Install a set of packages from a flavor and purge other ones.
1154 install_flavor $2 --purge
1155 ;;
1156 set-release)
1157 # Change curent release and upgrade packages.
1159 RELEASE=$2
1160 if [ -z "$RELEASE" ]; then
1161 echo -e "\nPlease specify the release you want on the command line."
1162 echo -e "Example: tazpkg set-release cooking\n"
1163 exit 0
1164 fi
1165 rm /var/lib/tazpkg/mirror
1166 echo "$RELEASE" > /etc/slitaz-release
1167 tazpkg recharge && tazpkg upgrade
1168 ;;
1169 remove)
1170 # Remove packages.
1172 check_root
1173 check_for_package_on_cmdline
1174 if [ ! -f "$INSTALLED/$PACKAGE/receipt" ]; then
1175 echo -e "\n$PACKAGE is not installed.\n"
1176 exit 0
1177 else
1178 ALTERED=""
1179 THE_PACKAGE=$PACKAGE # altered by receipt
1180 for i in $(cd $INSTALLED ; ls); do
1181 [ -f $i/receipt ] || continue
1182 DEPENDS=""
1183 . $INSTALLED/$i/receipt
1184 case " $(echo $DEPENDS) " in
1185 *\ $THE_PACKAGE\ *) ALTERED="$ALTERED $i";;
1186 esac
1187 done
1188 EXTRAVERSION=""
1189 . $INSTALLED/$THE_PACKAGE/receipt
1190 fi
1191 echo ""
1192 if [ -n "$ALTERED" ]; then
1193 echo "The following packages depend on $PACKAGE :"
1194 for i in $ALTERED; do
1195 echo " $i"
1196 done
1197 fi
1198 REFRESH=$(cd $INSTALLED ; grep -sl ^$PACKAGE$ */modifiers)
1199 if [ -n "$REFRESH" ]; then
1200 echo "The following packages have been modified by $PACKAGE :"
1201 for i in $REFRESH; do
1202 echo " ${i%/modifiers}"
1203 done
1204 fi
1205 echo "Remove $PACKAGE ($VERSION$EXTRAVERSION) ?"
1206 echo -n "Please confirm uninstallation (y/N) : "; read anser
1207 if [ "$anser" = "y" ]; then
1208 echo ""
1209 echo -e "\033[1mRemoving :\033[0m $PACKAGE"
1210 echo "================================================================================"
1211 # Pre remove commands.
1212 if grep -q ^pre_remove $INSTALLED/$PACKAGE/receipt; then
1213 pre_remove
1214 fi
1215 echo -n "Removing all files installed..."
1216 for file in `cat $INSTALLED/$PACKAGE/files.list`
1217 do
1218 [ $(grep ^$file$ $INSTALLED/*/files.list | wc -l) -gt 1 ] && continue
1219 rm -rf $file 2>/dev/null
1220 done
1221 status
1222 if grep -q ^post_remove $INSTALLED/$PACKAGE/receipt; then
1223 post_remove
1224 fi
1225 # Remove package receipt.
1226 echo -n "Removing package receipt..."
1227 rm -rf $INSTALLED/$PACKAGE
1228 status
1229 # Log this activity
1230 log Removed
1231 if [ -n "$ALTERED" ]; then
1232 echo -n "Remove packages depending on $PACKAGE"
1233 echo -n " (y/N) ? "; read anser
1234 if [ "$anser" = "y" ]; then
1235 for i in $ALTERED; do
1236 if [ -d "$INSTALLED/$i" ]; then
1237 tazpkg remove $i
1238 fi
1239 done
1240 fi
1241 fi
1242 if [ -n "$REFRESH" ]; then
1243 echo -n "Reinstall packages modified by $PACKAGE"
1244 echo -n " (y/N) ? "; read anser
1245 if [ "$anser" = "y" ]; then
1246 for i in $REFRESH; do
1247 if [ $(wc -l < $INSTALLED/$i) -gt 1 ]; then
1248 echo "Check $INSTALLED/$i for reinstallation"
1249 continue
1250 fi
1251 rm -r $INSTALLED/$i
1252 tazpkg get-install ${i%/modifiers} --forced
1253 done
1254 fi
1255 fi
1256 else
1257 echo ""
1258 echo "Uninstallation of $PACKAGE cancelled."
1259 fi
1260 echo ""
1261 ;;
1262 extract)
1263 # Extract .tazpkg cpio archive into a directory.
1265 check_for_package_on_cmdline
1266 check_for_package_file
1267 echo ""
1268 echo -e "\033[1mExtracting :\033[0m $PACKAGE"
1269 echo "================================================================================"
1270 # If no directory destination is found on the cmdline
1271 # we create one in the current dir using the package name.
1272 if [ -n "$TARGET_DIR" ]; then
1273 DESTDIR=$TARGET_DIR/$PACKAGE
1274 else
1275 DESTDIR=$PACKAGE
1276 fi
1277 mkdir -p $DESTDIR
1278 echo -n "Copying original package..."
1279 cp $PACKAGE_FILE $DESTDIR
1280 status
1281 cd $DESTDIR
1282 extract_package
1283 echo "================================================================================"
1284 echo "$PACKAGE is extracted to : $DESTDIR"
1285 echo ""
1286 ;;
1287 list-config)
1288 # List configuration files installed.
1290 if [ "$2" = "--box" ]; then
1291 mkdir -p $TMP_DIR && cd $TMP_DIR
1292 for i in $INSTALLED/*/volatile.cpio.gz; do
1293 zcat $i | cpio -id > /dev/null
1294 find * -type f 2>/dev/null | while read file; do
1295 if [ ! -e /$file ]; then
1296 echo -n "|--|--|--|File lost"
1297 else
1298 echo -n "$(stat -c "%A|%U|%G|%s|" /$file)"
1299 cmp $file /$file > /dev/null 2>&1 || \
1300 echo -n "$(stat -c "%.16y" /$file)"
1301 fi
1302 echo "|/$file"
1303 done
1304 rm -rf *
1305 done
1306 cd $TOP_DIR
1307 rm -rf $TMP_DIR
1308 else
1309 echo ""
1310 echo -e "\033[1mConfiguration files"
1311 echo "================================================================================"
1312 for i in $INSTALLED/*/volatile.cpio.gz; do
1313 [ -n "$2" -a "$i" != "$INSTALLED/$2/volatile.cpio.gz" ] && continue
1314 [ -f "$i" ] || continue
1315 zcat $i | cpio -t | grep -v "[0-9]* blocks"
1316 done | sed 's|^|/|' | sort
1317 echo "================================================================================"
1318 echo ""
1319 fi
1320 ;;
1321 repack-config)
1322 # Create SliTaz package archive from configuration files.
1324 mkdir -p $TMP_DIR && cd $TMP_DIR
1325 CONFIG_VERSION=1.0
1326 mkdir config-$CONFIG_VERSION
1327 cd config-$CONFIG_VERSION
1328 for i in $INSTALLED/*/volatile.cpio.gz; do
1329 zcat $i | cpio -t | grep -v "[0-9]* blocks"
1330 done > files.list
1331 mkdir fs
1332 cd fs
1333 ( cd / ; cpio -o -H newc ) < ../files.list | cpio -id > /dev/null
1334 mkdir -p etc/tazlito
1335 for i in $INSTALLED/*/receipt; do
1336 EXTRAVERSION=""
1337 . $i
1338 echo "$PACKAGE-$VERSION$EXTRAVERSION"
1339 done > etc/tazlito/config-packages.list
1340 cd ..
1341 echo "etc/tazlito/config-packages.list" >> files.list
1342 cat > receipt <<EOT
1343 # SliTaz package receipt.
1345 PACKAGE="config"
1346 VERSION="$CONFIG_VERSION"
1347 CATEGORY="base-system"
1348 SHORT_DESC="User configuration backup on $(date)"
1349 DEPENDS="$(ls $INSTALLED)"
1350 EOT
1351 cd ..
1352 tazpkg pack config-$CONFIG_VERSION
1353 cp config-$CONFIG_VERSION.tazpkg $TOP_DIR
1354 cd $TOP_DIR
1355 rm -rf $TMP_DIR
1356 ;;
1357 repack)
1358 # Create SliTaz package archive from an installed package.
1360 check_for_package_on_cmdline
1361 check_for_receipt
1362 EXTRAVERSION=""
1363 . $INSTALLED/$PACKAGE/receipt
1364 echo ""
1365 echo -e "\033[1mRepacking :\033[0m $PACKAGE-$VERSION$EXTRAVERSION.tazpkg"
1366 echo "================================================================================"
1367 if grep -qs ^NO_REPACK= $INSTALLED/$PACKAGE/receipt; then
1368 echo "Can't repack $PACKAGE"
1369 exit 1
1370 fi
1371 if [ -s $INSTALLED/$PACKAGE/modifiers ]; then
1372 echo "Can't repack, $PACKAGE files have been modified by:"
1373 for i in $(cat $INSTALLED/$PACKAGE/modifiers); do
1374 echo " $i"
1375 done
1376 exit 1
1377 fi
1378 MISSING=""
1379 while read i; do
1380 [ -e "$i" ] && continue
1381 [ -L "$i" ] || MISSING="$MISSING\n $i"
1382 done < $INSTALLED/$PACKAGE/files.list
1383 if [ -n "$MISSING" ]; then
1384 echo -n "Can't repack, the following files are lost:"
1385 echo -e "$MISSING"
1386 exit 1
1387 fi
1388 mkdir -p $TMP_DIR && cd $TMP_DIR
1389 FILES="fs.cpio.gz\n"
1390 for i in $(ls $INSTALLED/$PACKAGE) ; do
1391 [ "$i" = "volatile.cpio.gz" ] && continue
1392 [ "$i" = "modifiers" ] && continue
1393 cp $INSTALLED/$PACKAGE/$i . && FILES="$FILES$i\n"
1394 done
1395 ln -s / rootfs
1396 mkdir tmp
1397 sed 's/^/rootfs/' < files.list | cpio -o -H newc 2>/dev/null |\
1398 ( cd tmp ; cpio -id 2>/dev/null )
1399 mv tmp/rootfs fs
1400 if [ -f $INSTALLED/$PACKAGE/volatile.cpio.gz ]; then
1401 zcat $INSTALLED/$PACKAGE/volatile.cpio.gz | \
1402 ( cd fs; cpio -id )
1403 fi
1404 if grep -q repack_cleanup $INSTALLED/$PACKAGE/receipt; then
1405 . $INSTALLED/$PACKAGE/receipt
1406 repack_cleanup fs
1407 fi
1408 if [ -f $INSTALLED/$PACKAGE/md5sum ]; then
1409 sed 's, , fs,' < $INSTALLED/$PACKAGE/md5sum | \
1410 if ! md5sum -s -c; then
1411 echo -n "Can't repack, md5sum error."
1412 cd $TOP_DIR
1413 \rm -R $TMP_DIR
1414 exit 1
1415 fi
1416 fi
1417 find fs | cpio -o -H newc 2> /dev/null | gzip -9 > fs.cpio.gz
1418 echo -e "$FILES" | cpio -o -H newc 2> /dev/null > \
1419 $TOP_DIR/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
1420 cd $TOP_DIR
1421 \rm -R $TMP_DIR
1422 echo "Package $PACKAGE repacked successfully."
1423 echo "Size : `du -sh $PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
1424 echo ""
1425 ;;
1426 pack)
1427 # Create SliTaz package archive using cpio and gzip.
1429 check_for_package_on_cmdline
1430 cd $PACKAGE
1431 if [ ! -f "receipt" ]; then
1432 echo "Receipt is missing. Please read the documentation."
1433 exit 0
1434 else
1435 echo ""
1436 echo -e "\033[1mPacking :\033[0m $PACKAGE"
1437 echo "================================================================================"
1438 # Create files.list with redirecting find outpout.
1439 echo -n "Creating the list of files..." && cd fs
1440 find . -type f -print > ../files.list
1441 find . -type l -print >> ../files.list
1442 cd .. && sed -i s/'^.'/''/ files.list
1443 status
1444 echo -n "Creating md5sum of files..."
1445 while read file; do
1446 [ -L "fs$file" ] && continue
1447 [ -f "fs$file" ] || continue
1448 case "$file" in
1449 /lib/modules/*/modules.*|*.pyc) continue;;
1450 esac
1451 md5sum "fs$file" | sed 's/ fs/ /'
1452 done < files.list > md5sum
1453 status
1454 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum \
1455 description.txt 2> /dev/null | awk \
1456 '{ sz=$1 } END { print sz }')
1457 # Build cpio archives.
1458 echo -n "Compressing the fs... "
1459 find fs -print | cpio -o -H newc | gzip > fs.cpio.gz
1460 rm -rf fs
1461 status
1462 PACKED_SIZE=$(du -chs fs.cpio.gz receipt files.list \
1463 md5sum description.txt 2> /dev/null | awk \
1464 '{ sz=$1 } END { print sz }')
1465 echo -n "Undating receipt sizes..."
1466 sed -i s/^PACKED_SIZE.*$// receipt
1467 sed -i s/^UNPACKED_SIZE.*$// receipt
1468 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
1469 status
1470 echo -n "Creating full cpio archive... "
1471 find . -print | cpio -o -H newc > ../$PACKAGE.tazpkg
1472 status
1473 echo -n "Restoring original package tree... "
1474 zcat fs.cpio.gz | cpio -id
1475 status
1476 rm fs.cpio.gz && cd ..
1477 echo "================================================================================"
1478 echo "Package $PACKAGE compressed successfully."
1479 echo "Size : `du -sh $PACKAGE.tazpkg`"
1480 echo ""
1481 fi
1482 ;;
1483 recharge)
1484 # Recharge packages.list from a mirror.
1486 check_root
1487 for path in $LOCALSTATE $LOCALSTATE/undigest/*; do
1488 [ -f $path/mirror ] || continue
1489 echo ""
1490 if [ "$path" != "$LOCALSTATE" ]; then
1491 echo "Recharge undigest $(basename $path):"
1492 fi
1493 cd $path
1494 if [ -f "packages.list" ]; then
1495 echo -n "Creating backup of the last packages list..."
1496 mv -f packages.desc packages.desc.bak 2>/dev/null
1497 mv -f packages.md5 packages.md5.txt 2>/dev/null
1498 mv -f packages.txt packages.txt.bak 2>/dev/null
1499 mv -f packages.list packages.list.bak 2>/dev/null
1500 mv -f packages.equiv packages.equiv.bak 2>/dev/null
1501 mv -f files.list.lzma files.list.lzma.bak 2> /dev/nul
1502 status
1503 fi
1504 download_from "$(cat mirror)" packages.desc
1505 download_from "$(cat mirror)" packages.md5
1506 download_from "$(cat mirror)" packages.txt
1507 download_from "$(cat mirror)" packages.list
1508 download_from "$(cat mirror)" packages.equiv
1509 download_from "$(cat mirror)" files.list.lzma
1510 if [ -f "packages.list.bak" ]; then
1511 diff -u packages.list.bak packages.list | grep ^+[a-z] > packages.diff
1512 sed -i s/+// packages.diff
1513 echo ""
1514 echo -e "\033[1mMirrored packages diff\033[0m"
1515 echo "================================================================================"
1516 cat packages.diff
1517 if [ ! "`cat packages.diff | wc -l`" = 0 ]; then
1518 echo "================================================================================"
1519 echo "`cat packages.diff | wc -l` new packages on the mirror."
1520 echo ""
1521 else
1522 echo "`cat packages.diff | wc -l` new packages on the mirror."
1523 echo ""
1524 fi
1525 else
1526 echo -e "
1527 ================================================================================
1528 Last packages.list is ready to use. Note that next time you recharge the list,
1529 a list of differencies will be displayed to show new and upgradeable packages.\n"
1530 fi
1531 done
1532 ;;
1533 upgrade)
1534 # Upgrade all installed packages with the new version from the mirror.
1536 check_root
1537 check_for_packages_list
1538 cd $LOCALSTATE
1539 # Touch the blocked pkgs list to avoid errors and remove any old
1540 # upgrade list.
1541 touch blocked-packages.list
1542 rm -f upgradeable-packages.list
1543 echo ""
1544 echo -e "\033[1mAvailable upgrades\033[0m"
1545 echo "================================================================================"
1546 echo ""
1547 # Some packages must be installed first
1548 FIRST_CLASS_PACKAGE=" glibc-base slitaz-base-files slitaz-boot-scripts "
1549 for pkg in $INSTALLED/*
1550 do
1551 [ -f $pkg/receipt ] || continue
1552 EXTRAVERSION=""
1553 . $pkg/receipt
1554 # Display package name to show that Tazpkg is working...
1555 echo -en "\\033[0G "
1556 echo -en "\\033[0G$PACKAGE"
1557 # Skip specified pkgs listed in $LOCALSTATE/blocked-packages.list
1558 if grep -q "^$PACKAGE" $BLOCKED; then
1559 blocked=$(($blocked+1))
1560 else
1561 # Check if the installed package is in the current list (other
1562 # mirror or local).
1563 NEW_PACKAGE=$(get_package_filename $PACKAGE)
1565 if [ -n "$NEW_PACKAGE" ]; then
1566 # Set new pkg and version for futur comparaison
1567 NEW_VERSION=`echo $NEW_PACKAGE | sed s/$PACKAGE-/''/`
1568 # Change '-' and 'pre' to points.
1569 NEW_VERSION=`echo $NEW_VERSION | sed s/'-'/'.'/`
1570 VERSION=`echo $VERSION | sed s/'-'/'.'/`$EXTRAVERSION
1571 NEW_VERSION=`echo $NEW_VERSION | sed s/'pre'/'.'/`
1572 VERSION=`echo $VERSION | sed s/'pre'/'.'/`
1573 NEW_VERSION=`echo $NEW_VERSION | sed 's/[A-Z]\.//'`
1574 VERSION=`echo $VERSION | sed 's/[A-Z]\.//'`
1575 # Compare version. Upgrade are only available for official
1576 # packages, so we control de mirror and it should be ok if
1577 # we just check for egality.
1578 RELEASE=""
1579 if [ -f installed.md5 -a -f packages.md5 ]; then
1580 current_md5=$(grep -s " $PACKAGE-$VERSION" installed.md5 | awk '{ print $1 }')
1581 new_md5=$(grep -hs " $PACKAGE-$VERSION" packages.md5 undigest/*/packages.md5 | head -1 | awk '{ print $1 }')
1582 [ -n "$current_md5" ] && [ -n "$new_md5" ] &&
1583 [ "$current_md5" != "$new_md5" ] && RELEASE=build
1584 fi
1585 if [ "$VERSION" != "$NEW_VERSION" -o -n "$RELEASE" ]; then
1586 # Version seems different. Check for major, minor or
1587 # revision
1588 PKG_MAJOR=`echo ${VERSION%_*} | cut -f1 -d"."`
1589 NEW_MAJOR=`echo ${NEW_VERSION%_*} | cut -f1 -d"."`
1590 PKG_MINOR=`echo ${VERSION%_*} | cut -f2 -d"."`
1591 NEW_MINOR=`echo ${NEW_VERSION%_*} | cut -f2 -d"."`
1592 # Minor
1593 if [ "$NEW_MINOR" -gt "$PKG_MINOR" ] 2> /dev/null; then
1594 RELEASE=minor
1595 fi
1596 if [ "$NEW_MINOR" -lt "$PKG_MINOR" ] 2> /dev/null; then
1597 RELEASE=$WARNING
1598 FIXE=yes
1599 fi
1600 # Major
1601 if [ "$NEW_MAJOR" -gt "$PKG_MAJOR" ] 2> /dev/null; then
1602 RELEASE=major
1603 FIXE=""
1604 fi
1605 if [ "$NEW_MAJOR" -lt "$PKG_MAJOR" ] 2> /dev/null; then
1606 RELEASE=$WARNING
1607 FIXE=yes
1608 fi
1609 # Default to revision.
1610 if [ -z $RELEASE ]; then
1611 RELEASE=revision
1612 fi
1613 # Pkg name is already displayed by the check process.
1614 echo -en "\033[24G $VERSION"
1615 echo -en "\033[38G --->"
1616 echo -en "\033[43G $NEW_VERSION"
1617 echo -en "\033[58G $CATEGORY"
1618 echo -e "\033[72G $RELEASE"
1619 up=$(($up+1))
1620 echo "$PACKAGE" >> upgradeable-packages.list
1621 case "$FIRST_CLASS_PACKAGE" in
1622 *\ $PACKAGE\ *) echo "$PACKAGE" >> upgradeable-packages.list$$;;
1623 esac
1624 unset RELEASE
1625 fi
1626 packages=$(($packages+1))
1627 fi
1628 fi
1629 done
1630 if [ -z $blocked ]; then
1631 blocked=0
1632 fi
1633 # Clean last checked package and display summary.
1634 if [ ! "$up" = "" ]; then
1635 echo -e "\\033[0G "
1636 echo "================================================================================"
1637 echo "$packages installed and listed packages to consider, $up to upgrade, $blocked blocked."
1638 echo ""
1639 else
1640 echo -e "\\033[0GSystem is up-to-date. "
1641 echo ""
1642 echo "================================================================================"
1643 echo "$packages installed and listed packages to consider, 0 to upgrade, $blocked blocked."
1644 echo ""
1645 exit 0
1646 fi
1647 # What to do if major or minor version is smaller.
1648 if [ "$FIXE" == "yes" ]; then
1649 echo -e "$WARNING ---> Installed package seems more recent than the mirrored one."
1650 echo "You can block packages using the command : 'tazpkg block package'"
1651 echo "Or upgrade package at you own risks."
1652 echo ""
1653 fi
1654 # Ask for upgrade, it can be done another time.
1655 echo -n "Upgrade now (y/N) ? "; read anser
1656 if [ ! "$anser" = "y" ]; then
1657 echo -e "\nExiting. No package upgraded.\n"
1658 exit 0
1659 fi
1660 # If anser is yes (y). Install all new versions.
1661 cat upgradeable-packages.list >> upgradeable-packages.list$$
1662 mv -f upgradeable-packages.list$$ upgradeable-packages.list
1663 yes y | tazpkg get-install-list upgradeable-packages.list --forced
1664 rm -f upgradeable-packages.list
1665 ;;
1666 bugs)
1667 # Show known bugs in package(s)
1669 cd $INSTALLED
1670 shift
1671 LIST=$@
1672 [ -n "$LIST" ] || LIST=`ls`
1673 MSG="No known bugs."
1674 for PACKAGE in $LIST; do
1675 BUGS=""
1676 EXTRAVERSION=""
1677 . $PACKAGE/receipt
1678 if [ -n "$BUGS" ]; then
1679 MSG="
1680 Bug list completed"
1681 cat <<EOT
1683 Bugs in package $PACKAGE version $VERSION$EXTRAVERSION:
1684 $BUGS
1685 EOT
1686 fi
1687 done
1688 echo "$MSG"
1689 ;;
1690 check)
1691 # Check installed packages set.
1693 check_root
1694 cd $INSTALLED
1695 for PACKAGE in `ls`; do
1696 if [ ! -f $PACKAGE/receipt ]; then
1697 echo "The package $PACKAGE installation is not completed"
1698 continue
1699 fi
1700 DEPENDS=""
1701 EXTRAVERSION=""
1702 . $PACKAGE/receipt
1703 if [ -s $PACKAGE/modifiers ]; then
1704 echo "The package $PACKAGE $VERSION$EXTRAVERSION has been modified by :"
1705 for i in $(cat $PACKAGE/modifiers); do
1706 echo " $i"
1707 done
1708 fi
1709 MSG="Files lost from $PACKAGE $VERSION$EXTRAVERSION :\n"
1710 while read file; do
1711 [ -e "$file" ] && continue
1712 if [ -L "$file" ]; then
1713 MSG="$MSG target of symlink"
1714 fi
1715 echo -e "$MSG $file"
1716 MSG=""
1717 done < $PACKAGE/files.list
1718 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n"
1719 for i in $DEPENDS; do
1720 [ -d $i ] && continue
1721 echo -e "$MSG $i"
1722 MSG=""
1723 done
1724 MSG="Dependencies loop between $PACKAGE and :\n"
1725 ALL_DEPS=""
1726 check_for_deps_loop $PACKAGE $DEPENDS
1727 done
1728 echo -n "Looking for known bugs... "
1729 tazpkg bugs
1730 if [ "$PACKAGE_FILE" = "--full" ]; then
1731 for file in */md5sum; do
1732 CONFIG_FILES=""
1733 . $(dirname "$file")/receipt
1734 [ -s "$file" ] || continue
1735 while read md5 f; do
1736 [ -f $f ] || continue
1737 for i in $CONFIG_FILES; do
1738 case "$f" in
1739 $i|$i/*) continue 2;;
1740 esac
1741 done
1742 echo "$md5 $f"
1743 done < "$file" | md5sum -c - 2> /dev/null | \
1744 grep -v OK$ | sed 's/FAILED$/MD5SUM MISMATCH/'
1745 done
1746 FILES=" "
1747 for file in $(cat */files.list); do
1748 [ -d "$file" ] && continue
1749 case "$FILES" in *\ $file\ *) continue;; esac
1750 [ $(grep "^$file$" */files.list 2> /dev/null | \
1751 wc -l) -gt 1 ] || continue
1752 FILES="$FILES$file "
1753 echo "The following packages provide $file :"
1754 grep -l "^$file$" */files.list | while read f
1755 do
1756 pkg=${f%/files.list}
1757 echo -n " $pkg"
1758 if [ -f $pkg/modifiers ]; then
1759 echo -n " (overridden by $(echo "$(cat $pkg/modifiers)"))"
1760 fi
1761 echo ""
1762 done
1763 done
1764 MSG="No package has installed the following files:\n"
1765 find /etc /bin /sbin /lib /usr /var/www \
1766 -not -type d 2> /dev/null | while read file; do
1767 case "$file" in *\[*) continue;; esac
1768 grep -q "^$file$" */files.list && continue
1769 echo -e "$MSG $file"
1770 MSG=""
1771 done
1772 fi
1773 echo "Check completed."
1774 ;;
1775 block)
1776 # Add a pkg name to the list of blocked packages.
1778 check_root
1779 check_for_package_on_cmdline
1780 echo ""
1781 if grep -q "^$PACKAGE" $BLOCKED; then
1782 echo "$PACKAGE is already in the blocked packages list."
1783 echo ""
1784 exit 0
1785 else
1786 echo -n "Add $PACKAGE to : $BLOCKED..."
1787 echo $PACKAGE >> $BLOCKED
1788 status
1789 # Log this activity
1790 . $INSTALLED/$PACKAGE/receipt
1791 log Blocked
1792 fi
1793 echo ""
1794 ;;
1795 unblock)
1796 # Remove a pkg name from the list of blocked packages.
1798 check_root
1799 check_for_package_on_cmdline
1800 echo ""
1801 if grep -q "^$PACKAGE" $BLOCKED; then
1802 echo -n "Removing $PACKAGE from : $BLOCKED..."
1803 sed -i s/$PACKAGE/''/ $BLOCKED
1804 sed -i '/^$/d' $BLOCKED
1805 status
1806 # Log this activity
1807 . $INSTALLED/$PACKAGE/receipt
1808 log Unblocked
1809 else
1810 echo "$PACKAGE is not in the blocked packages list."
1811 echo ""
1812 exit 0
1813 fi
1814 echo ""
1815 ;;
1816 get)
1817 # Downlowd a package with wget.
1819 check_for_package_on_cmdline
1820 check_for_packages_list
1821 check_for_package_in_list
1822 echo ""
1823 download $PACKAGE.tazpkg
1824 echo ""
1825 ;;
1826 get-install)
1827 # Download and install a package.
1829 check_root
1830 check_for_package_on_cmdline
1831 check_for_packages_list
1832 DO_CHECK=""
1833 while [ -n "$3" ]; do
1834 case "$3" in
1835 --forced)
1836 DO_CHECK="no"
1837 ;;
1838 --root=*)
1839 ROOT="${3#--root=}"
1840 ;;
1841 --list=*)
1842 INSTALL_LIST="${3#--list=}"
1843 ;;
1844 *) shift 2
1845 echo -e "\nUnknown option $*.\n"
1846 exit 1
1847 ;;
1848 esac
1849 shift
1850 done
1851 AUTOEXEC="no"
1852 if ! check_for_package_in_list check; then
1853 PACKAGE=get-$PACKAGE
1854 AUTOEXEC=$PACKAGE
1855 check_for_package_in_list
1856 if [ -n "$(get_installed_package_pathname $PACKAGE $ROOT)" ]; then
1857 $AUTOEXEC $ROOT
1858 exit 0
1859 fi
1860 fi
1861 # Check if forced install.
1862 if [ "$DO_CHECK" = "no" ]; then
1863 rm -f $CACHE_DIR/$PACKAGE.tazpkg
1864 else
1865 check_for_installed_package $ROOT
1866 fi
1867 cd $CACHE_DIR
1868 if [ -f "$PACKAGE.tazpkg" ]; then
1869 echo "$PACKAGE already in the cache : $CACHE_DIR"
1870 # Check package download was finished
1871 tail -c 2k $PACKAGE.tazpkg | grep -q 00000000TRAILER || {
1872 echo "Continue $PACKAGE download"
1873 download $PACKAGE.tazpkg
1875 else
1876 echo ""
1877 download $PACKAGE.tazpkg
1878 fi
1879 PACKAGE_FILE=$CACHE_DIR/$PACKAGE.tazpkg
1880 install_package $ROOT
1881 [ "$AUTOEXEC" != "no" ] && $PACKAGE $ROOT
1882 ;;
1883 clean-cache)
1884 # Remove all downloaded packages.
1886 check_root
1887 files=`ls -1 $CACHE_DIR | wc -l`
1888 echo ""
1889 echo -e "\033[1mClean cache :\033[0m $CACHE_DIR"
1890 echo "================================================================================"
1891 echo -n "Cleaning cache directory..."
1892 rm -rf $CACHE_DIR/*
1893 status
1894 echo "================================================================================"
1895 echo "$files file(s) removed from cache."
1896 echo ""
1897 ;;
1898 list-undigest)
1899 # list undigest URLs.
1901 if [ "$2" = "--box" ]; then
1902 for i in $LOCALSTATE/undigest/*/mirror; do
1903 [ -f $i ] || continue
1904 echo "$(basename $(dirname $i))|$(cat $i)"
1905 done
1906 else
1907 echo ""
1908 echo -e "\033[1mCurrent undigest(s)\033[0m"
1909 echo "================================================================================"
1910 for i in $LOCALSTATE/undigest/*/mirror; do
1911 if [ ! -f $i ]; then
1912 echo "No undigest mirror found."
1913 exit 1
1914 fi
1915 echo "$(basename $(dirname $i)) $(cat $i)"
1916 done
1917 echo ""
1918 fi
1919 ;;
1920 remove-undigest)
1921 # remove undigest URL.
1923 check_root
1924 if [ -d $LOCALSTATE/undigest/$2 ]; then
1925 echo -n "Remove $2 undigest (y/N) ? "; read anser
1926 if [ "$anser" = "y" ]; then
1927 echo -n "Removing $2 undigest..."
1928 rm -rf $LOCALSTATE/undigest/$2
1929 status
1930 rmdir $LOCALSTATE/undigest 2> /dev/null
1931 fi
1932 else
1933 echo "Undigest $2 not found"
1934 fi
1935 ;;
1936 add-undigest|setup-undigest)
1937 # Add undigest URL.
1939 check_root
1940 undigest=$2
1941 [ -d $LOCALSTATE/undigest ] || mkdir $LOCALSTATE/undigest
1942 if [ -z "$undigest" ]; then
1943 i=1
1944 while [ -d $LOCALSTATE/undigest/$i ]; do
1945 i=$(($i+1))
1946 done
1947 undigest=$i
1948 fi
1949 if [ ! -d $LOCALSTATE/undigest/$undigest ]; then
1950 echo "Creating new undigest $undigest."
1951 mkdir $LOCALSTATE/undigest/$undigest
1952 fi
1953 setup_mirror $LOCALSTATE/undigest/$undigest $3
1954 ;;
1955 setup-mirror)
1956 # Change mirror URL.
1958 check_root
1959 setup_mirror $LOCALSTATE $2
1960 ;;
1961 reconfigure)
1962 # Replay post_install from receipt
1964 check_for_package_on_cmdline
1965 check_root
1966 if [ -d "$INSTALLED/$PACKAGE" ]; then
1967 check_for_receipt
1968 # Check for post_install
1969 if grep -q ^post_install $INSTALLED/$PACKAGE/receipt; then
1970 . $INSTALLED/$PACKAGE/receipt
1971 post_install
1972 # Log this activity
1973 log Reconfigured
1974 else
1975 echo -e "\nNothing to do for $PACKAGE."
1976 fi
1977 else
1978 echo -e "\npackage $PACKAGE is not installed."
1979 echo -e "Install package with 'tazpkg install' or 'tazpkg get-install'\n"
1980 fi
1981 ;;
1982 shell)
1983 # Tazpkg SHell
1985 if test $(id -u) = 0 ; then
1986 PROMPT="\\033[1;33mtazpkg\\033[0;39m# "
1987 else
1988 PROMPT="\\033[1;33mtazpkg\\033[0;39m> "
1989 fi
1990 if [ ! "$2" = "--noheader" ]; then
1991 clear
1992 echo ""
1993 echo -e "\033[1mTazpkg SHell.\033[0m"
1994 echo "================================================================================"
1995 echo "Type 'usage' to list all available commands or 'quit' or 'q' to exit."
1996 echo ""
1997 fi
1998 while true
1999 do
2000 echo -en "$PROMPT"; read cmd
2001 case $cmd in
2002 q|quit)
2003 break ;;
2004 shell)
2005 echo "You are already running a Tazpkg SHell." ;;
2006 su)
2007 su -c 'exec tazpkg shell --noheader' && break ;;
2008 "")
2009 continue ;;
2010 *)
2011 tazpkg $cmd ;;
2012 esac
2013 done
2014 ;;
2015 usage|*)
2016 # Print a short help or give usage for an unknown or empty command.
2018 usage
2019 ;;
2020 esac
2022 exit 0