From 87a1e93583628c84c13f805339f58c5ac82d4e4f Mon Sep 17 00:00:00 2001 From: Mogeko Date: Thu, 18 Nov 2021 15:28:31 +0000 Subject: [PATCH] feat: compile libtorrent locally --- .github/workflows/build.yml | 6 ++-- .gitignore | 3 ++ Dockerfile | 42 ++++++++++++++++++++-------- Makefile | 9 +++--- example/config/qBittorrent-data.conf | 2 -- example/config/rss/feeds.json | 2 -- example/config/watched_folders.json | 2 -- 7 files changed, 43 insertions(+), 23 deletions(-) delete mode 100644 example/config/qBittorrent-data.conf delete mode 100644 example/config/rss/feeds.json delete mode 100644 example/config/watched_folders.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b51eb3b..8700f9d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,14 +17,16 @@ jobs: - name: Check version id: check_ver run: | - NEW_VER=$(curl -s "${ALPINE_PKG_URL}" | grep -Po "(\d+\.)+\d+\-r\d+" | head -1) + RAW_VER=$(curl -s "${REPO_TAGS}" | grep -Po "release-(\d+\.){2}\d+\.zip" | head -1) + NEW_VER="${RAW_VER:8:5}-r0" echo "::set-output name=new_ver::${NEW_VER}" env: - ALPINE_PKG_URL: https://pkgs.alpinelinux.org/package/edge/testing/x86_64/qbittorrent-nox + REPO_TAGS: https://github.com/qbittorrent/qBittorrent/tags build: runs-on: ubuntu-latest needs: check + if: ${{ github.event_name == 'pull_request' }} steps: - name: Checkout uses: actions/checkout@v2 diff --git a/.gitignore b/.gitignore index 7edf369..52e3aee 100644 --- a/.gitignore +++ b/.gitignore @@ -74,3 +74,6 @@ $RECYCLE.BIN/ # End of https://www.toptal.com/developers/gitignore/api/macos,windows,linux +# Custom example dirs +example/config +!example/config/qBittorrent.conf diff --git a/Dockerfile b/Dockerfile index aa09f27..ea255a8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,44 @@ -FROM alpine:edge as builder +FROM alpine:3.14 as libtorrent_builder -RUN apk add --no-cache boost-dev build-base clang qt5-qtbase-dev qt5-qttools-dev libtorrent-rasterbar-dev tar +RUN apk add --no-cache \ + autoconf automake binutils boost-dev cppunit-dev libtool linux-headers ncurses-dev openssl-dev zlib-dev \ + build-base clang tar WORKDIR /workspace -ARG VERSION +ARG LIBTORRENT_VERSION +ADD https://github.com/arvidn/libtorrent/archive/refs/tags/v${LIBTORRENT_VERSION}.tar.gz /workspace +RUN tar -zxf v${LIBTORRENT_VERSION}.tar.gz -C . \ + && cd libtorrent-${LIBTORRENT_VERSION} \ + && ./autotool.sh \ + && ./configure CXXFLAGS="-std=c++14" --prefix=/workspace/pkg --with-libiconv \ + && CC=clang make -j$(nproc) \ + && make install-strip -ADD https://github.com/qbittorrent/qBittorrent/archive/refs/tags/release-${VERSION}.tar.gz /workspace +FROM alpine:3.14 as qbittorrent_builder -RUN tar -zxf release-${VERSION}.tar.gz -C . \ - && mv qBittorrent-release-${VERSION}/* . \ - && ./configure --prefix=/workspace --disable-gui \ - && CC=clang make \ +RUN apk add --no-cache \ + boost-dev qt5-qtbase-dev qt5-qttools-dev \ + build-base clang tar + +WORKDIR /workspace + +COPY --from=libtorrent_builder /workspace/pkg /usr + +ARG QBITTORRENT_VERSION +ADD https://github.com/qbittorrent/qBittorrent/archive/refs/tags/release-${QBITTORRENT_VERSION}.tar.gz /workspace +RUN tar -zxf release-${QBITTORRENT_VERSION}.tar.gz -C . \ + && cd qBittorrent-release-${QBITTORRENT_VERSION} \ + && ./configure --prefix=/workspace/pkg --disable-gui \ + && CC=clang make -j$(nproc) \ && make install -FROM alpine:edge +FROM alpine:3.14 -RUN apk add --no-cache busybox libcrypto3 libgcc libstdc++ libtorrent-rasterbar musl qt5-qtbase zlib +RUN apk add --no-cache busybox libgcc openssl qt5-qtbase zlib -COPY --from=builder /workspace/bin/qbittorrent-nox /usr/bin/qbittorrent-nox +COPY --from=libtorrent_builder /workspace/pkg /usr +COPY --from=qbittorrent_builder /workspace/pkg /usr ADD --chown=1000:100 root / diff --git a/Makefile b/Makefile index 22cbc4e..3402a45 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ +LIBTORRENT_VERSION = 1.2.14 +QBITTORRENT_VERSION = 4.3.8 + CMD = /usr/bin/docker IMAGE = mogeko/qbittorrent -VERSION = 4.3.8 PORT = 8080 CONF_DIR = $(shell pwd)/example/config DL_DIR = $(shell pwd)/example/data @@ -11,7 +13,8 @@ all: build run build: @$(CMD) build . \ - --build-arg VERSION=$(VERSION) \ + --build-arg LIBTORRENT_VERSION=$(LIBTORRENT_VERSION) \ + --build-arg QBITTORRENT_VERSION=$(QBITTORRENT_VERSION) \ --tag $(IMAGE) run: id := $(shell head -200 /dev/urandom | cksum | cut -f1 -d " ") @@ -30,5 +33,3 @@ help: id := $(shell head -200 /dev/urandom | cksum | cut -f1 -d " ") help: @-$(CMD) run -it --name qbt-$(id) $(IMAGE) --help @$(CMD) rm -f qbt-$(id) - -rm: clean diff --git a/example/config/qBittorrent-data.conf b/example/config/qBittorrent-data.conf deleted file mode 100644 index b0af648..0000000 --- a/example/config/qBittorrent-data.conf +++ /dev/null @@ -1,2 +0,0 @@ -[Stats] -AllStats=@Variant(\0\0\0\x1c\0\0\0\x2\0\0\0\x12\0\x41\0l\0l\0t\0i\0m\0\x65\0\x44\0L\0\0\0\x5\0\0\0\0\0\0\x1a\xb0\0\0\0\x12\0\x41\0l\0l\0t\0i\0m\0\x65\0U\0L\0\0\0\x5\0\0\0\0\0\0&\xb8) diff --git a/example/config/rss/feeds.json b/example/config/rss/feeds.json deleted file mode 100644 index 2c63c08..0000000 --- a/example/config/rss/feeds.json +++ /dev/null @@ -1,2 +0,0 @@ -{ -} diff --git a/example/config/watched_folders.json b/example/config/watched_folders.json deleted file mode 100644 index 2c63c08..0000000 --- a/example/config/watched_folders.json +++ /dev/null @@ -1,2 +0,0 @@ -{ -}