Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

[TRAFODION-2802 ] source the .bashrc before access JAVA_HOME #1413

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion install/traf_checkset_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,14 @@ if [ ! -d ${javapath} ]; then
exit 1
fi

source $HOME/.bashrc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcing ~/.bashrc and looking into this file is not a very good solution, IMHO. There are so many other ways we can set JAVA_HOME. For example: /etc/bashrc, ~/.trafodion, $TRAF_HOME/.sqenvcom.sh.

I would suggest to just check whether JAVA_HOME is set, otherwise duplicate the code in $TRAF_HOME/.sqenvcom.sh that sets JAVA_HOME. If JAVA_HOME is not already set, then you can then add a line

export JAVA_HOME=...

To the file ~/.trafodion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before, we must prepare environment step by step as following document: [https://cwiki.apache.org/confluence/display/TRAFODION/Create+Build+Environment]
I only write them in one command.
Yes. I think this is not a good way too.

javahome=`grep JAVA_HOME ~/.bashrc | wc -l`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above

if [ "x${javahome}" = "x0" ]; then
echo -en "\n# Added by traf_checkset_env.sh of trafodion\n" >> $HOME/.bashrc
echo -en "export JAVA_HOME=${javapath}\n" >> $HOME/.bashrc
echo -en "export PATH=\$PATH:\$JAVA_HOME/bin\n" >> $HOME/.bashrc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above. Writing into the user's .bashrc is probably not a very good idea. You can create a file ~/.trafodion instead.

export JAVA_HOME=${javapath}
export PATH=$PATH:$JAVA_HOME/bin
else
java_version=`${JAVA_HOME}/bin/java -version 2>&1 | awk 'NR==1{ gsub(/"/,""); print $3}'`
case ${java_version} in
Expand All @@ -268,11 +271,13 @@ if [ "x${local_locale}" != "x" ]; then
if [ "x${lang_set}" != "xen_US.UTF-8" ]; then
echo -en "\n# Added by traf_checkset_env.sh of trafodion\n" >> $HOME/.bashrc
echo -en "export LANG=\"en_US.UTF-8\"\n" >> $HOME/.bashrc
export LANG="en_US.UTF-8"
fi
lc_all_set=`grep LC_TIME ~/.bashrc | awk -F= '{ print $2 }'`
if [ "x${lc_all_set}" != "xen_US.UTF-8" ]; then
echo -en "\n# Added by traf_checkset_env.sh of trafodion\n" >> $HOME/.bashrc
echo -en "export LC_ALL=\"en_US.UTF-8\"\n" >> $HOME/.bashrc
export LC_ALL="en_US.UTF-8"
fi
fi

Expand All @@ -282,7 +287,6 @@ if (("${#faillibs[@]}" > "0")); then
exit 1;
fi

source $HOME/.bashrc
echo $'\n'"Build environment is created SUCCESS!"

echo $'\n'"Install the required Build tools start!"
Expand Down