Skip to content

Instantly share code, notes, and snippets.

@Kungergely
Last active December 20, 2019 09:40
Show Gist options
  • Save Kungergely/eaec3f51f1d6deceffcd03f21c5cf17a to your computer and use it in GitHub Desktop.
Save Kungergely/eaec3f51f1d6deceffcd03f21c5cf17a to your computer and use it in GitHub Desktop.
Dockerfile for building cnvgrib, w3lib and g2lib RPM packages for CentOS 8
FROM centos:8
RUN mkdir -p /build
RUN dnf -y --nogpgcheck install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm wget curl zip unzip bzip2 gcc gcc-c++ rpm-build make libpng-devel
RUN dnf -y --nogpgcheck --enablerepo=PowerTools install gcc-gfortran jasper-devel
# SuSE SRPM, get it e.g. from ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home%3A/gbvalor/SLE_11/src/cnvgrib-1.4.0-1.1.src.rpm
COPY cnvgrib-1.4.0-1.1.src.rpm /build
RUN cd /build && \
mkdir cnvgrib-1.4.0-1.1 && cd cnvgrib-1.4.0-1.1 && \
rpm2cpio ../cnvgrib-1.4.0-1.1.src.rpm | cpio -civ * && \
mkdir -p /root/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} && \
mv cnvgrib_w3lib_g2lib-1.4.0.tar.bz2 /root/rpmbuild/SOURCES && \
# Due to an idiotic typo in the Makefile templates
sed -i -e "s/make/sed -i \"s\/unclude\/include\/g\" g2lib\/Makefile.\*\nmake/g" cnvgrib.spec && \
# To remove any reference to the inmem struct member which has apparently been removed from later libjasper versions
# See https://github.com/cloudruninc/wps/issues/5 for additional info
sed -i -e 's#make#sed -i -e "s\/.*inmem.*//g" g2lib\/dec_jpeg2000.c\nmake#g' cnvgrib.spec && \
sed -i -e 's#make#sed -i -e "s\/.*image\.inmem.*\//g" g2lib\/enc_jpeg2000.c\nmake#g' cnvgrib.spec && \
# Optional (somewhat cosmetic) line, to make rpmbuild include the designated distro ID (e.g. el8) in the resulting filenames as well
sed -i 's/Release: 1.1/Release: 1.1\%\{\?dist\}/g' cnvgrib.spec && \
rpmbuild -ba cnvgrib.spec
# Upon successful completion the resulting image will contain the following files:
# /root/rpmbuild/SRPMS/cnvgrib-1.4.0-1.1.el8.src.rpm
# /root/rpmbuild/RPMS/x86_64/cnvgrib-1.4.0-1.1.el8.x86_64.rpm
# /root/rpmbuild/RPMS/x86_64/w3lib-1.4.0-1.1.el8.x86_64.rpm
# /root/rpmbuild/RPMS/x86_64/g2lib-1.4.0-1.1.el8.x86_64.rpm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment