diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2024-11-02 13:37:39 +0100 |
|---|---|---|
| committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2024-11-02 13:37:39 +0100 |
| commit | 3faeed07c4825d5c3ceb323e814e703d9262cd82 (patch) | |
| tree | b6a61e24ffa0fbb4af5f145c137f1f584aaba1bc /.github/mock.sh | |
| parent | 735b04eff721a28e791714c0da4c8ac5726bfbcf (diff) | |
| parent | 6d1d1dac32841d5ca6ee51bb09b30a6c604b17e2 (diff) | |
| download | monitoring-plugins-3faeed07c4825d5c3ceb323e814e703d9262cd82.tar.gz | |
Merge branch 'master' into check_swap_again
Diffstat (limited to '.github/mock.sh')
| -rwxr-xr-x | .github/mock.sh | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/.github/mock.sh b/.github/mock.sh new file mode 100755 index 00000000..87543ce8 --- /dev/null +++ b/.github/mock.sh | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | set -x | ||
| 4 | |||
| 5 | set -euo pipefail | ||
| 6 | |||
| 7 | export DEBIAN_FRONTEND=noninteractive | ||
| 8 | |||
| 9 | BASE_PATH="/src" | ||
| 10 | |||
| 11 | ls -la ${BASE_PATH}/.github/os_detect.sh | ||
| 12 | . ${BASE_PATH}/.github/os_detect.sh | ||
| 13 | |||
| 14 | SRCRPM_DIR="/tmp/result-srcrpm" | ||
| 15 | RPM_DIR="/tmp/result-rpm" | ||
| 16 | SPEC_DIR="${BASE_PATH}/.github/" | ||
| 17 | SOURCE_DIR="." | ||
| 18 | SPEC_FILE="${SPEC_DIR}monitoring-plugins.spec" | ||
| 19 | |||
| 20 | cd ${BASE_PATH} | ||
| 21 | |||
| 22 | dnf -y --setopt="tsflags=nodocs" update && \ | ||
| 23 | if [ "${distro_id}" != "fedora" ]; then | ||
| 24 | dnf -y --setopt="tsflags=nodocs" install epel-release; | ||
| 25 | else | ||
| 26 | platform_id="$(echo "${platform_id}" | sed s/^f/fc/)"; | ||
| 27 | fi && \ | ||
| 28 | case ${distro_id} in | ||
| 29 | ol) | ||
| 30 | case ${platform_id} in | ||
| 31 | el9) | ||
| 32 | dnf config-manager --add-repo https://copr.fedorainfracloud.org/coprs/g/mock/mock-stable/repo/epel-9/group_mock-mock-stable-epel-9.repo | ||
| 33 | ;; | ||
| 34 | el8) | ||
| 35 | dnf config-manager --add-repo https://copr.fedorainfracloud.org/coprs/g/mock/mock-stable/repo/epel-8/group_mock-mock-stable-epel-8.repo | ||
| 36 | ;; | ||
| 37 | esac | ||
| 38 | ;; | ||
| 39 | esac | ||
| 40 | dnf -y --setopt="tsflags=nodocs" install mock rpm-build git-core && \ | ||
| 41 | usermod -a -G mock "$(whoami)" | ||
| 42 | |||
| 43 | SRC_RPM="monitoring-plugins-*-1.${platform_id}.src.rpm" | ||
| 44 | |||
| 45 | if command -v git > /dev/null 2>&1; then | ||
| 46 | git config --global --add safe.directory ${BASE_PATH} | ||
| 47 | SHA="$(git rev-parse HEAD)" | ||
| 48 | sed "s/^%global commit.*/%global commit ${SHA}/" ${SPEC_FILE} > ${SPEC_DIR}monitoring-plugins-git.spec | ||
| 49 | sed -i "s/^%global fromgit.*/%global fromgit 1/" ${SPEC_DIR}monitoring-plugins-git.spec | ||
| 50 | SPEC_FILE="${SPEC_DIR}monitoring-plugins-git.spec" | ||
| 51 | SRC_RPM="monitoring-plugins-*git.${SHA:0:7}*.${platform_id}.src.rpm" | ||
| 52 | fi | ||
| 53 | |||
| 54 | mkdir -p "${SRCRPM_DIR}" "${RPM_DIR}" | ||
| 55 | #rpmbuild --undefine=_disable_source_fetch --define "_sourcedir ${SOURCE_DIR}" -ba ${SPEC_FILE} | ||
| 56 | dnf -y --setopt="tsflags=nodocs" install rpmdevtools && \ | ||
| 57 | spectool -g -C ${SOURCE_DIR} ${SPEC_FILE} && \ | ||
| 58 | { mock --dnf --clean --spec ${SPEC_FILE} --sources=${SOURCE_DIR} --result=${SRCRPM_DIR} --build || \ | ||
| 59 | { cat ${SRCRPM_DIR}/{root,build}.log; exit 1; } } | ||
| 60 | |||
| 61 | mock --dnf --clean --sources=${SOURCE_DIR} --result=${RPM_DIR} --rebuild "${SRCRPM_DIR}"/${SRC_RPM} || \ | ||
| 62 | { cat ${RPM_DIR}/{root,build}.log; exit 1; } | ||
| 63 | |||
| 64 | ls -la ${SOURCE_DIR} ${SRCRPM_DIR} ${RPM_DIR} | ||
