tazpkg rev 55

Add: Tazpkg SHell mode
author Christophe Lincoln <pankso@slitaz.org>
date Wed Feb 27 23:43:51 2008 +0100 (2008-02-27)
parents 549f4948508b
children aed5e37e0662
files tazpkg
line diff
     1.1 --- a/tazpkg	Wed Feb 27 19:12:12 2008 +0100
     1.2 +++ b/tazpkg	Wed Feb 27 23:43:51 2008 +0100
     1.3 @@ -67,10 +67,10 @@
     1.4  		mkdir -p $CACHE_DIR
     1.5  	fi
     1.6  	if [ ! -d "$INSTALLED" ]; then
     1.7 -	  mkdir -p $INSTALLED
     1.8 +		mkdir -p $INSTALLED
     1.9  	fi
    1.10  	if [ ! -f "$LOCALSTATE/mirror" ]; then
    1.11 -	  echo "$DEFAULT_MIRROR" > $LOCALSTATE/mirror
    1.12 +		echo "$DEFAULT_MIRROR" > $LOCALSTATE/mirror
    1.13  	fi
    1.14  fi
    1.15  
    1.16 @@ -81,8 +81,9 @@
    1.17  # Print the usage.
    1.18  usage ()
    1.19  {
    1.20 -	echo -e "SliTaz packages manager - Version: $VERSION
    1.21 -\033[1mUsage: \033[0m tazpkg [command] [package|dir|pattern|list|cat|--opt] [dir|--opt]
    1.22 +	echo -e "SliTaz packages manager - Version: $VERSION\n
    1.23 +\033[1mUsage:\033[0m tazpkg [command] [package|dir|pattern|list|cat|--opt] [dir|--opt]
    1.24 +       tazpkg shell\n
    1.25  \033[1mCommands: \033[0m
    1.26    usage         Print this short usage.
    1.27    list          List installed packages on the system by category or all.
    1.28 @@ -128,7 +129,7 @@
    1.29  {
    1.30  	if test $(id -u) != 0 ; then
    1.31  		echo -e "\nYou must be root to run `basename $0` with this option."
    1.32 -		echo -e "Please type 'su' and root password to become super-user.\n"
    1.33 +		echo -e "Please use 'su' and root password to become super-user.\n"
    1.34  		exit 0
    1.35  	fi
    1.36  }
    1.37 @@ -1268,6 +1269,39 @@
    1.38  		fi
    1.39  		echo ""
    1.40  		;;
    1.41 +	shell)
    1.42 +		# Tazpkg SHell
    1.43 +		#
    1.44 +		if test $(id -u) = 0 ; then
    1.45 +			PROMPT="\\033[1;33mtazpkg\\033[0;39m# "
    1.46 +		else
    1.47 +			PROMPT="\\033[1;33mtazpkg\\033[0;39m> "
    1.48 +		fi
    1.49 +		if [ ! "$2" = "--noheader" ]; then
    1.50 +			clear
    1.51 +			echo ""
    1.52 +			echo -e "\033[1mTazpkg SHell.\033[0m"
    1.53 +			echo "================================================================================"
    1.54 +			echo "Type 'usage' to list all avalaible commands and 'quit' or 'q' to exit."
    1.55 +			echo ""
    1.56 +		fi
    1.57 +		while true
    1.58 +		do
    1.59 +			echo -en "$PROMPT"; read cmd
    1.60 +			case $cmd in
    1.61 +				q|quit)
    1.62 +					break ;;
    1.63 +				shell)
    1.64 +					echo "You are already running a Tazpkg SHell." ;;
    1.65 +				su)
    1.66 +					su -c 'exec tazpkg shell --noheader' && break ;;
    1.67 +				"")
    1.68 +					continue ;;
    1.69 +				*)
    1.70 +					tazpkg $cmd ;;
    1.71 +			esac
    1.72 +		done
    1.73 +		;;
    1.74  	usage|*)
    1.75  		# Print a short help or give usage for an unknow or empty command.
    1.76  		#