jordansissel / fpm

Effing package management! Build packages for multiple platforms (deb, rpm, etc) with great ease and sanity.
http://fpm.readthedocs.io/en/latest/
Other
11.14k stars 1.07k forks source link

How to set python3.8 as prerequisite #1890

Open uday1kiran opened 2 years ago

uday1kiran commented 2 years ago

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.

jordansissel commented 2 years ago

To the best of my knowledge, you can't install rpms from an rpm script because yum/dnf/rpm only allow one application to control the rpm database at one time. Attempting to do so results in the error message you get, "cant' create transaction lock on ..." because access is locked. RPM tries to protect itself from concurrency bugs by requiring that only one program can install rpms at a given time.

You may find workarounds using a post-install script to schedule an at or cronjob which tries to install the extra package afterwards, but it might get complicated as weird edge cases (the job fails, etc) become frustrating to resolve.

uday1kiran commented 2 years ago

We set python3 as dependency but it installs 3.6 version on CentOS and 3.7 on aws linux 2. But we need 3.8 to be installed, that's why we are trying above steps with before script.

Can you suggest an alternative solution?

Because python 3.8+ required for other steps to continue in the installation.

On Sat, 23 Apr, 2022, 2:00 am Jordan Sissel, @.***> wrote:

To the best of my knowledge, you can't install rpms from an rpm script because yum/dnf/rpm only allow one application to control the rpm database at one time. Attempting to do so results in the error message you get, "cant' create transaction lock on ..." because access is locked. RPM tries to protect itself from concurrency bugs by requiring that only one program can install rpms at a given time.

You may find workarounds using a post-install script to schedule an at or cronjob which tries to install the extra package afterwards, but it might get complicated as weird edge cases (the job fails, etc) become frustrating to resolve.

— Reply to this email directly, view it on GitHub https://github.com/jordansissel/fpm/issues/1890#issuecomment-1106835581, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACGXBQTDYXLZVP5V3TIILVTVGMD47ANCNFSM5UBR7VYA . You are receiving this because you authored the thread.Message ID: @.***>