Last active
March 14, 2018 19:39
-
-
Save timcharper/f1f821fad32fac6751ddc7ce7bceb189 to your computer and use it in GitHub Desktop.
Docker powered rpm-build (HACK that works for sbt-native-packager); put in your path and chmod +x
This file contains hidden or 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
#!/bin/bash | |
# silly little workaround to make rpmbuild work through docker | |
# Build the image if it doesn't already exist | |
if !(docker inspect rpm-build 2>/dev/null 1>/dev/null); then | |
echo "rpm-build image does not exist; building" | |
rm -rf /tmp/rpm-build | |
mkdir -p /tmp/rpm-build | |
cat <<-EOF > /tmp/rpm-build/Dockerfile | |
FROM centos:7 | |
RUN yum install -y rpm-build && yum clean all | |
EOF | |
cd /tmp/rpm-build | |
docker build . -t rpm-build | |
cd - | |
rm -rf /tmp/rpm-build | |
fi | |
declare -a ALLARGS | |
ALLARGS+=("$@") | |
declare -a FOLDERS | |
while [ $# -gt 0 ]; do | |
case "$1" in | |
"_topdir "*) | |
FOLDERS+=("${1:8}") | |
;; | |
esac | |
shift | |
done | |
declare -a VOLUME_ARGS | |
for f in "${FOLDERS[@]}"; do | |
VOLUME_ARGS+=(-v $f:$f) | |
done | |
CMD="$(printf "cd %q; rpmbuild " $(pwd))" | |
for a in "${ALLARGS[@]}"; do | |
CMD="$CMD $(printf "%q" "$a")" | |
done | |
set -x | |
docker run --rm -i "${VOLUME_ARGS[@]}" rpm-build bash -c "$CMD" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment