2020-04-14 04:22:32 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# NOTE: Keep this script in the same directory as resources for AppImage creation
|
2021-07-06 09:43:28 +00:00
|
|
|
APPIMAGE_RESOURCES_DIR=$(dirname $(readlink -f $0))/../extras
|
2020-04-14 04:22:32 +00:00
|
|
|
echo "APPIMAGE_RESOURCES_DIR set to ${APPIMAGE_RESOURCES_DIR}"
|
|
|
|
|
|
|
|
if [[ "$#" -ne 1 ]]; then
|
|
|
|
echo "Wrong number of arguments (\$# = $# args) provided."
|
2020-10-01 23:00:39 +00:00
|
|
|
echo "Usage: generate_appimages.sh <build_directory_path>"
|
|
|
|
echo "AppImages will be generated in the path this script is called from."
|
2020-04-14 04:22:32 +00:00
|
|
|
exit 1
|
|
|
|
else
|
2020-04-15 04:12:13 +00:00
|
|
|
BUILD_DIR=$(readlink -f $1)
|
2020-04-14 04:22:32 +00:00
|
|
|
echo "BUILD_DIR set to ${BUILD_DIR}"
|
|
|
|
fi
|
|
|
|
|
2020-04-15 04:12:13 +00:00
|
|
|
wget --timestamping --directory-prefix=${BUILD_DIR} \
|
2020-11-03 14:25:41 +00:00
|
|
|
https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
|
2020-04-15 04:12:13 +00:00
|
|
|
chmod a+x ${BUILD_DIR}/linuxdeploy-x86_64.AppImage
|
|
|
|
|
|
|
|
wget --timestamping --directory-prefix=${BUILD_DIR} \
|
|
|
|
https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage
|
|
|
|
chmod a+x ${BUILD_DIR}/linuxdeploy-plugin-qt-x86_64.AppImage
|
2020-04-14 04:22:32 +00:00
|
|
|
|
2020-10-02 00:07:09 +00:00
|
|
|
wget --timestamping --directory-prefix=${BUILD_DIR} \
|
|
|
|
https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-x86_64.AppImage
|
|
|
|
chmod a+x ${BUILD_DIR}/linuxdeploy-plugin-appimage-x86_64.AppImage
|
|
|
|
|
2020-04-14 04:22:32 +00:00
|
|
|
# Copy icons into the <resolution>/<app_name>.<ext> directory structure that linuxdeploy nominally expects,
|
|
|
|
# e.g. 16x16/duckstation-qt.png, 32x32/duckstation-qt.png, etc.
|
2021-01-31 07:28:42 +00:00
|
|
|
FRONTENDS=("qt" "nogui")
|
2020-04-14 04:22:32 +00:00
|
|
|
ICONS_QT=()
|
2021-01-31 07:28:42 +00:00
|
|
|
ICONS_NOGUI=()
|
2020-04-14 04:22:32 +00:00
|
|
|
|
2021-07-06 09:43:28 +00:00
|
|
|
for filename in ${APPIMAGE_RESOURCES_DIR}/icons/icon-*px.png; do
|
|
|
|
[[ ${filename} =~ ${APPIMAGE_RESOURCES_DIR}/icons/icon-(.*)px.png ]];
|
2020-10-01 23:00:39 +00:00
|
|
|
res=${BASH_REMATCH[1]}
|
2020-04-14 04:22:32 +00:00
|
|
|
mkdir -p ${BUILD_DIR}/AppImage-icons/${res}x${res}
|
|
|
|
for frontend in ${FRONTENDS[@]}; do
|
|
|
|
# Copy icon to proper directory
|
2021-07-06 09:43:28 +00:00
|
|
|
cp -v ${APPIMAGE_RESOURCES_DIR}/icons/icon-${res}px.png ${BUILD_DIR}/AppImage-icons/${res}x${res}/duckstation-${frontend}.png
|
2020-04-14 04:22:32 +00:00
|
|
|
# Append icon filepath to array that will later be passed to linuxdeploy
|
|
|
|
eval "ICONS_${frontend^^}+=(${BUILD_DIR}/AppImage-icons/${res}x${res}/duckstation-${frontend}.png)"
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
2020-05-16 12:35:07 +00:00
|
|
|
# Add data files into the AppDir
|
2020-10-01 23:00:39 +00:00
|
|
|
DATA_DIR=${APPIMAGE_RESOURCES_DIR}/../data
|
2020-05-16 12:35:07 +00:00
|
|
|
echo "Data directory is: ${DATA_DIR}"
|
|
|
|
for frontend in ${FRONTENDS[@]}; do
|
2020-10-01 23:00:39 +00:00
|
|
|
CURRENT_APPDIR=${BUILD_DIR}/duckstation-${frontend}.AppDir
|
2020-05-16 12:35:07 +00:00
|
|
|
mkdir -p ${CURRENT_APPDIR}/usr/bin
|
|
|
|
cp -av ${DATA_DIR}/* ${CURRENT_APPDIR}/usr/bin
|
|
|
|
done
|
|
|
|
|
2020-07-28 09:16:12 +00:00
|
|
|
# Add translations into the AppDir.
|
|
|
|
TRANSLATIONS_DIR=${BUILD_DIR}/bin/translations
|
|
|
|
echo "Translation directory is: ${BUILD_DIR}"
|
|
|
|
for frontend in ${FRONTENDS[@]}; do
|
2020-10-01 23:00:39 +00:00
|
|
|
CURRENT_APPDIR=${BUILD_DIR}/duckstation-${frontend}.AppDir
|
2020-07-28 09:16:12 +00:00
|
|
|
mkdir -p ${CURRENT_APPDIR}/usr/bin
|
|
|
|
cp -av ${TRANSLATIONS_DIR} ${CURRENT_APPDIR}/usr/bin
|
|
|
|
done
|
|
|
|
|
2021-09-25 23:56:56 +00:00
|
|
|
# Replace Patchelf
|
|
|
|
curl -sSfLO https://github.com/NixOS/patchelf/releases/download/0.12/patchelf-0.12.tar.bz2
|
|
|
|
tar xvf patchelf-0.12.tar.bz2
|
|
|
|
cd patchelf-0.12*/
|
|
|
|
./configure
|
|
|
|
make && sudo make install
|
|
|
|
cd ${BUILD_DIR}
|
|
|
|
|
2020-05-23 09:35:35 +00:00
|
|
|
# Pass UPDATE_INFORMATION and OUTPUT variables (used by linuxdeploy-plugin-appimage)
|
|
|
|
# to the environment of the linuxdeploy commands
|
2020-04-14 04:22:32 +00:00
|
|
|
|
2021-09-25 23:56:56 +00:00
|
|
|
${BUILD_DIR}/linuxdeploy-x86_64.AppImage --appimage-extract
|
|
|
|
mv ${BUILD_DIR}/squashfs-root/usr/bin/patchelf ${BUILD_DIR}/squashfs-root/usr/bin/patchelf.orig
|
|
|
|
sudo cp /usr/local/bin/patchelf ${BUILD_DIR}/squashfs-root/usr/bin/patchelf
|
|
|
|
|
|
|
|
${BUILD_DIR}/squashfs-root/AppRun \
|
2020-10-01 23:00:39 +00:00
|
|
|
--appdir=${BUILD_DIR}/duckstation-qt.AppDir \
|
2020-05-16 03:10:31 +00:00
|
|
|
--executable=${BUILD_DIR}/bin/duckstation-qt \
|
2021-07-06 09:43:28 +00:00
|
|
|
--desktop-file=${APPIMAGE_RESOURCES_DIR}/linux-desktop-files/duckstation-qt.desktop \
|
2020-04-14 04:22:32 +00:00
|
|
|
${ICONS_QT[@]/#/--icon-file=} \
|
2020-10-02 00:07:09 +00:00
|
|
|
--plugin=qt
|
|
|
|
|
|
|
|
# Patch AppRun to work around system Qt libraries being loaded ahead of bundled libraries
|
|
|
|
sed -i 's|exec "$this_dir"/AppRun.wrapped "$@"|exec env LD_LIBRARY_PATH="$this_dir"/usr/lib:$LD_LIBRARY_PATH "$this_dir"/AppRun.wrapped "$@"|' \
|
|
|
|
${BUILD_DIR}/duckstation-qt.AppDir/AppRun
|
2021-09-25 23:56:56 +00:00
|
|
|
|
|
|
|
mkdir -p ${BUILD_DIR}/duckstation-qt.AppDir/usr/plugins
|
|
|
|
mkdir -p ${BUILD_DIR}/duckstation-qt.AppDir/usr/lib/dri
|
|
|
|
cp /usr/lib/x86_64-linux-gnu/{libQt5WaylandClient.so.5,libEGL_mesa.so.0} ${BUILD_DIR}/duckstation-qt.AppDir/usr/lib
|
|
|
|
cp /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so ${BUILD_DIR}/duckstation-qt.AppDir/usr/lib/dri
|
|
|
|
cp -r /usr/lib/x86_64-linux-gnu/qt5/plugins/{xcbglintegrations,platforms,wayland-graphics-integration-client,wayland-decoration-client,wayland-shell-integration} ${BUILD_DIR}/duckstation-qt.AppDir/usr/plugins
|
|
|
|
|
|
|
|
cat <<'EOF'>> ${BUILD_DIR}/duckstation-qt.AppDir/apprun-hooks/linuxdeploy-plugin-qt-hook.sh
|
2021-11-28 09:27:29 +00:00
|
|
|
if [[ "${WAYLAND_DISPLAY}" == "wayland"* ]]; then
|
2021-11-28 07:55:41 +00:00
|
|
|
if [ -z ${QT_QPA_PLATFORM} ]; then
|
2021-09-25 23:56:56 +00:00
|
|
|
export QT_QPA_PLATFORM=wayland
|
2021-11-28 07:55:41 +00:00
|
|
|
fi
|
|
|
|
fi
|
2021-09-25 23:56:56 +00:00
|
|
|
EOF
|
2020-10-02 00:07:09 +00:00
|
|
|
|
|
|
|
UPDATE_INFORMATION="zsync|https://github.com/stenzek/duckstation/releases/download/latest/duckstation-qt-x64.AppImage.zsync" \
|
|
|
|
OUTPUT="duckstation-qt-x64.AppImage" \
|
|
|
|
${BUILD_DIR}/linuxdeploy-plugin-appimage-x86_64.AppImage \
|
2021-09-25 23:56:56 +00:00
|
|
|
--appdir=${BUILD_DIR}/duckstation-qt.AppDir
|
2020-04-14 04:22:32 +00:00
|
|
|
|
2021-01-31 07:28:42 +00:00
|
|
|
UPDATE_INFORMATION="zsync|https://github.com/stenzek/duckstation/releases/download/latest/duckstation-nogui-x64.AppImage.zsync" \
|
|
|
|
OUTPUT="duckstation-nogui-x64.AppImage" \
|
2021-09-25 23:56:56 +00:00
|
|
|
${BUILD_DIR}/squashfs-root/AppRun \
|
2021-01-31 07:28:42 +00:00
|
|
|
--appdir=${BUILD_DIR}/duckstation-nogui.AppDir \
|
|
|
|
--executable=${BUILD_DIR}/bin/duckstation-nogui \
|
2021-07-06 09:43:28 +00:00
|
|
|
--desktop-file=${APPIMAGE_RESOURCES_DIR}/linux-desktop-files/duckstation-nogui.desktop \
|
2021-01-31 07:28:42 +00:00
|
|
|
${ICONS_NOGUI[@]/#/--icon-file=} \
|
2020-05-23 09:35:35 +00:00
|
|
|
--output=appimage
|