Monday, February 24, 2025

Make RPM package on Fedora and RedHat

To create a Golf  installation package for Fedora or RedHat (or similar based on those, like Rocky), first get Golf source code. To do that, install git first:

sudo dnf install git

Then get Golf source code:

git clone https://github.com/golf-lang/golf.git
cd golf

For Redhat/Rocky/etc. install EPEL:

sudo dnf install epel-release

Next, install rpm-build package:

sudo dnf install rpm-build

On Fedora, install spectool:

sudo dnf install spectool

while on Redhat/Rocky/etc. install rpmdevtools:

sudo dnf install rpmdevtools

Just to be sure wget is installed:

sudo dnf install wget

Get the fedora.spec file from Golf's github repo:

wget 'https://raw.githubusercontent.com/golf-lang/golf/refs/heads/main/fedora.spec' -O fedora.spec

Create directory structure for RPM build:

spectool -g -R  fedora.spec

Next, get the dependencies for Golf (i.e. packages needed to build it):

sudo dnf builddep -y fedora.spec

The Golf source code already contains necessary spec files to produce a .rpm package. So you can just do this from command line:

rpmbuild -ba fedora.spec

In the home directory, this will produce file ~/rpmbuild/RPMS/x86_64/golf-<version>-1.<distro>.x86_64.rpm (where <version> is the Golf's current version, and <distro> is a shorthand for Linux distro), and you can now copy that file to another system with the same Linux installed, and install Golf with:

sudo dnf install ~/rpmbuild/RPMS/x86_64/golf-<version>-1.<distro>.x86_64.rpm