5
5
ARCHIVE_DIR=$CHARM_DIR/files/archives
6
6
IBM_XLC_INSTALL_PATH=/opt/ibm/xlC
7
IBM_XLC_PARENT_FOLDER=/opt/ibm
9
8
# Check whether XL C/C++ is installed
12
if [ -d $IBM_XLC_INSTALL_PATH ] ; then
14
juju-log " IBM XL C/C++ : IBM XL C/C++ is installed"
18
juju-log " IBM XL C/C++ : IBM XL C/C++ is not installed"
11
if [ -d $IBM_XLC_INSTALL_PATH ]; then
13
juju-log " IBM XL C/C++ : IBM XL C/C++ is installed"
16
juju-log " IBM XL C/C++ : IBM XL C/C++ is not installed"
25
# enabling manpages and error messages
21
# enabling manpages and error messages
30
24
cd $IBM_XLC_INSTALL_PATH
31
25
xlc_conf_path=`find . -name xlc_configure`
32
26
xlc_version=`echo $xlc_conf_path | awk -F'/' '{print $2}'`
35
if grep export profile | grep "/opt/ibm/msg/%L/%N" profile
37
juju-log "IBM XL C/C++ : export NLSPATH already added in profile file"
39
sudo sed -i -e '$a\export NLSPATH=$NLSPATH:/opt/ibm/msg/%L/%N ' /etc/profile
41
juju-log "IBM XL C/C++ : Enabling of error messages done successfully"
43
juju-log "IBM XL C/C++ : Enabling of error messages is not done correctly , please review /etc/profile file"
48
if grep export profile | grep $xlc_version/man/en_US
50
juju-log "IBM XL C/C++ : export MANPATH for version $xlc_version already added in profile file"
53
echo export MANPATH=$IBM_XLC_INSTALL_PATH/$xlc_version/man/en_US:"$"MANPATH >> /etc/profile
55
juju-log "IBM XL C/C++ : Enabling of manual pages done successfully"
57
juju-log "IBM XL C/C++ : Enabling of manual pages is not done correctly , please review /etc/profile file"
28
if grep "NLSPATH:/opt/ibm/msg/%L/%N" /etc/profile
30
juju-log "IBM XL C/C++ : export NLSPATH already added in /etc/profile"
32
echo "export NLSPATH=/opt/ibm/msg/%L/%N:\$NLSPATH" >> /etc/profile
34
juju-log "IBM XL C/C++ : Enabling of error messages done successfully"
36
juju-log "IBM XL C/C++ : Enabling of error messages is not done correctly, please review /etc/profile"
40
if grep "$xlc_version/man/en_US" /etc/profile
42
juju-log "IBM XL C/C++ : export MANPATH for version $xlc_version already added in /etc/profile"
44
echo "export MANPATH=$IBM_XLC_INSTALL_PATH/$xlc_version/man/en_US:\$MANPATH" >> /etc/profile
46
juju-log "IBM XL C/C++ : Enabling of manual pages done successfully"
48
juju-log "IBM XL C/C++ : Enabling of manual pages is not done correctly, please review /etc/profile"
64
54
# Creating sample C/C++ programs for testing the compiler installation
65
create_prog_compiler()
69
cd $CHARM_DIR/files/archives/
70
if [ -f $CHARM_DIR/files/archives/hello.c ]; then
71
juju-log "IBM XL C/C++ : Sample C file hello.c already exists in files/archives folder , you can run it for your verification"
75
echo "#include <stdio.h>" >> hello.c
76
echo "int main(void)" >> hello.c
78
echo "printf(\""Hello World C\!\\n\"");" >> hello.c
79
echo "return 0;" >> hello.c
81
juju-log "IBM XL C/C++ : Created sample C program <hello.c> in files/archives to test the product installation and the critical search paths."
86
if [ -f $CHARM_DIR/files/archives/hello1.cpp ]; then
87
juju-log "IBM XL C/C++ : Sample C++ file hello1.cpp already exists in files/archives folder, you can run it for your verification"
91
echo "#include <iostream>" >> hello1.cpp
92
echo "using namespace std;" >> hello1.cpp
93
echo "int main()" >> hello1.cpp
94
echo "{" >> hello1.cpp
95
echo "cout << \""Hello World C++\!\\n\"";" >> hello1.cpp
96
echo "return 0;" >> hello1.cpp
97
echo "}" >> hello1.cpp
98
juju-log "IBM XL C/C++ : Created sample C++ program <hello1.cpp> in files/archives to test the product installation and the critical search paths."
55
create_prog_compiler()
58
if [ -f $ARCHIVE_DIR/hello.c ]; then
59
juju-log "IBM XL C/C++ : Sample C file hello.c already exists in files/archives folder, you can run it for your verification"
62
echo "#include <stdio.h>" >> hello.c
63
echo "int main(void)" >> hello.c
65
echo "printf(\""Hello World C\!\\n\"");" >> hello.c
66
echo "return 0;" >> hello.c
68
juju-log "IBM XL C/C++ : Created sample C program <hello.c> in files/archives to test the product installation and the critical search paths."
71
if [ -f $ARCHIVE_DIR/hello1.cpp ]; then
72
juju-log "IBM XL C/C++ : Sample C++ file hello1.cpp already exists in files/archives folder, you can run it for your verification"
75
echo "#include <iostream>" >> hello1.cpp
76
echo "using namespace std;" >> hello1.cpp
77
echo "int main()" >> hello1.cpp
78
echo "{" >> hello1.cpp
79
echo "cout << \""Hello World C++\!\\n\"";" >> hello1.cpp
80
echo "return 0;" >> hello1.cpp
81
echo "}" >> hello1.cpp
82
juju-log "IBM XL C/C++ : Created sample C++ program <hello1.cpp> in files/archives to test the product installation and the critical search paths."
107
87
juju-log "IBM XL C/C++ : Begin config-changed hook"
109
89
# Check for architecture
110
90
ARCHITECTURE=`uname -m`
111
91
if [ "$ARCHITECTURE" != "ppc64le" ]; then
112
juju-log "IBM XL C/C++: Unsupported platform. IBM XL C/C++ installed with this Charm supports only POWER LE (ppc64le) platforms."
113
status-set blocked "Unsupported platform ,deploy on Power LE platform"
92
juju-log "IBM XL C/C++: Unsupported platform. IBM XL C/C++ installed with this Charm supports only POWER LE (ppc64le) platforms."
93
status-set blocked "Unsupported platform ,deploy on Power LE platform"
120
# Extract IBM XLC packages and install it
122
98
xlc_installed=`is_xlc_installed`
123
99
if [ $xlc_installed == False ]; then
124
if [ -f $ARCHIVE_DIR/IBM_XL_C_CPP*.tar.gz ]; then
126
# extract XLC package if it is present at /files/archives folder
127
juju-log " IBM XL C/C++ : Extracting the packages"
130
juju-log "IBM XL C/C++: Unable to extract the XL C/C++ package content. Verify whether the package is corrupt."
131
# Remove corrupt archive file
132
rm $ARCHIVE_DIR/*.tar.gz
133
status-set blocked "Package is corrupt, failed to extract"
136
juju-log "IBM XL C/C++ packages extracted successfully"
138
# lib and required packages before installing xlc
139
apt-get install gcc g++ libc6-dev perl -y
141
# Running install command
142
juju-log "IBM XL C/C++ : Running install command for installing IBM XL C/C++"
143
echo 1 | $ARCHIVE_DIR/install
145
juju-log "IBM XL C/C++ : Error while installing Compiler packages into the default location, /opt/ibm/."
148
juju-log "IBM XL C/C++ : Compiler packages are successfully installed and configured into default location ,opt/ibm/."
149
# For enabling the manual pages and xlc error codes
151
# For creating sample C/C++ programs
153
status-set active "IBM XL C/C++ Installed successfully"
160
juju-log "IBM XL C/C++ : XL C/C++ packages are missing. Please place correct packages at files/archives folder."
161
status-set blocked "XL C/C++ packages are missing, place correct packages at files/archives folder"
100
juju-log "IBM XL C/C++ : Installing packages"
101
status-set maintenance "Installing IBM XL C/C++ packages"
102
# Note: package list comes from: http://public.dhe.ibm.com/software/server/POWER/Linux/xl-compiler/eval/ppc64le/
103
apt-get install -qy xlc.13.1.3 xlc-license-eval.13.1.3 libxlc libxlc-devel.13.1.3 libxlsmp libxlsmp-devel.4.1.3 libxlmass-devel.8.1.3
104
if [ $? -ne 0 ]; then
105
juju-log "IBM XL C/C++: Failed to install packages"
106
status-set blocked "Failed to install IBM XL C/C++ packages"
109
juju-log "IBM XL C/C++ : Running xlc_configure"
111
echo 1 | /opt/ibm/xlC/13.1.3/bin/xlc_configure
112
if [ $? -ne 0 ]; then
113
juju-log "IBM XL C/C++ : Error running xlc_configure"
114
status-set blocked "Failed to run xlc_configure"
117
# For enabling the manual pages and xlc error codes
119
# For creating sample C/C++ programs
121
juju-log "IBM XL C/C++ : Compiler packages are successfully installed and configured"
122
status-set active "IBM XL C/C++ Ready"
166
juju-log "IBM XL C/C++ : XL C/C++ is already installed at /opt/ibm/xlC location"
167
status-set blocked "XL C/C++ is already installed at /opt/ibm/xlC location"
126
juju-log "IBM XL C/C++ : XL C/C++ is already installed at $IBM_XLC_INSTALL_PATH"
127
status-set blocked "XL C/C++ is already installed at $IBM_XLC_INSTALL_PATH"
173
juju-log "IBM XL C/C++: End config-change hook"
130
juju-log "IBM XL C/C++ : End config-change hook"