Lampros - Weird Bricks

Create an RPM for Hiawatha 11.1 for Alma Linux

24 April, 2022 | Hiawatha

Install Docker:

1. Create a docker container running Alma Linux 8.5:

At the same time mount the local directory $(pwd)/cache to /var/cache/dnf on the container. This will save us a lot of time re-downloading packages if something were to go wrong with the process.

docker run -dt -v$(pwd)/cache:/var/cache/dnf --name hiawatha_in_alma_linux almalinux:8.5 bash
docker exec -it hiawatha_in_alma_linux bash

Install build dependencies:

The line: 'echo 'keepcache=True' >> /etc/dnf/dnf.conf' tells dnf to keep the local packages around under /var/cache/dnf.

echo 'keepcache=True' >> /etc/dnf/dnf.conf
dnf -y install cmake glibc-devel rpm-build libxml2-devel libxslt-devel gcc

Build Hiawatha:

1. Create target directories:

mkdir -p /target/usr
mkdir -p /target/etc/systemd/system
mkdir -p /target/var/log/hiawatha
mkdir -p /target/var/www

2. Download and compile Hiawatha:

cd /tmp
curl -LO https://gitlab.com/hsleisink/hiawatha/-/archive/v11.1/hiawatha-v11.1.tar.gz
tar -xzf hiawatha-v11.1.tar.gz
cd hiawatha-v11.1
mkdir build
cd build
cmake .. -DENABLE_MONITOR=on -DENABLE_TOMAHAWK=on -DCMAKE_INSTALL_PREFIX=/target/usr -DCMAKE_INSTALL_SYSCONFDIR=/target/etc -DLOG_DIR=/var/log/hiawatha -DWEBROOT_DIR=/var/www/hiawatha -DPID_DIR=/var/run -DWORK_DIR=/var/lib/hiawatha/
make install/strip

Build an RPM out of Hiawatha

1. Install Ruby:

dnf -y install ruby ruby-devel

2. Install the FPM gem:

gem install fpm --no-document

3. Copy the systemd unit in place and fix up the paths:

cd /target
cp /tmp/hiawatha-v11.1/extra/debian/hiawatha.service /target/etc/systemd/system/
sed -i 's!ExecStartPre=/usr/sbin/wigwam -q!ExecStartPre=/usr/sbin/wigwam -q -c /etc/hiawatha!g' /target/etc/systemd/system/hiawatha.service
sed -i 's!ExecStart=/usr/sbin/hiawatha!ExecStart=/usr/sbin/hiawatha -c /etc/hiawatha!g' /target/etc/systemd/system/hiawatha.service
mv /var/www/hiawatha /target/var/www/

4. Create symlinks so that files are in their expected locations:

cd /target/usr/lib64
ln -s hiawatha/libmbedtls.so.17 .
ln -s hiawatha/libmbedx509.so.4 .
ln -s hiawatha/libmbedcrypto.so.11 .

5. Build the RPM:

cd /target
fpm --verbose -v 11.1 -n hiawatha -d libxslt -s dir -t rpm .=/

Sources: