add RPMBUILD_BASE_DIR to configure the base dir used for rpmbuild
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Robert Kaussow 2020-06-12 08:50:48 +02:00
parent a87cecf558
commit 5be7bae090
No known key found for this signature in database
GPG Key ID: 65362AE74AF98B61
3 changed files with 23 additions and 11 deletions

View File

@ -6,6 +6,8 @@ LABEL maintainer="Robert Kaussow <mail@geeklabor.de>" \
org.label-schema.vendor="Robert Kaussow" \
org.label-schema.schema-version="1.0"
ENV RPMBUILD_BASE_DIR=/drone/src
RUN yum install -q -y \
dash \
gcc gcc-c++ \
@ -35,11 +37,12 @@ RUN yum install -q -y \
yum-utils rpm-build rpmdevtools \
epel-release && \
rpm --import https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7 && \
ln -s dash /bin/sh && \
yum clean all
ADD overlay/ /
USER root
WORKDIR /drone/src
WORKDIR ${RPMBUILD_BASE_DIR}
CMD []

View File

@ -6,18 +6,24 @@
Simple Docker image based on CentOS 7 to build RPM packages.
## Environment variables
```Shell
RPMBUILD_BASE_DIR=/drone/src
```
## How to use
There are two wrapper scripts around the rpmbuild command you could use:
- `/bin/rpmbuild-official`: This will simply forward your command to the official binary at `/usr/bin/rpmbuild`
- `/bin/rpmbuil`: This is a modified wrapper to prepare the environment before calling rpmbuil
- `/usr/local/bin/rpmbuild-official`: This will simply forward your command to the official binary at `/usr/bin/rpmbuild`
- `/usr/local/bin/rpmbuil`: This is a modified wrapper to prepare the environment before calling rpmbuil
The wrapper `/bin/rpmbuil` will do the following:
The wrapper `/usr/local/bin/rpmbuil` will do the following:
- create `$(pwd)/dist`
- create rpmbuild folder structure (`BUILDRPMS|SOURCES|SPECS|SRPMS`) under `$(pwd)/dist`
- sync local patchfiles from `$(pwd)/patch` to `$(pwd)/dist/SOURCES`
- create `$RPMBUILD_BASE_DIR/dist`
- create rpmbuild folder structure (`BUILDRPMS|SOURCES|SPECS|SRPMS`) under `$RPMBUILD_BASE_DIR/dist`
- sync local patchfiles from `$RPMBUILD_BASE_DIR/patch` to `$RPMBUILD_BASE_DIR/dist/SOURCES` if the `patch` folder exist
- call `/bin/rpmbuil` with the given parameters
## License

View File

@ -1,11 +1,14 @@
#!/usr/bin/env sh
set -eo pipefail
DIR=$(pwd)
mkdir -p "${RPMBUILD_BASE_DIR%/}/dist"
mkdir -p "${RPMBUILD_BASE_DIR%/}/dist"
mkdir -p ./dist
echo '%_topdir '"${DIR%/}"'/dist' > /root/.rpmmacros
echo '%_topdir '"${RPMBUILD_BASE_DIR%/}"'/dist' > /root/.rpmmacros
rpmdev-setuptree
rsync -q -av "${DIR%/}/patch/" "${DIR%/}/dist/SOURCES"
if [ -d "$DIR" ]; then
rsync -q -av "${RPMBUILD_BASE_DIR%/}/patch/" "${RPMBUILD_BASE_DIR%/}/dist/SOURCES"
fi
exec /usr/bin/rpmbuild "$@"