|
| 1 | +# Instructions on building libtorrent: |
| 2 | +# https://github.com/arvidn/libtorrent/blob/RC_2_1/docs/building.rst |
| 3 | + |
| 4 | +FROM alpine:3.24.0@sha256:a2d49ea686c2adfe3c992e47dc3b5e7fa6e6b5055609400dc2acaeb241c829f4 |
| 5 | + |
| 6 | +ARG VERSION=2.1.[0-9]\\+ |
| 7 | + |
| 8 | +SHELL ["/bin/ash", "-euo", "pipefail", "-c"] |
| 9 | + |
| 10 | +# Build libtorrent-rasterbar-dev |
| 11 | +# hadolint ignore=DL3003,DL3018,SC2086 |
| 12 | +RUN apk --update add --no-cache boost-python3 libgcc libstdc++ openssl python3 && \ |
| 13 | + apk --update add --no-cache --virtual build-dependencies boost-dev cmake coreutils g++ gcc git jq py3-setuptools python3-dev openssl-dev samurai && \ |
| 14 | + # Checkout from source |
| 15 | + cd "$(mktemp -d)" && \ |
| 16 | + git clone --branch "$( \ |
| 17 | + wget -qO - https://api.github.com/repos/arvidn/libtorrent/tags?per_page=100 | jq -r '.[].name' | \ |
| 18 | + awk '{print $1" "$1}' | \ |
| 19 | + # Get rid of prefixes |
| 20 | + sed 's/^libtorrent[^0-9]//i' | \ |
| 21 | + sed 's/^v//i' | \ |
| 22 | + # Use periods for major.minor.patch |
| 23 | + sed 's/[^a-zA-Z0-9.]\([0-9]\+.* .*\)/.\1/g' | \ |
| 24 | + sed 's/[^a-zA-Z0-9.]\([0-9]\+.* .*\)/.\1/g' | \ |
| 25 | + # Make sure patch version exists |
| 26 | + sed 's/^\([0-9]\+\.[0-9]\+\)\([^0-9.].\+\)/\1.0\2/' | \ |
| 27 | + # Get the right version |
| 28 | + sort --version-sort --key=1,1 | \ |
| 29 | + grep "${VERSION}" | \ |
| 30 | + # Ignore pre-releases (release candidates, betas, etc.) |
| 31 | + grep -viE -- '-(rc|alpha|beta)' | \ |
| 32 | + tail -1 | \ |
| 33 | + awk '{print $2}' \ |
| 34 | + )" --depth 1 https://github.com/arvidn/libtorrent.git && \ |
| 35 | + cd libtorrent && \ |
| 36 | + git clean --force && \ |
| 37 | + git submodule update --depth=1 --init --recursive && \ |
| 38 | + # Build shared libraries |
| 39 | + mkdir build-shared && \ |
| 40 | + cd build-shared && \ |
| 41 | + cmake \ |
| 42 | + -DCMAKE_INSTALL_PREFIX=/usr \ |
| 43 | + # https://github.com/arvidn/libtorrent/blob/RC_2_1/docs/building.rst#building-with-cmake |
| 44 | + -G Ninja \ |
| 45 | + -DCMAKE_BUILD_TYPE=Release \ |
| 46 | + -DCMAKE_CXX_STANDARD=20 \ |
| 47 | + -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \ |
| 48 | + -Dpython-bindings=ON \ |
| 49 | + -Dpython-egg-info=ON \ |
| 50 | + -Dpython-install-system-dir=ON \ |
| 51 | + .. && \ |
| 52 | + ninja "-j$(nproc)" && \ |
| 53 | + ninja install && \ |
| 54 | + cd .. && \ |
| 55 | + # Build static libraries |
| 56 | + mkdir build-static && \ |
| 57 | + cd build-static && \ |
| 58 | + cmake \ |
| 59 | + -DCMAKE_INSTALL_PREFIX=/usr \ |
| 60 | + # https://github.com/arvidn/libtorrent/blob/RC_2_1/docs/building.rst#building-with-cmake |
| 61 | + -G Ninja \ |
| 62 | + -DCMAKE_BUILD_TYPE=Release \ |
| 63 | + -DCMAKE_CXX_STANDARD=20 \ |
| 64 | + -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \ |
| 65 | + -DBUILD_SHARED_LIBS=OFF \ |
| 66 | + .. && \ |
| 67 | + ninja "-j$(nproc)" && \ |
| 68 | + ninja install && \ |
| 69 | + cd .. && \ |
| 70 | + # Remove temp files |
| 71 | + cd && \ |
| 72 | + apk del --purge build-dependencies && \ |
| 73 | + rm -rf /tmp/* |
0 commit comments