Commit d80949cb authored by Vitaly Lipatov's avatar Vitaly Lipatov

distr_info: cleanup code, fix quotes

parent bcb38d23
...@@ -354,11 +354,16 @@ esac ...@@ -354,11 +354,16 @@ esac
echo "$DIST_OS" echo "$DIST_OS"
} }
get_uname_m()
{
uname -m | tr [:upper:] [:lower:] | tr -d " \t\r\n"
}
get_arch() get_arch()
{ {
local DIST_ARCH local DIST_ARCH
# Resolve the architecture # Resolve the architecture
DIST_ARCH=`uname -m | tr [:upper:] [:lower:] | tr -d " \t\r\n"` DIST_ARCH="$(get_uname_m)"
case "$DIST_ARCH" in case "$DIST_ARCH" in
'ia32' | 'i386' | 'i486' | 'i586' | 'i686') 'ia32' | 'i386' | 'i486' | 'i586' | 'i686')
DIST_ARCH="x86" DIST_ARCH="x86"
...@@ -385,7 +390,7 @@ case "$DIST_ARCH" in ...@@ -385,7 +390,7 @@ case "$DIST_ARCH" in
DIST_ARCH="parisc" DIST_ARCH="parisc"
;; ;;
armv*) armv*)
if [ -z "`readelf -A /proc/self/exe | grep Tag_ABI_VFP_args`" ] ; then if [ -z "$(readelf -A /proc/self/exe | grep Tag_ABI_VFP_args)" ] ; then
DIST_ARCH="armel" DIST_ARCH="armel"
else else
DIST_ARCH="armhf" DIST_ARCH="armhf"
...@@ -399,7 +404,7 @@ get_bit_size() ...@@ -399,7 +404,7 @@ get_bit_size()
{ {
local DIST_BIT local DIST_BIT
# Check if we are running on 64bit platform, seems like a workaround for now... # Check if we are running on 64bit platform, seems like a workaround for now...
DIST_BIT=`uname -m | tr [:upper:] [:lower:] | tr -d " \t\r\n"` DIST_BIT="$(get_uname_m)"
case "$DIST_BIT" in case "$DIST_BIT" in
'amd64' | 'ia64' | 'x86_64' | 'ppc64') 'amd64' | 'ia64' | 'x86_64' | 'ppc64')
DIST_BIT="64" DIST_BIT="64"
...@@ -423,18 +428,20 @@ echo "$DIST_BIT" ...@@ -423,18 +428,20 @@ echo "$DIST_BIT"
# TODO: check before calc # TODO: check before calc
get_memory_size() { get_memory_size() {
local detected=0 local detected=0
local DIST_OS=$(get_base_os_name) local DIST_OS="$(get_base_os_name)"
if [ $DIST_OS = "macosx" ] case "$DIST_OS" in
then macosx)
detected=$((`sysctl hw.memsize | sed s/"hw.memsize: "//`/1024/1024)) detected=$((`sysctl hw.memsize | sed s/"hw.memsize: "//`/1024/1024))
elif [ $DIST_OS = "freebsd" ] ;;
then freebsd)
detected=$((`sysctl hw.physmem | sed s/"hw.physmem: "//`/1024/1024)) detected=$((`sysctl hw.physmem | sed s/"hw.physmem: "//`/1024/1024))
elif [ $DIST_OS = "linux" ] ;;
then linux)
[ -r /proc/meminfo ] && detected=$((`cat /proc/meminfo | grep MemTotal | awk '{print $2}'`/1024)) [ -r /proc/meminfo ] && detected=$((`cat /proc/meminfo | grep MemTotal | awk '{print $2}'`/1024))
fi ;;
# Exit codes only support values between 0 and 255. So use stdout. esac
# Exit codes only support values between 0 and 255. So use stdout.
echo $detected echo $detected
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment