Change binary names as part of curl's build

Change the binary names of curl and libcurl as part of the curl build
process by patching curl's build scripts. When running 'make' in the
patched curl directory the resulting binaries will be already named
'curl-impersonate-ff' and 'curl-impersonate-chrome' (and the same for
libcurl), thus saving the need for manually renaming them after the
compilation. This also enables running 'make install' with curl's own
Makefiles in order to install curl-impersonate.
This commit is contained in:
lwthiker
2022-04-11 17:59:51 +03:00
parent 22508c6863
commit 8ffeb3ca56
7 changed files with 438 additions and 83 deletions

View File

@@ -83,7 +83,8 @@ RUN cd ${CURL_VERSION} && \
# Compile curl with nghttp2, libbrotli and nss (firefox) or boringssl (chrome).
# Enable keylogfile for debugging of TLS traffic.
RUN cd ${CURL_VERSION} && \
./configure --enable-static \
./configure --prefix=/build/install \
--enable-static \
--disable-shared \
--with-nghttp2=/usr/local \
--with-brotli=/build/brotli-${BROTLI_VERSION}/build/installed \
@@ -91,30 +92,31 @@ RUN cd ${CURL_VERSION} && \
LIBS="-pthread" \
CFLAGS="-I/build/boringssl/build" \
USE_CURL_SSLKEYLOGFILE=true && \
make
make && make install
RUN mkdir out && \
cp ${CURL_VERSION}/src/curl out/curl-impersonate-chrome && \
cp /build/install/bin/curl-impersonate-chrome out/ && \
ln -s curl-impersonate-chrome out/curl-impersonate && \
strip out/curl-impersonate
RUN rm -Rf /build/install
# Re-compile libcurl dynamically
RUN cd ${CURL_VERSION} && \
./configure --with-nghttp2=/usr/local \
./configure --prefix=/build/install \
--with-nghttp2=/usr/local \
--with-brotli=/build/brotli-${BROTLI_VERSION}/build/installed \
--with-openssl=/build/boringssl/build \
LIBS="-pthread" \
CFLAGS="-I/build/boringssl/build" \
USE_CURL_SSLKEYLOGFILE=true && \
make clean && make
make clean && make && make install
# 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\.//') && \
# Copy libcurl-impersonate and symbolic links
RUN cp -d /build/install/lib/libcurl-impersonate* /build/out
RUN ver=$(readlink -f curl-7.81.0/lib/.libs/libcurl-impersonate-chrome.so | sed 's/.*so\.//') && \
major=$(echo -n $ver | cut -d'.' -f1) && \
cp "${CURL_VERSION}/lib/.libs/libcurl.so.$ver" "out/libcurl-impersonate-chrome.so.$ver" && \
ln -s "libcurl-impersonate-chrome.so.$ver" "out/libcurl-impersonate-chrome.so.$major" && \
ln -s "libcurl-impersonate-chrome.so.$ver" "out/libcurl-impersonate-chrome.so" && \
ln -s "libcurl-impersonate-chrome.so.$ver" "out/libcurl-impersonate.so.$ver" && \
ln -s "libcurl-impersonate.so.$ver" "out/libcurl-impersonate.so" && \
strip "out/libcurl-impersonate.so.$ver"
@@ -130,10 +132,6 @@ RUN chmod +x out/curl_*
FROM alpine:3.15.0
# Copy curl-impersonate from the builder image
COPY --from=builder /build/out/curl-impersonate-chrome /usr/local/bin/
RUN ln -s curl-impersonate-chrome /usr/local/bin/curl-impersonate
COPY --from=builder /build/install /usr/local
# Wrapper scripts
COPY --from=builder /build/out/curl_* /usr/local/bin/
# Copy libcurl-impersonate from the builder image
COPY --from=builder /build/out/libcurl-impersonate.so /usr/local/lib/