Skip to content

Commit

Permalink
pkg: RPM - add mock config for EL8/EL9 based on alma+epel-(8|9)-x86_64
Browse files Browse the repository at this point in the history
This mock config can be used to build RPM packages from a kamailio src.rpm.
- update pkg/kamailio/obs/README -> README.md to include mock
  instructions
- add script create-src-rpm.sh to create src.rpm for package
  building

Cherry-pick from 9de780b
  • Loading branch information
space88man committed Oct 7, 2023
1 parent 04ef597 commit 42f2035
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 18 deletions.
16 changes: 0 additions & 16 deletions pkg/kamailio/obs/README

This file was deleted.

35 changes: 35 additions & 0 deletions pkg/kamailio/obs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# RPM Specs

## For OpenSuse Build Service (OBS)

Here are the RPM packaging specs for openSUSE Build Service:

* https://build.opensuse.org/

It builds RPM packages for following distributions:

* CentOS 6 and 7
* RHEL 6 and 7
* Fedora 25 and 26
* openSUSE 42.2 and 42.3

Kamailio's RPMs bulding projects for various versions can be found at:

* https://build.opensuse.org/project/subprojects/home:kamailio

## For local build using mock

# prepare source tarball from repo
cd kamailio/
mkdir -p ../rpmbuild/SOURCES ../rpmbuild/SPECS
./pkg/kamailio/scripts/git-archive-all.sh kamailio-5.8.0 ../rpmbuild/SOURCES/kamailio-5.8.0_src
# prepare src.rpm with version/release: replace MYVER/MYREL below
cp pkg/kamailio/obs/kamailio.spec ../rpmbuild/SPECS/
sed -i -e s'/^%define ver.*/%define ver MYVER/' -e s'/^%define rel.*/%define rel MYREL/' ../rpmbuild/SPECS/kamailio.spec
rpmbuild -bs --define "_topdir $PWD/../rpmbuild" ../rpmbuild/SPECS/kamailio.spec

# build for EL8/9
mock -r pkg/kamailio/obs/kamailio-8-x86_64.cfg ../rpmbuild/SRPMS/*src.rpm
mock -r pkg/kamailio/obs/kamailio-9-x86_64.cfg ../rpmbuild/SRPMS/*src.rpm


19 changes: 19 additions & 0 deletions pkg/kamailio/obs/kamailio-8-x86_64.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
include('almalinux-8-x86_64.cfg')
include('templates/epel-8.tpl')

config_opts['root'] = "kamailio-8-{{ target_arch }}"
config_opts['description'] = 'Kamailio- AlmaLinux 8 + EPEL'

config_opts['dnf.conf'] += """
# you must copy the kamailio RPM signing key to the host as
# /etc/pki/mock/kamailio-rpm-pub.key
# curl https://rpm.kamailio.org/rpm-pub.key | sudo tee /etc/pki/mock/kamailio-rpm-pub.key
[kamailio]
name=Support packages for kamailio
baseurl=http://rpm.kamailio.org/centos/$releasever/master/master/$basearch/
gpgkey=file:///etc/pki/mock/kamailio-rpm-pub.key
"""

# since EL9 the chroots don't include C/C++ development tools
config_opts['chroot_additional_packages'] = "gcc gcc-c++ make GeoIP-devel autoconf automake libtool"
19 changes: 19 additions & 0 deletions pkg/kamailio/obs/kamailio-9-x86_64.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
include('almalinux-9-x86_64.cfg')
include('templates/epel-9.tpl')

config_opts['root'] = "kamailio-9-{{ target_arch }}"
config_opts['description'] = 'Kamailio- AlmaLinux 9 + EPEL'

config_opts['dnf.conf'] += """
# you must copy the kamailio RPM signing key to the host as
# /etc/pki/mock/kamailio-rpm-pub.key
# curl https://rpm.kamailio.org/rpm-pub.key | sudo tee /etc/pki/mock/kamailio-rpm-pub.key
[kamailio]
name=Support packages for kamailio
baseurl=http://rpm.kamailio.org/centos/$releasever/master/master/$basearch/
gpgkey=file:///etc/pki/mock/kamailio-rpm-pub.key
"""

# since EL9 the chroots don't include C/C++ development tools
config_opts['chroot_additional_packages'] = "gcc gcc-c++ make GeoIP-devel autoconf automake libtool"
37 changes: 37 additions & 0 deletions pkg/kamailio/scripts/create-src-rpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
#

usage() {
echo Usage: create-src-rpm.sh '<version>' '<release>'
}

# creates a src.rpm for mock
VER=$1
REL=$2
[[ -n $VER ]] || { echo "Version not specified"; usage; exit 1; }
[[ -n $REL ]] || { echo "Release not specified"; usage; exit 2; }

git submodule update --init

TMP=$(date +"%s")
RPMBUILD=rpmbuild.${TMP}

rm -rf $RPMBUILD/*
mkdir -p $RPMBUILD/{SRPMS,SPECS,SOURCES}
./pkg/kamailio/scripts/git-archive-all.sh kamailio-${VER} $RPMBUILD/SOURCES/kamailio-${VER}_src

# prepare src.rpm with version/release
cp pkg/kamailio/obs/kamailio.spec $RPMBUILD/SPECS/
sed -i -e s"/^%define ver.*/%define ver ${VER}/" -e s"/^%define rel.*/%define rel ${REL}/" ${RPMBUILD}/SPECS/kamailio.spec

rm -f ${RPMBUILD}/SRPMS/*.src.rpm
rpmbuild -bs --define "_topdir $PWD/$RPMBUILD" $RPMBUILD/SPECS/kamailio.spec

echo "src.rpm is created in $RPMBUILD/SRPMS"
echo "To build:"
echo Run: mock -r pkg/kamailio/obs/kamailio-8-x86_64.cfg $RPMBUILD/SRPMS/*src.rpm
echo Run: mock -r pkg/kamailio/obs/kamailio-9-x86_64.cfg $RPMBUILD/SRPMS/*src.rpm


exit 0

Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/usr/bin/env bash
# packaging script to include submodules
# modified from: https://gist.github.com/arteymix/03702e3eb05c2c161a86b49d4626d21f
# Usage: pkg/scripts/git-archive-all.sh kamailio-5.8.0 ../output/kamailio-5.8.0_src

usage() {
echo Usage: pkg/scripts/git-archive-all.sh kamailio-5.8.0 ../output/kamailio-5.8.0_src
echo Usage: pkg/kamailio/scripts/git-archive-all.sh kamailio-5.8.0 ../output/kamailio-5.8.0_src
}

if [ -z $1 ]; then
Expand Down

0 comments on commit 42f2035

Please sign in to comment.