EOX GitLab Instance

Commit a961260a authored by Stephan Meißl's avatar Stephan Meißl
Browse files

Merge branch 'docker' into 'master'

Adding docker based build

See merge request !16
parents ffce4963 d026dd68
FROM jc21/rpmbuild-centos6
USER root
# for convenience, otherwise they would need to be fetched on every RPM build
RUN yum install -y ant armadillo-devel chrpath curl-devel doxygen fontconfig-devel geos-devel ghostscript "java-devel >= 1:1.6.0" jpackage-utils libgcj libjpeg-devel libpng-devel libtool librx-devel numpy "perl(ExtUtils::MakeMaker)" pkgconfig proj-devel python-devel ruby ruby-devel swig tetex-latex xz-devel zlib-devel
RUN yum install -y bash-completion cfitsio-devel expat-devel freexl-devel g2clib-devel giflib-devel hdf-devel jasper-devel json-c-devel libdap-devel libgeotiff-devel libgta-devel libtiff-devel libtirpc-devel libwebp-devel netcdf-devel ogdi-devel openjpeg2-devel pcre-devel perl-generators poppler-devel python2-numpy sqlite-devel unixODBC-devel xerces-c-devel
# Necessary to use devtoolset-7 for newer GDAL versions
RUN yum install -y centos-release-scl && yum upgrade -y && yum install -y devtoolset-7
ADD build-spec-devtoolset-7.sh /bin/
RUN chmod +x /bin/build-spec-devtoolset-7.sh
USER rpmbuilder
# Docker-based build
Base image taken from here: https://github.com/jc21/docker-rpmbuild-centos6
```
cd builder/build
```
Build and tag the docker file:
```
cd docker/
docker build . -t my-rpmbuild-centos6
cd ..
```
Run the build on a single spec file (Using devtoolset-7)
```
docker run --name rpmbuild-centos6 -v `pwd`:/home/rpmbuilder/rpmbuild --rm=true my-rpmbuild-centos6 /bin/build-spec-devtoolset-7.sh /home/rpmbuilder/rpmbuild/SPECS/gdal.spec
```
Build single spec file without devtoolset-7:
```
docker run --name rpmbuild-centos6 -v `pwd`:/home/rpmbuilder/rpmbuild --rm=true my-rpmbuild-centos6 /bin/build-spec /home/rpmbuilder/rpmbuild/SPECS/some.spec
```
Build all spec files in `SPECS`:
```
docker run --name rpmbuild-centos6 -v `pwd`:/home/rpmbuilder/rpmbuild --rm=true my-rpmbuild-centos6 /bin/build-all
```
#!/bin/bash
getopt --test > /dev/null
if [[ $? -ne 4 ]]; then
echo "I’m sorry, `getopt --test` failed in this environment."
exit 1
fi
##############################################
# show_help #
##############################################
function show_help {
echo "Please specify the name of a spec package to build."
echo ""
echo "Usage: $0 [-r dependancy.rpm] /path/to/specfile [/path/to/specfile] [/path/to/specfile]"
echo " -u Uninstalls specified yum package first"
echo " -p Installs specified yum package next"
echo " -r Installs the specified RPM next"
echo " -b Skip broken packages in RPM install, only applies with -r and/or -p"
echo " -o Set yum to ignore obsoletes"
echo ""
echo "Example: $0 -r RPMS/x86_64/php.rpm -r RPMS/noarch/slack.rpm SPECS/php-memcache.spec"
echo ""
}
SHORT=p:u:br:ho
LONG=help
# -temporarily store output to be able to check for errors
# -activate advanced mode getopt quoting e.g. via “--options”
# -pass arguments only via -- "$@" to separate them correctly
PARSED=$(getopt --options $SHORT --longoptions $LONG --name "$0" -- "$@")
if [[ $? -ne 0 ]]; then
# e.g. $? == 1
# then getopt has complained about wrong arguments to stdout
exit 2
fi
# use eval with "$PARSED" to properly handle the quoting
eval set -- "$PARSED"
upackages=""
packages=""
rpmfiles=""
skip_broken=""
obsoletes=""
# now enjoy the options in order and nicely split until we see --
while true; do
case "$1" in
-u)
upackages+="$2 "
shift 2
;;
-p)
packages+="$2 "
shift 2
;;
-o)
obsoletes="--setopt=obsoletes=0"
shift 1
;;
-r)
rpmfiles+="$2 "
shift 2
;;
-h|--help)
show_help
exit 1
;;
-b)
skip_broken="--skip-broken"
shift
;;
--)
shift
break
;;
*)
echo "Programming error"
exit 3
;;
esac
done
# handle non-option arguments
if [[ $# -eq 0 ]]; then
show_help
exit 1
fi
# Yum cleaning
sudo yum clean all
sudo rm -rf rm -rf /var/cache/yum
cd ~/rpmbuild
## Uninstall PACKAGES
if [ -n "$upackages" ]; then
echo "Uninstalling Yum Packages ..."
sudo yum -y erase $upackages
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
echo "Done uninstalling Yum Packages"
fi
## Install PACKAGES
if [ -n "$packages" ]; then
echo "Installing Yum Packages ..."
sudo yum -y $skip_broken $obsoletes install $packages
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
echo "Done installing Yum Packages"
fi
## Install RPMS
if [ -n "$rpmfiles" ]; then
echo "Installing RPMs ..."
sudo yum -y $skip_broken $obsoletes localinstall $rpmfiles
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
echo "Done installing built RPMs"
fi
## Build Spec
echo "BUILDING: $@ ..."
cd ~/rpmbuild
sudo yum-builddep -y $1
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
scl enable devtoolset-7 "rpmbuild --clean -ba $@"
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment