maj rebuild script

This commit is contained in:
Gitouche 2023-07-18 16:01:21 +02:00
parent 820354e276
commit f47e903451

View file

@ -6,25 +6,32 @@ cd ${ABSDIR}
type -P docker >/dev/null && DOCKER=$(which docker)
type -P podman >/dev/null && DOCKER=$(which podman)
ICINGA2_VERSION=2.13.8
ICINGA2_SPECSOURCE='https://archive.softwareheritage.org/browse/content/sha1_git:6ad9b69b021045c50ada3f1b19f746bbeb51d949/raw/?filename=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'
ICINGA2_SOURCERPM='https://packages.icinga.com/fedora/38/release/src/icinga2/icinga2-2.14.0-1.fc38.src.rpm'
ICINGA_SELINUX_COMMON_SOURCERPM='https://packages.icinga.com/fedora/38/release/src/icinga-selinux-common/icinga-selinux-common-1.0.0-1.fc38.src.rpm'
ARCH=$(${DOCKER} run --rm docker.io/library/rockylinux:8 uname -i)
ICINGA2_DIST=$(echo $ICINGA2_SOURCERPM | awk -F "/" '{print $NF}' | awk -F "." '{print $(NF-2)}')
ICINGA2_REVISION=$(echo $ICINGA2_SOURCERPM | awk -F "/" '{print $NF}' | awk -F ".${ICINGA2_DIST}" '{print $1}' | awk -F "-" '{print $NF}')
ICINGA_SELINUX_COMMON_DIST=$(echo $ICINGA_SELINUX_COMMON_SOURCERPM | awk -F "/" '{print $NF}' | awk -F "." '{print $(NF-2)}')
ICINGA_SELINUX_COMMON_REVISION=$(echo $ICINGA_SELINUX_COMMON_SOURCERPM | awk -F "/" '{print $NF}' | awk -F ".${ICINGA_SELINUX_COMMON_DIST}" '{print $1}' | awk -F "-" '{print $NF}')
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 -y install dnf-plugins-core hardlink mysql-devel
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
rpm -E %{rhel} | grep -q 9 && {
dnf -y install --enablerepo=crb mysql-devel
}
dnf install -qy rpm-build rpmdevtools bison boost-devel cmake flex gcc-c++ libedit-devel libstdc++-devel logrotate make 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.13.5|Version: ${ICINGA2_VERSION}|g" ~/rpmbuild/SPECS/icinga2.spec'
runuser -l dontbuildasroot -c 'rpm -i ${ICINGA2_SOURCERPM}'
runuser -l dontbuildasroot -c 'rpm -i ${ICINGA_SELINUX_COMMON_SOURCERPM}'
runuser -l dontbuildasroot -c 'sed -i "s|Release: ${ICINGA2_REVISION}\.${ICINGA2_DIST}$|Release: ${ICINGA2_REVISION}%{?dist}|" ~/rpmbuild/SPECS/icinga2.spec'
runuser -l dontbuildasroot -c 'sed -i "s|\.${ICINGA2_DIST}|\$(rpm -E %{dist})|g" ~/rpmbuild/SPECS/icinga2.spec'
runuser -l dontbuildasroot -c 'sed -i "s|Release: ${ICINGA_SELINUX_COMMON_REVISION}\.${ICINGA_SELINUX_COMMON_DIST}$|Release: ${ICINGA_SELINUX_COMMON_REVISION}%{?dist}|" ~/rpmbuild/SPECS/icinga-selinux-common.spec'
runuser -l dontbuildasroot -c 'spectool -g -R ~/rpmbuild/SPECS/icinga-selinux-common.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'