Skip to content

Instantly share code, notes, and snippets.

@Kungergely
Last active January 2, 2020 13:56
Show Gist options
  • Save Kungergely/1d271eb769e3f720d78317b61ed11729 to your computer and use it in GitHub Desktop.
Save Kungergely/1d271eb769e3f720d78317b61ed11729 to your computer and use it in GitHub Desktop.
Bash script for creating a static subpackage of (lib)curl 7.61.1 and subsequent rebuild of the RPM package for CentOS 8
eccodes#!/bin/bash
mkdir docker-curl; cd docker-curl
wget http://vault.centos.org/8.0.1905/BaseOS/Source/SPackages/curl-7.61.1-8.el8.src.rpm
rpm2cpio ./curl-*.src.rpm | cpio -dium
cat > curl-spec.patch <<"EOF"
--- curl.spec.orig 2019-05-16 08:57:52.000000000 +0200
+++ curl.spec 2019-12-31 10:29:34.000000000 +0100
@@ -1,7 +1,7 @@
Summary: A utility for getting files from remote servers (FTP, HTTP, and others)
Name: curl
Version: 7.61.1
-Release: 8%{?dist}
+Release: 9%{?dist}
License: MIT
Source: https://curl.haxx.se/download/%{name}-%{version}.tar.xz
@@ -151,6 +151,19 @@
developing programs which use the libcurl library. It contains the API
documentation of the library, too.
+%package -n libcurl-static
+Summary: Static libraries for building applications with libcurl
+Requires: libcurl%{?_isa} = %{version}-%{release}
+Requires: libcurl-devel%{?_isa} = %{version}-%{release}
+
+Provides: curl-static = %{version}-%{release}
+Provides: curl-static%{?_isa} = %{version}-%{release}
+
+%description -n libcurl-static
+The libcurl-static package contains the static libraries
+for developing programs which use the libcurl library.
+
+
%package -n curl-minimal
Summary: Conservatively configured build of curl for minimal installations
Provides: curl = %{version}-%{release}
@@ -232,7 +245,7 @@
mkdir build-{full,minimal}
export common_configure_opts=" \
--cache-file=../config.cache \
- --disable-static \
+ --enable-static \
--enable-symbol-hiding \
--enable-ipv6 \
--enable-threaded-resolver \
@@ -350,6 +363,9 @@
%{_mandir}/man3/*
%{_datadir}/aclocal/libcurl.m4
+%files -n libcurl-static
+%{_libdir}/libcurl.a*
+
%files -n curl-minimal
%{_bindir}/curl.minimal
%{_mandir}/man1/curl.1*
@@ -360,6 +376,9 @@
%{_libdir}/libcurl.so.4.[0-9].[0-9].minimal
%changelog
+* Mon Dec 30 2019 Gergely Kun <[email protected]> - 7.61.1-9
+- Added -static subpackage for providing the static libraries
+
* Fri Jan 11 2019 Kamil Dudka <[email protected]> - 7.61.1-8
- curl -J: do not append to the destination file (#1660827)
EOF
patch < curl-spec.patch
cat > Dockerfile <<EOF
FROM centos:8
RUN mkdir -p /root/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} && mkdir -p /curl/build
RUN dnf -y --enablerepo=PowerTools install cmake gcc zip unzip bzip2 make rpm-build automake brotli-devel groff krb5-devel libidn2-devel libnghttp2-devel libssh-devel openldap-devel openssh-clients openssh-server openssl-devel python3-devel stunnel zlib-devel perl-IO-Compress gnutls-utils nghttp2 git
RUN rpm --rebuilddb; rm -rf /var/lib/rpm/* && cp /var/lib/rpmrebuilddb.*/* /var/lib/rpm && dnf -y install perl-interpreter perl-PathTools perl-Digest-MD5 perl-Exporter perl-MIME-Base64 perl-libs perl-Time-Local perl-Time-HiRes valgrind
RUN dnf -y install http://repo.okay.com.mx/centos/8/x86_64/release/okay-release-1-3.el8.noarch.rpm && dnf -y install libmetalink-devel libpsl-devel
COPY 0001-curl-7.61.1-test320-gnutls.patch /root/rpmbuild/SOURCES
COPY 0002-curl-7.61.1-tlsv1.0-man.patch /root/rpmbuild/SOURCES
COPY 0003-curl-7.61.1-TLS-1.3-PHA.patch /root/rpmbuild/SOURCES
COPY 0004-curl-7.61.1-CVE-2018-16842.patch /root/rpmbuild/SOURCES
COPY 0005-curl-7.61.1-CVE-2018-16840.patch /root/rpmbuild/SOURCES
COPY 0006-curl-7.61.1-CVE-2018-16839.patch /root/rpmbuild/SOURCES
COPY 0007-curl-7.63.0-JO-preserve-local-file.patch /root/rpmbuild/SOURCES
COPY 0101-curl-7.32.0-multilib.patch /root/rpmbuild/SOURCES
COPY 0102-curl-7.36.0-debug.patch /root/rpmbuild/SOURCES
COPY 0103-curl-7.59.0-python3.patch /root/rpmbuild/SOURCES
COPY 0104-curl-7.19.7-localhost6.patch /root/rpmbuild/SOURCES
COPY curl-7.61.1.tar.xz /root/rpmbuild/SOURCES
COPY curl.spec /root/rpmbuild/SPECS
RUN cd /root/rpmbuild/SPECS && rpmbuild -ba curl.spec
EOF
docker build -t curl-builder .
mkdir build; cd build
docker run --mount type=bind,dst=/curl/build,src=`pwd` -t curl-builder:latest cp -r --no-preserve=all /root/rpmbuild/{RPMS/x86_64,SRPMS} /curl/build
cp x86_64/* .; cp SRPMS/* .
# Resulting packages:
# curl-7.61.1-9.el8.src.rpm
# curl-7.61.1-9.el8.x86_64.rpm
# libcurl-7.61.1-9.el8.x86_64.rpm
# libcurl-devel-7.61.1-9.el8.x86_64.rpm
# libcurl-static-7.61.1-9.el8.x86_64.rpm
# curl-minimal-7.61.1-9.el8.x86_64.rpm
# libcurl-minimal-7.61.1-9.el8.x86_64.rpm
# curl-debugsource-7.61.1-9.el8.x86_64.rpm
# curl-debuginfo-7.61.1-9.el8.x86_64.rpm
# libcurl-debuginfo-7.61.1-9.el8.x86_64.rpm
# curl-minimal-debuginfo-7.61.1-9.el8.x86_64.rpm
# libcurl-minimal-debuginfo-7.61.1-9.el8.x86_64.rpm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment