From b5055ff6cbd6917ecae32c3a5b70922a2ab36064 Mon Sep 17 00:00:00 2001 From: xargon Date: Thu, 9 Jun 2022 10:25:20 +0200 Subject: [PATCH 1/4] NEW VARIABLES SYSTEM --- global.sh | 23 +++++++++++++++++++++++ net.retrodeck.retrodeck.yml | 7 ++++++- retrodeck.sh | 17 +++++++++++++---- tools/move-roms.sh | 33 +++++++++++++++++---------------- 4 files changed, 59 insertions(+), 21 deletions(-) create mode 100755 global.sh diff --git a/global.sh b/global.sh new file mode 100755 index 00000000..363c2ecf --- /dev/null +++ b/global.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# This file is containing some global function needed for the script such as the config file tools + +conf_init() { + # initializing and reading the retrodeck config file + if [ ! -f $rd_conf ] + then # I have to initialize the variables as they cannot be red from an empty config file + touch $rd_conf + version="$(cat /app/retrodeck/version)" # version info taken from the version file + rdhome="$HOME/retrodeck" # the retrodeck home, aka ~/retrodeck + roms_folder="$rdhome/roms" # default roms folder location (intenral) + else # i just read the variables + source $rd_conf + fi +} + +conf_write() { + # writes the variables in the retrodeck config file + sed -i "s%version=.*%version=$version%" $rd_conf + sed -i "s%rdhome=.*%rdhome=$rdhome%" $rd_conf + sed -i "s%rdhome=.*%rdhome=$roms_folder" $rd_conf +} \ No newline at end of file diff --git a/net.retrodeck.retrodeck.yml b/net.retrodeck.retrodeck.yml index 65f03b92..be45244f 100644 --- a/net.retrodeck.retrodeck.yml +++ b/net.retrodeck.retrodeck.yml @@ -1018,6 +1018,9 @@ modules: - cp retrodeck.sh /app/bin/retrodeck.sh - chmod +x /app/bin/retrodeck.sh + + - cp global.sh /app/bin/global.sh + - chmod +x /app/bin/global.sh # Desktop entry - cp net.retrodeck.retrodeck.desktop /app/share/applications/net.retrodeck.retrodeck.desktop @@ -1073,4 +1076,6 @@ modules: - type: file path: net.retrodeck.retrodeck.desktop - type: file - path: net.retrodeck.retrodeck.appdata.xml \ No newline at end of file + path: net.retrodeck.retrodeck.appdata.xml + - type: file + path: global.sh \ No newline at end of file diff --git a/retrodeck.sh b/retrodeck.sh index 7f9ce114..05f8f6e7 100644 --- a/retrodeck.sh +++ b/retrodeck.sh @@ -1,10 +1,15 @@ #!/bin/bash +# Init default values, this may be overwritten by retrodeck.cfg as it sourced later with global.sh + lockfile="$HOME/retrodeck/.lock" # where the lockfile is located -version="$(cat /app/retrodeck/version)" # version info taken from the version file -rdhome="$HOME/retrodeck" # the retrodeck home, aka ~/retrodecck emuconfigs="/app/retrodeck/emu-configs" # folder with all the default emulator configs sdcard="/run/media/mmcblk0p1" # Steam Deck SD default path +rd_conf="/app/retrodeck/retrodeck.cfg" # RetroDECK config file path +version="$(cat /app/retrodeck/version)" # version info taken from the version file +rdhome="$HOME/retrodeck" # the retrodeck home, aka ~/retrodeck + +source global.sh # Functions area @@ -325,7 +330,9 @@ done if [ -f "$lockfile" ] && [ "$(cat "$lockfile")" != "$version" ]; then echo "Lockfile version is "$(cat "$lockfile")" but the actual version is $version" - post_update + conf_init # Initializing/reading the config file (sourced from global.sh) + post_update # Executing post update script + conf_write # Writing variables in the config file (sourced from global.sh) start_retrodeck exit 0 fi @@ -335,7 +342,9 @@ fi if [ ! -f "$lockfile" ]; then echo "Lockfile not found" - finit + conf_init # Initializing/reading the config file (sourced from global.sh) + finit # Executing First/Force init + conf_write # Writing variables in the config file (sourced from global.sh) exit 0 fi diff --git a/tools/move-roms.sh b/tools/move-roms.sh index a6bfafce..eca4bbb9 100644 --- a/tools/move-roms.sh +++ b/tools/move-roms.sh @@ -1,29 +1,30 @@ #!/bin/bash -if [ -d ~/retrodeck/roms ] && [ -d /run/media/mmcblk0p1/retrodeck/roms ] -then # found both internal and sd folders - zenity --title "RetroDECK" --warning --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --text="I found a roms folder both in internal and SD Card,\nin order to make this tool useful you should remove one of the two or merge them." +source global.sh + +zenity --question --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" --cancel-label="Quit" --ok-label "Continue" --text="WARNING: this script is experimental\nplease be sure you back up your data before continuing.\n\nDo you want to continue?" +if [ $? == 1 ] #cancel +then exit 0 fi -if [ -d ~/retrodeck/roms ] && [ ! -d /run/media/mmcblk0p1/retrodeck/roms ] -then # found internal folder and not the external - roms_path=~/retrodeck - new_roms_path=/run/media/mmcblk0p1/retrodeck +zenity --question --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" --cancel-label="Cancel" --ok-label "Browse" --text="The roms folder is now: $roms_folder\nplease select the new location.\nA retrodeck/roms folder will be created starting from the directory that you selected." +if [ $? == 1 ] #cancel +then + exit 0 fi -if [ ! -d ~/retrodeck/roms ] && [ -d /run/media/mmcblk0p1/retrodeck/roms ] -then # found external folder and not the internal - roms_path=/run/media/mmcblk0p1/retrodeck - new_roms_path=~/retrodeck -fi +new_roms_path="$(zenity --file-selection --title="Choose a new roms folder location" --directory)"/retrodeck/roms -zenity --title "RetroDECK" --question --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --text="Should I move the roms from\n\n$roms_path/roms\n\nto\n\n$new_roms_path/roms?" +zenity --title "RetroDECK" --question --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --text="Should I move the roms from\n\n$roms_folder\n\nto\n\n$new_roms_path?" if [ $? == 0 ] #yes then mkdir -p $new_roms_path - mv -f $roms_path/roms $new_roms_path/roms + mv -f $roms_folder $new_roms_path rm -f /var/config/emulationstation/ROMs - ln -s $new_roms_path/roms /var/config/emulationstation/ROMs - rm -f $roms_path/roms + ln -s $new_roms_path /var/config/emulationstation/ROMs + rm -f $roms_folder + zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" --text="Done\nYour roms are now located in:\n\n$roms_folder\n\nPress OK to continue." + $roms_folder=$new_roms_path # Updating variable + conf_write # Writing variables in the config file (sourced from global.sh) fi From 7b6b1cfb124ea08d52dd2649e209764ca7291af7 Mon Sep 17 00:00:00 2001 From: xargon Date: Sat, 11 Jun 2022 09:30:13 +0200 Subject: [PATCH 2/4] WORKFLOW: restored the cooker-selfhosted.yml from the branch cooker --- .github/workflows/cooker-selfhosted.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cooker-selfhosted.yml b/.github/workflows/cooker-selfhosted.yml index 834c7e77..b1b2c982 100644 --- a/.github/workflows/cooker-selfhosted.yml +++ b/.github/workflows/cooker-selfhosted.yml @@ -41,15 +41,14 @@ jobs: flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo flatpak install -y org.kde.Sdk//5.15-21.08 org.kde.Platform//5.15-21.08 io.qt.qtwebengine.BaseApp/x86_64/5.15-21.08 org.freedesktop.Sdk.Extension.llvm13 - # for main remember to change ~ into ${GITHUB_WORKSPACE} + # for main remember to change ${HOME} into ${GITHUB_WORKSPACE} - name: Build flatpak run: | - flatpak-builder --build-only --user --force-clean --repo=~/local ~/retrodeck-flatpak-cooker net.retrodeck.retrodeck.yml + flatpak-builder --user --force-clean --keep-build-dirs --repo=${HOME}/local ${HOME}/retrodeck-flatpak-cooker net.retrodeck.retrodeck.yml - name: Create Bundle run: | - flatpak-builder --user --force-clean --repo=~/local ~/retrodeck-flatpak-cooker net.retrodeck.retrodeck.yml - flatpak build-bundle $GITHUB_WORKSPACE/local RetroDECK.flatpak net.retrodeck.retrodeck + flatpak build-bundle ${HOME}/local RetroDECK.flatpak net.retrodeck.retrodeck - name: Read version from version file id: version From 672fad50aec918e3fec94d4a8be81de9fc1822aa Mon Sep 17 00:00:00 2001 From: xargon Date: Sat, 11 Jun 2022 10:34:46 +0200 Subject: [PATCH 3/4] WORKFLOW: restored the cooker-selfhosted.yml from the branch cooker --- net.retrodeck.retrodeck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net.retrodeck.retrodeck.yml b/net.retrodeck.retrodeck.yml index be45244f..c60829b7 100644 --- a/net.retrodeck.retrodeck.yml +++ b/net.retrodeck.retrodeck.yml @@ -210,7 +210,7 @@ modules: - >- mv ${FLATPAK_DEST}/share/pixmaps/retroarch.svg ${FLATPAK_DEST}/share/icons/hicolor/scalable/apps/ - - rmdir --ignore-fail-on-non-empty ${FLATPAK_DEST}/share/pixmaps/ + - rm -rf ${FLATPAK_DEST}/share/pixmaps/ - mkdir -p ${FLATPAK_DEST}/etc - >- sed s:@prefix@:${FLATPAK_DEST}:g retroarch.cfg > From c12ed8e9407a334fedef4c02e00ba15bc72521e5 Mon Sep 17 00:00:00 2001 From: xargon Date: Sat, 11 Jun 2022 10:41:10 +0200 Subject: [PATCH 4/4] RETROARCH: folder deletion was maybe wrong --- net.retrodeck.retrodeck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net.retrodeck.retrodeck.yml b/net.retrodeck.retrodeck.yml index c60829b7..be45244f 100644 --- a/net.retrodeck.retrodeck.yml +++ b/net.retrodeck.retrodeck.yml @@ -210,7 +210,7 @@ modules: - >- mv ${FLATPAK_DEST}/share/pixmaps/retroarch.svg ${FLATPAK_DEST}/share/icons/hicolor/scalable/apps/ - - rm -rf ${FLATPAK_DEST}/share/pixmaps/ + - rmdir --ignore-fail-on-non-empty ${FLATPAK_DEST}/share/pixmaps/ - mkdir -p ${FLATPAK_DEST}/etc - >- sed s:@prefix@:${FLATPAK_DEST}:g retroarch.cfg >