Skip to content

Commit

Permalink
update for develop branch of deluge
Browse files Browse the repository at this point in the history
  • Loading branch information
zakkarry committed Sep 14, 2024
1 parent 35e0561 commit 09cc728
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 18 deletions.
30 changes: 21 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,40 @@ LABEL maintainer="aptalca"
ENV PYTHON_EGG_CACHE="/config/plugins/.python-eggs" \
TMPDIR=/run/deluged-temp

# copy release version script
COPY root/version.sh /app

# install software
RUN \
echo "**** install build packages ****" && \
apk add --no-cache --upgrade --virtual=build-dependencies \
build-base \
python3-dev && \
python3-dev \
musl-dev \
git \
py3-cairo \
py3-gobject3 \
py3-zope-interface && \
echo "**** install packages ****" && \
apk add --no-cache --upgrade \
boost1.84-python3 \
geoip \
python3 \
p7zip && \
if [ -z ${DELUGE_VERSION+x} ]; then \
DELUGE_VERSION=$(curl -sL https://pypi.python.org/pypi/deluge/json |jq -r '. | .info.version');\
fi && \
python3 -m venv /lsiopy && \
pip install -U --no-cache-dir \
pip \
setuptools \
wheel && \
mkdir /app/deluge-src && \
git clone https://github.com/deluge-torrent/deluge.git /app/deluge-src/ && \
cd /app/deluge-src && \
sh /app/version.sh > /app/deluge-src/RELEASE-VERSION && \
sed -i '/libtorrent/d' /app/deluge-src/requirements*.txt && \
sed -i "s|VERSION_FILE = os.path.join(os.path.dirname(__file__), 'RELEASE-VERSION')|VERSION_FILE = '/app/deluge-src/RELEASE-VERSION'|" /app/deluge-src/version.py && \
sed -i '/version = call_git_describe(prefix, suffix)/s/version = call_git_describe(prefix, suffix)/version = release_version/' /app/deluge-src/version.py && \
pip install -r /app/deluge-src/requirements-dev.txt && \
python3 /app/deluge-src/setup.py develop && \
pip install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.20/ \
deluge[all]==${DELUGE_VERSION} \
pygeoip && \
echo "**** grab GeoIP database ****" && \
curl -L --retry 10 --retry-max-time 60 --retry-all-errors \
Expand All @@ -49,12 +61,12 @@ RUN \
apk del --purge \
build-dependencies && \
rm -rf \
$HOME/.cache \
$HOME/.cache \
/tmp/*

COPY --from=libtorrent /libtorrent-build/usr/lib/libtorrent-rasterbar.* /usr/lib/
COPY --from=libtorrent /libtorrent-build/usr/lib/libtorrent-rasterbar.* /usr/lib/

COPY --from=libtorrent /libtorrent-build/usr/lib/python3.12 /lsiopy/lib/python3.12
COPY --from=libtorrent /libtorrent-build/usr/lib/python3.12 /lsiopy/lib/python3.12

# add local files
COPY root/ /
Expand Down
30 changes: 21 additions & 9 deletions Dockerfile.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,40 @@ LABEL maintainer="aptalca"
ENV PYTHON_EGG_CACHE="/config/plugins/.python-eggs" \
TMPDIR=/run/deluged-temp

# copy release version script
COPY root/version.sh /app

# install software
RUN \
echo "**** install build packages ****" && \
apk add --no-cache --upgrade --virtual=build-dependencies \
build-base \
python3-dev && \
python3-dev \
musl-dev \
git \
py3-cairo \
py3-gobject3 \
py3-zope-interface && \
echo "**** install packages ****" && \
apk add --no-cache --upgrade \
boost1.84-python3 \
geoip \
python3 \
p7zip && \
if [ -z ${DELUGE_VERSION+x} ]; then \
DELUGE_VERSION=$(curl -sL https://pypi.python.org/pypi/deluge/json |jq -r '. | .info.version');\
fi && \
python3 -m venv /lsiopy && \
pip install -U --no-cache-dir \
pip \
setuptools \
wheel && \
mkdir /app/deluge-src && \
git clone https://github.com/deluge-torrent/deluge.git /app/deluge-src/ && \
cd /app/deluge-src && \
sh /app/version.sh > /app/deluge-src/RELEASE-VERSION && \
sed -i '/libtorrent/d' /app/deluge-src/requirements*.txt && \
sed -i "s|VERSION_FILE = os.path.join(os.path.dirname(__file__), 'RELEASE-VERSION')|VERSION_FILE = '/app/deluge-src/RELEASE-VERSION'|" /app/deluge-src/version.py && \
sed -i '/version = call_git_describe(prefix, suffix)/s/version = call_git_describe(prefix, suffix)/version = release_version/' /app/deluge-src/version.py && \
pip install -r /app/deluge-src/requirements-dev.txt && \
python3 /app/deluge-src/setup.py develop && \
pip install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.20/ \
deluge[all]==${DELUGE_VERSION} \
pygeoip && \
echo "**** grab GeoIP database ****" && \
curl -L --retry 10 --retry-max-time 60 --retry-all-errors \
Expand All @@ -49,12 +61,12 @@ RUN \
apk del --purge \
build-dependencies && \
rm -rf \
$HOME/.cache \
$HOME/.cache \
/tmp/*

COPY --from=libtorrent /libtorrent-build/usr/lib/libtorrent-rasterbar.* /usr/lib/
COPY --from=libtorrent /libtorrent-build/usr/lib/libtorrent-rasterbar.* /usr/lib/

COPY --from=libtorrent /libtorrent-build/usr/lib/python3.12 /lsiopy/lib/python3.12
COPY --from=libtorrent /libtorrent-build/usr/lib/python3.12 /lsiopy/lib/python3.12

# add local files
COPY root/ /
Expand Down
24 changes: 24 additions & 0 deletions root/etc/s6-overlay/s6-rc.d/svc-deluged/run
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,30 @@

DELUGE_LOGLEVEL=${DELUGE_LOGLEVEL:-info}

# downlad latest GeoIP.dat after aged a week
geoip_dat_path="/usr/share/GeoIP/GeoIP.dat"
echo "[info] Checking GeoIP.dat ($geoip_dat_path)..."

if [ -e "$geoip_dat_path" ]; then
current_time=$(date +%s)
# file's modification and creation times in seconds since epoch
modification_time=$(stat -c %Y "$geoip_dat_path")
creation_time=$(stat -c %W "$geoip_dat_path")
week_seconds=$((7 * 24 * 60 * 60))

if (((current_time - modification_time) > week_seconds)) || (((current_time - creation_time) > week_seconds)); then
echo "[info] Found outdated GeoIP.dat...updating (timeout 30s)"
curl -s -L --retry 3 --retry-max-time 30 --retry-all-errors \
"https://mailfud.org/geoip-legacy/GeoIP.dat.gz" |
gunzip >$geoip_dat_path
fi
else
echo "[info] No GeoIP.dat found...updating (timeout 30s)"
curl -s -L --retry 3 --retry-max-time 30 --retry-all-errors \
"https://mailfud.org/geoip-legacy/GeoIP.dat.gz" |
gunzip >$geoip_dat_path
fi

if [[ -f /config/core.conf ]]; then
DELUGED_PORT=$(grep '"daemon_port"' /config/core.conf | tr -cd "[:digit:]")
fi
Expand Down
35 changes: 35 additions & 0 deletions root/etc/s6-overlay/s6-rc.d/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash

prefix="deluge-"
suffix=".dev0"
cmd="git describe --tags --match ${prefix}[0-9]*"

if output=$(eval "$cmd" 2>/dev/null); then
version="${output#"$prefix"}"
version="${version%"$suffix"}"
# Check if there is a dash in the version string
if [[ "$version" == *"-"* ]]; then
# Determine the segment type
segment=".dev"
if [[ "$version" != *"dev"* ]]; then
segment=".post"
fi

# Process the version string to format it correctly
version=$(echo "$version" | awk -F'-' -v seg="$segment" '
{
# Remove the last group after the final dot
split($1, parts, ".")
n = length(parts)
if (n > 1) {
$1 = parts[1] "." parts[2] "." parts[3] seg substr($2,1,3)
}
print $1
}')
fi

echo "$version"
else
echo "None"
fi

0 comments on commit 09cc728

Please sign in to comment.