Skip to content

Commit

Permalink
Update Compilation-Alpine-Linux.md
Browse files Browse the repository at this point in the history
Update Compilation-Alpine-Linux.md

Update Compilation-Alpine-Linux.md
  • Loading branch information
userdocs committed Oct 15, 2024
1 parent 7075471 commit 18d0d54
Showing 1 changed file with 52 additions and 42 deletions.
94 changes: 52 additions & 42 deletions Compilation-Alpine-Linux.md
Original file line number Diff line number Diff line change
@@ -1,72 +1,69 @@
# Alpine Linux build instructions

This guide will help you install qBittorrent on Alpine Linux using a combination of packages installed using `apk` and dependencies built using `cmake`.
This guide will help you install qBittorrent on Alpine Linux

ℹ️ This guide should work in any [Alpine arch](http://dl-cdn.alpinelinux.org/alpine/latest-stable/main) as long as the required [packages dependencies](https://pkgs.alpinelinux.org) are available to install for that arch. This guide was tested on `x86_64`
> [!NOTE]
>
> - This guide should work in any [Alpine arch](http://dl-cdn.alpinelinux.org/alpine/latest-stable/main) as long as the required [packages dependencies](https://pkgs.alpinelinux.org) are available to install for that arch. This guide was tested on `x86_64`
>
> - This guide will install qBittorrent and dependencies using shared libraries. At the point of writing this guide the latest version of Alpine is `3.20`
>
> - Check out the [common information](https://github.com/qbittorrent/qBittorrent/wiki/Compilation-with-CMake-common-information) page to learn more about the available build configuration options for qBittorrent (for example, to compile qBittorrent without the GUI) and also CMake itself, if you're new to it.
ℹ️ This guide will install qBittorrent and dependencies using shared libraries. At the point of writing this guide the latest version of Alpine is `3.13`

The majority of these commands are copy and paste but some can be modified. For example, in the libtorrent section there is a choice between libtorrent `v1` or `v2`. Check the notes and commented commands for more information.

Check out the [common information](https://github.com/qbittorrent/qBittorrent/wiki/Compilation-with-CMake-common-information) page to learn more about the available build configuration options for qBittorrent (for example, to compile qBittorrent without the GUI) and also CMake itself, if you're new to it.
> [!IMPORTANT]
> The majority of these commands are copy and paste but some can be modified. For example, in the libtorrent section there is a choice between libtorrent `v1` or `v2`. Check the notes and commented commands for more information.
## Build dependencies

These are the build dependencies we need to install using `apk`

```ash
apk add autoconf automake build-base cmake curl git libtool linux-headers perl pkgconf python3 python3-dev re2c tar
```bash
apk add build-base cmake curl git linux-headers python3 re2c tar xz ninja-build ninja-is-really-ninja
```

## Application dependencies

These are application dependencies we need to install using `apk`

ℹ️ The `iconv` libraries needed for `libtorrent` v1.2 are built into `/usr/lib/libc.so` so we do not need to install `iconv` as a dependency.

```ash
apk add icu-dev libexecinfo-dev openssl-dev qt5-qtbase-dev qt5-qttools-dev zlib-dev qt5-qtsvg-dev
```

## Ninja build

⚠️ There is no `apk` version for Alpine `3.12` or greater so we need to build it. It won't take long.
> [!WARNING]
> If you are using a desktop and want the GUI for qBittorrent, you will need to append the dependency `qt6-qtsvg-dev` to the command below
```bash
git clone --shallow-submodules --recurse-submodules https://github.com/ninja-build/ninja.git ~/ninja && cd ~/ninja
git checkout "$(git tag -l --sort=-v:refname "v*" | head -n 1)"
cmake -Wno-dev -B build \
-D CMAKE_CXX_STANDARD=17 \
-D CMAKE_INSTALL_PREFIX="/usr/local"
cmake --build build
cmake --install build
apk add zlib-dev icu-dev openssl-dev qt6-qtbase-dev qt6-qttools-dev
```

## Boost build files

ℹ️ All we need to bootstrap boost is to download and extract the files. There is nothing to build at this step.
> [!TIP]
> Get the latest version info via
>
> - https://github.com/boostorg/boost/releases/latest
> - `curl -sL https://api.github.com/repos/boostorg/boost/releases/latest | jq -r '.tag_name'`
Download and extract the boost files.

> [!NOTE]
> All we need to bootstrap boost is to download and extract the files. There is nothing to build at this step.
```bash
curl -sNLk https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.gz -o "$HOME/boost_1_76_0.tar.gz"
tar xf "$HOME/boost_1_76_0.tar.gz" -C "$HOME"
curl -sNLko- https://github.com/boostorg/boost/releases/latest/download/boost-1.86.0-b2-nodocs.tar.xz | tar xfJ -
```

## Libtorrent

Download and build libtorrent by checking out the `RC_1_2` branch. You can also change the `git checkout` command filter `"v1*"` to `"v2*"` to use the latest version of a specific tag

ℹ️ Any tag can be used to checkout the version you want - https://github.com/arvidn/libtorrent/tags
> [!TIP]
> Any tag can be used to checkout the version you want - https://github.com/arvidn/libtorrent/tags
```bash
git clone --shallow-submodules --recurse-submodules https://github.com/arvidn/libtorrent.git ~/libtorrent && cd ~/libtorrent
# git checkout "$(git tag -l --sort=-v:refname "v2*" | head -n 1)" # always checkout the latest release of libtorrent v2
git checkout "$(git tag -l --sort=-v:refname "v1*" | head -n 1)" # always checkout the latest release of libtorrent v1
git checkout "$(git tag -l --sort=-v:refname | awk '/v1/' | head -1)" # always checkout the latest release of libtorrent v1
cmake -Wno-dev -G Ninja -B build \
-D CMAKE_BUILD_TYPE="Release" \
-D CMAKE_CXX_STANDARD=17 \
-D BOOST_INCLUDEDIR="$HOME/boost_1_76_0/" \
-D CMAKE_CXX_STANDARD=20 \
-D BOOST_INCLUDEDIR="$HOME/boost-1.86.0/" \
-D CMAKE_INSTALL_LIBDIR="lib" \
-D CMAKE_INSTALL_PREFIX="/usr/local"
cmake --build build
Expand All @@ -77,32 +74,45 @@ cmake --install build

Build and install qBittorrent

ℹ️ Any tag can be used to checkout the version you want - https://github.com/qbittorrent/qBittorrent/tags
> [!TIP]
> Any tag can be used to checkout the version you want - https://github.com/qbittorrent/qBittorrent/tags
⚠️ You are most likely not using a GUI (desktop) with Alpine, so remember to pass `-D GUI=OFF`.
> [!WARNING]
> You are most likely not using a GUI (desktop) with Alpine, so remember we pass `-D GUI=OFF`.
> Removing `-D GUI=OFF` will build the desktop version `qbittorrent` instead of the cli `qbittorrent-nox`
```bash
git clone --shallow-submodules --recurse-submodules https://github.com/qbittorrent/qBittorrent.git ~/qbittorrent && cd ~/qbittorrent
git checkout "$(git tag -l --sort=-v:refname | head -n 1)" # always checkout the latest release of qbittorrent
git checkout "$(git tag -l --sort=-v:refname | awk '!/[0-9][a-zA-Z]/' | head -1)" # always checkout the latest release of qbittorrent
cmake -Wno-dev -G Ninja -B build \
-D CMAKE_BUILD_TYPE="release" \
-D CMAKE_CXX_STANDARD=17 \
-D BOOST_INCLUDEDIR="$HOME/boost_1_76_0/" \
-D CMAKE_CXX_STANDARD_LIBRARIES="/usr/lib/libexecinfo.so" \
-D CMAKE_INSTALL_PREFIX="/usr/local"
-D CMAKE_CXX_STANDARD=20 \
-D BOOST_INCLUDEDIR="$HOME/boost-1.86.0/" \
-D CMAKE_INSTALL_PREFIX="/usr/local" \
-D GUI=OFF
cmake --build build
cmake --install build
```

## Post installation

Tidy up the downloaded build files

```bash
cd && rm -rf qbittorrent libtorrent ninja boost_1_76_0 boost_1_76_0.tar.gz
cd && rm -rf qbittorrent libtorrent boost-1.86.0
```

## Post build
## Run the binary

You can now run `qbittorrent` or `qbittorrent-nox` as it will be in the path.

Desktop version: `-D GUI=ON`

```bash
qbittorrent
```

You can now run `qbittorrent-no` as it will be in the path (or `qbittorrent`, if you build with the GUI).
cli version: `-D GUI=OFF`

```bash
qbittorrent-nox
Expand Down

0 comments on commit 18d0d54

Please sign in to comment.