tazpkg view tazpkg @ rev 74

add add-flavor, install-flavor and set-release
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Apr 28 11:04:49 2008 +0000 (2008-04-28)
parents 680ec3abef92
children d11eb5165891
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 let 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 a short description. Tazpkg
8 # also relolv 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=1.9
18 ####################
19 # Script variables #
20 ####################
22 # Packages categories.
23 CATEGORIES="
24 base-system
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 # Initialize some variables to use words
39 # rater than numbers for functions and actions.
40 COMMAND=$1
41 if [ -f "$2" ]; then
42 # Set pkg basename for install, extract
43 PACKAGE=$(basename ${2%.tazpkg} 2>/dev/null)
44 else
45 # Pkg name for remove, search and all other cmds
46 PACKAGE=${2%.tazpkg}
47 fi
48 PACKAGE_FILE=$2
49 TARGET_DIR=$3
50 TOP_DIR=`pwd`
51 TMP_DIR=/tmp/tazpkg-$$-$RANDOM
53 # Path to tazpkg used dir and configuration files
54 LOCALSTATE=/var/lib/tazpkg
55 INSTALLED=$LOCALSTATE/installed
56 CACHE_DIR=/var/cache/tazpkg
57 MIRROR=$LOCALSTATE/mirror
58 PACKAGES_LIST=$LOCALSTATE/packages.list
59 BLOCKED=$LOCALSTATE/blocked-packages.list
60 DEFAULT_MIRROR="http://download.tuxfamily.org/slitaz/packages/`cat /etc/slitaz-release`/"
62 # Bold red warnig for upgrade.
63 WARNING="\\033[1;31mWARNING\\033[0;39m"
65 # Check if the directories and files used by Tazpkg
66 # exists. If not and user is root we creat them.
67 if test $(id -u) = 0 ; then
68 if [ ! -d "$CACHE_DIR" ]; then
69 mkdir -p $CACHE_DIR
70 fi
71 if [ ! -d "$INSTALLED" ]; then
72 mkdir -p $INSTALLED
73 fi
74 if [ ! -f "$LOCALSTATE/mirror" ]; then
75 echo "$DEFAULT_MIRROR" > $LOCALSTATE/mirror
76 fi
77 fi
79 ####################
80 # Script functions #
81 ####################
83 # Print the usage.
84 usage ()
85 {
86 echo -e "SliTaz packages manager - Version: $VERSION\n
87 \033[1mUsage:\033[0m tazpkg [command] [package|dir|pattern|list|cat|--opt] [dir|--opt]
88 tazpkg shell\n
89 \033[1mCommands: \033[0m
90 usage Print this short usage.
91 list List installed packages on the system by category or all.
92 xhtml-list Creates a xHTML list of installed packges.
93 list-mirror List all available packages on the mirror (--diff for new).
94 info Print informations about the package.
95 desc Print description of a package (if it exist).
96 list-files List of files installed with the package.
97 search Search for a package by pattern or name (options: -i|-l|-m).
98 search-file Search for file(s) in all installed packages files.
99 install Install a local (*.tazpkg) package (--forced to force).
100 install-list Install all packages from a list of packages.
101 remove Remove the specified package and all installed files.
102 extract Extract a (*.tazpkg) package into a directory.
103 pack Pack an unpacked or prepared package tree.
104 recharge Recharge your packages.list from the mirror.
105 repack Creates a package archive from an installed package.
106 upgrade Upgrade all installed and listed packages on the mirror.
107 block|unblock Block an installed package version or unblock it for upgrade.
108 get Download a package into the current directory.
109 get-install Download and install a package from the mirror.
110 get-install-list Download and install a list of packages from the mirror.
111 check Verify installed packages concistancy.
112 add-flavor Install the flavor list of packages.
113 install-flavor Install the flavor list of packages and remove other ones.
114 set-release Change release and update packages
115 clean-cache Clean all packages downloaded in cache directory.
116 setup-mirror Change the mirror url configuration.
117 reconfigure Replay post install script from package."
118 }
120 # Status function with color (supported by Ash).
121 status()
122 {
123 local CHECK=$?
124 echo -en "\\033[70G[ "
125 if [ $CHECK = 0 ]; then
126 echo -en "\\033[1;33mOK"
127 else
128 echo -en "\\033[1;31mFailed"
129 fi
130 echo -e "\\033[0;39m ]"
131 return $CHECK
132 }
134 # Check if user is root to install, or remove packages.
135 check_root()
136 {
137 if test $(id -u) != 0 ; then
138 echo -e "\nYou must be root to run `basename $0` with this option."
139 echo -e "Please use 'su' and root password to become super-user.\n"
140 exit 0
141 fi
142 }
144 # Check for a package name on cmdline.
145 check_for_package_on_cmdline()
146 {
147 if [ -z "$PACKAGE" ]; then
148 echo -e "\nPlease specify a package name on the command line.\n"
149 exit 0
150 fi
151 }
153 # Check if the package (*.tazpkg) exist before installing or extracting.
154 check_for_package_file()
155 {
156 if [ ! -f "$PACKAGE_FILE" ]; then
157 echo -e "
158 Unable to find : $PACKAGE_FILE\n"
159 exit 0
160 fi
161 }
163 # Check for the receipt of an installed package.
164 check_for_receipt()
165 {
166 if [ ! -f "$INSTALLED/$PACKAGE/receipt" ]; then
167 echo -e "\nUnable to find the receipt : $INSTALLED/$PACKAGE/receipt\n"
168 exit 0
169 fi
170 }
172 # Check if a package is already installed.
173 check_for_installed_package()
174 {
175 if [ -d "$INSTALLED/${PACKAGE%-[0-9]*}" ]; then
176 echo -e "
177 $PACKAGE is already installed. You can use the --forced option to force
178 installation or remove it and reinstall.\n"
179 exit 0
180 fi
181 }
183 # Check for packages.list to download and install packages.
184 check_for_packages_list()
185 {
186 if [ ! -f "$LOCALSTATE/packages.list" ]; then
187 if test $(id -u) = 0 ; then
188 tazpkg recharge
189 else
190 echo -e "
191 Unable to find the list : $LOCALSTATE/packages.list\n
192 You must probably run 'tazpkg recharge' as root to get the last list of
193 packages avalaible on the mirror.\n"
194 exit 0
195 fi
196 fi
197 }
199 # Check for a package in packages.list. Used by get and get-install to grep
200 # package basename.
201 check_for_package_in_list()
202 {
203 if grep -q "^$PACKAGE-[0-9]" $LOCALSTATE/packages.list; then
204 PACKAGE=`grep ^$PACKAGE-[0-9] $LOCALSTATE/packages.list`
205 else
206 echo -e "\nUnable to find : $PACKAGE in the mirrored packages list.\n"
207 exit 0
208 fi
209 }
211 # Download a file trying all mirrors
212 download()
213 {
214 for i in $(cat $MIRROR); do
215 wget $i$@ && break
216 done
217 }
219 # Extract a package with cpio and gzip.
220 extract_package()
221 {
222 echo -n "Extracting $PACKAGE... "
223 cpio -id < $PACKAGE.tazpkg && rm -f $PACKAGE.tazpkg
224 gzip -d fs.cpio.gz
225 echo -n "Extracting the pseudo fs... "
226 cpio -id < fs.cpio && rm fs.cpio
227 }
229 # This function install a package in the rootfs.
230 install_package()
231 {
232 ROOT=$1
233 if [ -n "$ROOT" ]; then
234 # get absolute path
235 ROOT=$(cd $ROOT; pwd)
236 fi
237 mkdir -p $TMP_DIR
238 echo ""
239 echo -e "\033[1mInstallation of :\033[0m $PACKAGE"
240 echo "================================================================================"
241 echo -n "Copying $PACKAGE... "
242 cp $PACKAGE_FILE $TMP_DIR
243 status
244 cd $TMP_DIR
245 extract_package
246 SELF_INSTALL=0
247 # Include temporary receipt to get the right variables.
248 . $PWD/receipt
249 if [ $SELF_INSTALL -ne 0 -a -n "$ROOT" ]; then
250 echo -n "Checking post install dependencies... "
251 [ -d "$INSTALLED/${PACKAGE%-[0-9]*}" ]
252 if ! status; then
253 echo "Please run 'tazpkg install $PACKAGE_FILE' and retry."
254 cd .. && rm -rf $TMP_DIR
255 exit 1
256 fi
257 fi
258 # Remember modified packages
259 for i in $(grep -v '\[' files.list); do
260 [ -e "$ROOT$i" ] || continue
261 [ -d "$ROOT$i" ] && continue
262 for j in $(grep -l "^$i$" $ROOT$INSTALLED/*/files.list); do
263 [ "$j" = "$ROOT$INSTALLED/$PACKAGE/files.list" ] && continue
264 grep -qs ^$PACKAGE$ $(dirname $j)/modifiers && continue
265 echo "$PACKAGE" >> $(dirname $j)/modifiers
266 done
267 done
268 # Make the installed package data dir to store
269 # the receipt and the files list.
270 mkdir -p $ROOT$INSTALLED/$PACKAGE
271 cp receipt files.list $ROOT$INSTALLED/$PACKAGE
272 # Copy the description if found.
273 if [ -f "description.txt" ]; then
274 cp description.txt $ROOT$INSTALLED/$PACKAGE
275 fi
276 # Pre install commands.
277 if grep -q ^pre_install $ROOT$INSTALLED/$PACKAGE/receipt; then
278 pre_install $ROOT
279 fi
280 echo -n "Installing $PACKAGE... "
281 cp -a fs/* $ROOT/
282 status
283 # Remove the temporary random directory.
284 echo -n "Removing all tmp files... "
285 cd .. && rm -rf $TMP_DIR
286 status
287 # Post install commands.
288 if grep -q ^post_install $ROOT$INSTALLED/$PACKAGE/receipt; then
289 post_install $ROOT
290 fi
291 cd $TOP_DIR
292 echo "================================================================================"
293 echo "$PACKAGE ($VERSION) is installed."
294 echo ""
295 }
297 # Check for missing deps listed in a receipt packages.
298 check_for_deps()
299 {
300 for i in $DEPENDS
301 do
302 if [ ! -d "$INSTALLED/$i" ]; then
303 MISSING_PACKAGE=$i
304 deps=$(($deps+1))
305 fi
306 done
307 if [ ! "$MISSING_PACKAGE" = "" ]; then
308 echo -e "\033[1mTracking dependencies for :\033[0m $PACKAGE"
309 echo "================================================================================"
310 for i in $DEPENDS
311 do
312 if [ ! -d "$INSTALLED/$i" ]; then
313 MISSING_PACKAGE=$i
314 echo "Missing : $MISSING_PACKAGE"
315 fi
316 done
317 echo "================================================================================"
318 echo "$deps missing package(s) to install."
319 fi
320 }
322 # Install all missing deps. First ask user then install all missing deps
323 # from local dir, cdrom, media or from the mirror. In case we want to
324 # install packages from local, we need a packages.list to find the version.
325 install_deps()
326 {
327 echo ""
328 echo -n "Install all missing dependencies (y/N) ? "; read anser
329 if [ "$anser" = "y" ]; then
330 for pkg in $DEPENDS
331 do
332 if [ ! -d "$INSTALLED/$pkg" ]; then
333 # We can install packages from a local dir by greping
334 # the TAZPKG_BASENAME in the local packages.list.
335 if [ -f "$TOP_DIR/packages.list" ]; then
336 echo "Checking if $pkg exist in local list... "
337 TAZPKG_BASENAME=`grep -e ^$pkg-[0-9] $TOP_DIR/packages.list`
338 if [ -f "$TAZPKG_BASENAME.tazpkg" ]; then
339 tazpkg install $TAZPKG_BASENAME.tazpkg
340 fi
341 # Install deps from the mirror.
342 else
343 if [ ! -f "$LOCALSTATE/packages.list" ]; then
344 tazpkg recharge
345 fi
346 tazpkg get-install $pkg
347 fi
348 fi
349 done
350 else
351 echo -e "\nLeaving dependencies for $PACKAGE unsolved."
352 echo -e "The package is installed but will probably not work.\n"
353 fi
354 }
356 # xHTML packages list header.
357 xhtml_header()
358 {
359 cat > $XHTML_LIST << _EOT_
360 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
361 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
362 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
363 <head>
364 <title>Installed packages list</title>
365 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
366 <meta name="modified" content="$DATE" />
367 <meta name="generator" content="Tazpkg" />
368 <style type="text/css"><!--
369 body { font: 12px sans-serif, vernada, arial; margin: 0; }
370 #header { background: #f0ba08; color: black; height: 50px;
371 border-top: 1px solid black; border-bottom: 1px solid black; }
372 #content { margin: 0px 50px 26px 50px; }
373 #footer { border-top: 1px solid black; padding-top: 10px;}
374 h1 { margin: 14px 0px 0px 16px; }
375 pre { padding-left: 5px; }
376 hr { color: white; background: white; height: 1px; border: 0; }
377 --></style>
378 </head>
379 <body bgcolor="#ffffff">
380 <div id="header">
381 <h1><font color="#3e1220">Installed packages list</font></h1>
382 </div>
383 <hr />
384 <!-- Start content -->
385 <div id="content">
387 <p>
388 _packages_ packages installed - List generated on : $DATE
389 <p>
391 _EOT_
392 }
394 # xHTML content with packages infos.
395 xhtml_pkg_info()
396 {
397 cat >> $XHTML_LIST << _EOT_
398 <h3>$PACKAGE</h3>
399 <pre>
400 Version : $VERSION
401 Short desc : $SHORT_DESC
402 Web site : <a href="$WEB_SITE">$WEB_SITE</a>
403 </pre>
405 _EOT_
406 }
408 # xHTML packages list footer.
409 xhtml_footer()
410 {
411 cat >> $XHTML_LIST << _EOT_
412 <hr />
413 <p id="footer">
414 $packages packages installed - List generated on : $DATE
415 </p>
417 <!-- End content -->
418 </div>
419 </body>
420 </html>
421 _EOT_
422 }
424 # Search pattern in installed packages.
425 search_in_installed_packages()
426 {
427 echo "Installed packages"
428 echo "================================================================================"
429 list=`ls -1 $INSTALLED | grep -i "$PATTERN"`
430 for pkg in $list
431 do
432 . $INSTALLED/$pkg/receipt
433 echo -n "$PACKAGE "
434 echo -en "\033[24G $VERSION"
435 echo -e "\033[42G $CATEGORY"
436 packages=$(($packages+1))
437 done
438 # Set correct ending messages.
439 if [ "$packages" = "" ]; then
440 echo "0 installed packages found for : $PATTERN"
441 echo ""
442 else
443 echo "================================================================================"
444 echo "$packages installed package(s) found for : $PATTERN"
445 echo ""
446 fi
447 }
449 # Search in packages.list for avalaible pkgs.
450 search_in_packages_list()
451 {
452 echo "Available packages name-version"
453 echo "================================================================================"
454 if [ -f "$LOCALSTATE/packages.list" ]; then
455 cat $LOCALSTATE/packages.list | grep -i "$PATTERN"
456 packages=`cat $LOCALSTATE/packages.list | grep "$PATTERN" | wc -l`
457 else
458 echo -e "
459 No 'packages.list' found to check for mirrored packages. For more results,
460 please run once 'tazpkg recharge' as root before searching.\n"
461 fi
462 if [ "$packages" = "0" ]; then
463 echo "0 available packages found for : $PATTERN"
464 echo ""
465 else
466 echo "================================================================================"
467 echo "$packages available package(s) found for : $PATTERN"
468 echo ""
469 fi
470 }
472 # search --mirror: Search in packages.txt for avalaible pkgs and give more
473 # infos than --list or default.
474 search_in_packages_txt()
475 {
476 echo "Matching packages name with version and desc"
477 echo "================================================================================"
478 if [ -f "$LOCALSTATE/packages.txt" ]; then
479 cat $LOCALSTATE/packages.txt | grep -A 2 "^$PATTERN"
480 packages=`cat $LOCALSTATE/packages.txt | grep -i "^$PATTERN" | wc -l`
481 else
482 echo -e "
483 No 'packages.txt' found to check for mirrored packages. For more results,
484 please run once 'tazpkg recharge' as root before searching.\n"
485 fi
486 if [ "$packages" = "0" ]; then
487 echo "0 available packages found for : $PATTERN"
488 echo ""
489 else
490 echo "================================================================================"
491 echo "$packages available package(s) found for : $PATTERN"
492 echo ""
493 fi
494 }
496 # Install package-list from a flavor
497 install_flavor()
498 {
499 check_root
500 FLAVOR=$1
501 ARG=$2
502 mkdir -p $TMP_DIR
503 [ -f $FLAVOR.flavor ] && cp $FLAVOR.flavor $TMP_DIR
504 cd $TMP_DIR
505 if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
506 zcat $FLAVOR.flavor | cpio -i 2>/dev/null
507 while read file; do
508 for pkg in $(ls -d $INSTALLED/${file%%-*}*); do
509 . $pkg/receipt
510 [ "$PACKAGE-$VERSION" = "$file" ] && break
511 done
512 [ "$PACKAGE-$VERSION" = "$file" ] && continue
513 cd $CACHE_DIR
514 download $file.tazpkg
515 cd $TMP_DIR
516 tazpkg install $CACHE_DIR/$file.tazpkg --forced
517 done < $FLAVOR.pkglist
518 [ "$ARG" == "--purge" ] && for pkg in $(ls $INSTALLED); do
519 [ -d $INSTALLED/$pkg ] || continue
520 . $INSTALLED/$pkg/receipt
521 grep -q ^$PACKAGE-$VERSION$ $FLAVOR.pkglist && continue
522 tazpkg remove $PACKAGE
523 done
524 else
525 echo "Can't find flavor $FLAVOR Abort."
526 fi
527 cd $TOP_DIR
528 rm -rf $TMP_DIR
529 }
531 ###################
532 # Tazpkg commands #
533 ###################
535 case "$COMMAND" in
536 list)
537 # List all installed packages or a specific category.
538 #
539 if [ "$2" = "blocked" ]; then
540 if [ -f $BLOCKED ]; then
541 LIST=`cat $BLOCKED`
542 fi
543 echo ""
544 echo -e "\033[1mBlocked packages\033[0m"
545 echo "================================================================================"
546 if [ -n $LIST ];then
547 echo $LIST
548 echo ""
549 else
550 echo -e "No blocked packages found.\n"
551 fi
552 exit 0
553 fi
554 # Display the list of categories.
555 if [ "$2" = "cat" -o "$2" = "categories" ]; then
556 echo ""
557 echo -e "\033[1mPackages categories :\033[0m"
558 echo "================================================================================"
559 for i in $CATEGORIES
560 do
561 echo $i
562 categories=$(($categories+1))
563 done
564 echo "================================================================================"
565 echo "$categories categories"
566 echo ""
567 exit 0
568 fi
569 # Check for an asked category.
570 if [ -n "$2" ]; then
571 ASKED_CATEGORY=$2
572 echo ""
573 echo -e "\033[1mInstalled packages of category :\033[0m $ASKED_CATEGORY"
574 echo "================================================================================"
575 for pkg in $INSTALLED/*
576 do
577 . $pkg/receipt
578 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
579 echo -n "$PACKAGE"
580 echo -e "\033[24G $VERSION"
581 packages=$(($packages+1))
582 fi
583 done
584 echo "================================================================================"
585 echo -e "$packages packages installed of category $ASKED_CATEGORY."
586 echo ""
587 else
588 # By default list all packages and version.
589 echo ""
590 echo -e "\033[1mList of all installed packages\033[0m"
591 echo "================================================================================"
592 for pkg in $INSTALLED/*
593 do
594 . $pkg/receipt
595 echo -n "$PACKAGE"
596 echo -en "\033[24G $VERSION"
597 echo -e "\033[42G $CATEGORY"
598 packages=$(($packages+1))
599 done
600 echo "================================================================================"
601 echo "$packages packages installed."
602 echo ""
603 fi
604 ;;
605 xhtml-list)
606 # Get infos in receipts and build list.
607 DATE=`date +%Y-%m-%d\ \%H:%M:%S`
608 if [ -n "$2" ]; then
609 XHTML_LIST=$2
610 else
611 XHTML_LIST=installed-packages.html
612 fi
613 echo ""
614 echo -e "\033[1mCreating xHTML list of installed packages\033[0m"
615 echo "================================================================================"
616 echo -n "Generating xHTML header..."
617 xhtml_header
618 status
619 # Packages
620 echo -n "Creating packages informations..."
621 for pkg in $INSTALLED/*
622 do
623 . $pkg/receipt
624 xhtml_pkg_info
625 packages=$(($packages+1))
626 done
627 status
628 echo -n "Generating xHTML footer..."
629 xhtml_footer
630 status
631 # sed pkgs nb in header.
632 sed -i s/'_packages_'/"$packages"/ $XHTML_LIST
633 echo "================================================================================"
634 echo "$XHTML_LIST created - $packages packages."
635 echo ""
636 ;;
637 list-mirror)
638 # List all available packages on the mirror. Option --diff display
639 # last mirrored packages diff (see recharge).
640 check_for_packages_list
641 case $2 in
642 --diff)
643 if [ -f "$LOCALSTATE/packages.diff" ]; then
644 echo ""
645 echo -e "\033[1mMirrored packages diff\033[0m"
646 echo "================================================================================"
647 cat $LOCALSTATE/packages.diff
648 echo "================================================================================"
649 pkgs=`cat $LOCALSTATE/packages.diff | wc -l`
650 echo "$pkgs new packages listed on the mirror."
651 echo ""
652 else
653 echo -e "\nUnable to list anything, no packages.diff found."
654 echo -e "Recharge your current list to creat a first diff.\n"
655 fi && exit 0 ;;
656 --text|--txt)
657 echo ""
658 echo -e "\033[1mList of available packages on the mirror\033[0m"
659 echo "================================================================================"
660 cat $LOCALSTATE/packages.txt ;;
661 --raw|*)
662 echo ""
663 echo -e "\033[1mList of available packages on the mirror\033[0m"
664 echo "================================================================================"
665 cat $LOCALSTATE/packages.list ;;
666 esac
667 echo "================================================================================"
668 pkgs=`cat $LOCALSTATE/packages.list | wc -l`
669 echo "$pkgs packages in the last recharged list."
670 echo ""
671 ;;
672 list-files)
673 # List files installed with the package.
674 #
675 check_for_package_on_cmdline
676 check_for_receipt
677 echo ""
678 echo -e "\033[1mInstalled files with :\033[0m $PACKAGE"
679 echo "================================================================================"
680 cat $INSTALLED/$PACKAGE/files.list | sort
681 echo "================================================================================"
682 files=`cat $INSTALLED/$PACKAGE/files.list | wc -l`
683 echo "$files files installed with $PACKAGE."
684 echo ""
685 ;;
686 info)
687 # Informations about package.
688 #
689 check_for_package_on_cmdline
690 check_for_receipt
691 . $INSTALLED/$PACKAGE/receipt
692 echo ""
693 echo -e "\033[1mTazpkg informations\033[0m
694 ================================================================================
695 Package : $PACKAGE
696 Version : $VERSION
697 Category : $CATEGORY
698 Short desc : $SHORT_DESC
699 Maintainer : $MAINTAINER"
700 if [ ! "$DEPENDS" = "" ]; then
701 echo -e "Depends : $DEPENDS"
702 fi
703 if [ ! "$SUGGESTED" = "" ]; then
704 echo -e "Suggested : $SUGGESTED"
705 fi
706 if [ ! "$BUILD_DEPENDS" = "" ]; then
707 echo -e "Build deps : $BUILD_DEPENDS"
708 fi
709 if [ ! "$WANTED" = "" ]; then
710 echo -e "Wanted src : $WANTED"
711 fi
712 if [ ! "$WEB_SITE" = "" ]; then
713 echo -e "Web site : $WEB_SITE"
714 fi
715 echo "================================================================================"
716 echo ""
717 ;;
718 desc)
719 # Display package description.txt if available.
720 if [ -f "$INSTALLED/$PACKAGE/description.txt" ]; then
721 echo ""
722 echo -e "\033[1mDescription of :\033[0m $PACKAGE"
723 echo "================================================================================"
724 cat $INSTALLED/$PACKAGE/description.txt
725 echo "================================================================================"
726 echo ""
727 else
728 echo -e "\nSorry, no description available for this package.\n"
729 fi
730 ;;
731 search)
732 # Search for a package by pattern or name.
733 #
734 PATTERN="$2"
735 if [ -z "$PATTERN" ]; then
736 echo -e "\nPlease specify a pattern or a package name to search."
737 echo -e "Example : 'tazpkg search paint'.\n"
738 exit 0
739 fi
740 echo ""
741 echo -e "\033[1mSearch result for :\033[0m $PATTERN"
742 echo ""
743 # Default is to search in installed pkgs and the raw list.
744 case $3 in
745 -i|--installed)
746 search_in_installed_packages ;;
747 -l|--list)
748 search_in_packages_list ;;
749 -m|--mirror)
750 search_in_packages_txt ;;
751 *)
752 search_in_installed_packages
753 search_in_packages_list ;;
754 esac
755 ;;
756 search-file)
757 # Search for a file by pattern or name in all files.list.
758 #
759 if [ -z "$2" ]; then
760 echo -e "\nPlease specify a pattern or a file name to search."
761 echo -e "Example : 'tazpkg search-file libnss'. \n"
762 exit 0
763 fi
764 echo ""
765 echo -e "\033[1mSearch result for file :\033[0m $2"
766 echo "================================================================================"
767 # Check all pkg files.list in search match with specify the package
768 # name and the full path to the file(s).
769 for pkg in $INSTALLED/*
770 do
771 if grep -q "$2" $pkg/files.list; then
772 . $pkg/receipt
773 echo ""
774 echo -e "\033[1mPackage $PACKAGE :\033[0m"
775 grep "$2" $pkg/files.list
776 files=`grep $2 $pkg/files.list | wc -l`
777 match=$(($match+$files))
778 fi
779 done
780 if [ "$match" = "" ]; then
781 echo "0 file found for : $2"
782 echo ""
783 else
784 echo ""
785 echo "================================================================================"
786 echo "$match file(s) found for : $2"
787 echo ""
788 fi
789 ;;
790 install)
791 # Install .tazpkg packages.
792 #
793 check_root
794 check_for_package_on_cmdline
795 check_for_package_file
796 # Check if forced install.
797 DO_CHECK="yes"
798 while [ -n "$3" ]; do
799 case "$3" in
800 --forced)
801 DO_CHECK="no"
802 ;;
803 --root=*)
804 install_package ${3#--root=}
805 exit $?
806 ;;
807 *) shift 2
808 echo -e "\nUnknown option $*.\n"
809 exit 1
810 ;;
811 esac
812 shift
813 done
814 if [ "$DO_CHECK" = "yes" ]; then
815 check_for_installed_package
816 fi
817 install_package
818 # Resolv package deps.
819 check_for_deps
820 if [ ! "$MISSING_PACKAGE" = "" ]; then
821 install_deps
822 fi
823 ;;
824 install-list|get-install-list)
825 # Install a set of packages from a list.
826 #
827 check_root
828 if [ -z "$2" ]; then
829 echo -e "
830 Please change directory (cd) to the packages repository, and specify the
831 list of packages to install. Example : tazpkg install-list packages.list\n"
832 exit 0
833 fi
834 # Check if the packages list exist.
835 if [ ! -f "$2" ]; then
836 echo "Unable to find : $2"
837 exit 0
838 else
839 LIST=`cat $2`
840 fi
841 # Set $COMMAND and install all packages.
842 if [ "$1" = "get-install-list" ]; then
843 COMMAND=get-install
844 else
845 COMMAND=install
846 fi
847 for pkg in $LIST
848 do
849 if [ "$3" = "--forced" ]; then
850 tazpkg $COMMAND $pkg --forced
851 else
852 tazpkg $COMMAND $pkg
853 fi
854 done
855 ;;
856 add-flavor)
857 # Install a set of packages from a flavor.
858 #
859 install_flavor $2
860 ;;
861 install-flavor)
862 # Install a set of packages from a flavor and purge other ones.
863 #
864 install_flavor $2 --purge
865 ;;
866 set-release)
867 # Change curent release and upgrade packages.
868 #
869 RELEASE=$2
870 rm /var/lib/tazpkg/mirror
871 echo "$RELEASE" > /etc/slitaz-release
872 tazpkg recharge && tazpkg upgrade
873 ;;
874 remove)
875 # Remove packages.
876 #
877 check_root
878 check_for_package_on_cmdline
879 if [ ! -d "$INSTALLED/$PACKAGE" ]; then
880 echo -e "\n$PACKAGE is not installed.\n"
881 exit 0
882 else
883 ALTERED=""
884 THE_PACKAGE=$PACKAGE # altered by receipt
885 for i in $(cd $INSTALLED ; ls); do
886 DEPENDS=""
887 . $INSTALLED/$i/receipt
888 case " $(echo $DEPENDS) " in
889 *\ $THE_PACKAGE\ *) ALTERED="$ALTERED $i";;
890 esac
891 done
892 . $INSTALLED/$THE_PACKAGE/receipt
893 fi
894 echo ""
895 if [ -n "$ALTERED" ]; then
896 echo "The following packages depend on $PACKAGE :"
897 for i in $ALTERED; do
898 echo " $i"
899 done
900 fi
901 echo "Remove $PACKAGE ($VERSION) ?"
902 echo -n "Please confirm uninstallation (y/N) : "; read anser
903 if [ "$anser" = "y" ]; then
904 echo ""
905 echo -e "\033[1mRemoving :\033[0m $PACKAGE"
906 echo "================================================================================"
907 # Pre remove commands.
908 if grep -q ^pre_remove $INSTALLED/$PACKAGE/receipt; then
909 pre_remove
910 fi
911 echo -n "Removing all files installed..."
912 for file in `cat $INSTALLED/$PACKAGE/files.list`
913 do
914 [ $(grep ^$file$ $INSTALLED/*/files.list | wc -l) -gt 1 ] && continue
915 rm -f $file 2>/dev/null
916 done
917 status
918 if grep -q ^post_remove $INSTALLED/$PACKAGE/receipt; then
919 post_remove
920 fi
921 # Remove package receipt.
922 echo -n "Removing package receipt..."
923 rm -rf $INSTALLED/$PACKAGE
924 status
925 if [ -n "$ALTERED" ]; then
926 echo -n "Remove packages depending on $PACKAGE"
927 echo -n " (y/N) ? "; read anser
928 if [ "$anser" = "y" ]; then
929 for i in $ALTERED; do
930 if [ -d "$INSTALLED/$i" ]; then
931 tazpkg remove $i
932 fi
933 done
934 fi
935 fi
936 else
937 echo ""
938 echo "Uninstallation of $PACKAGE cancelled."
939 fi
940 echo ""
941 ;;
942 extract)
943 # Extract .tazpkg cpio archive into a directory.
944 #
945 check_for_package_on_cmdline
946 check_for_package_file
947 echo ""
948 echo -e "\033[1mExtracting :\033[0m $PACKAGE"
949 echo "================================================================================"
950 # If any directory destination is found on the cmdline
951 # we creat one in the current dir using the package name.
952 if [ -n "$TARGET_DIR" ]; then
953 DESTDIR=$TARGET_DIR/$PACKAGE
954 else
955 DESTDIR=$PACKAGE
956 fi
957 mkdir -p $DESTDIR
958 echo -n "Copying original package..."
959 cp $PACKAGE_FILE $DESTDIR
960 status
961 cd $DESTDIR
962 extract_package
963 echo "================================================================================"
964 echo "$PACKAGE is extracted to : $DESTDIR"
965 echo ""
966 ;;
967 repack)
968 # Creat SliTaz package archive from an installed package.
969 #
970 check_for_package_on_cmdline
971 check_for_receipt
972 eval $(grep ^VERSION= $INSTALLED/$PACKAGE/receipt)
973 echo ""
974 echo -e "\033[1mRepacking :\033[0m $PACKAGE-$VERSION.tazpkg"
975 echo "================================================================================"
976 if grep -qs ^NO_REPACK= $INSTALLED/$PACKAGE/receipt; then
977 echo "Can't repack $PACKAGE"
978 exit 1
979 fi
980 if [ -s $INSTALLED/$PACKAGE/modifiers ]; then
981 echo "Can't repack, $PACKAGE files have been modified by:"
982 for i in $(cat $INSTALLED/$PACKAGE/modifiers); do
983 echo " $i"
984 done
985 exit 1
986 fi
987 MISSING=""
988 while read i; do
989 [ -e "$i" ] && continue
990 [ -L "$i" ] || MISSING="$MISSING\n $i"
991 done < $INSTALLED/$PACKAGE/files.list
992 if [ -n "$MISSING" ]; then
993 echo -n "Can't repack, the following files are lost:"
994 echo -e "$MISSING"
995 exit 1
996 fi
997 mkdir -p $TMP_DIR && cd $TMP_DIR
998 FILES="fs.cpio.gz\n"
999 for i in $(ls $INSTALLED/$PACKAGE) ; do
1000 cp $INSTALLED/$PACKAGE/$i . && FILES="$FILES$i\n"
1001 done
1002 ln -s / rootfs
1003 mkdir tmp
1004 sed 's/^/rootfs/' < files.list | cpio -o -H newc 2>/dev/null |\
1005 ( cd tmp ; cpio -id 2>/dev/null )
1006 mv tmp/rootfs fs
1007 find fs | cpio -o -H newc 2> /dev/null | gzip -9 > fs.cpio.gz
1008 echo -e "$FILES" | cpio -o -H newc 2> /dev/null > \
1009 $TOP_DIR/$PACKAGE-$VERSION.tazpkg
1010 cd $TOP_DIR
1011 \rm -R $TMP_DIR
1012 echo "Package $PACKAGE repacked successfully."
1013 echo "Size : `du -sh $PACKAGE-$VERSION.tazpkg`"
1014 echo ""
1015 ;;
1016 pack)
1017 # Creat SliTaz package archive using cpio and gzip.
1019 check_for_package_on_cmdline
1020 cd $PACKAGE
1021 if [ ! -f "receipt" ]; then
1022 echo "Receipt is missing. Please read the documentation."
1023 exit 0
1024 else
1025 echo ""
1026 echo -e "\033[1mPacking :\033[0m $PACKAGE"
1027 echo "================================================================================"
1028 # Creat files.list with redirecting find outpout.
1029 echo -n "Creating the list of files..." && cd fs
1030 find . -type f -print > ../files.list
1031 find . -type l -print >> ../files.list
1032 cd .. && sed -i s/'^.'/''/ files.list
1033 status
1034 # Build cpio archives.
1035 echo -n "Compressing the fs... "
1036 find fs -print | cpio -o -H newc > fs.cpio
1037 gzip fs.cpio && rm -rf fs
1038 echo -n "Creating full cpio archive... "
1039 find . -print | cpio -o -H newc > ../$PACKAGE.tazpkg
1040 echo -n "Restoring original package tree... "
1041 gzip -d fs.cpio.gz && cpio -id < fs.cpio
1042 rm fs.cpio && cd ..
1043 echo "================================================================================"
1044 echo "Package $PACKAGE compressed successfully."
1045 echo "Size : `du -sh $PACKAGE.tazpkg`"
1046 echo ""
1047 fi
1048 ;;
1049 recharge)
1050 # Recharge packages.list from a mirror.
1052 check_root
1053 cd $LOCALSTATE
1054 echo ""
1055 if [ -f "$LOCALSTATE/packages.list" ]; then
1056 echo -n "Creating backup of the last packages list..."
1057 mv -f packages.txt packages.txt.bak 2>/dev/null
1058 mv -f packages.list packages.list.bak
1059 status
1060 fi
1061 download packages.txt
1062 download packages.list
1063 if [ -f "$LOCALSTATE/packages.list.bak" ]; then
1064 diff -u packages.list.bak packages.list | grep ^+[a-z] > packages.diff
1065 sed -i s/+// packages.diff
1066 echo ""
1067 echo -e "\033[1mMirrored packages diff\033[0m"
1068 echo "================================================================================"
1069 cat packages.diff
1070 if [ ! "`cat packages.diff | wc -l`" = 0 ]; then
1071 echo "================================================================================"
1072 echo "`cat packages.diff | wc -l` new packages on the mirror."
1073 echo ""
1074 else
1075 echo "`cat packages.diff | wc -l` new packages on the mirror."
1076 echo ""
1077 fi
1078 else
1079 echo -e "
1080 ================================================================================
1081 Last packages.list is ready to use. Note that next time you recharge the list,
1082 a list of differencies will be displayed to show new and upgradable packages.\n"
1083 fi
1084 ;;
1085 upgrade)
1086 # Upgrade all installed packages with the new version from the mirror.
1088 check_root
1089 check_for_packages_list
1090 cd $LOCALSTATE
1091 # Touch the blocked pkgs list to avoid errors and remove any old
1092 # upgrade list.
1093 touch blocked-packages.list
1094 rm -f upradable-packages.list
1095 echo ""
1096 echo -e "\033[1mAvalaible upgrade\033[0m"
1097 echo "================================================================================"
1098 echo ""
1099 # Some packages must be installed first
1100 FIRST_CLASS_PACKAGE=" glibc-base "
1101 FIRST_CLASS=""
1102 for pkg in $INSTALLED/*
1103 do
1104 . $pkg/receipt
1105 # Diplay package name to show that Tazpkg is working...
1106 echo -en "\\033[0G "
1107 echo -en "\\033[0G$PACKAGE"
1108 # Skip specified pkgs listed in $LOCALSTATE/blocked-packages.list
1109 if grep -q "^$PACKAGE" $BLOCKED; then
1110 blocked=$(($blocked+1))
1111 else
1112 # Check if the installed package is in the current list (other
1113 # mirror or local).
1114 if grep -q "^$PACKAGE-[0-9]" packages.list; then
1115 # Set new pkg and version for futur comparaison
1116 NEW_PACKAGE=`grep ^$PACKAGE-[0-9] packages.list`
1117 NEW_VERSION=`echo $NEW_PACKAGE | sed s/$PACKAGE-/''/`
1118 # Change '-' and 'pre' to points.
1119 NEW_VERSION=`echo $NEW_VERSION | sed s/'-'/'.'/`
1120 VERSION=`echo $VERSION | sed s/'-'/'.'/`
1121 NEW_VERSION=`echo $NEW_VERSION | sed s/'pre'/'.'/`
1122 VERSION=`echo $VERSION | sed s/'pre'/'.'/`
1123 # Compare version. Upgrade are only avalaible for official
1124 # packages, so we control de mirror and it should be ok if
1125 # we just check for egality.
1126 if [ "$VERSION" != "$NEW_VERSION" ]; then
1127 # Version seems different. Check for major, minor or
1128 # revision
1129 PKG_MAJOR=`echo $VERSION | cut -f1 -d"."`
1130 NEW_MAJOR=`echo $NEW_VERSION | cut -f1 -d"."`
1131 PKG_MINOR=`echo $VERSION | cut -f2 -d"."`
1132 NEW_MINOR=`echo $NEW_VERSION | cut -f2 -d"."`
1133 # Minor
1134 if [ "$NEW_MINOR" -gt "$PKG_MINOR" ]; then
1135 RELEASE=minor
1136 fi
1137 if [ "$NEW_MINOR" -lt "$PKG_MINOR" ]; then
1138 RELEASE=$WARNING
1139 FIXE=yes
1140 fi
1141 # Major
1142 if [ "$NEW_MAJOR" -gt "$PKG_MAJOR" ]; then
1143 RELEASE=major
1144 FIXE=""
1145 fi
1146 if [ "$NEW_MAJOR" -lt "$PKG_MAJOR" ]; then
1147 RELEASE=$WARNING
1148 FIXE=yes
1149 fi
1150 # Default to revision.
1151 if [ -z $RELEASE ]; then
1152 RELEASE=revision
1153 fi
1154 # Pkg name is already displayed by the check process.
1155 echo -en "\033[24G $VERSION"
1156 echo -en "\033[38G --->"
1157 echo -en "\033[43G $NEW_VERSION"
1158 echo -en "\033[58G $CATEGORY"
1159 echo -e "\033[72G $RELEASE"
1160 up=$(($up+1))
1161 echo "$PACKAGE" >> upradable-packages.list
1162 case "$FIRST_CLASS_PACKAGE" in
1163 *\ $PACKAGE\ *) FIRST_CLASS="$FIRST_CLASS $PACKAGE";;
1164 esac
1165 unset RELEASE
1166 fi
1167 packages=$(($packages+1))
1168 fi
1169 fi
1170 done
1171 if [ -z $blocked ]; then
1172 blocked=0
1173 fi
1174 # Clean last checked package and display summary.
1175 if [ ! "$up" = "" ]; then
1176 echo -e "\\033[0G "
1177 echo "================================================================================"
1178 echo "$packages installed and listed packages to consider, $up to upgrade, $blocked blocked."
1179 echo ""
1180 else
1181 echo -e "\\033[0GSystem is up to date. "
1182 echo ""
1183 echo "================================================================================"
1184 echo "$packages installed and listed packages to consider, 0 to upgrade, $blocked blocked."
1185 echo ""
1186 exit 0
1187 fi
1188 # What to do if major or minor version is smaller.
1189 if [ "$FIXE" == "yes" ]; then
1190 echo -e "$WARNING ---> Installed package seems more recent than the mirrored one."
1191 echo "You can block packages using the command : 'tazpkg block package'"
1192 echo "Or upgrade package at you own risks."
1193 echo ""
1194 fi
1195 # Ask for upgrade, it can be done an other time.
1196 echo -n "Upgrade now (y/N) ? "; read anser
1197 if [ ! "$anser" = "y" ]; then
1198 echo -e "\nExiting. No package upgraded.\n"
1199 exit 0
1200 fi
1201 # If anser is yes (y). Install all new version.
1202 for pkg in $FIRST_CLASS `cat upradable-packages.list`
1203 do
1204 tazpkg get-install $pkg --forced
1205 done
1206 ;;
1207 check)
1208 # check installed packages set.
1210 check_root
1211 cd $INSTALLED
1212 for PACKAGE in `ls`; do
1213 DEPENDS=""
1214 . $PACKAGE/receipt
1215 if [ -s $PACKAGE/modifiers ]; then
1216 echo "The package $PACKAGE $VERSION has been modified by :"
1217 for i in $(cat $PACKAGE/modifiers); do
1218 echo " $i"
1219 done
1220 fi
1221 MSG="Files lost from $PACKAGE $VERSION :\n"
1222 while read file; do
1223 [ -e "$file" ] && continue
1224 if [ -L "$file" ]; then
1225 MSG="$MSG target of symlink"
1226 fi
1227 echo -e "$MSG $file"
1228 MSG=""
1229 done < $PACKAGE/files.list
1230 MSG="Missing dependencies for $PACKAGE $VERSION :\n"
1231 for i in $DEPENDS; do
1232 [ -d $i ] && continue
1233 echo -e "$MSG $i"
1234 MSG=""
1235 done
1236 done
1237 if [ "$PACKAGE_FILE" = "--full" ]; then
1238 FILES=" "
1239 for file in $(cat */files.list); do
1240 [ -d "$file" ] && continue
1241 case "$FILES" in *\ $file\ *) continue;; esac
1242 [ $(grep "^$file$" */files.list 2> /dev/null | \
1243 wc -l) -gt 1 ] || continue
1244 FILES="$FILES$file "
1245 echo "The following packages provide $file :"
1246 grep -l "^$file$" */files.list | while read f
1247 do
1248 pkg=${f%/files.list}
1249 echo -n " $pkg"
1250 if [ -f $pkg/modifiers ]; then
1251 echo -n " (known as overridden by $(cat $pkg/modifiers))"
1252 fi
1253 echo ""
1254 done
1255 done
1256 MSG="No package has installed the following files:\n"
1257 find /etc /bin /sbin /lib /usr -not -type d | while read file; do
1258 case "$file" in *\[*) continue;; esac
1259 grep -q "^$file$" */files.list && continue
1260 echo -e "$MSG $file"
1261 MSG=""
1262 done
1263 fi
1264 echo "Check completed."
1265 ;;
1266 block)
1267 # Add a pkg name to the list of blocked packages.
1269 check_root
1270 check_for_package_on_cmdline
1271 echo ""
1272 if grep -q "^$PACKAGE" $BLOCKED; then
1273 echo "$PACKAGE is already in the blocked packages list."
1274 echo ""
1275 exit 0
1276 else
1277 echo -n "Add $PACKAGE to : $BLOCKED..."
1278 echo $PACKAGE >> $BLOCKED
1279 status
1280 fi
1281 echo ""
1282 ;;
1283 unblock)
1284 # Remove a pkg name to the list of blocked packages.
1286 check_root
1287 check_for_package_on_cmdline
1288 echo ""
1289 if grep -q "^$PACKAGE" $BLOCKED; then
1290 echo -n "Removing $PACKAGE from : $BLOCKED..."
1291 sed -i s/$PACKAGE/''/ $BLOCKED
1292 sed -i '/^$/d' $BLOCKED
1293 status
1294 else
1295 echo "$PACKAGE is not in the blocked packages list."
1296 echo ""
1297 exit 0
1298 fi
1299 echo ""
1300 ;;
1301 get)
1302 # Downlowd a package with wget.
1304 check_for_package_on_cmdline
1305 check_for_packages_list
1306 check_for_package_in_list
1307 echo ""
1308 download $PACKAGE.tazpkg
1309 echo ""
1310 ;;
1311 get-install)
1312 # Download and install a package.
1314 check_root
1315 check_for_package_on_cmdline
1316 check_for_packages_list
1317 check_for_package_in_list
1318 # Check if forced install.
1319 if [ "$3" = "--forced" ]; then
1320 rm -f $CACHE_DIR/$PACKAGE.tazpkg
1321 else
1322 check_for_installed_package
1323 fi
1324 cd $CACHE_DIR
1325 if [ -f "$PACKAGE.tazpkg" ]; then
1326 echo "$PACKAGE already in the cache : $CACHE_DIR"
1327 else
1328 echo ""
1329 download $PACKAGE.tazpkg
1330 fi
1331 PACKAGE_FILE=$CACHE_DIR/$PACKAGE.tazpkg
1332 install_package
1333 check_for_deps
1334 if [ ! "$MISSING_PACKAGE" = "" ]; then
1335 install_deps
1336 fi
1337 ;;
1338 clean-cache)
1339 # Remove all downloaded packages.
1341 check_root
1342 files=`ls -1 $CACHE_DIR | wc -l`
1343 echo ""
1344 echo -e "\033[1mClean cache :\033[0m $CACHE_DIR"
1345 echo "================================================================================"
1346 echo -n "Cleaning cache directory..."
1347 rm -rf $CACHE_DIR/*
1348 status
1349 echo "================================================================================"
1350 echo "$files file(s) removed from cache."
1351 echo ""
1352 ;;
1353 setup-mirror)
1354 # Change mirror URL.
1356 check_root
1357 # Backup old list.
1358 if [ -f "$LOCALSTATE/mirror" ]; then
1359 cp -f $LOCALSTATE/mirror $LOCALSTATE/mirror.bak
1360 fi
1361 echo ""
1362 echo -e "\033[1mCurrent mirror(s)\033[0m"
1363 echo "================================================================================"
1364 echo " `cat $MIRROR`"
1365 echo "
1366 Please enter URL of the new mirror (http or ftp). You must specify the complet
1367 address to the directory of the packages and packages.list file."
1368 echo ""
1369 echo -n "New mirror URL : "
1370 read NEW_MIRROR_URL
1371 if [ "$NEW_MIRROR_URL" = "" ]; then
1372 echo "Nothing as been change."
1373 else
1374 echo "Setting mirror(s) to : $NEW_MIRROR_URL"
1375 echo "$NEW_MIRROR_URL" > $LOCALSTATE/mirror
1376 fi
1377 echo ""
1378 ;;
1379 reconfigure)
1380 # Replay post_install from receipt
1382 check_for_package_on_cmdline
1383 check_root
1384 if [ -d "$INSTALLED/$PACKAGE" ]; then
1385 check_for_receipt
1386 # Check for post_install
1387 if grep -q ^post_install $INSTALLED/$PACKAGE/receipt; then
1388 . $INSTALLED/$PACKAGE/receipt
1389 post_install
1390 else
1391 echo -e "\nNothing to do for $PACKAGE."
1392 fi
1393 else
1394 echo -e "\npackage $PACKAGE is not installed."
1395 echo -e "Install package with 'tazpkg install' or 'tazpkg get-install'\n"
1396 fi
1397 ;;
1398 shell)
1399 # Tazpkg SHell
1401 if test $(id -u) = 0 ; then
1402 PROMPT="\\033[1;33mtazpkg\\033[0;39m# "
1403 else
1404 PROMPT="\\033[1;33mtazpkg\\033[0;39m> "
1405 fi
1406 if [ ! "$2" = "--noheader" ]; then
1407 clear
1408 echo ""
1409 echo -e "\033[1mTazpkg SHell.\033[0m"
1410 echo "================================================================================"
1411 echo "Type 'usage' to list all avalaible commands and 'quit' or 'q' to exit."
1412 echo ""
1413 fi
1414 while true
1415 do
1416 echo -en "$PROMPT"; read cmd
1417 case $cmd in
1418 q|quit)
1419 break ;;
1420 shell)
1421 echo "You are already running a Tazpkg SHell." ;;
1422 su)
1423 su -c 'exec tazpkg shell --noheader' && break ;;
1424 "")
1425 continue ;;
1426 *)
1427 tazpkg $cmd ;;
1428 esac
1429 done
1430 ;;
1431 usage|*)
1432 # Print a short help or give usage for an unknow or empty command.
1434 usage
1435 ;;
1436 esac
1438 exit 0