summaryrefslogtreecommitdiffstats
path: root/.github/mock.sh
diff options
context:
space:
mode:
Diffstat (limited to '.github/mock.sh')
-rwxr-xr-x.github/mock.sh50
1 files changed, 50 insertions, 0 deletions
diff --git a/.github/mock.sh b/.github/mock.sh
new file mode 100755
index 0000000..7fbe690
--- /dev/null
+++ b/.github/mock.sh
@@ -0,0 +1,50 @@
1#!/bin/bash
2
3set -x
4
5export DEBIAN_FRONTEND=noninteractive
6
7BASE_PATH="/src"
8
9ls -la ${BASE_PATH}/.github/os_detect.sh
10. ${BASE_PATH}/.github/os_detect.sh
11
12SRCRPM_DIR="/tmp/result-srcrpm"
13RPM_DIR="/tmp/result-rpm"
14SPEC_DIR="${BASE_PATH}/.github/"
15SOURCE_DIR="."
16SPEC_FILE="${SPEC_DIR}monitoring-plugins.spec"
17
18cd ${BASE_PATH}
19
20dnf -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)
36SRC_RPM="monitoring-plugins-*-1.${platform_id}.src.rpm"
37if 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"
44fi
45mkdir -p "${SRCRPM_DIR}" "${RPM_DIR}"
46#rpmbuild --undefine=_disable_source_fetch --define "_sourcedir ${SOURCE_DIR}" -ba ${SPEC_FILE}
47dnf -y --setopt="tsflags=nodocs" install rpmdevtools && spectool -g -C ${SOURCE_DIR} ${SPEC_FILE} && \
48mock --dnf --clean --spec ${SPEC_FILE} --sources=${SOURCE_DIR} --result=${SRCRPM_DIR} --build || { cat ${SRCRPM_DIR}/{root,build}.log; exit 1; }
49mock --dnf --clean --sources=${SOURCE_DIR} --result=${RPM_DIR} --rebuild ${SRCRPM_DIR}/${SRC_RPM} || { cat ${RPM_DIR}/{root,build}.log; exit 1; }
50ls -la ${SOURCE_DIR} ${SRCRPM_DIR} ${RPM_DIR}