Add get_distro function, fix java setup in arch

This commit is contained in:
Ivan Malison 2016-09-06 11:13:44 -07:00
parent 607defac56
commit c069b18298
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8
2 changed files with 46 additions and 10 deletions

View File

@ -19,6 +19,35 @@ function add_to_path {
eval "$($_python_command $HOME/.lib/python/shell_path.py --include-assignment "$@")"
}
# Taken from http://www.unix.com/shell-programming-and-scripting/27932-how-know-linux-distribution-i-am-using.html
function get_distro {
# start with uname and branch the decision from there
dist=$(uname -s 2> /dev/null)
if [ "$dist" = "Linux" ]; then
get_linux_distro && return 0
elif [ -n "$dist" ]; then
echo "$dist"
return 0
fi
proc_version || echo "Unknown"
return 1
}
function get_linux_distro {
if [ -r /etc/lsb-release ]; then
dist=$(grep 'DISTRIB_ID' /etc/lsb-release | sed 's/DISTRIB_ID=//' | head -1)
[ -n "$dist" ] && echo "$dist" && return 0
fi
dist=$(find /etc/ -maxdepth 1 -name '*release' 2> /dev/null | sed 's/\/etc\///' | sed 's/-release//' | head -1)
[ -n "$dist" ] && echo "$dist" && return 0
dist=$(find /etc/ -maxdepth 1 -name '*version' 2> /dev/null | sed 's/\/etc\///' | sed 's/-version//' | head -1)
[ -n "$dist" ] && echo "$dist" && return 0
return 1
}
function is_osx() {
case `uname` in
'Darwin')

View File

@ -17,13 +17,17 @@ function _setup_env {
}
function _osx_path_setup {
hash brew 2>/dev/null && add_to_path --before "$(brew --prefix coreutils)/libexec/gnubin"
if command_exists "brew";
add_to_path --before "$(brew --prefix coreutils)/libexec/gnubin"
# Access gnu man pages.
add_to_path "$(brew --prefix)/opt/coreutils/libexec/gnuman" --path-var "MANPATH"
then
# Adds airport utility
add_to_path "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources" --after
# I believe that this is here because of some issue with
# python builds in OSX
# I believe that this is here because of some issue with python builds in
# OSX
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
}
@ -58,15 +62,18 @@ function _java_setup {
export GRADLE_HOME="$(brew --prefix gradle)"
export ANDROID_HOME="$(brew --prefix android-sdk)"
add_to_path "$ANDROID_HOME" --after
# Access gnu man pages.
hash brew 2> /dev/null && export MANPATH="$(brew --prefix)/opt/coreutils/libexec/gnuman:$MANPATH"
else
# This may be ubuntu/debian specific
export JAVA_HOME="$(update-alternatives --config java | get_cols ' -1' | head -n 1)"
is_osx && export VISUAL="which emacsclient -c -n"
fi
case get_distro in
Arch)
# Arch does not seem to need to set JAVA_HOME
;;
Debian)
# This may be ubuntu/debian specific
export JAVA_HOME="$(update-alternatives --config java | get_cols ' -1' | head -n 1)"
;;
esac
add_to_path "$JAVA_HOME/bin"
}