mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-26 12:00:05 +00:00
Add scripts and files for AppImage packaging in dist folder
This commit is contained in:
parent
376d33cff4
commit
a7a7b95e8c
9
dist/appimage/AppRun-hook.sh
vendored
Executable file
9
dist/appimage/AppRun-hook.sh
vendored
Executable file
@ -0,0 +1,9 @@
|
||||
# try to make Qt apps more "native looking" on Gtk-based desktops, if possible
|
||||
# see https://github.com/AppImage/AppImageKit/issues/977#issue-462374883
|
||||
case "${XDG_CURRENT_DESKTOP}" in
|
||||
*GNOME*|*gnome*|*X-Cinnamon*|*XFCE*)
|
||||
export QT_QPA_PLATFORMTHEME=gtk3
|
||||
;;
|
||||
esac
|
||||
export GDK_BACKEND=x11
|
||||
export QT_QPA_PLATFORM=xcb
|
10
dist/appimage/AppRun.sh
vendored
Executable file
10
dist/appimage/AppRun.sh
vendored
Executable file
@ -0,0 +1,10 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
# make sure errors in sourced scripts will cause this script to stop
|
||||
set -e
|
||||
|
||||
this_dir="$(readlink -f "$(dirname "$0")")"
|
||||
|
||||
source "$this_dir"/apprun-hooks/"AppRun-hook"
|
||||
|
||||
exec "$this_dir"/AppRun.wrapped "$@"
|
43
dist/appimage/AppRun.wrapped.sh
vendored
Executable file
43
dist/appimage/AppRun.wrapped.sh
vendored
Executable file
@ -0,0 +1,43 @@
|
||||
#!/bin/sh -e
|
||||
|
||||
appdir=$(readlink -f ${APPDIR:-$(dirname "$0")})
|
||||
|
||||
desktopfile=$(ls -1 "$appdir"/*.desktop | head -n1)
|
||||
|
||||
if [ ! -f "$desktopfile" ]; then
|
||||
echo "No desktop file found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
library_path=""
|
||||
library_type=
|
||||
|
||||
binary="$appdir"/usr/bin/$(sed -n 's|^Exec=||p' "$desktopfile" | cut -d' ' -f1)
|
||||
|
||||
for lib_tuple in libstdc++.so.6:'^GLIBCXX_[0-9]' libgcc_s.so.1:'^GCC_[0-9]'; do
|
||||
lib_filename=$(echo "$lib_tuple" | cut -d: -f1)
|
||||
version_prefix=$(echo "$lib_tuple" | cut -d: -f2)
|
||||
lib_dir="$appdir"/usr/optional/"$lib_filename"/
|
||||
lib_path="$lib_dir"/"$lib_filename"
|
||||
if [ -e "$lib_path" ]; then
|
||||
lib=$(PATH="/sbin:$PATH" ldconfig -p | grep "$lib_filename" | awk 'NR==1 {print $NF}')
|
||||
sym_sys=$(tr '\0' '\n' < "$lib" | grep -e "$version_prefix" | sort --version-sort | tail -n1)
|
||||
sym_app=$(tr '\0' '\n' < "$lib_path" | grep -e "$version_prefix" | sort --version-sort | tail -n1)
|
||||
if [ z$(printf "${sym_sys}\n${sym_app}" | sort --version-sort | tail -n1) != z"$sym_sys" ]; then
|
||||
export library_path="$lib_dir"/:"$library_path"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
export LD_LIBRARY_PATH="$library_path:$LD_LIBRARY_PATH"
|
||||
|
||||
if [ -n "$cxxpath" ] || [ -n "$gccpath" ]; then
|
||||
if [ -e "$appdir"/usr/optional/exec.so ]; then
|
||||
export LD_PRELOAD="$appdir"/usr/optional/exec.so:"$LD_PRELOAD"
|
||||
fi
|
||||
fi
|
||||
|
||||
#echo ">>>>> $LD_LIBRARY_PATH"
|
||||
#echo ">>>>> $LD_PRELOAD"
|
||||
|
||||
exec "$binary" "$@"
|
212
dist/appimage/deploy-linux.sh
vendored
Executable file
212
dist/appimage/deploy-linux.sh
vendored
Executable file
@ -0,0 +1,212 @@
|
||||
#!/bin/bash
|
||||
# [DEPLOY_QT=1] deploy-linux.sh <executable>
|
||||
# (Simplified) bash re-implementation of [linuxdeploy](https://github.com/linuxdeploy).
|
||||
# Reads [executable] and copies required libraries to [AppDir]/usr/lib
|
||||
# Copies the desktop and svg icon to [AppDir]
|
||||
# Respects the AppImage excludelist
|
||||
#
|
||||
# Unlike linuxdeploy, this does not:
|
||||
# - Copy any icon other than svg (too lazy to add that without a test case)
|
||||
# - Do any verification on the desktop file
|
||||
# - Run any linuxdeploy plugins
|
||||
# - *Probably other things I didn't know linuxdeploy can do*
|
||||
#
|
||||
#~ set -x
|
||||
export _PREFIX="/usr"
|
||||
export _LIB_DIRS="lib64 lib"
|
||||
export _QT_PLUGIN_PATH="${_PREFIX}/lib64/qt6/plugins"
|
||||
export _EXCLUDES="ld-linux.so.2 \
|
||||
ld-linux-x86-64.so.2 \
|
||||
ld-linux-aarch64.so.1 \
|
||||
libasound.so.2 \
|
||||
libc.so.6 \
|
||||
libdl.so.2 \
|
||||
libgcc_s.so.1 \
|
||||
libm.so.6 \
|
||||
libpthread.so.0 \
|
||||
librt.so.1 \
|
||||
libstdc++.so.6 \
|
||||
libEGL.so.1 \
|
||||
libfreetype.so.6 \
|
||||
libGL.so.1 \
|
||||
libfribidi.so.0 \
|
||||
libGLX.so.0 \
|
||||
libgbm.so.1 \
|
||||
libGLdispatch.so.0 \
|
||||
libgdk-3.so.0 \
|
||||
libICE.so.6 \
|
||||
libgdk_pixbuf-2.0.so.0 \
|
||||
libOpenGL.so.0 \
|
||||
libgio-2.0.so.0 \
|
||||
libQt6EglFSDeviceIntegration.so.6 \
|
||||
libgpg-error.so.0 \
|
||||
libQt6OpenGL.so.6 \
|
||||
libgtk-3.so.0 \
|
||||
libSM.so.6 \
|
||||
libharfbuzz.so.0 \
|
||||
libX11.so.6 \
|
||||
libXcomposite.so.1 \
|
||||
libXcursor.so.1 \
|
||||
libXdamage.so.1 \
|
||||
libinput.so.10 \
|
||||
libXext.so.6 \
|
||||
libmount.so.1 \
|
||||
libXfixes.so.3 \
|
||||
libmtdev.so.1 \
|
||||
libXi.so.6 \
|
||||
libpango-1.0.so.0 \
|
||||
libXinerama.so.1 \
|
||||
libpangocairo-1.0.so.0 \
|
||||
libXrandr.so.2 \
|
||||
libpangoft2-1.0.so.0 \
|
||||
libXrender.so.1 \
|
||||
libpcre2-8.so.0 \
|
||||
libatk-1.0.so.0 \
|
||||
libpixman-1.so.0 \
|
||||
libatk-bridge-2.0.so.0 \
|
||||
libresolv.so.2 \
|
||||
libatspi.so.0 \
|
||||
libselinux.so.1 \
|
||||
libblkid.so.1 \
|
||||
libcairo-gobject.so.2 \
|
||||
libuuid.so.1 \
|
||||
libcairo.so.2 \
|
||||
libthai.so.0 \
|
||||
libcom_err.so.2 \
|
||||
libts.so.0 \
|
||||
libdatrie.so.1 \
|
||||
libwacom.so.2 \
|
||||
libdrm.so.2 \
|
||||
libxcb-icccm.so.4 \
|
||||
libepoxy.so.0 \
|
||||
libxcb-randr.so.0 \
|
||||
libevdev.so.2 \
|
||||
libxcb.so.1 \
|
||||
libexpat.so.1 \
|
||||
libfontconfig.so.1 \
|
||||
libz.so.1"
|
||||
|
||||
export _EXECUTABLE="$1"
|
||||
|
||||
# Get possible system library paths
|
||||
export _SYSTEM_PATHS=$(echo -n $PATH | tr ":" " ")
|
||||
export _SEARCH_PATHS=
|
||||
for i in ${_LIB_DIRS}; do
|
||||
for j in ${_SYSTEM_PATHS}; do
|
||||
_TRY_PATH="$(readlink -e "$j/../$i" || true)"
|
||||
if [[ -n "${_TRY_PATH}" ]]; then
|
||||
_SEARCH_PATHS="${_SEARCH_PATHS} ${_TRY_PATH}"
|
||||
fi
|
||||
done
|
||||
done
|
||||
_SEARCH_PATHS="${_SEARCH_PATHS} $(patchelf --print-rpath $_EXECUTABLE | tr ':' ' ')"
|
||||
# Get a list of only unique ones
|
||||
_SEARCH_PATHS=$(echo -n "${_SEARCH_PATHS}" | sed 's/ /\n/g' | sort -u)
|
||||
|
||||
# find_library [library]
|
||||
# Finds the full path of partial name [library] in _SEARCH_PATHS
|
||||
# This is a time-consuming function.
|
||||
_NOT_FOUND=""
|
||||
function find_library {
|
||||
local _PATH=""
|
||||
for i in ${_SEARCH_PATHS}; do
|
||||
_PATH=$(find $i -regex ".*$(echo -n $1 | tr '+' '.')" -print -quit)
|
||||
if [ "$_PATH" != "" ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ "$_PATH" != "" ]; then
|
||||
echo -n $(readlink -e $_PATH)
|
||||
fi
|
||||
}
|
||||
|
||||
# get_dep_names [object]
|
||||
# Returns a space-separated list of all required libraries needed by [object].
|
||||
function get_dep_names {
|
||||
echo -n $(patchelf --print-needed $1)
|
||||
}
|
||||
|
||||
# get_deps [object] [library_path]
|
||||
# Finds and installs all libraries required by [object] to [library_path].
|
||||
# This is a recursive function that also depends on find_library.
|
||||
function get_deps {
|
||||
local _DEST=$2
|
||||
for i in $(get_dep_names $1); do
|
||||
_EXCL=`echo "$_EXCLUDES" | tr ' ' '\n' | grep $i`
|
||||
if [ "$_EXCL" != "" ]; then
|
||||
#>&2 echo "$i is on the exclude list... skipping"
|
||||
continue
|
||||
fi
|
||||
if [ -f $_DEST/$i ]; then
|
||||
continue
|
||||
fi
|
||||
local _LIB=$(find_library $i)
|
||||
if [ -z $_LIB ]; then
|
||||
echo -n "$i:"
|
||||
continue
|
||||
fi
|
||||
>&2 cp -v $_LIB $_DEST/$i &
|
||||
get_deps $_LIB $_DEST
|
||||
done
|
||||
}
|
||||
|
||||
export -f get_deps
|
||||
export -f get_dep_names
|
||||
export -f find_library
|
||||
|
||||
_ERROR=0
|
||||
if [ -z "$_EXECUTABLE" ]; then
|
||||
_ERROR=1
|
||||
fi
|
||||
|
||||
if [ "$_ERROR" -eq 1 ]; then
|
||||
>&2 echo "usage: $0 <executable> [AppDir]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LIB_DIR="$(readlink -m $(dirname $_EXECUTABLE)/../lib)"
|
||||
mkdir -p $LIB_DIR
|
||||
_NOT_FOUND=$(get_deps $_EXECUTABLE $LIB_DIR)
|
||||
|
||||
if [ "${DEPLOY_QT}" == "1" ]; then
|
||||
# Find Qt path from search paths
|
||||
for i in ${_SEARCH_PATHS}; do
|
||||
_QT_CORE_LIB=$(find ${i} -type f -regex '.*/libQt6Core\.so.*' | head -n 1)
|
||||
if [ -n "${_QT_CORE_LIB}" ]; then
|
||||
_QT_PATH=$(dirname ${_QT_CORE_LIB})/../
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
_QT_PLUGIN_PATH=$(readlink -e $(find ${_QT_PATH} -type d -regex '.*/plugins/platforms' | head -n 1)/../)
|
||||
|
||||
for i in audio bearer imageformats mediaservice platforminputcontexts platformthemes xcbglintegrations platforms wayland-decoration-client wayland-graphics-integration-client wayland-graphics-integration-server wayland-shell-integration; do
|
||||
mkdir -p ${LIB_DIR}/../plugins/${i}
|
||||
cp -rnv ${_QT_PLUGIN_PATH}/${i}/*.so ${LIB_DIR}/../plugins/${i}
|
||||
find ${LIB_DIR}/../plugins/ -type f -regex '.*\.so' -exec patchelf --set-rpath '$ORIGIN/../../lib:$ORIGIN' {} ';'
|
||||
# Find any remaining libraries needed for Qt libraries
|
||||
_NOT_FOUND+=$(find ${LIB_DIR}/../plugins/${i} -type f -exec bash -c "get_deps {} $LIB_DIR" ';')
|
||||
done
|
||||
|
||||
_QT_CONF=${LIB_DIR}/../bin/qt.conf
|
||||
echo "[Paths]" > ${_QT_CONF}
|
||||
echo "Prefix = ../" >> ${_QT_CONF}
|
||||
echo "Plugins = plugins" >> ${_QT_CONF}
|
||||
echo "Imports = qml" >> ${_QT_CONF}
|
||||
echo "Qml2Imports = qml" >> ${_QT_CONF}
|
||||
fi
|
||||
|
||||
# Fix rpath of libraries and executable so they can find the packaged libraries
|
||||
find ${LIB_DIR} -type f -exec patchelf --set-rpath '$ORIGIN' {} ';'
|
||||
patchelf --set-rpath '$ORIGIN/../lib' $_EXECUTABLE
|
||||
|
||||
_APPDIR=$2
|
||||
cd ${_APPDIR}
|
||||
|
||||
cp -nvs $(find -type f -regex '.*/icons/.*\.svg' || head -n 1) ./
|
||||
cp -nvs $(find -type f -regex '.*/applications/.*\.desktop' || head -n 1) ./
|
||||
|
||||
if [ "${_NOT_FOUND}" != "" ]; then
|
||||
>&2 echo "WARNING: failed to find the following libraries:"
|
||||
>&2 echo "$(echo -n $_NOT_FOUND | tr ':' '\n' | sort -u)"
|
||||
fi
|
BIN
dist/appimage/exec-aarch64.so
vendored
Executable file
BIN
dist/appimage/exec-aarch64.so
vendored
Executable file
Binary file not shown.
79
dist/appimage/package-appimage-arm64.sh
vendored
Executable file
79
dist/appimage/package-appimage-arm64.sh
vendored
Executable file
@ -0,0 +1,79 @@
|
||||
mv ./linux-arm64-appimage/AppDir.7z ./AppDir.7z
|
||||
7z x AppDir.7z
|
||||
|
||||
# Seperate AppDir for all Citra executables
|
||||
cp -r AppDir AppDir-qt
|
||||
cp -r AppDir AppDir-room
|
||||
|
||||
rm -vf AppDir/usr/bin/citra-qt AppDir/usr/bin/citra-room
|
||||
rm -vf AppDir-room/usr/bin/citra AppDir-room/usr/bin/citra-qt
|
||||
rm -vf AppDir-qt/usr/bin/citra AppDir-qt/usr/bin/citra-room
|
||||
|
||||
mv ./AppDir/usr/share/applications/citra-qt.desktop ./AppDir/usr/share/applications/citra.desktop
|
||||
mv ./AppDir-room/usr/share/applications/citra-qt.desktop ./AppDir-room/usr/share/applications/citra-room.desktop
|
||||
|
||||
# Download appimagetool, needed to build an AppImage
|
||||
wget https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage
|
||||
|
||||
# Set executable bit
|
||||
chmod a+x appimagetool-x86_64.AppImage
|
||||
|
||||
# Workaround for https://github.com/AppImage/AppImageKit/issues/828
|
||||
export APPIMAGE_EXTRACT_AND_RUN=1
|
||||
|
||||
# Deploy Citra's needed dependencies
|
||||
DEPLOY_QT=0 ./dist/appimage/deploy-linux.sh AppDir/usr/bin/citra AppDir
|
||||
DEPLOY_QT=0 ./dist/appimage/deploy-linux.sh AppDir-room/usr/bin/citra-room AppDir-room
|
||||
DEPLOY_QT=1 ./dist/appimage/deploy-linux.sh AppDir-qt/usr/bin/citra-qt AppDir-qt
|
||||
|
||||
mkdir AppDir/apprun-hooks
|
||||
mkdir -p AppDir/usr/optional
|
||||
mkdir -p AppDir/usr/optional/libstdc++
|
||||
mkdir -p AppDir/usr/optional/libgcc_s
|
||||
|
||||
mkdir AppDir-room/apprun-hooks
|
||||
mkdir -p AppDir-room/usr/optional
|
||||
mkdir -p AppDir-room/usr/optional/libstdc++
|
||||
mkdir -p AppDir-room/usr/optional/libgcc_s
|
||||
|
||||
mkdir AppDir-qt/apprun-hooks
|
||||
mkdir -p AppDir-qt/usr/optional
|
||||
mkdir -p AppDir-qt/usr/optional/libstdc++
|
||||
mkdir -p AppDir-qt/usr/optional/libgcc_s
|
||||
|
||||
cp ./dist/appimage/AppRun.sh AppDir/AppRun
|
||||
cp ./dist/appimage/AppRun.wrapped.sh AppDir/AppRun.wrapped
|
||||
cp ./dist/appimage/AppRun-hook.sh AppDir/apprun-hooks/AppRun-hook
|
||||
cp ./dist/appimage/exec-aarch64.so AppDir/usr/optional/exec.so
|
||||
cp --dereference /usr/lib/aarch64-linux-gnu/libstdc++.so.6 AppDir/usr/optional/libstdc++/libstdc++.so.6
|
||||
cp --dereference /lib/aarch64-linux-gnu/libgcc_s.so.1 AppDir/usr/optional/libgcc_s/libgcc_s.so.1
|
||||
|
||||
cp ./dist/appimage/AppRun.sh AppDir-room/AppRun
|
||||
cp ./dist/appimage/AppRun.wrapped.sh AppDir-room/AppRun.wrapped
|
||||
cp ./dist/appimage/AppRun-hook.sh AppDir-room/apprun-hooks/AppRun-hook
|
||||
cp ./dist/appimage/exec-aarch64.so AppDir-room/usr/optional/exec.so
|
||||
cp --dereference /usr/lib/aarch64-linux-gnu/libstdc++.so.6 AppDir-room/usr/optional/libstdc++/libstdc++.so.6
|
||||
cp --dereference /lib/aarch64-linux-gnu/libgcc_s.so.1 AppDir-room/usr/optional/libgcc_s/libgcc_s.so.1
|
||||
|
||||
cp ./dist/appimage/AppRun.sh AppDir-qt/AppRun
|
||||
cp ./dist/appimage/AppRun.wrapped.sh AppDir-qt/AppRun.wrapped
|
||||
cp ./dist/appimage/AppRun-hook.sh AppDir-qt/apprun-hooks/AppRun-hook
|
||||
cp ./dist/appimage/exec-aarch64.so AppDir-qt/usr/optional/exec.so
|
||||
cp --dereference /usr/lib/aarch64-linux-gnu/libstdc++.so.6 AppDir-qt/usr/optional/libstdc++/libstdc++.so.6
|
||||
cp --dereference /lib/aarch64-linux-gnu/libgcc_s.so.1 AppDir-qt/usr/optional/libgcc_s/libgcc_s.so.1
|
||||
|
||||
# Build an AppImage
|
||||
ARCH=aarch64 ./appimagetool-x86_64.AppImage AppDir citra.AppImage
|
||||
ARCH=aarch64 ./appimagetool-x86_64.AppImage AppDir-room citra-room.AppImage
|
||||
ARCH=aarch64 ./appimagetool-x86_64.AppImage AppDir-qt citra-qt.AppImage
|
||||
|
||||
mkdir -p ./build/bundle
|
||||
mv citra.AppImage ./build/bundle
|
||||
mv citra-room.AppImage ./build/bundle
|
||||
mv citra-qt.AppImage ./build/bundle
|
||||
|
||||
mkdir ./build/bundle/dist
|
||||
cp ./dist/icon.png ./build/bundle/dist/citra.png
|
||||
cp ./license.txt ./build/bundle
|
||||
cp ./README.md ./build/bundle
|
||||
cp -r ./dist/scripting ./build/bundle/scripting
|
Loading…
Reference in New Issue
Block a user