Skip to content

Commit

Permalink
Merge pull request #754 from Samueru-sama/dev
Browse files Browse the repository at this point in the history
Unify ryujinx
  • Loading branch information
ivan-hc authored Jul 3, 2024
2 parents 2078165 + a742b06 commit b9cd009
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 110 deletions.
1 change: 0 additions & 1 deletion programs/x86_64-apps
Original file line number Diff line number Diff line change
Expand Up @@ -1586,7 +1586,6 @@
◆ rustdict : A dictionary CLI tool in Rust inspired by BetaPictoris's dict.
◆ rx-bin : A modern and extensible pixel editor implemented in Rust.
◆ ryowallet : Modern GUI interface for Ryo Currency.
◆ ryujinx-appimage : Unofficial AppImage of the Ryujinx emulator.
◆ ryujinx : A simple, experimental Nintendo Switch emulator.
◆ sabaki : Modern, elegant, cross-platform Go/Baduk/Weiqi game board.
◆ saber : A (work-in-progress) cross-platform libre handwritten notes app.
Expand Down
113 changes: 77 additions & 36 deletions programs/x86_64/ryujinx
Original file line number Diff line number Diff line change
@@ -1,75 +1,116 @@
#!/bin/sh

# AM INSTALL SCRIPT VERSION 3.
# AM INSTALL SCRIPT VERSION 3.5
set -u
APP=ryujinx
SITE="Ryujinx/release-channel-master"
SITE1=$(curl -Ls https://api.github.com/repos/Ryujinx/release-channel-master/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*linux.*x64.*gz$" | head -1)
SITE2=$(curl -Ls https://api.github.com/repos/Samueru-sama/Ryujinx-AppImage/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*$APP.*appimage$" | head -1)

# CREATE DIRECTORIES AND ADD REMOVER
[ -n "$APP" ] && mkdir -p "/opt/$APP/tmp" "/opt/$APP/icons" && cd "/opt/$APP/tmp" || exit 1
printf "#!/bin/sh\nset -e\nrm -f /usr/local/bin/$APP\nrm -R -f /opt/$APP" > ../remove
printf '\n%s' "rm -f /usr/local/share/applications/$APP-AM.desktop" >> ../remove
chmod a+x ../remove || exit 1

# DOWNLOAD AND PREPARE THE APP, $version is also used for updates
version=$(curl -Ls https://api.github.com/repos/Ryujinx/release-channel-master/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*" | grep -vi "i386|i686|aarch64|arm64|armv7l" | grep -i "linux_x64.tar.gz" | head -1)
wget "$version" || exit 1
[ -e ./*7z ] && 7z x ./*7z && rm -f ./*7z
# CHOOSE A VERSION
read -r -p "
Choose which version of Ryujinx to use:
1. Ryujinx
Official portable build of Ryujinx
Source: https://ryujinx.org
2. Ryujinx AppImage
Unofficial AppImage of Ryujinx, has the advantage that it is one smaller file
It can be sandboxed with 'am --sandbox ryujinx' or 'appman --sandbox ryujinx'
Source: https://github.com/Samueru-sama/Ryujinx-AppImage
Which version you choose (type a number and press ENTER)?: " RESPONSE
case "$RESPONSE" in
1) rm -f /opt/"$APP"/version
UPDATER=1
version="$SITE1"
wget "$version" || exit 1;;

2) rm -f /opt/"$APP"/version
UPDATER=2
version="$SITE2"
wget "$version" || exit 1;;

*) ../remove && echo "Not a valid number, aborting" && exit 1;;
esac

# PREPARE THE APP, $version is also used for updates
[ -e ./*tar.* ] && tar fx ./*tar.* && rm -f ./*tar.*
[ -e ./*zip ] && unzip -qq ./*zip 1>/dev/null && rm -f ./*zip
cd ..
if [ -d ./tmp/* 2>/dev/null ]; then mv ./tmp/*/* ./; else mv ./tmp/* ./"$APP" 2>/dev/null || mv ./tmp/* ./; fi
if [ -d ./tmp/* 2>/dev/null ]; then mv ./tmp/*/* ./; else mv ./tmp/*mage ./"$APP"; fi
rm -R -f ./tmp || exit 1
echo "$version" > ./version
chmod a+x ./Ryujinx.sh || exit 1
if [ -e ./Ryujinx ]; then
chmod a+x ./Ryujinx* && ln -s ./Ryujinx.sh ./"$APP" || exit 1
else
chmod a+x ./"$APP" || exit 1
fi

# LINK TO PATH
ln -s "/opt/$APP/Ryujinx.sh" "/usr/local/bin/$APP"
ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP"

# SCRIPT TO UPDATE THE PROGRAM
cat >> ./AM-updater << 'EOF'
#!/bin/sh
set -u
APP=ryujinx
SITE="Ryujinx/release-channel-master"
#SITE1=$(curl -Ls https://api.github.com/repos/Ryujinx/release-channel-master/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*linux.*x64.*gz$" | head -1)
#SITE2=$(curl -Ls https://api.github.com/repos/Samueru-sama/Ryujinx-AppImage/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*$APP.*appimage$" | head -1)
version0=$(cat "/opt/$APP/version")
version=$(curl -Ls https://api.github.com/repos/Ryujinx/release-channel-master/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*" | grep -vi "i386|i686|aarch64|arm64|armv7l" | grep -i "linux_x64.tar.gz" | head -1)
version="REPLACETHIS"
[ -n "$version" ] || { echo "Error getting link"; exit 1; }
if [ "$version" != "$version0" ]; then
mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1
notify-send "A new version of $APP is available, please wait"
wget "$version" || exit 1
[ -e ./*7z ] && 7z x ./*7z && rm -f ./*7z
wget "$version" -O download.tar.bz2 || exit 1
[ -e ./*tar.* ] && tar fx ./*tar.* && rm -f ./*tar.*
[ -e ./*zip ] && unzip -qq ./*zip 1>/dev/null && rm -f ./*zip
cd ..
if [ -d ./tmp/* 2>/dev/null ]; then mv --backup=t ./tmp/*/* ./; else mv --backup=t ./tmp/* ./"$APP" 2>/dev/null || mv --backup=t ./tmp/* ./; fi
chmod a+x ./Ryujinx.sh || exit 1
if [ -d ./tmp/* ]; then mv --backup=t ./tmp/*/* ./; else mv --backup=t ./tmp/*mage ./"$APP"; fi
if [ -e ./Ryujinx ]; then
chmod a+x ./Ryujinx ./Ryujinx.sh || exit 1
else
chmod a+x ./"$APP" || exit 1
fi
echo "$version" > ./version
rm -R -f ./tmp ./*~
notify-send "$APP is updated!"
else
echo "Update not needed!"
fi
EOF
[ "$UPDATER" = 1 ] && { sed -i 's|REPLACETHIS|$SITE1|g; s|#SITE1|SITE1|g' ./AM-updater || exit 1; }
[ "$UPDATER" = 2 ] && { sed -i 's|REPLACETHIS|$SITE2|g; s|#SITE2|SITE2|g' ./AM-updater || exit 1; }
chmod a+x ./AM-updater || exit 1

# ICON
mkdir -p icons
wget https://portable-linux-apps.github.io/icons/ryujinx.png -O ./icons/"$APP" 2> /dev/null

# LAUNCHER
echo "[Desktop Entry]
Version=1.0
Name=Ryujinx
Type=Application
Icon=/opt/$APP/icons/$APP
Exec=/opt/$APP/Ryujinx.sh %f
Comment=A Nintendo Switch Emulator
GenericName=Nintendo Switch Emulator
Terminal=false
Categories=Game;Emulator;
MimeType=application/x-nx-nca;application/x-nx-nro;application/x-nx-nso;application/x-nx-nsp;application/x-nx-xci;
Keywords=Switch;Nintendo;Emulator;
StartupWMClass=Ryujinx
PrefersNonDefaultGPU=true" > /usr/local/share/applications/"$APP"-AM.desktop
# LAUNCHER & ICON
if [ "$UPDATER" = "1" ]; then
DESKTOP="https://raw.githubusercontent.com/Ryujinx/Ryujinx/master/distribution/linux/Ryujinx.desktop"
ICON="https://raw.githubusercontent.com/Ryujinx/Ryujinx/master/src/Ryujinx/Ryujinx.ico"
wget "$DESKTOP" -O ./"$APP".desktop 2>/dev/null && wget "$ICON" -O ./DirIcon 2>/dev/null
sed -i "s#Exec=[^ ]*#Exec=$APP#g; s#Icon=.*#Icon=/opt/$APP/icons/$APP#g" ./"$APP".desktop
else
./"$APP" --appimage-extract *.desktop 1>/dev/null && mv ./squashfs-root/*.desktop ./"$APP".desktop
./"$APP" --appimage-extract .DirIcon 1>/dev/null && mv ./squashfs-root/.DirIcon ./DirIcon
COUNT=0
while [ "$COUNT" -lt 10 ]; do # Tries to get the actual icon/desktop if it is a symlink to another symlink
if [ -L ./"$APP".desktop ]; then
LINKPATH=$(readlink ./"$APP".desktop)
./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop
fi
if [ -L ./DirIcon ]; then
LINKPATH=$(readlink ./DirIcon)
./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./DirIcon
fi
[ ! -L ./"$APP".desktop ] && [ ! -L ./DirIcon ] && break
COUNT=$((COUNT + 1))
done
sed -i "s#Exec=[^ ]*#Exec=$APP#g; s#Icon=.*#Icon=/opt/$APP/icons/$APP#g" ./"$APP".desktop
rm -R -f ./squashfs-root
fi
mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null
73 changes: 0 additions & 73 deletions programs/x86_64/ryujinx-appimage

This file was deleted.

0 comments on commit b9cd009

Please sign in to comment.