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