From e5e701d0eee07aacc5673d28aed0a9de4df26919 Mon Sep 17 00:00:00 2001
From: stickz <stickman002@mail.com>
Date: Sun, 24 Nov 2024 11:31:26 -0500
Subject: [PATCH] Add ruTorrent v5.1 support

This commit bumps the ruTorrent version to 5.1 for mobile support. It also retrieves and builds the required dump torrent dependency.

**Full Changelog**: https://github.com/Novik/ruTorrent/compare/v4.3.6...v5.1.0
---
 Dockerfile | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 8899e07..f795c6a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -7,9 +7,10 @@ ARG XMLRPC_VERSION=01.58.00
 ARG MKTORRENT_VERSION=v1.1
 ARG GEOIP2_PHPEXT_VERSION=1.3.1
 
-# v4.3.6
-ARG RUTORRENT_VERSION=31c8d351002fb1bdcd71c0652aa516384d330712
+# v5.1.0
+ARG RUTORRENT_VERSION=84a98bfdd4380319fa1cac0a08ec8b137c494f72
 ARG GEOIP2_RUTORRENT_VERSION=4ff2bde530bb8eef13af84e4413cedea97eda148
+ARG DUMP_TORRENT_VERSION=302ac444a20442edb4aeabef65b264a85ab88ce9
 
 # v6.1-0.9.8-0.13.8
 ARG RTORRENT_STICKZ_VERSION=7e852c88465682864ef80d86f1d085d932ef3d89
@@ -18,7 +19,7 @@ ARG ALPINE_VERSION=3.19
 ARG ALPINE_S6_VERSION=${ALPINE_VERSION}-2.2.0.3
 
 FROM --platform=${BUILDPLATFORM} alpine:${ALPINE_VERSION} AS src
-RUN apk --update --no-cache add curl git tar tree xz
+RUN apk --update --no-cache add curl git tar tree sed xz
 WORKDIR /src
 
 FROM src AS src-libsig
@@ -69,6 +70,13 @@ FROM src AS src-mmdb
 RUN curl -SsOL "https://github.com/crazy-max/geoip-updater/raw/mmdb/GeoLite2-City.mmdb" \
   && curl -SsOL "https://github.com/crazy-max/geoip-updater/raw/mmdb/GeoLite2-Country.mmdb"
 
+FROM src AS src-dump-torrent
+RUN git init . && git remote add origin "https://github.com/TheGoblinHero/dumptorrent.git"
+ARG DUMP_TORRENT_VERSION
+RUN git fetch origin "${DUMP_TORRENT_VERSION}" && git checkout -q FETCH_HEAD
+RUN sed -i '1i #include <sys/time.h>' scrapec.c
+RUN rm -rf .git*
+
 FROM crazymax/alpine-s6:${ALPINE_S6_VERSION} AS builder
 RUN apk --update --no-cache add \
     autoconf \
@@ -172,6 +180,12 @@ RUN mkdir -p ${DIST_PATH}/usr/lib/php82/modules
 RUN cp -f /usr/lib/php82/modules/geoip.so ${DIST_PATH}/usr/lib/php82/modules/
 RUN tree ${DIST_PATH}
 
+WORKDIR /usr/local/src/dump-torrent
+COPY --from=src-dump-torrent /src .
+RUN make dumptorrent -j$(nproc)
+RUN cp dumptorrent ${DIST_PATH}/usr/local/bin
+RUN tree ${DIST_PATH}
+
 FROM crazymax/alpine-s6:${ALPINE_S6_VERSION}
 COPY --from=builder /dist /
 COPY --from=src-rutorrent --chown=nobody:nogroup /src /var/www/rutorrent