Skip to content

Commit

Permalink
fix linux appimage & cross compile build. fix #559 (#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
abcfy2 authored Jun 17, 2024
1 parent c9f1c9a commit 8df67d0
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 53 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/build_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
container: "ubuntu:20.04"
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/cache@v3
uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
/usr/src/
Expand All @@ -28,7 +28,7 @@ jobs:
appimage-build-dependencies-cache-
- name: Build AppImage
run: .github/workflows/build_appimage.sh
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: qBittorrent-Enhanced-Edition-x86_64.AppImage
path: ".github/workflows/qBittorrent-Enhanced-Edition*.AppImage*"
Expand All @@ -53,8 +53,7 @@ jobs:
# cross toolchain downloads from: https://musl.cc/
# you need to find the name ${cross_host}-cross.tgz
- arm-linux-musleabi
# Waiting this issue to be resolved: https://github.com/zlib-ng/zlib-ng/issues/1138
# - arm-linux-musleabihf
- arm-linux-musleabihf
- aarch64-linux-musl
- mips-linux-musl
- mipsel-linux-musl
Expand All @@ -64,8 +63,8 @@ jobs:
- i686-linux-musl
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/cache@v3
uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
/usr/src/
Expand All @@ -77,7 +76,7 @@ jobs:
env:
CROSS_HOST: "${{ matrix.cross_host }}"
run: .github/workflows/cross_build.sh
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: qbittorrent-enhanced-nox_${{ matrix.cross_host }}_static
path: |
Expand Down
55 changes: 30 additions & 25 deletions .github/workflows/build_appimage.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash -e

# This scrip is for building AppImage
# Please run this scrip in docker image: ubuntu:20.04
# This script is for building AppImage
# Please run this script in docker image: ubuntu:20.04
# E.g: docker run --rm -v `git rev-parse --show-toplevel`:/build ubuntu:20.04 /build/.github/workflows/build_appimage.sh
# If you need keep store build cache in docker volume, just like:
# $ docker volume create qbee-cache
Expand Down Expand Up @@ -81,6 +81,7 @@ EOF
curl \
git \
unzip \
g++-10 \
pkg-config \
libssl-dev \
libzstd-dev \
Expand Down Expand Up @@ -119,6 +120,9 @@ EOF
libwayland-dev \
libwayland-egl-backend-dev

update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 100

apt autoremove --purge -y
# strip all compiled files by default
export CFLAGS='-s'
Expand All @@ -134,8 +138,8 @@ prepare_buildenv() {
cmake_binary_url="https://github.com/Kitware/CMake/releases/download/v${cmake_latest_ver}/cmake-${cmake_latest_ver}-linux-x86_64.tar.gz"
cmake_sha256_url="https://github.com/Kitware/CMake/releases/download/v${cmake_latest_ver}/cmake-${cmake_latest_ver}-SHA-256.txt"
if [ x"${USE_CHINA_MIRROR}" = x1 ]; then
cmake_binary_url="https://ghproxy.com/${cmake_binary_url}"
cmake_sha256_url="https://ghproxy.com/${cmake_sha256_url}"
cmake_binary_url="https://mirror.ghproxy.com/${cmake_binary_url}"
cmake_sha256_url="https://mirror.ghproxy.com/${cmake_sha256_url}"
fi
if [ -f "/usr/src/cmake-${cmake_latest_ver}-linux-x86_64.tar.gz" ]; then
cd /usr/src
Expand All @@ -154,7 +158,7 @@ prepare_buildenv() {
ninja_ver="$(retry curl -ksSL --compressed https://ninja-build.org/ \| grep "'The last Ninja release is'" \| sed -r "'s@.*<b>(.+)</b>.*@\1@'" \| head -1)"
ninja_binary_url="https://github.com/ninja-build/ninja/releases/download/${ninja_ver}/ninja-linux.zip"
if [ x"${USE_CHINA_MIRROR}" = x1 ]; then
ninja_binary_url="https://ghproxy.com/${ninja_binary_url}"
ninja_binary_url="https://mirror.ghproxy.com/${ninja_binary_url}"
fi
if [ ! -f "/usr/src/ninja-${ninja_ver}-linux.zip.download_ok" ]; then
rm -f "/usr/src/ninja-${ninja_ver}-linux.zip"
Expand All @@ -172,7 +176,7 @@ prepare_ssl() {
echo "openssl version: ${openssl_ver}"
openssl_latest_url="https://github.com/openssl/openssl/archive/refs/tags/${openssl_filename}"
if [ x"${USE_CHINA_MIRROR}" = x1 ]; then
openssl_latest_url="https://ghproxy.com/${openssl_latest_url}"
openssl_latest_url="https://mirror.ghproxy.com/${openssl_latest_url}"
fi
mkdir -p "/usr/src/openssl-${openssl_ver}/"
if [ ! -f "/usr/src/openssl-${openssl_ver}/.unpack_ok" ]; then
Expand Down Expand Up @@ -205,7 +209,6 @@ prepare_qt() {
./configure \
-ltcg \
-release \
-c++std c++17 \
-optimize-size \
-openssl-linked \
-no-icu \
Expand Down Expand Up @@ -262,7 +265,7 @@ prepare_qt() {
if [ ! -d "/usr/src/qt6gtk2/" ]; then
qt6gtk2_git_url="https://github.com/trialuser02/qt6gtk2.git"
if [ x"${USE_CHINA_MIRROR}" = x1 ]; then
qt6gtk2_git_url="https://ghproxy.com/${qt6gtk2_git_url}"
qt6gtk2_git_url="https://mirror.ghproxy.com/${qt6gtk2_git_url}"
fi
retry git clone --depth 1 --recursive "${qt6gtk2_git_url}" "/usr/src/qt6gtk2/"
fi
Expand Down Expand Up @@ -300,7 +303,7 @@ prepare_libtorrent() {
echo "libtorrent-rasterbar branch: ${LIBTORRENT_BRANCH}"
libtorrent_git_url="https://github.com/arvidn/libtorrent.git"
if [ x"${USE_CHINA_MIRROR}" = x1 ]; then
libtorrent_git_url="https://ghproxy.com/${libtorrent_git_url}"
libtorrent_git_url="https://mirror.ghproxy.com/${libtorrent_git_url}"
fi
if [ ! -d "/usr/src/libtorrent-rasterbar-${LIBTORRENT_BRANCH}/" ]; then
retry git clone --depth 1 --recursive --shallow-submodules --branch "${LIBTORRENT_BRANCH}" \
Expand Down Expand Up @@ -350,7 +353,7 @@ build_appimage() {
# build AppImage
linuxdeploy_qt_download_url="https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage"
if [ x"${USE_CHINA_MIRROR}" = x1 ]; then
linuxdeploy_qt_download_url="https://ghproxy.com/${linuxdeploy_qt_download_url}"
linuxdeploy_qt_download_url="https://mirror.ghproxy.com/${linuxdeploy_qt_download_url}"
fi
[ -x "/tmp/linuxdeployqt-continuous-x86_64.AppImage" ] || retry curl -kSLC- -o /tmp/linuxdeployqt-continuous-x86_64.AppImage "${linuxdeploy_qt_download_url}"
chmod -v +x '/tmp/linuxdeployqt-continuous-x86_64.AppImage'
Expand Down Expand Up @@ -404,6 +407,18 @@ EOF
wayland-shell-integration
)
exclude_libs=(
libX11-xcb.so.1
libXau.so.6
libXcomposite.so.1
libXcursor.so.1
libXdamage.so.1
libXdmcp.so.6
libXext.so.6
libXfixes.so.3
libXi.so.6
libXinerama.so.1
libXrandr.so.2
libXrender.so.1
libatk-1.0.so.0
libatk-bridge-2.0.so.0
libatspi.so.0
Expand All @@ -422,8 +437,8 @@ EOF
libffi.so.6
libgcrypt.so.20
libgdk-3.so.0
libgdk_pixbuf-2.0.so.0
libgdk-x11-2.0.so.0
libgdk_pixbuf-2.0.so.0
libgio-2.0.so.0
libglib-2.0.so.0
libgmodule-2.0.so.0
Expand All @@ -441,6 +456,8 @@ EOF
libpango-1.0.so.0
libpangocairo-1.0.so.0
libpangoft2-1.0.so.0
libpcre.so.3
libpcre2-8.so.0
libpixman-1.so.0
libprotobuf-lite.so.9
libselinux.so.1
Expand All @@ -449,34 +466,22 @@ EOF
libwayland-cursor.so.0
libwayland-egl.so.1
libwayland-server.so.0
libX11-xcb.so.1
libXau.so.6
libxcb-cursor.so.0
libxcb-glx.so.0
libxcb-icccm.so.4
libxcb-image.so.0
libxcb-keysyms.so.1
libxcb-randr.so.0
libxcb-render.so.0
libxcb-render-util.so.0
libxcb-render.so.0
libxcb-shape.so.0
libxcb-shm.so.0
libxcb-sync.so.1
libxcb-util.so.1
libxcb-xfixes.so.0
libxcb-xkb.so.1
libXcomposite.so.1
libXcursor.so.1
libXdamage.so.1
libXdmcp.so.6
libXext.so.6
libXfixes.so.3
libXinerama.so.1
libXi.so.6
libxkbcommon.so.0
libxkbcommon-x11.so.0
libXrandr.so.2
libXrender.so.1
libxkbcommon.so.0
)

# fix AppImage output file name
Expand Down
52 changes: 32 additions & 20 deletions .github/workflows/cross_build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash -e

# This scrip is for static cross compiling
# Please run this scrip in docker image: abcfy2/muslcc-toolchain-ubuntu:${CROSS_HOST}
# This script is for static cross compiling
# Please run this script in docker image: abcfy2/muslcc-toolchain-ubuntu:${CROSS_HOST}
# E.g: docker run --rm -v `git rev-parse --show-toplevel`:/build abcfy2/muslcc-toolchain-ubuntu:arm-linux-musleabi /build/.github/workflows/cross_build.sh
# If you need keep store build cache in docker volume, just like:
# $ docker volume create qbee-nox-cache
Expand All @@ -17,12 +17,22 @@ export LIBTORRENT_BRANCH="RC_1_2"
# Ubuntu mirror for local building
if [ x"${USE_CHINA_MIRROR}" = x1 ]; then
source /etc/os-release
cat >/etc/apt/sources.list <<EOF
if [ -f /etc/apt/sources.list.d/ubuntu.sources ]; then
cat >/etc/apt/sources.list.d/ubuntu.sources <<EOF
Types: deb
URIs: http://repo.huaweicloud.com/ubuntu/
Suites: ${UBUNTU_CODENAME} ${UBUNTU_CODENAME}-updates ${UBUNTU_CODENAME}-backports ${UBUNTU_CODENAME}-security
Components: main universe restricted multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
EOF
else
cat >/etc/apt/sources.list <<EOF
deb http://repo.huaweicloud.com/ubuntu/ ${UBUNTU_CODENAME} main restricted universe multiverse
deb http://repo.huaweicloud.com/ubuntu/ ${UBUNTU_CODENAME}-updates main restricted universe multiverse
deb http://repo.huaweicloud.com/ubuntu/ ${UBUNTU_CODENAME}-backports main restricted universe multiverse
deb http://repo.huaweicloud.com/ubuntu/ ${UBUNTU_CODENAME}-security main restricted universe multiverse
EOF
fi
export PIP_INDEX_URL="https://repo.huaweicloud.com/repository/pypi/simple"
fi

Expand All @@ -43,10 +53,7 @@ apt install -y \
unzip \
zip \
pkg-config \
python3 \
python3-requests \
python3-semantic-version \
python3-lxml \
pipx \
python3-pip

# use zlib-ng instead of zlib by default
Expand Down Expand Up @@ -128,14 +135,19 @@ retry() {
return 1
}

# This function is used to check version less than or equal to another version
verlte() {
printf '%s\n' "$1" "$2" | sort -C -V
}

prepare_cmake() {
if ! which cmake &>/dev/null; then
cmake_latest_ver="$(retry curl -ksSL --compressed https://cmake.org/download/ \| grep "'Latest Release'" \| sed -r "'s/.*Latest Release\s*\((.+)\).*/\1/'" \| head -1)"
cmake_binary_url="https://github.com/Kitware/CMake/releases/download/v${cmake_latest_ver}/cmake-${cmake_latest_ver}-linux-x86_64.tar.gz"
cmake_sha256_url="https://github.com/Kitware/CMake/releases/download/v${cmake_latest_ver}/cmake-${cmake_latest_ver}-SHA-256.txt"
if [ x"${USE_CHINA_MIRROR}" = x1 ]; then
cmake_binary_url="https://ghproxy.com/${cmake_binary_url}"
cmake_sha256_url="https://ghproxy.com/${cmake_sha256_url}"
cmake_binary_url="https://mirror.ghproxy.com/${cmake_binary_url}"
cmake_sha256_url="https://mirror.ghproxy.com/${cmake_sha256_url}"
fi
if [ -f "/usr/src/cmake-${cmake_latest_ver}-linux-x86_64.tar.gz" ]; then
cd /usr/src
Expand All @@ -156,7 +168,7 @@ prepare_ninja() {
ninja_ver="$(retry curl -ksSL --compressed https://ninja-build.org/ \| grep "'The last Ninja release is'" \| sed -r "'s@.*<b>(.+)</b>.*@\1@'" \| head -1)"
ninja_binary_url="https://github.com/ninja-build/ninja/releases/download/${ninja_ver}/ninja-linux.zip"
if [ x"${USE_CHINA_MIRROR}" = x1 ]; then
ninja_binary_url="https://ghproxy.com/${ninja_binary_url}"
ninja_binary_url="https://mirror.ghproxy.com/${ninja_binary_url}"
fi
if [ ! -f "/usr/src/ninja-${ninja_ver}-linux.zip.download_ok" ]; then
rm -f "/usr/src/ninja-${ninja_ver}-linux.zip"
Expand All @@ -174,7 +186,7 @@ prepare_zlib() {
zlib_ng_latest_url="https://github.com/zlib-ng/zlib-ng/archive/refs/tags/${zlib_ng_latest_tag}.tar.gz"
echo "zlib-ng version ${zlib_ng_latest_tag}"
if [ x"${USE_CHINA_MIRROR}" = x1 ]; then
zlib_ng_latest_url="https://ghproxy.com/${zlib_ng_latest_url}"
zlib_ng_latest_url="https://mirror.ghproxy.com/${zlib_ng_latest_url}"
fi
if [ ! -f "/usr/src/zlib-ng-${zlib_ng_latest_tag}/.unpack_ok" ]; then
mkdir -p "/usr/src/zlib-ng-${zlib_ng_latest_tag}/"
Expand Down Expand Up @@ -208,7 +220,7 @@ prepare_zlib() {
fi
cd "/usr/src/zlib-${zlib_ver}"

if [ x"${TARGET_HOST}" = xWindows ]; then
if [ x"${TARGET_HOST}" = x"Windows" ]; then
make -f win32/Makefile.gcc BINARY_PATH="${CROSS_PREFIX}/bin" INCLUDE_PATH="${CROSS_PREFIX}/include" LIBRARY_PATH="${CROSS_PREFIX}/lib" SHARED_MODE=0 PREFIX="${CROSS_HOST}-" -j$(nproc) install
else
CHOST="${CROSS_HOST}" ./configure --prefix="${CROSS_PREFIX}" --static
Expand All @@ -219,13 +231,13 @@ prepare_zlib() {
}

prepare_ssl() {
openssl_filename="$(retry curl -ksSL --compressed https://www.openssl.org/source/ \| grep -o "'href=\"openssl-3\(\.[0-9]*\)*tar.gz\"'" \| grep -o "'[^\"]*.tar.gz'" \| head -1)"
openssl_filename="$(retry curl -ksSL --compressed https://www.openssl.org/source/ \| grep -o "'href=\"openssl-3\(\.[0-9]*\)*tar.gz\"'" \| grep -o "'[^\"]*.tar.gz'" \| sort -r \| head -1)"
openssl_ver="$(echo "${openssl_filename}" | sed -r 's/openssl-(.+)\.tar\.gz/\1/')"
echo "OpenSSL version ${openssl_ver}"
if [ ! -f "/usr/src/openssl-${openssl_ver}/.unpack_ok" ]; then
openssl_download_url="https://github.com/openssl/openssl/archive/refs/tags/${openssl_filename}"
if [ x"${USE_CHINA_MIRROR}" = x1 ]; then
openssl_download_url="https://ghproxy.com/${openssl_download_url}"
openssl_download_url="https://mirror.ghproxy.com/${openssl_download_url}"
fi
mkdir -p "/usr/src/openssl-${openssl_ver}/"
retry curl -kL "${openssl_download_url}" \| tar -zxf - --strip-components=1 -C "/usr/src/openssl-${openssl_ver}/"
Expand Down Expand Up @@ -271,8 +283,8 @@ prepare_qt() {
echo "Using qt version: ${qt_ver}"
mkdir -p "/usr/src/qtbase-${qt_ver}" "/usr/src/qttools-${qt_ver}"
if [ ! -f "/usr/src/qt-host/${qt_ver}/gcc_64/bin/qt.conf" ]; then
pip3 install py7zr
retry curl -ksSL --compressed "https://cdn.jsdelivr.net/gh/engnr/qt-downloader@master/qt-downloader" \| python3 - linux desktop "${qt_ver}" gcc_64 -o "/usr/src/qt-host" -m qtbase qttools icu
pipx install aqtinstall
retry "${HOME}/.local/bin/aqt" install-qt -O /usr/src/qt-host linux desktop "${qt_ver}" --archives qtbase qttools icu
fi
if [ ! -f "/usr/src/qtbase-${qt_ver}/.unpack_ok" ]; then
qtbase_url="https://download.qt.io/official_releases/qt/${qt_major_ver}/${qt_ver}/submodules/qtbase-everywhere-src-${qt_ver}.tar.xz"
Expand All @@ -281,7 +293,7 @@ prepare_qt() {
fi
cd "/usr/src/qtbase-${qt_ver}"
rm -fr CMakeCache.txt CMakeFiles
if [ x"${TARGET_HOST}" = xWindows ]; then
if [ x"${TARGET_HOST}" = x"Windows" ]; then
QT_BASE_EXTRA_CONF='-xplatform win32-g++'
fi

Expand Down Expand Up @@ -321,7 +333,7 @@ prepare_libtorrent() {
echo "libtorrent-rasterbar branch: ${LIBTORRENT_BRANCH}"
libtorrent_git_url="https://github.com/arvidn/libtorrent.git"
if [ x"${USE_CHINA_MIRROR}" = x1 ]; then
libtorrent_git_url="https://ghproxy.com/${libtorrent_git_url}"
libtorrent_git_url="https://mirror.ghproxy.com/${libtorrent_git_url}"
fi
if [ ! -d "/usr/src/libtorrent-rasterbar-${LIBTORRENT_BRANCH}/" ]; then
retry git clone --depth 1 --recursive --shallow-submodules --branch "${LIBTORRENT_BRANCH}" \
Expand All @@ -340,7 +352,7 @@ prepare_libtorrent() {
fi
rm -fr build/CMakeCache.txt
# TODO: solve mingw build
if [ x"${TARGET_HOST}" = xWindows ]; then
if [ x"${TARGET_HOST}" = x"Windows" ]; then
find -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \) -print0 |
xargs -0 -r sed -i 's/Windows\.h/windows.h/g;
s/Shellapi\.h/shellapi.h/g;
Expand Down Expand Up @@ -392,7 +404,7 @@ build_qbittorrent() {
-DCMAKE_EXE_LINKER_FLAGS="-static"
cmake --build build
cmake --install build
if [ x"${TARGET_HOST}" = xWindows ]; then
if [ x"${TARGET_HOST}" = x"Windows" ]; then
cp -fv "src/release/qbittorrent-nox.exe" /tmp/
else
cp -fv "${CROSS_PREFIX}/bin/qbittorrent-nox" /tmp/
Expand Down

0 comments on commit 8df67d0

Please sign in to comment.