Created
November 19, 2021 10:00
-
-
Save palacaze/ba6dd6b664b5586425eb24af4722f3eb to your computer and use it in GitHub Desktop.
build an appimage
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
#!/usr/bin/env bash | |
# Dir of the script | |
readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd - P)" | |
readonly dist_dir="${script_dir}/../dist" | |
# Source common options to tweak the script | |
user_config_file="${script_dir}/foo-buildenv.conf" | |
if [[ -f "${user_config_file}" ]]; then | |
source "${user_config_file}" | |
fi | |
# Where to find the code repositories | |
: ${repo_root:="${HOME}/company"} | |
# Where we to store code archives, build, install... | |
: ${work_root:="${repo_root}/soft"} | |
# Where to put the AppImages | |
: ${deploy_root:="${work_root}/deploy"} | |
# Qt is needed to bundle libraries and assets | |
: ${qt_prefix:="${work_root}/3rdparty/qt"} | |
# The foo code source directory | |
readonly foo_root="${dist_dir}/.." | |
# The deploy dir/file | |
readonly deploy_dir="${deploy_root}/foo-viewer_$(date '+%F')" | |
readonly deploy_app="${deploy_dir}.AppImage" | |
# Our creation tools | |
readonly lindeploy_exe=linuxdeploy-x86_64.AppImage | |
readonly lindeploy_qt_exe=linuxdeploy-plugin-qt-x86_64.AppImage | |
readonly apptool_exe=appimagetool-x86_64.AppImage | |
readonly lindeploy="${deploy_root}/tools/${lindeploy_exe}" | |
readonly lindeploy_qt="${deploy_root}/tools/${lindeploy_qt_exe}" | |
readonly apptool="${deploy_root}/tools/${apptool_exe}" | |
# Checks | |
if [[ ! -f "${qt_prefix}/bin/qmake" ]]; then | |
echo "QMake executable not found at ${qt_prefix}/bin/qmake" | |
exit 1 | |
fi | |
if [[ ! -f "${foo_root}/bin/foo-viewer" ]]; then | |
echo "foo-viewer executable not found at ${foo_root}/bin/foo-viewer" | |
exit 1 | |
fi | |
if [[ ! -f "${dist_dir}/foo-viewer.desktop" ]]; then | |
echo "foo-viewer.desktop not found" | |
exit 1 | |
fi | |
if [[ ! -f "${dist_dir}/foo-viewer.svg" ]]; then | |
echo "foo-viewer.svg not found" | |
exit 1 | |
fi | |
# Create dirs | |
mkdir -p "${deploy_root}/tools" || exit 1 | |
mkdir -p "${deploy_dir}" || exit 1 | |
# Download tools if necessary | |
if [[ ! -f "${lindeploy}" ]]; then | |
wget -O "${lindeploy}" "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/${lindeploy_exe}" || exit 1 | |
fi | |
if [[ ! -f "${lindeploy_qt}" ]]; then | |
wget -O "${lindeploy_qt}" "https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/${lindeploy_qt_exe}" || exit 1 | |
fi | |
if [[ ! -f "${apptool}" ]]; then | |
wget -O "${apptool}" "https://github.com/AppImage/AppImageKit/releases/download/13/${apptool_exe}" || exit 1 | |
fi | |
chmod +x "${lindeploy}" | |
chmod +x "${lindeploy_qt}" | |
chmod +x "${apptool}" | |
# Invoke linuxdeploy first to create the AppRun directory structure | |
"${lindeploy}" \ | |
--appdir="${deploy_dir}" \ | |
-e "${foo_root}/bin/foo-viewer" \ | |
-d "${dist_dir}/foo-viewer.desktop" \ | |
-i "${dist_dir}/foo-viewer.svg" || exit 1 | |
# Add the Qt stuff using the dedicated plugin next | |
QMAKE="${qt_prefix}/bin/qmake" "${lindeploy_qt}" --appdir="${deploy_dir}" || exit 1 | |
# Bundle the result into an AppImage | |
"${apptool}" "${deploy_dir}" "${deploy_app}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment