Skip to content

Instantly share code, notes, and snippets.

@poplite
Created October 3, 2019 03:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save poplite/2f69f534f2c335fa7a84c4e6fc5b1e73 to your computer and use it in GitHub Desktop.
Save poplite/2f69f534f2c335fa7a84c4e6fc5b1e73 to your computer and use it in GitHub Desktop.
makeAppImage.sh for qBittorrent Enhanced Edition
#!/bin/bash
#
# Copyright 2019 poplite <poplite.xyz@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
set -e
set -o pipefail
PROGRAM_NAME="qbittorrent-enhanced"
SCRIPT_NAME=$0
# Read version from argument, needed by linuxdeployqt
export VERSION=$1
# Check if running as root
if [[ $(id -u) != 0 ]];
then
SUDO="sudo"
else
SUDO=""
fi
CONFIGURE_ARGS="--prefix=/usr"
BUILD_DEPENDS="build-essential curl tar"
DEPENDS="libtorrent-rasterbar-dev libboost-dev libqt5svg5-dev qtbase5-dev qttools5-dev-tools zlib1g-dev geoip-database"
BUILD_DIR="${VERSION}-build"
SOURCE_DIR="${PROGRAM_NAME}-${VERSION}"
APP_DIR="${PROGRAM_NAME}.AppDir"
TARBALL="${PROGRAM_NAME}_${VERSION}.orig.tar.gz"
TARBALL_URL="https://github.com/c0re100/qBittorrent-Enhanced-Edition/archive/release-${VERSION}.tar.gz"
LINUX_DEPQT_URL="https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage"
PATCH_URL="https://raw.githubusercontent.com/poplite/qBEE-Ubuntu-Packaging/master/qbittorrent-enhanced/debian/patches/qb-enhanced-desktop.diff"
BOLD_GREEN="\e[1;32m"
CLEAR_CLR="\e[0m"
echo_clr() {
echo -e "${BOLD_GREEN}\n$1${CLEAR_CLR}"
}
usage() {
echo -e "makeAppImage.sh for ${PROGRAM_NAME}"
echo -e "Usage: ${SCRIPT_NAME} version\n"
echo -e "version - Build version (Example: 4.1.6.1)"
}
print_info() {
echo -e "Build version :" "${BOLD_GREEN}${VERSION}${CLEAR_CLR}"
echo -e "AppDir path :" "${BOLD_GREEN}${APP_DIR}${CLEAR_CLR}"
echo -e "Make jobs number :" "${BOLD_GREEN}$(nproc)${CLEAR_CLR}"
echo -e "Configure options:" "${BOLD_GREEN}${CONFIGURE_ARGS}${CLEAR_CLR}"
}
[ -z "${VERSION}" ] && usage && exit 1
print_info
# 1. Install dependencies
echo_clr "Installing dependencies..."
${SUDO} apt-get update
${SUDO} apt-get install ${BUILD_DEPENDS} -y
${SUDO} apt-get install ${DEPENDS} -y
# 2. Create build directory
[ -d "${BUILD_DIR}" ] && rm -rf "${BUILD_DIR}"
mkdir -p "${BUILD_DIR}"
cd "${BUILD_DIR}"
# 3. Download linuxdeployqt
echo_clr "Downloading linuxdeployqt..."
echo "${LINUX_DEPQT_URL}"
curl -L "${LINUX_DEPQT_URL}" -o linuxdeployqt-continuous-x86_64.AppImage
chmod +x linuxdeployqt-continuous-x86_64.AppImage
# 4. Download tarball from Github
echo_clr "Downloading tarball..."
echo "${TARBALL_URL}"
curl -L "${TARBALL_URL}" -o "${TARBALL}"
# 5. Extract the tarball
tar -xzf "${TARBALL}"
mv "qBittorrent-Enhanced-Edition-release-${VERSION}" "${SOURCE_DIR}"
cd "${SOURCE_DIR}"
# 6. Apply patches
echo_clr "Applying patches..."
echo "${PATCH_URL}"
curl "${PATCH_URL}" | patch -p1
# 7. Build binaries
echo_clr "Building binaries..."
./configure ${CONFIGURE_ARGS}
make -j$(nproc)
INSTALL_ROOT="../../${APP_DIR}" make install
cp dist/unix/org.qbittorrent.qBittorrent.desktop "../${APP_DIR}"
cp dist/unix/menuicons/192x192/apps/qbittorrent.png "../${APP_DIR}"
# 8. Create AppImage
echo_clr "Creating AppImage..."
cd ../
./linuxdeployqt-continuous-x86_64.AppImage "${APP_DIR}/usr/bin/qbittorrent" -appimage -verbose=2
ls -lh "qBittorrent_(Enhanced_Edition)-${VERSION}-x86_64.AppImage"
echo_clr "Done."
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment