tazpkg rev 406

Use library libtaz, libtaz/commons; use can now use several option at the same time with install/get-install
author Antoine Bodin <gokhlayeh@slitaz.org>
date Tue Jan 25 00:01:48 2011 +0100 (2011-01-25)
parents 7c7613903abe
children 0f3501c4d867
files tazpkg tazpkg.conf
line diff
     1.1 --- a/tazpkg	Mon Jan 24 22:47:08 2011 +0100
     1.2 +++ b/tazpkg	Tue Jan 25 00:01:48 2011 +0100
     1.3 @@ -27,6 +27,8 @@
     1.4  # Script variables #
     1.5  ####################
     1.6  
     1.7 +source /usr/lib/slitaz/libtaz
     1.8 +source_lib commons
     1.9  . /etc/slitaz/tazpkg.conf
    1.10  
    1.11  # Include gettext helper script.
    1.12 @@ -49,6 +51,7 @@
    1.13  PACKAGE_FILE=$2
    1.14  TARGET_DIR=$3
    1.15  TOP_DIR=`pwd`
    1.16 +TMP_DIR=$tmp/$RANDOM
    1.17  INSTALL_LIST=""
    1.18  
    1.19  # Path to tazpkg used dir and configuration files
    1.20 @@ -60,12 +63,8 @@
    1.21  # Check if the directories and files used by Tazpkg
    1.22  # exist. If not and user is root we create them.
    1.23  if test $(id -u) = 0 ; then
    1.24 -	if [ ! -d "$CACHE_DIR" ]; then
    1.25 -		mkdir -p $CACHE_DIR
    1.26 -	fi
    1.27 -	if [ ! -d "$INSTALLED" ]; then
    1.28 -		mkdir -p $INSTALLED
    1.29 -	fi
    1.30 +	check_dir $CACHE_DIR
    1.31 +	check_dir $INSTALLED
    1.32  	if [ ! -f "$LOCALSTATE/mirror" ]; then
    1.33  		echo "$DEFAULT_MIRROR" > $LOCALSTATE/mirror
    1.34  	fi
    1.35 @@ -126,32 +125,6 @@
    1.36    reconfigure      `gettext \"Replay post install script from package.\"`"
    1.37  }
    1.38  
    1.39 -# Status function with color (supported by Ash).
    1.40 -status()
    1.41 -{
    1.42 -	local CHECK=$?
    1.43 -	echo -en "\\033[70G[ "
    1.44 -	if [ $CHECK = 0 ]; then
    1.45 -		echo -en "\\033[1;33m`gettext \"OK\"`"
    1.46 -	else
    1.47 -		echo -en "\\033[1;31m`gettext \"Failed\"`"
    1.48 -	fi
    1.49 -	echo -e "\\033[0;39m ]"
    1.50 -	return $CHECK
    1.51 -}
    1.52 -
    1.53 -# Check if user is root to install, or remove packages.
    1.54 -check_root()
    1.55 -{
    1.56 -	if test $(id -u) != 0 ; then
    1.57 -		echo
    1.58 -		gettext \
    1.59 -"You must be root to run tazpkg with this option. Please use the command:
    1.60 -su followed by the root password to become super-user."; echo
    1.61 -		echo "" && exit 0
    1.62 -	fi
    1.63 -}
    1.64 -
    1.65  # Check for a package name on cmdline.
    1.66  check_for_package_on_cmdline()
    1.67  {
    1.68 @@ -1756,28 +1729,14 @@
    1.69  		
    1.70  		# Get repositories priority list.
    1.71  		look_for_priority
    1.72 +		get_options_list="root forced list"
    1.73 +		get_options
    1.74  		
    1.75  		# Check if forced install.
    1.76  		DO_CHECK="yes"
    1.77 -		ROOT=""
    1.78 -		while [ -n "$3" ]; do
    1.79 -			case "$3" in
    1.80 -			--forced)
    1.81 -				DO_CHECK="no"
    1.82 -				;;
    1.83 -			--root=*)
    1.84 -				ROOT="${3#--root=}"
    1.85 -				;;
    1.86 -			--list=*)
    1.87 -				INSTALL_LIST="${3#--list=}"
    1.88 -				;;
    1.89 -			*)	shift 2
    1.90 -				echo -e "\n`gettext \"Unknow option\"` $*.\n" >&2
    1.91 -				exit 1
    1.92 -				;;
    1.93 -			esac
    1.94 -			shift
    1.95 -		done
    1.96 +		[ "$forced" ] && DO_CHECK=no
    1.97 +		[ "$root" ] && ROOT="$root"
    1.98 +		[ "$list" ] && INSTALL_LIST="$list"
    1.99  		if [ "$DO_CHECK" = "yes" ]; then
   1.100  			check_for_installed_package $ROOT
   1.101  		fi
   1.102 @@ -2638,26 +2597,13 @@
   1.103  		
   1.104  		# Get repositories priority list.
   1.105  		look_for_priority
   1.106 +		get_options_list="root forced list"
   1.107 +		get_options
   1.108  		
   1.109  		DO_CHECK=""
   1.110 -		while [ -n "$3" ]; do
   1.111 -			case "$3" in
   1.112 -			--forced)
   1.113 -				DO_CHECK="no"
   1.114 -				;;
   1.115 -			--root=*)
   1.116 -				ROOT="${3#--root=}"
   1.117 -				;;
   1.118 -			--list=*)
   1.119 -				INSTALL_LIST="${3#--list=}"
   1.120 -				;;
   1.121 -			*)	shift 2
   1.122 -				echo -e "\n`gettext \"Unknow option\"` $*.\n" >&2
   1.123 -				exit 1
   1.124 -				;;
   1.125 -			esac
   1.126 -			shift
   1.127 -		done
   1.128 +		[ "$forced" ] && DO_CHECK=no
   1.129 +		[ "$root" ] && ROOT="$root"
   1.130 +		[ "$list" ] && INSTALL_LIST="$list"
   1.131  		AUTOEXEC="no"
   1.132  		if ! check_for_package_in_list check; then
   1.133  			PACKAGE=get-$PACKAGE
     2.1 --- a/tazpkg.conf	Mon Jan 24 22:47:08 2011 +0100
     2.2 +++ b/tazpkg.conf	Tue Jan 25 00:01:48 2011 +0100
     2.3 @@ -4,31 +4,5 @@
     2.4  # Auto-installation of packages dependencies.
     2.5  AUTO_INSTALL_DEPS="yes"
     2.6  
     2.7 -# Path to all packages meta files (lists, receipt, desc).
     2.8 -LOCALSTATE="/var/lib/tazpkg"
     2.9 -
    2.10 -# Path to downloaded packages by get-install command.
    2.11 -CACHE_DIR="/var/cache/tazpkg"
    2.12 -
    2.13  # Path to Tazpkg log file.
    2.14  LOG="/var/log/tazpkg.log"
    2.15 -
    2.16 -# Path to the temporary directory used to extract packages.
    2.17 -TMP_DIR="/tmp/tazpkg-$$-$RANDOM"
    2.18 -
    2.19 -# Packages categories.
    2.20 -CATEGORIES="
    2.21 -base-system
    2.22 -x-window
    2.23 -utilities
    2.24 -network
    2.25 -graphics
    2.26 -multimedia
    2.27 -office
    2.28 -development
    2.29 -system-tools
    2.30 -security
    2.31 -games
    2.32 -misc
    2.33 -meta
    2.34 -non-free"