Last active
May 11, 2024 21:07
-
-
Save sfan5/8e2dd23f4eda7ccc40d229831ba33f8f to your computer and use it in GitHub Desktop.
Compiles qbittorrent-nox as statically linked build (+ deb package)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CMAKE_VER=3.29.3 | |
QT_VER=6.7.0 | |
LIBTORRENT_VER=2.0.10 | |
QBITTORRENT_VER=4.6.4 | |
export LANG=C.UTF-8 | |
export CXXFLAGS="-std=c++17 -flto=auto" | |
export LDFLAGS="-flto=auto" | |
export MAKEFLAGS="-j12" | |
# This script is tested and targeted at Ubuntu 20.04. | |
# Dependencies on Debian/Ubuntu: | |
if false; then | |
sudo apt install --no-install-recommends \ | |
g++ make cmake ninja-build pkg-config wget xz-utils systemd \ | |
zlib1g-dev libssl-dev libboost-system-dev | |
fi | |
# Set up prefix | |
rm -rf tmp && mkdir -p tmp | |
prefix=$PWD/tmp | |
export PATH="$prefix/bin:$PATH" | |
(cd tmp; ln -s . usr; ln -s . usr/local) | |
# First grab a newer CMake because Qt6 needs that (lolwtf?): | |
[ -s cmake-linux-x86_64.tar.gz ] || \ | |
wget https://cmake.org/files/v${CMAKE_VER%.*}/cmake-$CMAKE_VER-linux-x86_64.tar.gz \ | |
-O cmake-linux-x86_64.tar.gz | |
tar -xaf cmake-linux-x86_64.tar.gz --strip-components=1 -C $prefix | |
# Next compile qt6 | |
[ -s qtbase-src.tar.xz ] || \ | |
wget https://download.qt.io/official_releases/qt/${QT_VER%.*}/$QT_VER/submodules/qtbase-everywhere-src-$QT_VER.tar.xz \ | |
-O qtbase-src.tar.xz | |
[ -d qtbase-src ] || { | |
mkdir qtbase-src | |
tar -xaf qtbase-src.tar.xz --strip-components=1 -C qtbase-src | |
} | |
pushd qtbase-src | |
cmake -B build -G Ninja . \ | |
-DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS=OFF \ | |
-DFEATURE_gui=OFF -DFEATURE_shared=OFF | |
ninja -C build | |
DESTDIR=$prefix ninja -C build install | |
popd | |
# Another random part of qt6 (seriously) | |
[ -s qttools-src.tar.xz ] || \ | |
wget https://download.qt.io/official_releases/qt/${QT_VER%.*}/$QT_VER/submodules/qttools-everywhere-src-$QT_VER.tar.xz \ | |
-O qttools-src.tar.xz | |
[ -d qttools-src ] || { | |
mkdir qttools-src | |
tar -xaf qttools-src.tar.xz --strip-components=1 -C qttools-src | |
} | |
pushd qttools-src | |
cmake -B build -G Ninja . -DCMAKE_INSTALL_PREFIX=/usr | |
ninja -C build | |
DESTDIR=$prefix ninja -C build install | |
popd | |
# libtorrent | |
[ -s libtorrent.tar.gz ] || \ | |
wget https://github.com/arvidn/libtorrent/releases/download/v$LIBTORRENT_VER/libtorrent-rasterbar-$LIBTORRENT_VER.tar.gz \ | |
-O libtorrent.tar.gz | |
[ -d libtorrent ] || { | |
mkdir libtorrent | |
tar -xaf libtorrent.tar.gz --strip-components=1 -C libtorrent | |
} | |
pushd libtorrent | |
cmake . -DBUILD_SHARED_LIBS=OFF | |
make | |
make DESTDIR=$prefix install | |
popd | |
# And finally: qbittorrent | |
[ -s qbittorrent.tar.gz ] || \ | |
wget https://github.com/qbittorrent/qBittorrent/archive/release-$QBITTORRENT_VER.tar.gz \ | |
-O qbittorrent.tar.gz | |
[ -d qbittorrent ] || { | |
mkdir qbittorrent | |
tar -xaf qbittorrent.tar.gz --strip-components=1 -C qbittorrent | |
} | |
pushd qbittorrent | |
PKG_CONFIG_PATH=$prefix/lib/pkgconfig \ | |
PKG_CONFIG="$(which pkg-config) --static" \ | |
cmake . \ | |
-DQT6=ON -DGUI=OFF -DSYSTEMD=ON | |
make | |
strip --strip-all ./qbittorrent-nox | |
popd | |
echo | |
echo "Done." | |
echo "To install qbittorrent system-wide run:" | |
echo " \$ cd qbittorrent; sudo make install" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# Creates a DEB package from the build artifacts | |
[ -f qbittorrent/CMakeCache.txt ] || exit 1 | |
cd qbittorrent | |
make DESTDIR=$PWD/pkg install | |
ver=4.6.4 | |
arch=$(dpkg --print-architecture) | |
mkdir debian | |
cat >debian/control <<CONTROL | |
Package: qbittorrent-nox-static | |
Description: BitTorrent client based on libtorrent-rasterbar | |
Version: $ver | |
Architecture: $arch | |
Installed-Size: $(du -s pkg/ | awk '{print $1}') | |
Depends: zlib1g, libssl1.1, libstdc++6 | |
Maintainer: root <root@localhost> | |
CONTROL | |
tar -cvzf control.tar.gz --owner=0 --group=0 --numeric-owner -C debian . | |
tar -cvJf data.tar.xz --owner=0 --group=0 --numeric-owner -C pkg . | |
echo "2.0" >debian-binary | |
ar rD "../qbittorrent-nox-static_${ver}_$arch.deb" debian-binary control.tar.gz data.tar.xz | |
rm -rf pkg debian control.tar.gz data.tar.xz debian-binary | |
echo "OK." | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment