From d22e09eb4a2870dc65fdbc9d0eba2fd67edc3073 Mon Sep 17 00:00:00 2001 From: lwthiker Date: Sat, 26 Feb 2022 12:21:24 +0200 Subject: [PATCH] Compile libcurl.so in addition to curl-impersonate In addition to the statically linked curl-impersonate binary, compile libcurl.so for dynamic linking as well. The output file is saved at /build/out/libcurl-impersonate.so. Also strip the output binaries to reduce their size. For now, support is for the Chrome build only. --- chrome/Dockerfile | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/chrome/Dockerfile b/chrome/Dockerfile index c1cf986..00f2925 100644 --- a/chrome/Dockerfile +++ b/chrome/Dockerfile @@ -47,7 +47,7 @@ RUN cd ${NGHTTP2_VERSION} && \ # Compile nghttp2 RUN cd ${NGHTTP2_VERSION} && \ - ./configure && \ + ./configure --with-pic && \ make && make install # Download curl. @@ -67,13 +67,29 @@ RUN cd ${CURL_VERSION} && \ ./configure --with-openssl=/build/boringssl/build --enable-static --disable-shared --with-nghttp2=/usr/local LIBS="-pthread" CFLAGS="-I/build/boringssl/build" USE_CURL_SSLKEYLOGFILE=true && \ make -# 'xxd' is needed for the wrapper script -RUN apt-get install -y xxd - RUN mkdir out && \ - cp ${CURL_VERSION}/src/curl out/curl-impersonate + cp ${CURL_VERSION}/src/curl out/curl-impersonate && \ + strip out/curl-impersonate -# Wrapper script +# Re-compile libcurl dynamically +RUN cd ${CURL_VERSION} && \ + ./configure --enable-versioned-symbols \ + --with-openssl=/build/boringssl/build \ + --with-nghttp2=/usr/local \ + LIBS="-pthread" \ + CFLAGS="-I/build/boringssl/build" \ + USE_CURL_SSLKEYLOGFILE=true && \ + make clean && make + +# Rename to 'libcurl-impersonate' to avoid confusion, and recreate the +# symbolic links. +RUN ver=$(readlink -f curl-7.81.0/lib/.libs/libcurl.so | sed 's/.*so\.//') && \ + major=$(echo -n $ver | cut -d'.' -f1) && \ + cp "${CURL_VERSION}/lib/.libs/libcurl.so.$ver" "out/libcurl-impersonate.so.$ver" && \ + ln -s "libcurl-impersonate.so.$ver" "out/libcurl-impersonate.so.$major" && \ + ln -s "libcurl-impersonate.so.$ver" "out/libcurl-impersonate.so" && \ + strip "out/libcurl-impersonate.so.$ver" + +# Wrapper scripts COPY curl_chrome* out/ - -RUN chmod +x out/* +RUN chmod +x out/curl_*