diff --git a/Compilation:-Alpine-Linux.md b/Compilation:-Alpine-Linux.md new file mode 100644 index 0000000..99466d0 --- /dev/null +++ b/Compilation:-Alpine-Linux.md @@ -0,0 +1,152 @@ +# 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 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.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. + +## 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 +``` + +## 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 +``` + +## cmake helpful info + +This is a reference section with some helpful `cmake` tweaks you can apply if you need to debug or change anything during the build process. + +💡 To see the configuration options available you can use this command in the cloned git folder. + +``` +cmake -LAH . +``` + +ℹ️ To see project specific variables we can do this to see results after a specific option + + +``` +cmake -LAH . | awk '/CMAKE_VERBOSE_MAKEFILE/,EOF' +``` + +ℹ️ After you have run at least one configure command you can see and edit the project settings using `ccmake` to have an interactive method. + +```bash +ccmake . +``` + +💡 To set `cxx` flags you can add this to your `cmake` commands but it's optional. + +For example, these options can be set `-w` - no warnings `-s` - strip unneeded symbols + +```bash +-D CMAKE_CXX_FLAGS="-w -s" +``` + +💡 Ninja build is quiet by default. To enable verbose build information you have these options + +Pass `--verbose` to the build command (recommended) + +```bash +cmake --build build --verbose +``` + +Add it as cmake variable at configure time. + +```bash +-D CMAKE_VERBOSE_MAKEFILE=ON +``` + +## Ninja build + +⚠️ There is no `apk` version for Alpine `3.12` or greater so we need to build it. It won't take long. + +```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 +``` + +## Boost build files + +ℹ️ All we need to bootstrap boost is to download and extract the files. There is nothing to build at this step. + +Download and extract the boost files. + +```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" +``` + +## 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 + +```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 +cmake -Wno-dev -G Ninja -B build \ + -D CMAKE_BUILD_TYPE="Release" \ + -D CMAKE_CXX_STANDARD=17 \ + -D Boost_INCLUDE_DIR="$HOME/boost_1_76_0/" \ + -D CMAKE_INSTALL_LIBDIR="lib" \ + -D CMAKE_INSTALL_PREFIX="/usr/local" +cmake --build build +cmake --install build +``` + +## qBittorrent + +Build and install qBittorrent + +⚠️ If you do not want the GUI you can set `-D GUI=OFF` to only build and install `qbittorrent-nox` + +ℹ️ 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/qbittorrent/qBittorrent.git ~/qbittorrent && cd ~/qbittorrent +git checkout "$(git tag -l --sort=-v:refname | head -n 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_INCLUDE_DIR="$HOME/boost_1_76_0/" \ + -D CMAKE_CXX_STANDARD_LIBRARIES="/usr/lib/libexecinfo.so" \ + -D CMAKE_INSTALL_PREFIX="/usr/local" +cmake --build build +cmake --install build +``` + +Tidy up the downloaded build files + +```bash +cd && rm -rf qbittorrent libtorrent ninja boost_1_76_0 boost_1_76_0.tar.gz +``` + +## Post build + +You can now run `qbittorrent` as it will be in the path. + +```bash +qbittorrent +``` \ No newline at end of file