ansible-icinga2-rpminstall/rebuild_src_rpm.sh

43 lines
1.9 KiB
Bash
Raw Normal View History

2023-03-05 21:32:39 +00:00
#!/usr/bin/env bash
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
cd ${ABSDIR}
type -P docker >/dev/null && DOCKER=$(which docker)
type -P podman >/dev/null && DOCKER=$(which podman)
ICINGA2_VERSION=2.13.7
ICINGA2_SPECSOURCE='https://git.icinga.com/packaging/rpm-icinga2/-/raw/master/icinga2.spec'
ICINGA_SELINUX_COMMON_SOURCE='https://packages.icinga.com/fedora/36/release/src/icinga-selinux-common/icinga-selinux-common-1.0.0-1.fc36.icinga.src.rpm'
ARCH=$(${DOCKER} run --rm docker.io/library/rockylinux:8 uname -i)
mkdir /tmp/dockerrpmbuild-$$
for rocky_version in 8 9; do
${DOCKER} run -i --rm -v /tmp/dockerrpmbuild-$$:/out:Z docker.io/library/rockylinux:${rocky_version} <<EOF
rpm -E %{rhel} | grep -q 8 && {
dnf -y install dnf-plugins-core hardlink
dnf config-manager --set-enabled powertools
}
dnf install -qy rpm-build rpmdevtools bison boost-devel cmake flex gcc-c++ libedit-devel libstdc++-devel logrotate make mariadb-connector-c-devel ncurses-devel openssl-devel postgresql-devel selinux-policy-devel systemd-devel
useradd -m dontbuildasroot -s /bin/bash
runuser -l dontbuildasroot -c 'mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}'
runuser -l dontbuildasroot -c 'rpm2cpio ${ICINGA_SELINUX_COMMON_SOURCE} | cpio -idmvD ~/rpmbuild/SPECS/'
runuser -l dontbuildasroot -c 'curl -sSL -o ~/rpmbuild/SPECS/icinga2.spec ${ICINGA2_SPECSOURCE}'
runuser -l dontbuildasroot -c 'sed -i "s|Version: 2.11.4|Version: ${ICINGA2_VERSION}|g" ~/rpmbuild/SPECS/icinga2.spec'
runuser -l dontbuildasroot -c 'spectool -g -R ~/rpmbuild/SPECS/icinga2.spec'
runuser -l dontbuildasroot -c 'rpmbuild -ba ~/rpmbuild/SPECS/icinga-selinux-common.spec'
runuser -l dontbuildasroot -c 'rpmbuild -ba ~/rpmbuild/SPECS/icinga2.spec'
find ~dontbuildasroot/rpmbuild/ -name '*.rpm' -exec cp -f "{}" /out \;
EOF
if [[ $? == 0 ]]; then
mkdir -p ${ABSDIR}/files
2023-03-05 21:32:39 +00:00
mv -f /tmp/dockerrpmbuild-$$/*.rpm ${ABSDIR}/files/
else
exit 1
fi
done &&
rm -rf /tmp/dockerrpmbuild-$$