Skip to content

Instantly share code, notes, and snippets.

@Kungergely
Last active January 2, 2020 13:55
Show Gist options
  • Save Kungergely/14059e9102b5e620a5ecc2c62d2c1642 to your computer and use it in GitHub Desktop.
Save Kungergely/14059e9102b5e620a5ecc2c62d2c1642 to your computer and use it in GitHub Desktop.
Bash script for creating a static subpackage of jasper 2.0.14 and subsequent rebuild of the RPM package for CentOS 8
#!/bin/bash
mkdir docker-jasper; cd docker-jasper
wget https://downloads.redhat.com/redhat/rhel/rhel-8-beta/appstream/source/Packages/jasper-2.0.14-4.el8.src.rpm
rpm2cpio ./jasper-*.src.rpm | cpio -dium
cat > jasper-spec.patch <<"EOF"
--- jasper.spec.orig 2018-08-12 14:44:42.000000000 +0200
+++ jasper.spec 2019-12-30 18:23:24.000000000 +0100
@@ -6,7 +6,7 @@
Summary: Implementation of the JPEG-2000 standard, Part 1
Name: jasper
Version: 2.0.14
-Release: 4%{?dist}
+Release: 5%{?dist}
License: JasPer
URL: http://www.ece.uvic.ca/~frodo/jasper/
@@ -50,6 +50,15 @@
%description libs
%{summary}.
+%package static
+Summary: Static libraries for %{name}
+Conflicts: jasper < 1.900.1-4
+Requires: libjasper-devel = %{version}-%{release}
+%description static
+The %{name}-static package includes the static library
+necessary for developing programs which will manipulate
+JPEG-2000 files using the libjasper library.
+
%package utils
Summary: Nonessential utilities for %{name}
Requires: %{name} = %{version}-%{release}
@@ -77,22 +86,32 @@
%endif
+%build
+
mkdir -p builder
%cmake -G "Unix Makefiles" \
-H%{_builddir}/%{name}-%{version} \
-B%{_builddir}/%{name}-%{version}/builder
-
-%build
pushd builder
make clean all
-
popd
%install
pushd builder
make install DESTDIR=%{buildroot}
+popd
+
+%cmake -G "Unix Makefiles" \
+ -H%{_builddir}/%{name}-%{version} \
+ -B%{_builddir}/%{name}-%{version}/builder \
+ -DJAS_ENABLE_SHARED=0
+
+pushd builder
+make
+
+make install DESTDIR=%{buildroot}
#%if "%{_arch}" != "arm" && "%{_arch}" != "i386"
# mv %{buildroot}/usr/lib %{buildroot}/usr/lib64
@@ -130,12 +149,18 @@
%doc COPYRIGHT LICENSE README
%{_libdir}/libjasper.so*
+%files static
+%{_libdir}/*.a
+
%files utils
%{_bindir}/jiv
%{_mandir}/man1/jiv.1*
%changelog
+* Fri Dec 27 2019 Gergely Kun <gergely.kun@iblsoft.com> - 2.0.14-5
+- Added the "static" subpackage for installing the static library
+
* Wed May 30 2018 Josef Ridky <jridky@redhat.com> - 2.0.14-4
- Fix CVE-2016-9396 (#1583722)
EOF
patch < jasper-spec.patch
cat > Dockerfile <<EOF
FROM centos:8
RUN mkdir -p /root/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} && mkdir -p /jasper/build
RUN dnf -y --enablerepo=PowerTools install cmake freeglut-devel libGLU-devel libjpeg-devel libXmu-devel libXi-devel pkgconfig doxygen mesa-libGL-devel gcc curl zip unzip bzip2 make less rpm-build
COPY jasper-2.0.14-CVE-2016-9396.patch /root/rpmbuild/SOURCES
COPY jasper-2.0.2-test-ppc64-disable.patch /root/rpmbuild/SOURCES
COPY jasper-2.0.2-test-ppc64le-disable.patch /root/rpmbuild/SOURCES
COPY jasper-2.0.14.tar.gz /root/rpmbuild/SOURCES
COPY jasper.spec /root/rpmbuild/SPECS
RUN cd /root/rpmbuild/SPECS && rpmbuild -ba jasper.spec
EOF
docker build -t jasper-builder .
mkdir build; cd build
docker run --mount type=bind,dst=/jasper/build,src=`pwd` -t jasper-builder:latest cp -r --no-preserve=all /root/rpmbuild/{RPMS/x86_64,SRPMS} /jasper/build
cp x86_64/* .; cp SRPMS/* .
# Resulting packages:
# jasper-2.0.14-5.el8.src.rpm
# jasper-2.0.14-5.el8.x86_64.rpm
# jasper-devel-2.0.14-5.el8.x86_64.rpm
# jasper-libs-2.0.14-5.el8.x86_64.rpm
# jasper-static-2.0.14-5.el8.x86_64.rpm
# jasper-utils-2.0.14-5.el8.x86_64.rpm
# jasper-debugsource-2.0.14-5.el8.x86_64.rpm
# jasper-debuginfo-2.0.14-5.el8.x86_64.rpm
# jasper-libs-debuginfo-2.0.14-5.el8.x86_64.rpm
# jasper-utils-debuginfo-2.0.14-5.el8.x86_64.rpm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment