Skip to content

Commit

Permalink
squash: update flatpak support
Browse files Browse the repository at this point in the history
  • Loading branch information
jardon committed Nov 5, 2024
1 parent a116789 commit 065a7cb
Showing 1 changed file with 47 additions and 8 deletions.
55 changes: 47 additions & 8 deletions src/qt_gui/check_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,18 @@ void CheckUpdate::CheckForUpdates(const bool showMessage) {
#ifdef Q_OS_WIN
platformString = "win64-qt";
#elif defined(Q_OS_LINUX)
platformString = "linux-qt";
char path[PATH_MAX];

ssize_t len = readlink("/proc/self/exe", path, sizeof(path) - 1);

path[len] = '\0';
std::string executable_path(path);

if (executable_path.find("flatpak") != std::string::npos) {
platformString = "linux-flatpak";
} else {
platformString = "linux-qt"
}
#elif defined(Q_OS_MAC)
platformString = "macos-qt";
#endif
Expand Down Expand Up @@ -462,23 +473,51 @@ void CheckUpdate::Install() {
" exit 1\n"
" fi\n"
"}\n"
"set_package_type() {\n"
" if pgrep -f \"Shadps4-qt.AppImage\" > /dev/null; then\n"
" TYPE=\"appimage\"\n"
" else\n"
" TYPE=\"flatpak\"\n"
" fi\n"
"}\n"
"kill_process() {\n"
" if [ \"$TYPE\" == \"appimage\" ]; then\n"
" pkill -f \"Shadps4-qt.AppImage\"\n"
" sleep 2\n"
" else\n"
" pkill -f \"Shadps4\"\n"
" sleep 2\n"
" fi\n"
"}\n"
"update_package() {\n"
" if [ \"$TYPE\" == \"appimage\" ]; then\n"
" cp -r \"$1/\"* \"$2/\"\n"
" chmod +x \"$2/Shadps4-qt.AppImage\"\n"
" else\n"
" flatpak install -u \"$2/shadps4.flatpak\"\n"
" fi\n"
"}\n"
"restart_app() {\n"
" if [ \"$TYPE\" == \"appimage\" ]; then\n"
" cd \"$1\" && ./Shadps4-qt.AppImage\n"
" else\n"
" flatpak run -u com.shadps4emu.ShadPS4\n"
" fi\n"
"}\n"
"main() {\n"
" check_unzip\n"
" echo \"%1\"\n"
" sleep 2\n"
" extract_file\n"
" sleep 2\n"
" if pgrep -f \"shadPS4-qt.AppImage\" > /dev/null; then\n"
" pkill -f \"shadPS4-qt.AppImage\"\n"
" sleep 2\n"
" fi\n"
" cp -r \"%2/\"* \"%3/\"\n"
" set_package_type\n"
" sleep 2\n"
" update_package \"%2\" \"%3\"\n"
" sleep 2\n"
" restart_app \"%3\"\n"
" rm \"%3/update.sh\"\n"
" rm \"%3/temp_download_update.zip\"\n"
" chmod +x \"%3/shadPS4-qt.AppImage\"\n"
" rm -r \"%2\"\n"
" cd \"%3\" && ./shadPS4-qt.AppImage\n"
"}\n"
"main\n");
arguments << scriptFileName;
Expand Down

0 comments on commit 065a7cb

Please sign in to comment.