Skip to content

Instantly share code, notes, and snippets.

@sfan5
Last active February 25, 2024 18:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sfan5/8e2dd23f4eda7ccc40d229831ba33f8f to your computer and use it in GitHub Desktop.
Save sfan5/8e2dd23f4eda7ccc40d229831ba33f8f to your computer and use it in GitHub Desktop.
Compiles qbittorrent-nox as statically linked build (+ deb package)
#!/bin/bash -e
CMAKE_VER=3.28.3
QT_VER=6.6.2
LIBTORRENT_VER=2.0.10
QBITTORRENT_VER=4.6.3
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 autoconf automake libtool cmake ninja-build pkg-config \
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 . -DCMAKE_INSTALL_PREFIX=/usr
make
make DESTDIR=$prefix 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"
#!/bin/bash -e
# Creates a debian package from the build artifacts of the previous script
[ -f qbittorrent/CMakeCache.txt ] || exit 1
cd qbittorrent
make DESTDIR=$PWD/pkg install
ver=4.6.3
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