We have built application rpm file using fpm.
There we have set python3 as dependency, so it installs automatically before the main rpm.
But it installing 3.7. To replace that with 3.8, we need to check OS version before whether it is centos or awslinux and based on that we need to install specific rpm.
So, I kept these conditional blocks in the preinst script and passed to parameter --before-install.
But, it is getting stuck during rpm installation.
So, when I check with verbose mode. I found that, it is not working with preinst.
The reason, it is ptyhon install not able to apply lock and continr the installation as projectn has already acquired lock on it.
RPM: error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Resource temporarily unavailable)
Error: Could not run transaction.
+ echo 'centos is detected'
centos is detected
+ sudo yum install -yq python38
RPM: error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Resource temporarily unavailable)
Error: Could not run transaction.
Any suggestions you can provide
To be more specific, please find details below.
The tool using for creating rpm: fpm
I need to install python3.8 as dependency to out application rpm.
If I set that as dependency using -d python3, it is installing 3.7 version on amazon linux and 3.6 on centos 8.
To use 3.8 version, there are few other steps to be performed before installing package.
So, I removed the python3 from dependency section and added in --before-install as shell script.
This is the shell script I kept there.
#!/bin/bash
echo "Starting preinst"
echo "Checking OS Version"
DISTRO=$(cat /etc/*-release | grep -w NAME | cut -d= -f2 | tr -d '"' | tr '[:upper:]' '[:lower:]')
if [[ "$DISTRO" =~ "centos linux" ]]; then
echo "centos is detected"
sudo yum install -yq python38
elif [[ "$DISTRO" =~ "amazon linux" ]]; then
echo "amazon linux detected"
sudo yum install -yq amazon-linux-extras
sudo amazon-linux-extras enable python3.8
sudo yum install -yq python3.8
elif [[ "$DISTRO" =~ "ubuntu" ]]; then
echo "ubuntu detected"
sudo apt install pyhton3 -yq
else
echo "Neither centos nor amazon linux 2"
fi
It is triggering the script but stucking at the python installation from shell script.
RPM: error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Resource temporarily unavailable)
Error: Could not run transaction.
+ echo 'centos is detected'
centos is detected
+ sudo yum install -yq python38
RPM: error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Resource temporarily unavailable)
Error: Could not run transaction.
Any suggestions on how to fix this?
My requirement is to install python3.8 as part of our product rpm also as a dependency.