Last active
January 22, 2020 00:13
-
-
Save Tzrlk/75f90f2ffd6c53ae3b901d1560acc272 to your computer and use it in GitHub Desktop.
Script to build an RPM for a version of the DUC tool via Docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
DUC_VERSION=${1} | |
if [ -z "${DUC_VERSION}" ]; then | |
echo >&2 "You need to provide a valid release version to package." | |
exit 1 | |
fi | |
if [ ! -f "duc-${DUC_VERSION}.tar.gz" ]; then | |
RELEASE_BASE=https://github.com/zevv/duc/releases/download | |
curl -LO \ | |
${RELEASE_BASE}/${DUC_VERSION}/duc-${DUC_VERSION}.tar.gz \ | |
|| exit 1 | |
fi | |
if [ ! -f "duc-${DUC_VERSION}.spec" ]; then | |
RAW_BASE=https://raw.githubusercontent.com/zevv/duc | |
curl -L \ | |
-o duc-${DUC_VERSION}.spec \ | |
${RAW_BASE}/${DUC_VERSION}/build/duc.spec \ | |
|| exit 1 | |
sed -i \ | |
"s/^\(%global version\).*$/\1 ${DUC_VERSION}/" \ | |
duc-${DUC_VERSION}.spec \ | |
|| exit 1 | |
fi | |
RHEL_VERSION=${2:-7} | |
if [ -z "${RHEL_VERSION}" ]; then | |
echo >&2 "This should have defaulted to 7." | |
exit 1 | |
fi | |
DOCKER_OS="$(docker version -f "{{ .Client.Os }}")" | |
if [ "${DOCKER_OS}" = "windows" ]; then | |
WORKDIR=$(pwd -W) | |
else | |
WORKDIR=$(pwd) | |
fi | |
docker run -t --rm \ | |
--cap-add=SYS_ADMIN \ | |
-e MOCK_CONFIG=epel-${RHEL_VERSION}-x86_64 \ | |
-e SOURCES=rpmbuild/duc-${DUC_VERSION}.tar.gz \ | |
-e SPEC_FILE=rpmbuild/duc-${DUC_VERSION}.spec \ | |
-v ${WORKDIR}:/rpmbuild \ | |
-v ${WORKDIR}/output:/output \ | |
mmornati/mock-rpmbuilder \ | |
|| exit 1 | |
echo "RPM built as output/epel-${RHEL_VERSION}-x86_64/duc-${DUC_VERSION}-1.el${RHEL_VERSION}.x86_64.rpm" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Still getting
sh: /c/Program Files/Docker/Docker/resources/bin/docker: Bad address
when running on windows, but should work fine under linux. Bashified version of what I'm running on my internal build server.