I'm building an rpm to install a component on my machines, but I would like to check if certain python libraries are already installed so as not to reinstall them unnecessarily. So, in the %post
section of my spec file, I'm doing this:
function check4pythonlib() {
library=$1
if [[ $(/usr/local/bin/python2.7 -c "import $library" 2> /dev/null ; echo $?) -eq 0 ]]; then
echo "$library is installed"
else
echo "$library is not installed"
echo "Installing $library..."
cd /path/to/lib/$library
/usr/local/bin/python2.7 setup.py build
/usr/local/bin/python2.7 setup.py install
fi
}
check4pythonlib pythonlib1
check4pythonlib pythonlib2
I'm writing all output to a log file, and I see this:
is not installed
Installing ...
/usr/local/bin/python2.7: can't open file 'setup.py': [Errno 2] No such file or directory
/usr/local/bin/python2.7: can't open file 'setup.py': [Errno 2] No such file or directory
is not installed
Installing ...
/usr/local/bin/python2.7: can't open file 'setup.py': [Errno 2] No such file or directory
/usr/local/bin/python2.7: can't open file 'setup.py': [Errno 2] No such file or directory
It seems the argument is not being passed to the function. I have also tried enclosing the arguments in double quotes, but it does not work either. What can I do to properly pass the arguments during rpm installation, so that this works?