tazpkg rev 694

Code reformatting: use '_' and '_n' gettext functions, split solid "text" into "chapters" and "paragraphs", tiny misc.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Mon Dec 01 01:06:57 2014 +0200 (2014-12-01)
parents 0dedae7db044
children 52d1418d89d7
files Makefile tazpkg
line diff
     1.1 --- a/Makefile	Fri Nov 21 14:41:44 2014 +0100
     1.2 +++ b/Makefile	Mon Dec 01 01:06:57 2014 +0200
     1.3 @@ -18,7 +18,7 @@
     1.4  pot:
     1.5  	xgettext -o po/tazpkg.pot -L Shell \
     1.6  		--package-name=TazPkg \
     1.7 -		--package-version="$(VERSION)" -kaction -ktitle \
     1.8 +		--package-version="$(VERSION)" -kaction -ktitle -k_ -k_n \
     1.9  		./tazpkg ./tazpkg-box ./pkgs ./pkgs.cgi ./tazpkg-notify
    1.10  
    1.11  msgmerge:
     2.1 --- a/tazpkg	Fri Nov 21 14:41:44 2014 +0100
     2.2 +++ b/tazpkg	Mon Dec 01 01:06:57 2014 +0200
     2.3 @@ -28,44 +28,61 @@
     2.4  
     2.5  # Internationalization.
     2.6  #. /usr/bin/gettext.sh
     2.7 -TEXTDOMAIN='tazpkg'
     2.8 -export TEXTDOMAIN
     2.9 +export TEXTDOMAIN='tazpkg'
    2.10 +
    2.11  
    2.12  #
    2.13  # Functions set for translate categories
    2.14  #
    2.15  
    2.16 +
    2.17  # No operations, only for xgettext collect
    2.18 +
    2.19  gettext_noop() {
    2.20 -	gettext "base-system"; gettext "x-window"; gettext "utilities";
    2.21 -	gettext "network"; gettext "graphics"; gettext "multimedia";
    2.22 -	gettext "office"; gettext "development"; gettext "system-tools";
    2.23 -	gettext "security"; gettext "games"; gettext "misc"; gettext "meta";
    2.24 -	gettext "non-free"
    2.25 +	_ 'base-system'; _ 'x-window'; _ 'utilities'; _ 'network'; _ 'graphics';
    2.26 +	_ 'multimedia'; _ 'office'; _ 'development'; _ 'system-tools'; _ 'security';
    2.27 +	_ 'games'; _ 'misc'; _ 'meta'; _ "non-free"
    2.28  }
    2.29 +
    2.30 +
    2.31  # Make array of pre-translated categories
    2.32 +
    2.33  cat_i18n=""
    2.34  for c in "base-system" "x-window" "utilities" "network" "graphics" "multimedia" "office" "development" "system-tools" "security" "games" "misc" "meta" "non-free"; do
    2.35  	cat_i18n="$cat_i18n
    2.36  $(gettext "$c")	$c"
    2.37  done
    2.38 +
    2.39 +
    2.40  # If category is not one of those translated in native language, keep it
    2.41  # untranslated. This allows both native and english language support.
    2.42  # This also supports custom categories.
    2.43  # And now we support spaces in translated categories
    2.44 +
    2.45  reverse_translate_category()
    2.46  {
    2.47  	echo "$cat_i18n" | awk "BEGIN{FS=\"	\"}{if (/^$@	/) a=\$2}END{if (a==\"\") a=\"$@\"; print a}"
    2.48  }
    2.49  
    2.50 +
    2.51 +
    2.52  #
    2.53  # TazPKG output functions
    2.54  #
    2.55 +
    2.56 +
    2.57  # Print localized title
    2.58 +
    2.59  title() { newline; boldify "$(eval_gettext "$1")"; separator; }
    2.60 +
    2.61 +
    2.62  # Print footer
    2.63 -footer() { separator; echo "$1"; newline; }
    2.64 +
    2.65 +footer() { separator; echo "$1"; [ -n "$1" ] && newline; }
    2.66 +
    2.67 +
    2.68  # Print current action in brown color (separate from any other msgs)
    2.69 +
    2.70  action() {
    2.71  	case $output in
    2.72  		raw|gtk|html) eval_gettext "$@" ;;
    2.73 @@ -73,22 +90,22 @@
    2.74  	esac
    2.75  }
    2.76  
    2.77 +
    2.78  # Initialize some variables to use words rather than numbers for functions
    2.79  # and actions.
    2.80  COMMAND=$1
    2.81  PACKAGE=${2%/}
    2.82  PACKAGE_DIR="$(cd $(dirname $PACKAGE 2>/dev/null) 2>/dev/null; pwd)"
    2.83 -[ -n "$PACKAGE" ] &&
    2.84 -PACKAGE_FILE="$PACKAGE_DIR/${PACKAGE##*/}"
    2.85 +[ -n "$PACKAGE" ] && PACKAGE_FILE="$PACKAGE_DIR/${PACKAGE##*/}"
    2.86  if [ -f "$PACKAGE" ]; then
    2.87  	# Set pkg basename for install, extract
    2.88 -	PACKAGE=$(basename ${PACKAGE%.tazpkg} 2>/dev/null)
    2.89 +	PACKAGE=$(basename $PACKAGE .tazpkg 2>/dev/null)
    2.90  else
    2.91  	# Pkg name for remove, search and all other cmds
    2.92  	PACKAGE=${PACKAGE%.tazpkg}
    2.93  fi
    2.94  TARGET_DIR=$3
    2.95 -TOP_DIR=`pwd`
    2.96 +TOP_DIR=$(pwd)
    2.97  TMP_DIR=/tmp/$RANDOM
    2.98  INSTALL_LIST=""
    2.99  SAVE_CACHE_DIR="$CACHE_DIR"
   2.100 @@ -102,85 +119,92 @@
   2.101  # Need by check_depends
   2.102  TMPLOCALSTATE=
   2.103  
   2.104 +
   2.105 +
   2.106  ####################
   2.107  # Script functions #
   2.108  ####################
   2.109  
   2.110 +
   2.111  # Print the usage.
   2.112 +
   2.113  usage () {
   2.114  	cat << EOT
   2.115  
   2.116 -$(eval_gettext 'SliTaz package manager - Version:') $(colorize 34 $VERSION)
   2.117 -
   2.118 -$(boldify "$(gettext 'Usage:')")
   2.119 -  $(gettext 'tazpkg [command] [package|dir|pattern|list|cat|--opt] [dir|--opt]')
   2.120 -
   2.121 -$(boldify "$(gettext 'SHell:')") tazpkg shell
   2.122 -
   2.123 -$(boldify "$(gettext 'Commands:')")
   2.124 -  usage            $(gettext 'Print this short usage')
   2.125 -  bugs             $(gettext 'Show known bugs in packages')
   2.126 -  activity|-a      $(gettext 'Show TazPKG activity log')
   2.127 -  list|-l          $(gettext 'List installed packages on the system by category or all')
   2.128 -  list-mirror|-lm  $(gettext 'List all available packages on the mirror (--diff for new)')
   2.129 -  info             $(gettext 'Print information about a package')
   2.130 -  desc             $(gettext 'Print description of a package (if it exists)')
   2.131 -  list-files|-lf   $(gettext 'List the files installed with a package')
   2.132 -  list-config      $(gettext 'List the configuration files')
   2.133 -  search|-s        $(gettext 'Search for a package by pattern or name (options: -i|-l|-m)')
   2.134 -  search-pkgname   $(gettext 'Search on mirror for package having a particular file')
   2.135 -  search-file|-sf  $(gettext 'Search for file(s) in all installed packages files')
   2.136 -  install|-i       $(gettext 'Install a local (*.tazpkg) package (--forced to force)')
   2.137 -  install-list     $(gettext 'Install all packages from a list of packages.')
   2.138 -  remove|-r        $(gettext 'Remove the specified package and all installed files')
   2.139 -  extract|-e       $(gettext 'Extract a (*.tazpkg) package into a directory')
   2.140 -  pack             $(gettext 'Pack an unpacked or prepared package tree')
   2.141 -  recharge         $(gettext 'Recharge your packages.list from the mirror')
   2.142 -  up|help-up       $(eval_gettext 'Check packages $CHECKSUM to list and install latest upgrades')
   2.143 -  repack           $(gettext 'Create a package archive from an installed package')
   2.144 -  repack-config    $(gettext 'Create a package archive with configuration files')
   2.145 -  recompress       $(gettext 'Rebuild a package with a better compression ratio')
   2.146 -  block|unblock    $(gettext 'Block an installed package version or unblock it for upgrade')
   2.147 -  get              $(gettext 'Download a package into the current directory')
   2.148 -  get-install|-gi  $(gettext 'Download and install a package from the mirror')
   2.149 -  get-install-list $(gettext 'Download and install a list of packages from the mirror')
   2.150 -  check            $(gettext 'Verify consistency of installed packages')
   2.151 -  add-flavor       $(gettext 'Install the flavor list of packages')
   2.152 -  install-flavor   $(gettext 'Install the flavor list of packages and remove other ones')
   2.153 -  set-release      $(gettext 'Change release and update packages')
   2.154 -  clean-cache|-cc  $(gettext 'Clean all packages downloaded in cache directory')
   2.155 -  depends          $(gettext 'Display dependencies tree')
   2.156 -  rdepends         $(gettext 'Display reverse dependencies tree')
   2.157 -  convert          $(gettext 'Convert deb/rpm/tgz/pet/sfs/sb/arch/ipk package to tazpkg)')
   2.158 -  link             $(gettext 'Link a package from another slitaz installation')
   2.159 -  setup-mirror|-sm $(gettext 'Change the mirror url configuration')
   2.160 -  list-undigest    $(gettext 'List undigest mirrors')
   2.161 -  remove-undigest  $(gettext 'Remove an undigest mirror')
   2.162 -  add-undigest     $(gettext 'Add an undigest mirror')
   2.163 -  setup-undigest   $(gettext 'Update an undigest mirror')
   2.164 -  reconfigure      $(gettext 'Replay post install script from package')
   2.165 +$(_ 'SliTaz package manager - Version:') $(colorize 34 $VERSION)
   2.166 +
   2.167 +$(boldify "$(_ 'Usage:')")
   2.168 +  $(_ 'tazpkg [command] [package|dir|pattern|list|cat|--opt] [dir|--opt]')
   2.169 +
   2.170 +$(boldify "$(_ 'SHell:')") tazpkg shell
   2.171 +
   2.172 +$(boldify "$(_ 'Commands:')")
   2.173 +  usage            $(_ 'Print this short usage')
   2.174 +  bugs             $(_ 'Show known bugs in packages')
   2.175 +  activity|-a      $(_ 'Show TazPKG activity log')
   2.176 +  list|-l          $(_ 'List installed packages on the system by category or all')
   2.177 +  list-mirror|-lm  $(_ 'List all available packages on the mirror (--diff for new)')
   2.178 +  info             $(_ 'Print information about a package')
   2.179 +  desc             $(_ 'Print description of a package (if it exists)')
   2.180 +  list-files|-lf   $(_ 'List the files installed with a package')
   2.181 +  list-config      $(_ 'List the configuration files')
   2.182 +  search|-s        $(_ 'Search for a package by pattern or name (options: -i|-l|-m)')
   2.183 +  search-pkgname   $(_ 'Search on mirror for package having a particular file')
   2.184 +  search-file|-sf  $(_ 'Search for file(s) in all installed packages files')
   2.185 +  install|-i       $(_ 'Install a local (*.tazpkg) package (--forced to force)')
   2.186 +  install-list     $(_ 'Install all packages from a list of packages.')
   2.187 +  remove|-r        $(_ 'Remove the specified package and all installed files')
   2.188 +  extract|-e       $(_ 'Extract a (*.tazpkg) package into a directory')
   2.189 +  pack             $(_ 'Pack an unpacked or prepared package tree')
   2.190 +  recharge         $(_ 'Recharge your packages.list from the mirror')
   2.191 +  up|help-up       $(_ 'Check packages $CHECKSUM to list and install latest upgrades')
   2.192 +  repack           $(_ 'Create a package archive from an installed package')
   2.193 +  repack-config    $(_ 'Create a package archive with configuration files')
   2.194 +  recompress       $(_ 'Rebuild a package with a better compression ratio')
   2.195 +  block|unblock    $(_ 'Block an installed package version or unblock it for upgrade')
   2.196 +  get              $(_ 'Download a package into the current directory')
   2.197 +  get-install|-gi  $(_ 'Download and install a package from the mirror')
   2.198 +  get-install-list $(_ 'Download and install a list of packages from the mirror')
   2.199 +  check            $(_ 'Verify consistency of installed packages')
   2.200 +  add-flavor       $(_ 'Install the flavor list of packages')
   2.201 +  install-flavor   $(_ 'Install the flavor list of packages and remove other ones')
   2.202 +  set-release      $(_ 'Change release and update packages')
   2.203 +  clean-cache|-cc  $(_ 'Clean all packages downloaded in cache directory')
   2.204 +  depends          $(_ 'Display dependencies tree')
   2.205 +  rdepends         $(_ 'Display reverse dependencies tree')
   2.206 +  convert          $(_ 'Convert deb/rpm/tgz/pet/sfs/sb/arch/ipk package to tazpkg)')
   2.207 +  link             $(_ 'Link a package from another slitaz installation')
   2.208 +  setup-mirror|-sm $(_ 'Change the mirror url configuration')
   2.209 +  list-undigest    $(_ 'List undigest mirrors')
   2.210 +  remove-undigest  $(_ 'Remove an undigest mirror')
   2.211 +  add-undigest     $(_ 'Add an undigest mirror')
   2.212 +  setup-undigest   $(_ 'Update an undigest mirror')
   2.213 +  reconfigure      $(_ 'Replay post install script from package')
   2.214  
   2.215  EOT
   2.216  }
   2.217  
   2.218 +
   2.219  usage_up() {
   2.220  	cat << EOT
   2.221 -$(emsg "<b>$(gettext 'Usage for command up:')</b>") tazpkg up [$(gettext 'option')]
   2.222 -
   2.223 - * $(gettext 'Without options run in interactive mode and ask before install')
   2.224 -
   2.225 -$(boldify "$(gettext 'Where options are:')")
   2.226 -  --check    |-c   $(gettext 'Check only for available upgrades')
   2.227 -  --recharge |-r   $(gettext 'Force recharge of packages list and check')
   2.228 -  --install  |-i   $(gettext 'Check for upgrades and install them all')
   2.229 -
   2.230 -$(boldify "$(gettext 'Example:')")
   2.231 +$(emsg "<b>$(_ 'Usage for command up:')</b>") tazpkg up [$(_ 'option')]
   2.232 +
   2.233 + * $(_ 'Without options run in interactive mode and ask before install')
   2.234 +
   2.235 +$(boldify "$(_ 'Where options are:')")
   2.236 +  --check    |-c   $(_ 'Check only for available upgrades')
   2.237 +  --recharge |-r   $(_ 'Force recharge of packages list and check')
   2.238 +  --install  |-i   $(_ 'Check for upgrades and install them all')
   2.239 +
   2.240 +$(boldify "$(_ 'Example:')")
   2.241    tazpkg up --recharge --install
   2.242    tazpkg up -c -r
   2.243  EOT
   2.244  }
   2.245  
   2.246 +
   2.247  # Check if dir exists
   2.248 +
   2.249  check_dir()
   2.250  {
   2.251  	if ! [ -d "$1" ]; then
   2.252 @@ -192,8 +216,10 @@
   2.253  	fi
   2.254  }
   2.255  
   2.256 +
   2.257  # Check if the directories and files used by TazPKG
   2.258  # exist. If not and user is root we create them.
   2.259 +
   2.260  check_base_dir()
   2.261  {
   2.262  	if [ "$(id -u)" = "0" ]; then
   2.263 @@ -208,63 +234,73 @@
   2.264  }
   2.265  check_base_dir
   2.266  
   2.267 +
   2.268  # Check for a package name on cmdline.
   2.269 +
   2.270  check_for_package_on_cmdline()
   2.271  {
   2.272  	if [ -z "$PACKAGE" ]; then
   2.273  		newline
   2.274 -		gettext "Please specify a package name on the command line."; echo
   2.275 +		_ 'Please specify a package name on the command line.'
   2.276  		newline
   2.277  		exit 0
   2.278  	fi
   2.279  }
   2.280  
   2.281 +
   2.282  # Check if the package (*.tazpkg) exists before installing or extracting.
   2.283 +
   2.284  check_for_package_file()
   2.285  {
   2.286  	if [ ! -f "$PACKAGE_FILE" ]; then
   2.287  		newline
   2.288 -		eval_gettext "Unable to find: \$PACKAGE_FILE"; echo
   2.289 +		_ 'Unable to find: $PACKAGE_FILE'
   2.290  		newline
   2.291  		exit 0
   2.292  	fi
   2.293  }
   2.294  
   2.295 +
   2.296  # Check for the receipt of an installed package.
   2.297 +
   2.298  check_for_receipt()
   2.299  {
   2.300  	receipt_path="$1$INSTALLED/$PACKAGE/receipt"
   2.301  	if [ ! -f $receipt_path ]; then
   2.302  		newline
   2.303 -		eval_gettext 'Unable to find the receipt: $receipt_path'; echo
   2.304 +		_ 'Unable to find the receipt: $receipt_path'
   2.305  		newline
   2.306  		exit 0
   2.307  	fi
   2.308  }
   2.309  
   2.310 +
   2.311  # Get repositories priority using $LOCALSTATE/priority.
   2.312  # In this files, undigest are called by their name and main mirror
   2.313  # by main. Sort order: priority
   2.314 +
   2.315  look_for_priority()
   2.316  {
   2.317 -[ -s $LOCALSTATE/priority ] && priority=$(cat $LOCALSTATE/priority)
   2.318 -for rep in main $(ls $LOCALSTATE/undigest 2>/dev/null); do
   2.319 -	if [ ! -s $LOCALSTATE/priority ] || \
   2.320 -		! grep -q ^$rep$ $LOCALSTATE/priority; then
   2.321 -		priority=$(echo -e "$priority\n$rep")
   2.322 -	fi
   2.323 -done
   2.324 -priority=$(echo "$priority" | sed '/^$/d' | \
   2.325 -	while read line; do
   2.326 -	if [ "$line" = main ]; then
   2.327 -		echo $LOCALSTATE
   2.328 -	else
   2.329 -		echo $LOCALSTATE/undigest/$line
   2.330 -	fi
   2.331 -done)
   2.332 +	[ -s $LOCALSTATE/priority ] && priority=$(cat $LOCALSTATE/priority)
   2.333 +	for rep in main $(ls $LOCALSTATE/undigest 2>/dev/null); do
   2.334 +		if [ ! -s $LOCALSTATE/priority ] || \
   2.335 +			! grep -q ^$rep$ $LOCALSTATE/priority; then
   2.336 +			priority=$(echo -e "$priority\n$rep")
   2.337 +		fi
   2.338 +	done
   2.339 +	priority=$(echo "$priority" | sed '/^$/d' | \
   2.340 +		while read line; do
   2.341 +		if [ "$line" = main ]; then
   2.342 +			echo $LOCALSTATE
   2.343 +		else
   2.344 +			echo $LOCALSTATE/undigest/$line
   2.345 +		fi
   2.346 +	done)
   2.347  }
   2.348  
   2.349 +
   2.350  # Get package name in a directory
   2.351 +
   2.352  package_fullname_in_dir()
   2.353  {
   2.354  	[ -f $1/receipt ] || return
   2.355 @@ -273,7 +309,9 @@
   2.356  	echo $PACKAGE-$VERSION$EXTRAVERSION
   2.357  }
   2.358  
   2.359 +
   2.360  # Get package name that is already installed.
   2.361 +
   2.362  get_installed_package_pathname()
   2.363  {
   2.364  	for i in $2$INSTALLED/${1%%-*}*; do
   2.365 @@ -285,13 +323,16 @@
   2.366  	done
   2.367  }
   2.368  
   2.369 +
   2.370  # Check if a package is already installed.
   2.371 +
   2.372  check_for_installed_package()
   2.373  {
   2.374  	if [ -n "$(get_installed_package_pathname $PACKAGE $1)" ]; then
   2.375  		newline
   2.376 +		# FIXME
   2.377  		cat << EOT
   2.378 -$(colorize 34 $PACKAGE) $(gettext "package is already installed.
   2.379 +$(colorize 34 $PACKAGE) $(_ "package is already installed.
   2.380  You can use the --forced option to force installation.")
   2.381  EOT
   2.382  		newline
   2.383 @@ -299,7 +340,9 @@
   2.384  	fi
   2.385  }
   2.386  
   2.387 +
   2.388  # Check for packages.list to download and install packages.
   2.389 +
   2.390  check_for_packages_list()
   2.391  {
   2.392  	list_path="$LOCALSTATE/packages.list"
   2.393 @@ -308,16 +351,17 @@
   2.394  			tazpkg recharge
   2.395  		else
   2.396  			newline
   2.397 -			eval_gettext 'Unable to find the list: $list_path'; echo
   2.398 -			gettext \
   2.399 +			_ 'Unable to find the list: $list_path'
   2.400 +			_ \
   2.401  "You must probably run 'tazpkg recharge' as root to get the latest list of
   2.402 -packages available on the mirror."; echo
   2.403 +packages available on the mirror."
   2.404  			newline
   2.405  			exit 0
   2.406  		fi
   2.407  	fi
   2.408  }
   2.409  
   2.410 +
   2.411  get_cache_dir()
   2.412  {
   2.413  	echo $rep > $tmp/rep
   2.414 @@ -333,7 +377,9 @@
   2.415  	echo $CACHE_DIR > $tmp/cachedir
   2.416  }
   2.417  
   2.418 +
   2.419  # get an already installed package from packages.equiv
   2.420 +
   2.421  equivalent_pkg()
   2.422  {
   2.423  	for i in $(grep -hs "^$1=" $LOCALSTATE/packages.equiv \
   2.424 @@ -359,7 +405,9 @@
   2.425  	echo $1
   2.426  }
   2.427  
   2.428 +
   2.429  # get a virtual package from packages.equiv
   2.430 +
   2.431  virtual_pkg()
   2.432  {
   2.433  	for i in $(for rep in $priority; do
   2.434 @@ -381,23 +429,21 @@
   2.435  	done
   2.436  }
   2.437  
   2.438 +
   2.439  # Get package filename available on the mirror
   2.440 +
   2.441  get_package_filename()
   2.442  {
   2.443  	local pkg
   2.444  	for rep in $priority; do
   2.445 -		pkg=$(grep -A 1 -sh "^$1$" $rep/packages.txt | tail -1 | \
   2.446 -			sed 's/^ *//')
   2.447 -		[ "$pkg" ] && pkg=$(grep -sh "^$1-$pkg" \
   2.448 -			$rep/packages.list | head -1)
   2.449 +		pkg=$(grep -A 1 -sh "^$1$" $rep/packages.txt | tail -1 | sed 's/^ *//')
   2.450 +		[ "$pkg" ] && pkg=$(grep -sh "^$1-$pkg" $rep/packages.list | head -1)
   2.451  
   2.452  		# Allow user to call a package with his version number.
   2.453  		[ "$pkg" ] || pkg=$(grep -sh "^$1$" $rep/packages.list | head -1)
   2.454  
   2.455 -		[ "$pkg" ] || pkg=$(grep -sh "^$1-[0-9]" \
   2.456 -			$rep/packages.list | head -1)
   2.457 -		[ "$pkg" ] || pkg=$(grep -sh "^$1-.[\.0-9]" \
   2.458 -		$rep/packages.list | head -1)
   2.459 +		[ "$pkg" ] || pkg=$(grep -sh "^$1-[0-9]" $rep/packages.list | head -1)
   2.460 +		[ "$pkg" ] || pkg=$(grep -sh "^$1-.[\.0-9]" $rep/packages.list | head -1)
   2.461  		[ "$pkg" ] && get_cache_dir && break
   2.462  	done
   2.463  	if [ -z "$pkg" ]; then
   2.464 @@ -413,8 +459,10 @@
   2.465  	echo $pkg
   2.466  }
   2.467  
   2.468 +
   2.469  # Check for a package in packages.list. Used by get and get-install to grep
   2.470  # package basename.
   2.471 +
   2.472  check_for_package_in_list()
   2.473  {
   2.474  	local filename
   2.475 @@ -428,27 +476,33 @@
   2.476  		rm -f $tmp/rep $tmp/cachedir
   2.477  	else
   2.478  		newline
   2.479 -		eval_gettext "Unable to find: \$PACKAGE in the mirrored packages list."; echo
   2.480 +		_ 'Unable to find: $PACKAGE in the mirrored packages list.'
   2.481  		newline
   2.482  		[ -n "$check_only" ] && return 1
   2.483  		exit 0
   2.484  	fi
   2.485  }
   2.486  
   2.487 +
   2.488  # Log this activity
   2.489  # (there log_pkg because we have log() in libtaz.sh)
   2.490 +
   2.491  log_pkg()
   2.492  {
   2.493  	local extra
   2.494 +
   2.495  	[ "$1" = "Installed" ] && \
   2.496  	extra=" - $(fgrep $PACKAGE-$VERSION $LOCALSTATE/installed.$SUM | awk '{ print $1 }')"
   2.497 +
   2.498  	[ -e $LOG ] || touch $LOG
   2.499 -	DATE=`date +'%F %T'`
   2.500 +
   2.501  	[ -w $LOG ] &&
   2.502 -	echo "$DATE - $1 - $PACKAGE ($VERSION$EXTRAVERSION)$extra" >> $LOG
   2.503 +	echo "$(date +'%F %T') - $1 - $PACKAGE ($VERSION$EXTRAVERSION)$extra" >> $LOG
   2.504  }
   2.505  
   2.506 +
   2.507  # Download a get-package script from this mirror
   2.508 +
   2.509  download_get_script()
   2.510  {
   2.511  	local p
   2.512 @@ -456,16 +510,17 @@
   2.513  		local i
   2.514  		for i in $(cat $p/mirror) ; do
   2.515  			case "$i" in
   2.516 -			http://*|ftp://*)
   2.517 -				wget -O $2 ${i%packages/*}packages/get/$1 &&
   2.518 -				return 0 ;;
   2.519 +				http://*|ftp://*)
   2.520 +					wget -O $2 ${i%packages/*}packages/get/$1 && return 0 ;;
   2.521  			esac
   2.522  		done
   2.523  	done
   2.524  	return 1
   2.525  }
   2.526  
   2.527 +
   2.528  # Download a file from this mirror
   2.529 +
   2.530  download_from()
   2.531  {
   2.532  	local i
   2.533 @@ -475,13 +530,17 @@
   2.534  	for i in $mirrors; do
   2.535  		case "$i" in
   2.536  			# Mirror URL can have a trailing slash or not.
   2.537 -			http://*|ftp://*) busybox wget -c ${i%/}/$@ && break ;;
   2.538 -			*) ln -sf $i/$1 . && break ;;
   2.539 +			http://*|ftp://*)
   2.540 +				busybox wget -c ${i%/}/$@ && break ;;
   2.541 +			*)
   2.542 +				ln -sf $i/$1 . && break ;;
   2.543  		esac
   2.544  	done
   2.545  }
   2.546  
   2.547 +
   2.548  # Download a file trying all mirrors
   2.549 +
   2.550  download()
   2.551  {
   2.552  	local i
   2.553 @@ -492,16 +551,17 @@
   2.554  			download_from "$(cat $i/mirror)" "$@" && return
   2.555  		done
   2.556  	esac
   2.557 -	for i in $(cat `for rep in $priority; do echo $rep/mirror; done` \
   2.558 -		2> /dev/null); do
   2.559 +	for i in $(cat $(for rep in $priority; do echo $rep/mirror; done) 2>/dev/null); do
   2.560  		download_from "$i" "$@" && break
   2.561  	done
   2.562  }
   2.563  
   2.564 +
   2.565  # Extract a package with cpio and gzip/lzma.
   2.566 +
   2.567  extract_package()
   2.568  {
   2.569 -	action "Extracting \$PACKAGE..."
   2.570 +	action 'Extracting $PACKAGE...'
   2.571  	cpio -idm --quiet < ${PACKAGE_FILE##*/} && rm -f ${PACKAGE_FILE##*/}
   2.572  	status
   2.573  	if [ -f fs.cpio.lzma ]; then
   2.574 @@ -511,6 +571,7 @@
   2.575  	fi
   2.576  }
   2.577  
   2.578 +
   2.579  remove_with_path()
   2.580  {
   2.581  	# Avoid dirname errors by checking for argument.
   2.582 @@ -525,18 +586,21 @@
   2.583  	done
   2.584  }
   2.585  
   2.586 +
   2.587  grepesc()
   2.588  {
   2.589  	sed 's/\[/\\[/g'
   2.590  }
   2.591  
   2.592 +
   2.593  # This function installs a package in the rootfs.
   2.594 +
   2.595  install_package()
   2.596  {
   2.597  	ROOT=$1
   2.598  	if [ -n "$ROOT" ]; then
   2.599 -		 # Get absolute path
   2.600 -		 ROOT=$(cd $ROOT; pwd)
   2.601 +		# Get absolute path
   2.602 +		ROOT=$(realpath $ROOT)
   2.603  	fi
   2.604  	{
   2.605  		# Create package path early to avoid dependencies loop
   2.606 @@ -546,10 +610,12 @@
   2.607  		if grep -q ^pre_depends $TMP_DIR/receipt; then
   2.608  			pre_depends $ROOT
   2.609  		fi
   2.610 +
   2.611  		# Keep modifiers and file list on upgrade
   2.612  		cp $ROOT$INSTALLED/$PACKAGE/modifiers \
   2.613  		   $ROOT$INSTALLED/$PACKAGE/files.list $TMP_DIR 2> /dev/null
   2.614  		rm -rf $ROOT$INSTALLED/$PACKAGE 2> /dev/null
   2.615 +
   2.616  		# Make the installed package data dir to store
   2.617  		# the receipt and the files list.
   2.618  		mkdir -p $ROOT$INSTALLED/$PACKAGE
   2.619 @@ -561,35 +627,42 @@
   2.620  		cd $(dirname $PACKAGE_FILE)
   2.621  		$CHECKSUM $(basename $PACKAGE_FILE) >> $ROOT$LOCALSTATE/installed.$SUM
   2.622  	}
   2.623 +
   2.624  	# Resolve package deps.
   2.625  	check_for_deps $ROOT
   2.626 -	if [ ! "$MISSING_PACKAGE" = "" ]; then
   2.627 +	if [ -n "$MISSING_PACKAGE" ]; then
   2.628  		install_deps $ROOT
   2.629  	fi
   2.630  	mkdir -p $TMP_DIR
   2.631  	[ -n "$INSTALL_LIST" ] && echo "$PACKAGE_FILE" >> $ROOT$LOCALSTATE/$INSTALL_LIST-processed
   2.632 +
   2.633  	title 'Installation of: $PACKAGE'
   2.634 -	action "Copying \$PACKAGE..."
   2.635 +
   2.636 +	action 'Copying $PACKAGE...'
   2.637  	cp $PACKAGE_FILE $TMP_DIR
   2.638  	status
   2.639 +
   2.640  	cd $TMP_DIR
   2.641  	extract_package
   2.642  	SELF_INSTALL=0
   2.643  	EXTRAVERSION=""
   2.644  	CONFIG_FILES=""
   2.645 +
   2.646  	# Include temporary receipt to get the right variables.
   2.647  	. $PWD/receipt
   2.648  	cd $ROOT$INSTALLED
   2.649 +
   2.650  	if [ $SELF_INSTALL -ne 0 -a -n "$ROOT" ]; then
   2.651  		action "Checking post install dependencies..."
   2.652  		[ -f $INSTALLED/$PACKAGE/receipt ]
   2.653  		if ! status; then
   2.654  			command="tazpkg install $PACKAGE_FILE"
   2.655 -			eval_gettext "Please run '\$command' in / and retry."; echo
   2.656 +			_ "Please run '\$command' in / and retry."
   2.657  			rm -rf $TMP_DIR
   2.658  			exit 1
   2.659  		fi
   2.660  	fi
   2.661 +
   2.662  	# Get files to remove if upgrading
   2.663  	if [ -f $PACKAGE/files.list ]; then
   2.664  		while read file; do
   2.665 @@ -601,19 +674,23 @@
   2.666  			echo $file
   2.667  		done < $PACKAGE/files.list > $TMP_DIR/files2remove.list
   2.668  	fi
   2.669 +
   2.670  	# Remember modified packages
   2.671 -	{ check=false
   2.672 -	  for i in $(fgrep -v [ $TMP_DIR/files.list); do
   2.673 -		[ -e "$ROOT$i" ] || continue
   2.674 -		[ -d "$ROOT$i" ] && continue
   2.675 -		echo "- $i"
   2.676 -		check=true
   2.677 -	  done ;
   2.678 -	  $check && for i in *; do
   2.679 -	  	[ "$i" == "$PACKAGE" ] && continue
   2.680 -	  	[ -s $i/files.list ] || continue
   2.681 -	  	awk "{ printf \"$i %s\\n\",\$1 }" < $i/files.list
   2.682 -	  done; } | awk '
   2.683 +	{
   2.684 +		check=false
   2.685 +		for i in $(fgrep -v [ $TMP_DIR/files.list); do
   2.686 +			[ -e "$ROOT$i" ] || continue
   2.687 +			[ -d "$ROOT$i" ] && continue
   2.688 +			echo "- $i"
   2.689 +			check=true
   2.690 +		done ;
   2.691 +		$check && \
   2.692 +		for i in *; do
   2.693 +			[ "$i" == "$PACKAGE" ] && continue
   2.694 +			[ -s $i/files.list ] || continue
   2.695 +			awk "{ printf \"$i %s\\n\",\$1 }" < $i/files.list
   2.696 +		done;
   2.697 +	} | awk '
   2.698  {
   2.699  	if ($1 == "-" || file[$2] != "") {
   2.700  		file[$2] = file[$2] " " $1
   2.701 @@ -645,25 +722,29 @@
   2.702  
   2.703  	cd $TMP_DIR
   2.704  	cp receipt files.list $ROOT$INSTALLED/$PACKAGE
   2.705 +
   2.706  	# Copy the description if found.
   2.707  	if [ -f "description.txt" ]; then
   2.708  		cp description.txt $ROOT$INSTALLED/$PACKAGE
   2.709  	fi
   2.710 +
   2.711  	# Copy the md5sum if found.
   2.712  	if [ -f "$CHECKSUM" ]; then
   2.713  		cp $CHECKSUM $ROOT$INSTALLED/$PACKAGE
   2.714  	fi
   2.715 +
   2.716  	# Pre install commands.
   2.717  	if grep -q ^pre_install $ROOT$INSTALLED/$PACKAGE/receipt; then
   2.718  		pre_install $ROOT
   2.719  	fi
   2.720  	if [ -n "$CONFIG_FILES" ]; then
   2.721  		# save 'official' configuration files
   2.722 -		action "Saving configuration files for \$PACKAGE..."
   2.723 +		action 'Saving configuration files for $PACKAGE...'
   2.724  		for i in $CONFIG_FILES; do
   2.725  			{ cd fs ; find ${i#/} -type f 2> /dev/null; cd ..; }
   2.726  		done | { cd fs ; cpio -o -H newc --quiet | gzip -9; cd ..; } > \
   2.727  			$ROOT$INSTALLED/$PACKAGE/volatile.cpio.gz
   2.728 +
   2.729  		# keep user configuration files
   2.730  		for i in $CONFIG_FILES; do
   2.731  			{ cd fs ; find ${i#/} -type f 2> /dev/null; cd ..; }
   2.732 @@ -673,53 +754,66 @@
   2.733  		done
   2.734  		status
   2.735  	fi
   2.736 -	action "Installing \$PACKAGE..."
   2.737 +
   2.738 +	action 'Installing $PACKAGE...'
   2.739  	[ "$(busybox ls fs/* 2> /dev/null)" ] && cp -a fs/* $ROOT/
   2.740  	status
   2.741 +
   2.742  	if [ -s files2remove.list ]; then
   2.743 -		action "Removing old \$PACKAGE..."
   2.744 +		action 'Removing old $PACKAGE...'
   2.745  		while read file; do
   2.746  			remove_with_path $ROOT$file
   2.747  		done < files2remove.list
   2.748  		true
   2.749  		status
   2.750  	fi
   2.751 +
   2.752  	# Remove the temporary random directory.
   2.753  	action "Removing all tmp files..."
   2.754 -	cd .. && rm -rf $TMP_DIR
   2.755 +	cd ..; rm -rf $TMP_DIR
   2.756  	status
   2.757 +
   2.758  	# Post install commands.
   2.759  	if grep -q ^post_install $ROOT$INSTALLED/$PACKAGE/receipt; then
   2.760  		post_install $ROOT
   2.761  	fi
   2.762 - 	# Update-desktop-database if needed.
   2.763 +
   2.764 +	# Update-desktop-database if needed.
   2.765  	if [ "$(fgrep .desktop $ROOT$INSTALLED/$PACKAGE/files.list | fgrep /usr/share/applications/)" ]; then
   2.766  		updatedesktopdb=yes
   2.767  	fi
   2.768 +
   2.769  	# Update-mime-database if needed.
   2.770  	if [ "$(fgrep /usr/share/mime $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
   2.771  		updatemimedb=yes
   2.772  	fi
   2.773 +
   2.774  	# Update-icon-database
   2.775  	if [ "$(fgrep /usr/share/icon/hicolor $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
   2.776  		updateicondb=yes
   2.777  	fi
   2.778 +
   2.779  	# Compile glib schemas if needed.
   2.780  	if [ "$(fgrep /usr/share/glib-2.0/schemas $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
   2.781  		compile_schemas=yes
   2.782  	fi
   2.783 +
   2.784  	# Update depmod list
   2.785  	if [ "$(fgrep /lib/modules $ROOT$INSTALLED/$PACKAGE/files.list)" ]; then
   2.786  		updatedepmod=yes
   2.787  	fi
   2.788 +
   2.789  	cd $TOP_DIR
   2.790  	pkg_name="$PACKAGE ($VERSION$EXTRAVERSION)"
   2.791 -	footer "$(eval_gettext '$pkg_name is installed.')"
   2.792 +	footer "$(_ '$pkg_name is installed.')"
   2.793 +
   2.794  	# Log this activity
   2.795  	[ -n "$ROOT" ] || log_pkg Installed
   2.796  }
   2.797  
   2.798 +
   2.799  # This function may be called by a get script.
   2.800 +
   2.801  abort_package()
   2.802  {
   2.803  	cd $CUR_DIR
   2.804 @@ -728,7 +822,9 @@
   2.805  	exit 1
   2.806  }
   2.807  
   2.808 +
   2.809  # This function installs a package from a get script in the rootfs.
   2.810 +
   2.811  install_package_from_get_script()
   2.812  {
   2.813  	SCRIPT="$1"
   2.814 @@ -767,7 +863,7 @@
   2.815  	DEPENDS="$(unset DEPENDS; . $PACKAGE-$VERSION/receipt ; echo $DEPENDS)"
   2.816  	for i in $(find_depends $PACKAGE-$VERSION/fs); do
   2.817  		case " $DEPENDS " in
   2.818 -		*\ $i\ *) continue;;
   2.819 +			*\ $i\ *) continue;;
   2.820  		esac
   2.821  		grep -q '^DEPENDS="' $PACKAGE-$VERSION/receipt ||
   2.822  			echo 'DEPENDS=""' >> $PACKAGE-$VERSION/receipt
   2.823 @@ -788,7 +884,9 @@
   2.824  	rm -rf $TMP_DIR
   2.825  }
   2.826  
   2.827 +
   2.828  # Check for loop in deps tree.
   2.829 +
   2.830  check_for_deps_loop()
   2.831  {
   2.832  	local list
   2.833 @@ -798,6 +896,7 @@
   2.834  	shift
   2.835  	[ -n "$1" ] || return
   2.836  	list=""
   2.837 +
   2.838  	# Filter out already processed deps
   2.839  	for i in $@; do
   2.840  		case " $ALL_DEPS" in
   2.841 @@ -816,7 +915,9 @@
   2.842  	done
   2.843  }
   2.844  
   2.845 +
   2.846  # Check for missing deps listed in a receipt packages.
   2.847 +
   2.848  check_for_deps()
   2.849  {
   2.850  	local saved;
   2.851 @@ -828,37 +929,37 @@
   2.852  	rm -rf $TMP_DIR
   2.853  
   2.854  	num=0
   2.855 -	for pkgorg in $DEPENDS
   2.856 -	do
   2.857 +	for pkgorg in $DEPENDS; do
   2.858  		i=$(equivalent_pkg $pkgorg $1)
   2.859  		if [ ! -d "$1$INSTALLED/$i" ]; then
   2.860  			MISSING_PACKAGE=$i
   2.861  			num=$(($num+1))
   2.862  		elif [ ! -f "$1$INSTALLED/$i/receipt" ]; then
   2.863 -			eval_gettext "WARNING Dependency loop between \$PACKAGE and \$i."; echo
   2.864 +			_ 'WARNING Dependency loop between $PACKAGE and $i.'
   2.865  		fi
   2.866  	done
   2.867  
   2.868  	if [ ! "$MISSING_PACKAGE" = "" ]; then
   2.869 -		title "$(eval_gettext 'Tracking dependencies for: $PACKAGE')"
   2.870 -		for pkgorg in $DEPENDS
   2.871 -		do
   2.872 +		title "$(_ 'Tracking dependencies for: $PACKAGE')"
   2.873 +		for pkgorg in $DEPENDS; do
   2.874  			i=$(equivalent_pkg $pkgorg $1)
   2.875  			if [ ! -d "$1$INSTALLED/$i" ]; then
   2.876  				MISSING_PACKAGE=$i
   2.877 -				eval_gettext "Missing: \$MISSING_PACKAGE"; echo
   2.878 +				_ 'Missing: $MISSING_PACKAGE'
   2.879  			fi
   2.880  		done
   2.881  		separator
   2.882  		eval_ngettext \
   2.883 -			"\$num missing package to install." \
   2.884 -			"\$num missing packages to install." $num; echo
   2.885 +			'$num missing package to install.' \
   2.886 +			'$num missing packages to install.' $num; echo
   2.887  	fi
   2.888  }
   2.889  
   2.890 +
   2.891  # Install all missing deps. Auto install or ask user then install all missing
   2.892  # deps from local dir, cdrom, media or from the mirror. In case we want to
   2.893  # install packages from local, we need a packages.list to find the version.
   2.894 +
   2.895  install_deps()
   2.896  {
   2.897  	local root
   2.898 @@ -868,13 +969,12 @@
   2.899  		answer=0
   2.900  	else
   2.901  		newline
   2.902 -		gettext "Install all missing dependencies" && confirm
   2.903 +		_n 'Install all missing dependencies'; confirm
   2.904  		answer=$?
   2.905  		newline
   2.906  	fi
   2.907  	if [ $answer = 0 ]; then
   2.908 -		for pkgorg in $DEPENDS
   2.909 -		do
   2.910 +		for pkgorg in $DEPENDS; do
   2.911  			pkg=$(equivalent_pkg $pkgorg $1)
   2.912  			if [ ! -d "$1$INSTALLED/$pkg" ]; then
   2.913  				local list
   2.914 @@ -884,7 +984,7 @@
   2.915  				# the TAZPKG_BASENAME in the local packages.list.
   2.916  				found=0
   2.917  				if [ -f "$list" ]; then
   2.918 -					eval_gettext "Checking if \$pkg exists in local list..."; echo
   2.919 +					_ 'Checking if $pkg exists in local list...'
   2.920  					mkdir $TMP_DIR
   2.921  					for i in $pkg-*.tazpkg; do
   2.922  						[ -f $i ] || continue
   2.923 @@ -910,31 +1010,33 @@
   2.924  		done
   2.925  	else
   2.926  		newline
   2.927 -		eval_gettext \
   2.928 +		_ \
   2.929  "Leaving dependencies for \$PACKAGE unresolved.
   2.930 -The package is installed but will probably not work."; echo
   2.931 +The package is installed but will probably not work."
   2.932  		newline
   2.933  	fi
   2.934  }
   2.935  
   2.936 +
   2.937  # Search pattern in installed packages.
   2.938 +
   2.939  search_in_installed_packages()
   2.940  {
   2.941 -	gettext "Installed packages"; echo
   2.942 +	_ 'Installed packages'
   2.943  	separator
   2.944  	list=`ls -1 $INSTALLED | grep -i "$PATTERN"`
   2.945  	num=0
   2.946 -	for pkg in $list
   2.947 -	do
   2.948 +	for pkg in $list; do
   2.949  		EXTRAVERSION=""
   2.950  		[ -f $INSTALLED/$pkg/receipt ] || continue
   2.951  		. $INSTALLED/$pkg/receipt
   2.952 -		emsg "$PACKAGE<i 24> $VERSION$EXTRAVERSION<i 42> $(gettext $CATEGORY)"
   2.953 +		emsg "$PACKAGE<i 24> $VERSION$EXTRAVERSION<i 42> $(_n $CATEGORY)"
   2.954  		num=$(($num+1))
   2.955  	done
   2.956 +
   2.957  	# Set correct ending messages.
   2.958  	if [ x$num == x ]; then
   2.959 -		eval_gettext "No installed packages found for: \$PATTERN"; echo
   2.960 +		_ 'No installed packages found for: $PATTERN'
   2.961  		newline
   2.962  	else
   2.963  		footer "$(eval_ngettext \
   2.964 @@ -943,25 +1045,28 @@
   2.965  	fi
   2.966  }
   2.967  
   2.968 +
   2.969  # Search in packages.list for available pkgs.
   2.970 +
   2.971  search_in_packages_list()
   2.972  {
   2.973 -	gettext "Available packages name-version"; echo
   2.974 +	_ 'Available packages name-version'
   2.975  	separator
   2.976  	num=0
   2.977 +	BPATTERN="$(emsg "<b>$PATTERN</b>")"
   2.978  	for i in $LOCALSTATE/packages.list $LOCALSTATE/undigest/*/packages.list; do
   2.979 -		grep -is "$PATTERN" $i
   2.980 +		grep -is "$PATTERN" $i | sed "s|$PATTERN|$BPATTERN|"
   2.981  		num=$(($num + `grep -is "$PATTERN" $i | wc -l`))
   2.982  	done
   2.983  	if [ ! -f "$LOCALSTATE/packages.list" ]; then
   2.984  		newline
   2.985 -		gettext \
   2.986 +		_ \
   2.987  "No 'packages.list' found to check for mirrored packages. For more results,
   2.988 -please run 'tazpkg recharge' once as root before searching."; echo
   2.989 +please run 'tazpkg recharge' once as root before searching."
   2.990  		newline
   2.991  	fi
   2.992  	if [ "$num" = "0" ]; then
   2.993 -		eval_gettext "No available packages found for: \$PATTERN"; echo
   2.994 +		_ 'No available packages found for: $PATTERN'
   2.995  		newline
   2.996  	else
   2.997  		footer "$(eval_ngettext \
   2.998 @@ -970,11 +1075,13 @@
   2.999  	fi
  2.1000  }
  2.1001  
  2.1002 +
  2.1003  # search --mirror: Search in packages.txt for available pkgs and give more
  2.1004  # info than --list or default.
  2.1005 +
  2.1006  search_in_packages_txt()
  2.1007  {
  2.1008 -	gettext "Matching packages name with version and desc"; echo
  2.1009 +	_ 'Matching packages name with version and desc'
  2.1010  	separator
  2.1011  	num=0
  2.1012  	for i in $LOCALSTATE/packages.txt $LOCALSTATE/undigest/*/packages.txt; do
  2.1013 @@ -983,13 +1090,13 @@
  2.1014  	done
  2.1015  	if [ ! -f "$LOCALSTATE/packages.txt" ]; then
  2.1016  		newline
  2.1017 -		gettext \
  2.1018 +		_ \
  2.1019  "No 'packages.txt' found to check for mirrored packages. For more results,
  2.1020 -please run 'tazpkg recharge' once as root before searching."; echo
  2.1021 +please run 'tazpkg recharge' once as root before searching."
  2.1022  		newline
  2.1023  	fi
  2.1024  	if [ "$num" = "0" ]; then
  2.1025 -		eval_gettext "No available packages found for: \$PATTERN"; echo
  2.1026 +		_ 'No available packages found for: $PATTERN'
  2.1027  		newline
  2.1028  	else
  2.1029  		footer "$(eval_ngettext \
  2.1030 @@ -998,7 +1105,9 @@
  2.1031  	fi
  2.1032  }
  2.1033  
  2.1034 +
  2.1035  # Install package-list from a flavor
  2.1036 +
  2.1037  install_flavor()
  2.1038  {
  2.1039  	check_root $@
  2.1040 @@ -1013,6 +1122,7 @@
  2.1041  	cd $TMP_DIR
  2.1042  	if [ -f $FLAVOR.flavor ] || download $FLAVOR.flavor; then
  2.1043  		zcat < $FLAVOR.flavor | cpio --quiet -i >/dev/null
  2.1044 +
  2.1045  		while read file; do
  2.1046  			for pkg in $(ls -d $INSTALLED/${file%%-*}*); do
  2.1047  				[ -f $pkg/receipt ] || continue
  2.1048 @@ -1024,13 +1134,15 @@
  2.1049  			cd $CACHE_DIR
  2.1050  			download $file.tazpkg
  2.1051  			cd $TMP_DIR
  2.1052 -		        tazpkg install $CACHE_DIR/$file.tazpkg --forced
  2.1053 +			tazpkg install $CACHE_DIR/$file.tazpkg --forced
  2.1054  		done < $FLAVOR.pkglist
  2.1055 +
  2.1056  		[ -f $FLAVOR.nonfree ] && while read pkg; do
  2.1057  			[ -d $INSTALLED/$pkg ] || continue
  2.1058  			[ -d $INSTALLED/get-$pkg ] && tazpkg get-install get-$pkg
  2.1059  			get-$pkg
  2.1060  		done < $FLAVOR.nonfree
  2.1061 +
  2.1062  		[ "$ARG" == "--purge" ] && for pkg in $(ls $INSTALLED); do
  2.1063  			[ -f $INSTALLED/$pkg/receipt ] || continue
  2.1064  			EXTRAVERSION=""
  2.1065 @@ -1040,13 +1152,15 @@
  2.1066  			tazpkg remove $PACKAGE
  2.1067  		done
  2.1068  	else
  2.1069 -		eval_gettext "Can't find flavor \$FLAVOR. Abort."; echo
  2.1070 +		_ "Can't find flavor \$FLAVOR. Abort."
  2.1071  	fi
  2.1072  	cd $TOP_DIR
  2.1073  	rm -rf $TMP_DIR
  2.1074  }
  2.1075  
  2.1076 +
  2.1077  # Update mirror urls
  2.1078 +
  2.1079  setup_mirror()
  2.1080  {
  2.1081  	# Backup old list.
  2.1082 @@ -1055,11 +1169,11 @@
  2.1083  	fi
  2.1084  	title 'Current mirror(s)'
  2.1085  	echo "  `cat $1/mirror 2> /dev/null`"
  2.1086 -	gettext \
  2.1087 +	_ \
  2.1088  "Please enter URL of the new mirror (http, ftp or local path). You must specify
  2.1089 -the complete address to the directory of the packages and packages.list file."; echo
  2.1090 +the complete address to the directory of the packages and packages.list file."
  2.1091  	newline
  2.1092 -	gettext "New mirror(s) URL: "
  2.1093 +	_n 'New mirror(s) URL: '
  2.1094  	NEW_MIRROR_URL=$2
  2.1095  	if [ -n "$NEW_MIRROR_URL" ]; then
  2.1096  		echo $NEW_MIRROR_URL
  2.1097 @@ -1067,9 +1181,9 @@
  2.1098  		read NEW_MIRROR_URL
  2.1099  	fi
  2.1100  	if [ "$NEW_MIRROR_URL" = "" ]; then
  2.1101 -		gettext "Nothing has been changed."; echo
  2.1102 +		_ 'Nothing has been changed.'
  2.1103  	else
  2.1104 -		eval_gettext "Setting mirror(s) to: \$NEW_MIRROR_URL"; echo
  2.1105 +		_ 'Setting mirror(s) to: $NEW_MIRROR_URL'
  2.1106  		rm -f $1/mirror
  2.1107  		for i in $NEW_MIRROR_URL; do
  2.1108  			echo "${i%/}/" >> $1/mirror
  2.1109 @@ -1078,33 +1192,37 @@
  2.1110  	newline
  2.1111  }
  2.1112  
  2.1113 +
  2.1114  # recursive dependencies scan
  2.1115 +
  2.1116  dep_scan()
  2.1117  {
  2.1118 -for i in $1; do
  2.1119 -	case " $ALL_DEPS " in
  2.1120 -	*\ $i\ *) continue;;
  2.1121 -	esac
  2.1122 -	ALL_DEPS="$ALL_DEPS $i"
  2.1123 -	[ -n "$2" ] && echo "$2$i ($(fgrep -A 3 $i $LOCALSTATE/packages.txt \
  2.1124 -				     | tail -1 | sed 's/.*(\([^ ]*\).*/\1/'))"
  2.1125 -	[ -f $i/receipt ] || continue
  2.1126 -	DEPENDS=""
  2.1127 -	. $i/receipt
  2.1128 -	[ -n "$DEPENDS" ] && dep_scan "$DEPENDS" "$2  "
  2.1129 -done
  2.1130 +	for i in $1; do
  2.1131 +		case " $ALL_DEPS " in
  2.1132 +			*\ $i\ *) continue;;
  2.1133 +		esac
  2.1134 +		ALL_DEPS="$ALL_DEPS $i"
  2.1135 +		[ -n "$2" ] && echo "$2$i ($(fgrep -A 3 $i $LOCALSTATE/packages.txt | \
  2.1136 +						tail -1 | sed 's/.*(\([^ ]*\).*/\1/'))"
  2.1137 +		[ -f $i/receipt ] || continue
  2.1138 +		DEPENDS=""
  2.1139 +		. $i/receipt
  2.1140 +		[ -n "$DEPENDS" ] && dep_scan "$DEPENDS" "$2  "
  2.1141 +	done
  2.1142  }
  2.1143  
  2.1144 +
  2.1145  # recursive reverse dependencies scan
  2.1146 +
  2.1147  rdep_scan()
  2.1148  {
  2.1149 -SEARCH=$1
  2.1150 -
  2.1151 -for i in * ; do
  2.1152 -	DEPENDS=""
  2.1153 -	. $i/receipt
  2.1154 -	echo "$i $(echo $DEPENDS)"
  2.1155 -done | busybox awk -v search=$SEARCH '
  2.1156 +	SEARCH=$1
  2.1157 +
  2.1158 +	for i in * ; do
  2.1159 +		DEPENDS=""
  2.1160 +		. $i/receipt
  2.1161 +		echo "$i $(echo $DEPENDS)"
  2.1162 +	done | busybox awk -v search=$SEARCH '
  2.1163  function show_deps(deps, all_deps, pkg, space)
  2.1164  {
  2.1165  	if (all_deps[pkg] == 1) return
  2.1166 @@ -1125,27 +1243,33 @@
  2.1167  	show_deps(deps, all_deps, search, "")
  2.1168  }
  2.1169  ' | while read spc pkg; do
  2.1170 -	echo -n $spc | sed 's/=/ /g'
  2.1171 -	echo -n $pkg
  2.1172 -	echo -n ' ('
  2.1173 -	fgrep -A 3 $pkg $LOCALSTATE/packages.txt  | tail -1 | \
  2.1174 -				    sed 's/.*(\([^ ]*\).*/\1)/'
  2.1175 -done
  2.1176 +		echo -n $spc | sed 's/=/ /g'
  2.1177 +		echo -n $pkg
  2.1178 +		echo -n ' ('
  2.1179 +		fgrep -A 3 $pkg $LOCALSTATE/packages.txt  | tail -1 | \
  2.1180 +			sed 's/.*(\([^ ]*\).*/\1)/'
  2.1181 +	done
  2.1182  }
  2.1183  
  2.1184 +
  2.1185  # Check for ELF file
  2.1186 +
  2.1187  is_elf()
  2.1188  {
  2.1189  	[ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ]
  2.1190  }
  2.1191  
  2.1192 +
  2.1193  # Print shared library dependencies
  2.1194 +
  2.1195  ldd()
  2.1196  {
  2.1197  	LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
  2.1198  }
  2.1199  
  2.1200 +
  2.1201  # search dependencies for files in $TMP_DIR/$file/fs
  2.1202 +
  2.1203  find_depends()
  2.1204  {
  2.1205  	DEFAULT_DEPENDS="glibc-base gcc-lib-base"
  2.1206 @@ -1153,58 +1277,69 @@
  2.1207  	[ -n "$TMPLOCALSTATE" ] || TMPLOCALSTATE=$LOCALSTATE
  2.1208  	[ -f $TMPLOCALSTATE/files.list.lzma ] || tazpkg recharge > /dev/null
  2.1209  	for i in $TMPLOCALSTATE/files.list.lzma \
  2.1210 - 		$TMPLOCALSTATE/undigest/*/files.list.lzma ; do
  2.1211 - 		[ -f $i ] && lzma d $i -so >> $TMP_DIR/files.list
  2.1212 +		$TMPLOCALSTATE/undigest/*/files.list.lzma ; do
  2.1213 +		[ -f $i ] && lzma d $i -so >> $TMP_DIR/files.list
  2.1214  	done
  2.1215 -	find ${1:-$TMP_DIR/$file/fs} -type f | while read chkfile ; do
  2.1216 +
  2.1217 +	find ${1:-$TMP_DIR/$file/fs} -type f | \
  2.1218 +	while read chkfile ; do
  2.1219  		is_elf $chkfile || continue
  2.1220  		case "$chkfile" in
  2.1221 -		*.o|*.ko|*.ko.gz) continue;;
  2.1222 +			*.o|*.ko|*.ko.gz) continue;;
  2.1223  		esac
  2.1224 -		ldd $chkfile | while read lib rem; do
  2.1225 +
  2.1226 +		ldd $chkfile | \
  2.1227 +		while read lib rem; do
  2.1228  			case "$lib" in
  2.1229 -			statically|linux-gate.so*|ld-*.so|*/ld-*.so)
  2.1230 -				continue;;
  2.1231 +				statically|linux-gate.so*|ld-*.so|*/ld-*.so) continue;;
  2.1232  			esac
  2.1233  			find ${1:-$TMP_DIR/$file/fs} | grep -q /$lib$ && continue
  2.1234 +
  2.1235  			for dep in $(fgrep $lib files.list | cut -d: -f1); do
  2.1236  				case " $DEFAULT_DEPENDS " in
  2.1237 -				*\ $dep\ *) continue 2;;
  2.1238 +					*\ $dep\ *) continue 2;;
  2.1239  				esac
  2.1240  				grep -qs "^$dep$" $TMP_DIR/depends && continue 2
  2.1241  			done
  2.1242 +
  2.1243  			if [ -n "$dep" ]; then
  2.1244  				echo "$dep" >> $TMP_DIR/depends
  2.1245  			else
  2.1246  				grep -qs ^$lib$ $TMP_DIR/unresolved ||
  2.1247 -				echo "$lib" >> $TMP_DIR/unresolved
  2.1248 +					echo "$lib" >> $TMP_DIR/unresolved
  2.1249  			fi
  2.1250  		done
  2.1251  	done
  2.1252 +
  2.1253  	spc=""
  2.1254 -	sort < $TMP_DIR/depends 2> /dev/null | uniq | while read file; do
  2.1255 +	sort < $TMP_DIR/depends 2> /dev/null | uniq | \
  2.1256 +	while read file; do
  2.1257  		echo -n "$spc$file"
  2.1258  		spc=" "
  2.1259  	done
  2.1260  }
  2.1261  
  2.1262 +
  2.1263  show_unresolved_lib()
  2.1264  {
  2.1265  	if [ -s $TMP_DIR/unresolved ]; then
  2.1266  		echo -e "BUGS=\"`gettext \"No dependency for\"`" >> $1
  2.1267 -		sort < $TMP_DIR/unresolved | uniq | while read file; do
  2.1268 -			eval_gettext "WARNING: unknown dependency for \$lib"; echo
  2.1269 +		sort < $TMP_DIR/unresolved | uniq | \
  2.1270 +		while read file; do
  2.1271 +			_ 'WARNING: unknown dependency for $lib'
  2.1272  			echo -n " $file" >> $1
  2.1273  		done
  2.1274  		echo "\"" >> $1
  2.1275  	fi
  2.1276  }
  2.1277  
  2.1278 +
  2.1279  # convert a .tar.bz2 package to .tazpkg
  2.1280 +
  2.1281  convert_upkg()
  2.1282  {
  2.1283  	mkdir -p $TMP_DIR/fs
  2.1284 -	tar xjf $PACKAGE_FILE -C $TMP_DIR/fs 	
  2.1285 +	tar xjf $PACKAGE_FILE -C $TMP_DIR/fs
  2.1286  	if [ -d $TMP_DIR/fs/var/lib/upkg/packages ]; then
  2.1287  		cd $TMP_DIR
  2.1288  		package="$(sed '/^Package:/!d;s/.*: //' fs/var/lib/upkg/packages/*.info)"
  2.1289 @@ -1246,13 +1381,15 @@
  2.1290  		tazpkg pack $file
  2.1291  		mv $TMP_DIR/$file.tazpkg $TOP_DIR
  2.1292  	else
  2.1293 -		eval_gettext "\$PACKAGE_FILE does not look like an upkg package!"; echo
  2.1294 +		_ '$PACKAGE_FILE does not look like an upkg package!'
  2.1295  	fi
  2.1296  	cd $TOP_DIR
  2.1297  	rm -rf $TMP_DIR
  2.1298  }
  2.1299  
  2.1300 +
  2.1301  # convert a .spack package to .tazpkg
  2.1302 +
  2.1303  convert_spack()
  2.1304  {
  2.1305  	mkdir -p $TMP_DIR
  2.1306 @@ -1299,7 +1436,9 @@
  2.1307  	rm -rf $TMP_DIR
  2.1308  }
  2.1309  
  2.1310 +
  2.1311  # convert a .ipk package to .tazpkg
  2.1312 +
  2.1313  convert_ipk()
  2.1314  {
  2.1315  	mkdir -p $TMP_DIR
  2.1316 @@ -1314,8 +1453,7 @@
  2.1317  	i386|all)
  2.1318  		file=$package-$version
  2.1319  		mkdir -p $TMP_DIR/$file/fs
  2.1320 -		tar xOzf $PACKAGE_FILE ./data.tar.gz | \
  2.1321 -			tar xzf - -C $TMP_DIR/$file/fs
  2.1322 +		tar xOzf $PACKAGE_FILE ./data.tar.gz | tar xzf - -C $TMP_DIR/$file/fs
  2.1323  		cd $TMP_DIR
  2.1324  		cat > $file/receipt <<EOT
  2.1325  # SliTaz package receipt.
  2.1326 @@ -1360,13 +1498,15 @@
  2.1327  		mv $TMP_DIR/$file.tazpkg .
  2.1328  		;;
  2.1329  	*)
  2.1330 -		eval_gettext "Invalid target: \$target (expected i386)"; echo
  2.1331 +		_ 'Invalid target: $target (expected i386)'
  2.1332  		;;
  2.1333  	esac
  2.1334  	rm -rf $TMP_DIR
  2.1335  }
  2.1336  
  2.1337 +
  2.1338  # convert a .pkg.tar.gz/.pkg.tar.xz/.apk package to .tazpkg
  2.1339 +
  2.1340  convert_arch()
  2.1341  {
  2.1342  	mkdir -p $TMP_DIR/fs
  2.1343 @@ -1397,13 +1537,15 @@
  2.1344  		tazpkg pack $file
  2.1345  		mv $file.tazpkg $TOP_DIR
  2.1346  	else
  2.1347 -		eval_gettext "\$PACKAGE_FILE does not look like an Archlinux/Alpine package!"; echo
  2.1348 +		_ '$PACKAGE_FILE does not look like an Archlinux/Alpine package!'
  2.1349  	fi
  2.1350  	cd $TOP_DIR
  2.1351  	rm -rf $TMP_DIR
  2.1352  }
  2.1353  
  2.1354 +
  2.1355  # get package and version from PACKAGE_FILE
  2.1356 +
  2.1357  parse_pkgname()
  2.1358  {
  2.1359  	package=$(basename ${2:-$PACKAGE_FILE} $1)
  2.1360 @@ -1420,6 +1562,7 @@
  2.1361  	mkdir $file
  2.1362  }
  2.1363  
  2.1364 +
  2.1365  finish_convert_puppy()
  2.1366  {
  2.1367  	rm -f fs/*.specs
  2.1368 @@ -1455,12 +1598,14 @@
  2.1369  	rm -rf $TMP_DIR
  2.1370  }
  2.1371  
  2.1372 +
  2.1373  # convert a .sfs package to .tazpkg
  2.1374 +
  2.1375  convert_sfs()
  2.1376  {
  2.1377  	[ -n "$(which unsquashfs)" ] || tazpkg get-install squashfs 
  2.1378  	if ! unsquashfs -l $PACKAGE_FILE | grep -q squashfs-root/pet.specs$ ; then
  2.1379 -		eval_gettext "\$PACKAGE_FILE does not look like a Puppy package!"; echo
  2.1380 +		_ '$PACKAGE_FILE does not look like a Puppy package!'
  2.1381  		return 1
  2.1382  	fi
  2.1383  	mkdir -p $TMP_DIR 
  2.1384 @@ -1473,7 +1618,9 @@
  2.1385  	finish_convert_puppy
  2.1386  }
  2.1387  
  2.1388 +
  2.1389  # convert a .pet package to .tazpkg
  2.1390 +
  2.1391  convert_pet()
  2.1392  {
  2.1393  	mkdir -p $TMP_DIR 
  2.1394 @@ -1486,12 +1633,14 @@
  2.1395  	finish_convert_puppy
  2.1396  }
  2.1397  
  2.1398 +
  2.1399  # convert a .sb package to .tazpkg
  2.1400 +
  2.1401  convert_sb()
  2.1402  {
  2.1403  	[ -n "$(which unsquashfs)" ] || tazpkg get-install squashfs 
  2.1404  	if ! unsquashfs -l $PACKAGE_FILE | grep -q squashfs-root/var/log/removed_scripts ; then
  2.1405 -		eval_gettext "\$PACKAGE_FILE does not look like a Slax package!"; echo
  2.1406 +		_ '$PACKAGE_FILE does not look like a Slax package!'
  2.1407  		return 1
  2.1408  	fi
  2.1409  	mkdir -p $TMP_DIR 
  2.1410 @@ -1530,7 +1679,9 @@
  2.1411  	rm -rf $TMP_DIR
  2.1412  }
  2.1413  
  2.1414 +
  2.1415  # convert a .tgz package to .tazpkg
  2.1416 +
  2.1417  convert_tgz()
  2.1418  {
  2.1419  	parse_pkgname
  2.1420 @@ -1569,13 +1720,15 @@
  2.1421  		tazpkg pack $file
  2.1422  		mv $file.tazpkg $TOP_DIR
  2.1423  	else
  2.1424 -		eval_gettext "\$PACKAGE_FILE does not look like a Slackware package!"; echo
  2.1425 +		_ '$PACKAGE_FILE does not look like a Slackware package!'
  2.1426  	fi
  2.1427  	cd $TOP_DIR
  2.1428  	rm -rf $TMP_DIR
  2.1429  }
  2.1430  
  2.1431 +
  2.1432  # convert a .deb package to .tazpkg
  2.1433 +
  2.1434  convert_deb()
  2.1435  {
  2.1436  	mkdir -p $TMP_DIR
  2.1437 @@ -1624,14 +1777,16 @@
  2.1438  		mv $file.tazpkg $TOP_DIR
  2.1439  		;;
  2.1440  	*)
  2.1441 -		eval_gettext "Invalid target: \$target (expected i386)"; echo
  2.1442 +		_ 'Invalid target: $target (expected i386)'
  2.1443  		;;
  2.1444  	esac
  2.1445  	cd $TOP_DIR
  2.1446  	rm -rf $TMP_DIR
  2.1447  }
  2.1448  
  2.1449 +
  2.1450  # convert a .rpm package to .tazpkg
  2.1451 +
  2.1452  convert_rpm()
  2.1453  {
  2.1454  	mkdir -p $TMP_DIR
  2.1455 @@ -1673,8 +1828,8 @@
  2.1456  	# rpm2cpio can't extract some new RPMs
  2.1457  	if [ $? == 1 ]; then
  2.1458  		if [ ! -e $INSTALLED/p7zip-full/receipt ]; then
  2.1459 -			boldify $(gettext "Unable to extract the RPM using standard tools (rpm2cpio).")
  2.1460 -			gettext "Do you want to install 'p7zip-full' package" && confirm
  2.1461 +			boldify $(_ 'Unable to extract the RPM using standard tools (rpm2cpio).')
  2.1462 +			_n "Do you want to install 'p7zip-full' package"; confirm
  2.1463  			if [ $? = 0 ]; then
  2.1464  				tazpkg -gi p7zip-full
  2.1465  			else
  2.1466 @@ -1696,6 +1851,7 @@
  2.1467  	rm -rf $TMP_DIR
  2.1468  }
  2.1469  
  2.1470 +
  2.1471  update_desktop_database()
  2.1472  {
  2.1473  	if [ -f $1/usr/bin/update-desktop-database ] && [ -n "$updatedesktopdb" ]; then
  2.1474 @@ -1703,6 +1859,7 @@
  2.1475  	fi
  2.1476  }
  2.1477  
  2.1478 +
  2.1479  update_mime_database()
  2.1480  {
  2.1481  	if [ -f $1/usr/bin/update-mime-database ] && [ -n "$updatemimedb" ]; then
  2.1482 @@ -1710,6 +1867,7 @@
  2.1483  	fi
  2.1484  }
  2.1485  
  2.1486 +
  2.1487  update_icon_database()
  2.1488  {
  2.1489  	if [ -f $1/usr/bin/gtk-update-icon-cache ] && [ -n "$updateicondb" ]; then
  2.1490 @@ -1717,6 +1875,7 @@
  2.1491  	fi
  2.1492  }
  2.1493  
  2.1494 +
  2.1495  compile_glib_schemas()
  2.1496  {
  2.1497  	if [ -f $1/usr/bin/glib-compile-schemas ] && [ -n "$compile_schemas" ]; then
  2.1498 @@ -1724,6 +1883,7 @@
  2.1499  	fi
  2.1500  }
  2.1501  
  2.1502 +
  2.1503  update_kernel_modules()
  2.1504  {
  2.1505  	if [ -f $1/sbin/depmod ] && [ -n "$updatedepmod" ]; then
  2.1506 @@ -1731,6 +1891,10 @@
  2.1507  	fi
  2.1508  }
  2.1509  
  2.1510 +
  2.1511 +
  2.1512 +
  2.1513 +
  2.1514  ###################
  2.1515  # TazPKG commands #
  2.1516  ###################
  2.1517 @@ -1738,35 +1902,36 @@
  2.1518  case "$COMMAND" in
  2.1519  	list|-l)
  2.1520  		shift
  2.1521 +
  2.1522  		# List all installed packages or a specific category.
  2.1523  		if [ "$1" = "blocked" ]; then
  2.1524  			title 'Blocked packages'
  2.1525  			if [ -s "$BLOCKED" ];then