From 903773eb9c3cc2079187dc99c7b48662148ff679 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Fri, 25 Oct 2024 12:02:14 +0200 Subject: Add sanity options to test prepare scripts diff --git a/.github/mock.sh b/.github/mock.sh index 7fbe690..8da147e 100755 --- a/.github/mock.sh +++ b/.github/mock.sh @@ -2,6 +2,8 @@ set -x +set -euo pipefail + export DEBIAN_FRONTEND=noninteractive BASE_PATH="/src" diff --git a/.github/prepare_debian.sh b/.github/prepare_debian.sh index 3f4674a..c38d241 100755 --- a/.github/prepare_debian.sh +++ b/.github/prepare_debian.sh @@ -1,7 +1,7 @@ #!/bin/bash set -x -set -e +set -euo pipefail export DEBIAN_FRONTEND=noninteractive -- cgit v0.10-9-g596f From d996f6560065950393c186cb6c39d94ea9025ac1 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Fri, 25 Oct 2024 12:21:16 +0200 Subject: github/mock.sh: Improve readability and generel shellcheck stuff diff --git a/.github/mock.sh b/.github/mock.sh index 8da147e..0b91364 100755 --- a/.github/mock.sh +++ b/.github/mock.sh @@ -20,7 +20,11 @@ SPEC_FILE="${SPEC_DIR}monitoring-plugins.spec" cd ${BASE_PATH} dnf -y --setopt="tsflags=nodocs" update && \ - if [ ${distro_id} != "fedora" ]; then dnf -y --setopt="tsflags=nodocs" install epel-release; else platform_id="$(echo ${platform_id} | sed s/^f/fc/)"; fi && \ + if [ "${distro_id}" != "fedora" ]; then + dnf -y --setopt="tsflags=nodocs" install epel-release; + else + platform_id="$(echo "${platform_id}" | sed s/^f/fc/)"; + fi && \ case ${distro_id} in ol) case ${platform_id} in @@ -34,19 +38,27 @@ dnf -y --setopt="tsflags=nodocs" update && \ ;; esac dnf -y --setopt="tsflags=nodocs" install mock rpm-build git-core && \ - usermod -a -G mock $(whoami) + usermod -a -G mock "$(whoami)" + SRC_RPM="monitoring-plugins-*-1.${platform_id}.src.rpm" + if command -v git > /dev/null 2>&1; then git config --global --add safe.directory ${BASE_PATH} SHA="$(git rev-parse HEAD)" sed "s/^%global commit.*/%global commit ${SHA}/" ${SPEC_FILE} > ${SPEC_DIR}monitoring-plugins-git.spec sed -i "s/^%global fromgit.*/%global fromgit 1/" ${SPEC_DIR}monitoring-plugins-git.spec SPEC_FILE="${SPEC_DIR}monitoring-plugins-git.spec" - SRC_RPM="monitoring-plugins-*git.$(echo ${SHA:0:7})*.${platform_id}.src.rpm" + SRC_RPM="monitoring-plugins-*git.${SHA:0:7}*.${platform_id}.src.rpm" fi + mkdir -p "${SRCRPM_DIR}" "${RPM_DIR}" #rpmbuild --undefine=_disable_source_fetch --define "_sourcedir ${SOURCE_DIR}" -ba ${SPEC_FILE} -dnf -y --setopt="tsflags=nodocs" install rpmdevtools && spectool -g -C ${SOURCE_DIR} ${SPEC_FILE} && \ -mock --dnf --clean --spec ${SPEC_FILE} --sources=${SOURCE_DIR} --result=${SRCRPM_DIR} --build || { cat ${SRCRPM_DIR}/{root,build}.log; exit 1; } -mock --dnf --clean --sources=${SOURCE_DIR} --result=${RPM_DIR} --rebuild ${SRCRPM_DIR}/${SRC_RPM} || { cat ${RPM_DIR}/{root,build}.log; exit 1; } +dnf -y --setopt="tsflags=nodocs" install rpmdevtools && \ + spectool -g -C ${SOURCE_DIR} ${SPEC_FILE} && \ + { mock --dnf --clean --spec ${SPEC_FILE} --sources=${SOURCE_DIR} --result=${SRCRPM_DIR} --build || \ + { cat ${SRCRPM_DIR}/{root,build}.log; exit 1; } } + +mock --dnf --clean --sources=${SOURCE_DIR} --result=${RPM_DIR} --rebuild "${SRCRPM_DIR}/${SRC_RPM}" || \ + { cat ${RPM_DIR}/{root,build}.log; exit 1; } + ls -la ${SOURCE_DIR} ${SRCRPM_DIR} ${RPM_DIR} -- cgit v0.10-9-g596f From 78246e904ddfc9c0a88e9f47797dc38c1693abbb Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Fri, 25 Oct 2024 12:30:19 +0200 Subject: prepare_debian.sh: Fix typo diff --git a/.github/prepare_debian.sh b/.github/prepare_debian.sh index c38d241..3640e50 100755 --- a/.github/prepare_debian.sh +++ b/.github/prepare_debian.sh @@ -127,5 +127,5 @@ sed "/NP_HOST_TLS_CERT/s/.*/'NP_HOST_TLS_CERT' => '$(hostname)',/" -i /src/.gith # create some test files to lower inodes for i in $(seq 10); do - touch /media/ramdisk2/test.$1 + touch /media/ramdisk2/test.$i done -- cgit v0.10-9-g596f From 54162dbaf689d560656e3eb6c3313840ebc0513a Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Fri, 25 Oct 2024 12:52:32 +0200 Subject: mock.sh: remove some quotting to allow pathname expansion again diff --git a/.github/mock.sh b/.github/mock.sh index 0b91364..87543ce 100755 --- a/.github/mock.sh +++ b/.github/mock.sh @@ -58,7 +58,7 @@ dnf -y --setopt="tsflags=nodocs" install rpmdevtools && \ { mock --dnf --clean --spec ${SPEC_FILE} --sources=${SOURCE_DIR} --result=${SRCRPM_DIR} --build || \ { cat ${SRCRPM_DIR}/{root,build}.log; exit 1; } } -mock --dnf --clean --sources=${SOURCE_DIR} --result=${RPM_DIR} --rebuild "${SRCRPM_DIR}/${SRC_RPM}" || \ +mock --dnf --clean --sources=${SOURCE_DIR} --result=${RPM_DIR} --rebuild "${SRCRPM_DIR}"/${SRC_RPM} || \ { cat ${RPM_DIR}/{root,build}.log; exit 1; } ls -la ${SOURCE_DIR} ${SRCRPM_DIR} ${RPM_DIR} -- cgit v0.10-9-g596f