jobs: gerrit: build osmo-pcap + dep for centos7

We are about to remove the rpm spec files for almost all Osmocom git
repositories. The only two git repositories where we still need them,
because we have a customer using them on centos 7, are libosmocore and
osmo-pcap (SYS#6760). Add CI to ensure that these still build fine, and
that we don't remove these by mistake.

Related: OS#6446
Change-Id: I4d4a67c053ed29811c504158d1ef49430880ad4f
diff --git a/jobs/gerrit-verifications.yml b/jobs/gerrit-verifications.yml
index 607e909..1a5d656 100644
--- a/jobs/gerrit-verifications.yml
+++ b/jobs/gerrit-verifications.yml
@@ -121,6 +121,7 @@
           a1: !!python/tuple [arm-none-eabi, amd64]
           combination_filter: '!(arch=="arm-none-eabi" && label=="FreeBSD_amd64")'
           cmd: '{docker_run_ccache} {docker_img} {timeout_cmd} /build/contrib/jenkins_arch.sh "$arch"'
+          pipeline_binpkgs: "centos:7 debian:10 debian:12"  # centos7: SYS#6760
 
       - libsmpp34
 
@@ -258,7 +259,8 @@
               -e WITH_MANUALS="$WITH_MANUALS" \
               {docker_img} {timeout_cmd} /build/contrib/jenkins.sh
 
-      - osmo-pcap
+      - osmo-pcap:
+          pipeline_binpkgs: "centos:7 debian:10 debian:12"  # centos7: SYS#6760
 
       - osmo-pcu:
           slave_axis: !!python/tuple [osmocom-gerrit, rpi4-raspbian11]
diff --git a/scripts/obs/build_binpkg.py b/scripts/obs/build_binpkg.py
index ae2fe53..5c8cd01 100755
--- a/scripts/obs/build_binpkg.py
+++ b/scripts/obs/build_binpkg.py
@@ -69,6 +69,7 @@
     env = {"JOBS": str(args.jobs),
            "PACKAGE": args.package,
            "BUILDUSER": os.environ["USER"],
+           "DISTRO": args.docker,
            "PACKAGEFORMAT": "deb"}
 
     docker_args = []
diff --git a/scripts/obs/data/build_binpkg.Dockerfile b/scripts/obs/data/build_binpkg.Dockerfile
index 55bfe0c..b29d8f9 100644
--- a/scripts/obs/data/build_binpkg.Dockerfile
+++ b/scripts/obs/data/build_binpkg.Dockerfile
@@ -51,6 +51,24 @@
 		yum config-manager --set-enabled powertools && \
 		su user -c rpmdev-setuptree \
 		;; \
+	centos:7) \
+		yum -y install \
+			autoconf \
+			automake \
+			binutils \
+			dnf-utils \
+			gcc \
+			gcc-c++ \
+			glibc-devel \
+			iproute \
+			libtool \
+			make \
+			redhat-rpm-config \
+			rpm-build \
+			rpmdevtools \
+			wget && \
+		su user -c rpmdev-setuptree \
+		;; \
 	esac
 
 # Add master repository, where packages immediately get updated after merging
@@ -71,7 +89,7 @@
 		echo "deb https://downloads.osmocom.org/packages/osmocom:/$FEED/xUbuntu_$VERSION/ ./" \
 			> /etc/apt/sources.list.d/osmocom-$FEED.list \
 		;; \
-	almalinux:*) \
+	almalinux:*|centos:*) \
 		{ echo "[network_osmocom_$FEED]"; \
 		  echo "name=osmocom:$FEED"; \
 		  echo "type=rpm-md"; \
diff --git a/scripts/obs/data/build_rpm.sh b/scripts/obs/data/build_rpm.sh
index a73d164..7247999 100755
--- a/scripts/obs/data/build_rpm.sh
+++ b/scripts/obs/data/build_rpm.sh
@@ -22,7 +22,23 @@
 su "$BUILDUSER" -c "cp /obs/data/rpmmacros ~/.rpmmacros"
 
 # Force refresh of package index data (OS#6038)
-dnf makecache --refresh
+if command -v dnf; then
+	dnf makecache --refresh
+else
+	yum clean expire-cache
+fi
+
+case "$DISTRO" in
+	centos:7)
+		# HACK: remove pkg-config as centos7 has pkgconfig instead
+		# (which will get pulled in automatically). This could be
+		# solved more elegantly, but we only build very few centos7
+		# packages, so let's not spend too much time on this. In OBS
+		# this is handled in the centos7 prjconf:
+		# https://build.opensuse.org/projects/CentOS:CentOS-7/prjconf
+		sed -i '/^BuildRequires:.*pkg-config/d' "/home/$BUILDUSER/rpmbuild/SPECS/$spec"
+		;;
+esac
 
 $yum_builddep "/home/$BUILDUSER/rpmbuild/SPECS/$spec"
 
diff --git a/scripts/obs/lib/config.py b/scripts/obs/lib/config.py
index b4e23a0..82bf188 100644
--- a/scripts/obs/lib/config.py
+++ b/scripts/obs/lib/config.py
@@ -122,6 +122,7 @@
 docker_distro_default = "debian:12"
 docker_distro_other = [
     "almalinux:*",  # instead of centos (SYS#5818)
+    "centos:7",  # SYS#6760
     "debian:*",
     "ubuntu:*",
 ]