0

I'm regularly asked how to get some software on Amazon Linux 2023. Usually, I find the software to be already available on Fedora or modern Alma Linux. What do I do to get a software package that's easy to install on Amazon Linux?

1 Answer 1

1

First of all, you need to figure out the source package name of the package you want to install. That's often very easy – on your Fedora (or fedora-alike platform, not on your amazon linux machine) you figure out the package (for example, by asking rpm -qf /usr/bin/programname for the package name), then you ask dnf info {package name} | grep '^Source' to get the source package name. It's the part before the -X.XX-X.fcXX.src.rpm.

Then, armed with knowledge of the source package name, which we'll replace with $srcpkg in the following, you can run a target build. You need to set up the tools first. Luckily, that's a one-time: sudo dnf install mock fedpkg, done.

From there on, it's just

  1. cloning the package source repo
  2. doing a build for the target machine
  3. copying over the resulting packages to your amazon linux machine and
  4. installing them there
# 1.
fedpkg clone $pkgname
cd $pkgname

# 2.
fedpkg mockbuild --root /etc/mock/amazonlinux-2023-x86_64.cfg 

# 3. 
# Create a tar
# if in bash (you probably are): enable recursive globs
shopt -s globstar
tar cvf packages-$pkgname.tar results*/**/*.rpm

Now, you can just copy over your freshly created .tar file, and on your amazon linux machine:

cd /tmp/
mkdir packages
cd packages
tar xf /path/to/copied/over/packages-$pkgname.tar
shopt -s globstar
sudo dnf install **/*.rpm
# optionally: clean up packages
cd /tmp && rm -rf packages && rm /path/to/copied/over/packages-$pkgname.tar

Using this method for other RedHat-oid Linuxes

This works the same for Alma, Rocky Linux, RHEL and CentOS; you need to use a different mock root config in step 2. Note that when you look into /etc/mock, you will find pre-existing ones with +epel in their names – these might contain dependencies you need, but beware that you might have to enable EPEL on your target platform as well.

For instructions on how to build packages "the hard way" without mock, see I need a package for my version of RHEL/EPEL/CentOS/Fedora, but it's only packaged for other versions of Redhatoids

Because Amazon Linux is not RedHat, or CentOS, there's no EPEL for it, so you might need to first port things that are available in EPEL to amazon linux, install that in your own container config (i.e., a modified copy of amazonlinux-2023-….cfg), and then can proceed. You're essentially porting parts of another distro to Amazon Linux then. This might be the time to consider using a podman container to run the respective software in a non-Amazon Linux distro.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .