diff --git a/programs/x86_64/fontlet b/programs/x86_64/fontlet index 0405f654e..3b568c5b7 100644 --- a/programs/x86_64/fontlet +++ b/programs/x86_64/fontlet @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=fontlet -REPO="fontlet/fontlet-explorer" +SITE="fontlet/fontlet-explorer" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/fontlet/fontlet-explorer/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=fontlet -REPO="fontlet/fontlet-explorer" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="fontlet/fontlet-explorer" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/fontlet/fontlet-explorer/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/foobar2000 b/programs/x86_64/foobar2000 index 8bb43c55a..0bfa1f200 100644 --- a/programs/x86_64/foobar2000 +++ b/programs/x86_64/foobar2000 @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=foobar2000 -REPO="mmtrt/foobar2000_AppImage" +SITE="mmtrt/foobar2000_AppImage" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/mmtrt/foobar2000_AppImage/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=foobar2000 -REPO="mmtrt/foobar2000_AppImage" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="mmtrt/foobar2000_AppImage" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/mmtrt/foobar2000_AppImage/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/four b/programs/x86_64/four index 78b7b3f4d..a022257cf 100644 --- a/programs/x86_64/four +++ b/programs/x86_64/four @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=four -REPO="FYDesktop/FOUR" +SITE="FYDesktop/FOUR" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/FYDesktop/FOUR/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=four -REPO="FYDesktop/FOUR" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="FYDesktop/FOUR" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/FYDesktop/FOUR/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/foxfolio b/programs/x86_64/foxfolio index db43e7518..abe49ce53 100644 --- a/programs/x86_64/foxfolio +++ b/programs/x86_64/foxfolio @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=foxfolio -REPO="foxfolio/foxfolio-desktop" +SITE="foxfolio/foxfolio-desktop" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/foxfolio/foxfolio-desktop/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=foxfolio -REPO="foxfolio/foxfolio-desktop" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="foxfolio/foxfolio-desktop" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/foxfolio/foxfolio-desktop/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/fpm b/programs/x86_64/fpm index c986002ea..4fdc06caf 100644 --- a/programs/x86_64/fpm +++ b/programs/x86_64/fpm @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=fpm -REPO="jlambert360/FPM-AppImage" +SITE="jlambert360/FPM-AppImage" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/jlambert360/FPM-AppImage/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=fpm -REPO="jlambert360/FPM-AppImage" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="jlambert360/FPM-AppImage" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/jlambert360/FPM-AppImage/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/fractale b/programs/x86_64/fractale index 95ef6796c..ff6485c7e 100644 --- a/programs/x86_64/fractale +++ b/programs/x86_64/fractale @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=fractale -REPO="PJK136/Fractale" +SITE="PJK136/Fractale" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/PJK136/Fractale/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=fractale -REPO="PJK136/Fractale" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="PJK136/Fractale" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/PJK136/Fractale/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/fraidycat b/programs/x86_64/fraidycat index b70097174..1cca705b1 100644 --- a/programs/x86_64/fraidycat +++ b/programs/x86_64/fraidycat @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=fraidycat -REPO="kickscondor/fraidycat" +SITE="kickscondor/fraidycat" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/kickscondor/fraidycat/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=fraidycat -REPO="kickscondor/fraidycat" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="kickscondor/fraidycat" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/kickscondor/fraidycat/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/fraktal b/programs/x86_64/fraktal index 5796e135f..fdd766252 100644 --- a/programs/x86_64/fraktal +++ b/programs/x86_64/fraktal @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=fraktal -REPO="Fraktal-JS/fraktal" +SITE="Fraktal-JS/fraktal" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/Fraktal-JS/fraktal/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=fraktal -REPO="Fraktal-JS/fraktal" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="Fraktal-JS/fraktal" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/Fraktal-JS/fraktal/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/frame-eth-dev-appimage b/programs/x86_64/frame-eth-dev-appimage index 9707a2ae5..8d619f881 100644 --- a/programs/x86_64/frame-eth-dev-appimage +++ b/programs/x86_64/frame-eth-dev-appimage @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=frame-eth-dev-appimage -REPO="floating/frame" +SITE="floating/frame" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/floating/frame/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=frame-eth-dev-appimage -REPO="floating/frame" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="floating/frame" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/floating/frame/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/francetv b/programs/x86_64/francetv index 04e60ad74..bd890dcc9 100644 --- a/programs/x86_64/francetv +++ b/programs/x86_64/francetv @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=francetv -REPO="Paullux/FranceTV" +SITE="Paullux/FranceTV" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/Paullux/FranceTV/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=francetv -REPO="Paullux/FranceTV" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="Paullux/FranceTV" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/Paullux/FranceTV/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/franz b/programs/x86_64/franz index 5fba5ae46..c51d4e9a7 100644 --- a/programs/x86_64/franz +++ b/programs/x86_64/franz @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=franz -REPO="meetfranz/franz" +SITE="meetfranz/franz" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/meetfranz/franz/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=franz -REPO="meetfranz/franz" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="meetfranz/franz" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/meetfranz/franz/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/frappebooks b/programs/x86_64/frappebooks index 15281da0b..06b40f8ee 100644 --- a/programs/x86_64/frappebooks +++ b/programs/x86_64/frappebooks @@ -1,112 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=frappebooks -REPO="frappe/books" +SITE="frappe/books" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases/latest | grep -w -v i386 | grep -w -v i686 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/frappe/books/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=frappebooks -REPO="frappe/books" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases/latest | grep -w -v i386 | grep -w -v i686 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="frappe/books" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/frappe/books/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop 2>/dev/null -mv squashfs-root/share/applications/*.desktop ./$APP.desktop 2>/dev/null -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop 2>/dev/null -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop 2>/dev/null -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop 2>/dev/null -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/freac b/programs/x86_64/freac index 6f73d9996..c51171f86 100644 --- a/programs/x86_64/freac +++ b/programs/x86_64/freac @@ -1,112 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=freac -REPO="enzo1982/freac" +SITE="enzo1982/freac" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases/latest | grep -w -v i386 | grep -w -v i686 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/enzo1982/freac/releases/latest | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | grep -i "x86_64" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=freac -REPO="enzo1982/freac" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases/latest | grep -w -v i386 | grep -w -v i686 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="enzo1982/freac" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/enzo1982/freac/releases/latest | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | grep -i "x86_64" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop 2>/dev/null -mv squashfs-root/share/applications/*.desktop ./$APP.desktop 2>/dev/null -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop 2>/dev/null -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop 2>/dev/null -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop 2>/dev/null -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/freecad b/programs/x86_64/freecad index 5f4cc6566..95382cf7c 100644 --- a/programs/x86_64/freecad +++ b/programs/x86_64/freecad @@ -1,92 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=freecad SITE="FreeCAD/FreeCAD-Bundle" -# CREATE DIRECTORIES -if [ -z "$APP" ]; then exit 1; fi -mkdir -p "/opt/$APP/tmp" "/opt/$APP/icons" && cd "/opt/$APP/tmp" || exit 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 -# ADD THE REMOVER -echo "#!/bin/sh -rm -f /usr/share/applications/AM-$APP.desktop /usr/local/bin/$APP -rm -R -f /opt/$APP" >> "/opt/$APP/remove" -chmod a+x "/opt/$APP/remove" - -# DOWNLOAD AND PREPARE THE APP -# $version is also used for updates - -version=$(curl -Ls https://api.github.com/repos/FreeCAD/FreeCAD-Bundle/releases | grep browser_download_url | grep -v "txt\|aarch\|zsync" | grep -i appimage | cut -d '"' -f 4 | head -1) -wget "$version" -wget "$version.zsync" 2> /dev/null -echo "$version" >> /opt/$APP/version -# Use tar fx ./*tar* for example in this line in case a compressed file is downloaded. +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/FreeCAD/FreeCAD-Bundle/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. mv ./tmp/*mage ./"$APP" -mv ./tmp/*.zsync ./"$APP".zsync 2> /dev/null -chmod a+x "/opt/$APP/$APP" -rm -R -f ./tmp +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK +# LINK TO PATH ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> "/opt/$APP/AM-updater" << 'EOF' +cat >> ./AM-updater << 'EOF' #!/bin/sh +set -u APP=freecad SITE="FreeCAD/FreeCAD-Bundle" -if [ -z "$APP" ]; then exit 1; fi version0=$(cat "/opt/$APP/version") -version=$(curl -Ls https://api.github.com/repos/FreeCAD/FreeCAD-Bundle/releases | grep browser_download_url | grep -v "txt\|aarch\|zsync" | grep -i appimage | cut -d '"' -f 4 | head -1) -if test -f "/opt/$APP/*.zsync"; then - mkdir "/opt/$APP/tmp" - cd "/opt/$APP/tmp" || exit 1 - wget "$version.zsync" 2> /dev/null +version=$(curl -Ls https://api.github.com/repos/FreeCAD/FreeCAD-Bundle/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - mv ./tmp/*.zsync ./"$APP".zsync - rm -R -f ./tmp - zsync "/opt/$APP/$APP.zsync" - rm -R -f "/opt/$APP/*zs-old" "/opt/$APP/*.part" - chmod a+x /opt/$APP/$APP - if [ "$version" != "$version0" ]; then - rm -f /opt/$APP/version - echo "$version" >> /opt/$APP/version - fi + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" else - if [ "$version" = "$version0" ]; then - echo "Update not needed!" && exit 0 - else - notify-send "A new version of $APP is available, please wait" - mkdir "/opt/$APP/tmp" - cd "/opt/$APP/tmp" || exit 1 - wget $version - if ls . | grep mage; then - - cd .. - - if test -f ./tmp/*mage; then rm ./version - fi - echo "$version" >> ./version - mv --backup=t ./tmp/* ./"$APP" - chmod a+x "/opt/$APP/$APP" - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" - fi + echo "Update not needed!" fi EOF -chmod a+x "/opt/$APP/AM-updater" +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -cd "/opt/$APP" || exit 1 -./"$APP" --appimage-extract .DirIcon 1>/dev/null && mv ./squashfs-root/.DirIcon ./DirIcon ./"$APP" --appimage-extract *.desktop 1>/dev/null && mv ./squashfs-root/*.desktop ./"$APP".desktop -./"$APP" --appimage-extract share/applications/*.desktop 1>/dev/null && mv ./squashfs-root/share/applications/*.desktop ./"$APP".desktop -./"$APP" --appimage-extract usr/share/applications/*.desktop 1>/dev/null && mv ./squashfs-root/usr/share/applications/*.desktop ./"$APP".desktop -if [ -L ./DirIcon ]; then - LINKPATH=$(readlink ./DirIcon) - ./"$APP" --appimage-extract "$LINKPATH" && mv ./squashfs-root/"$LINKPATH" ./DirIcon -fi +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 -mv ./"$APP".desktop /usr/share/applications/AM-"$APP".desktop && mv ./DirIcon ./icons/"$APP" 2>/dev/null +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null rm -R -f ./squashfs-root diff --git a/programs/x86_64/freecad-assembly3 b/programs/x86_64/freecad-assembly3 index 1320b48aa..f0eb4a3e0 100644 --- a/programs/x86_64/freecad-assembly3 +++ b/programs/x86_64/freecad-assembly3 @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=freecad-assembly3 -REPO="realthunder/FreeCAD" +SITE="realthunder/FreeCAD" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/realthunder/FreeCAD/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=freecad-assembly3 -REPO="realthunder/FreeCAD" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="realthunder/FreeCAD" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/realthunder/FreeCAD/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/freeman b/programs/x86_64/freeman index fc93a3316..7f2ecfb02 100644 --- a/programs/x86_64/freeman +++ b/programs/x86_64/freeman @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=freeman -REPO="matthew-matvei/freeman" +SITE="matthew-matvei/freeman" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/matthew-matvei/freeman/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=freeman -REPO="matthew-matvei/freeman" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="matthew-matvei/freeman" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/matthew-matvei/freeman/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/freetexturepacker b/programs/x86_64/freetexturepacker index 58b93ac01..8ee4b0f24 100644 --- a/programs/x86_64/freetexturepacker +++ b/programs/x86_64/freetexturepacker @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=freetexturepacker -REPO="odrick/free-tex-packer" +SITE="odrick/free-tex-packer" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/odrick/free-tex-packer/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=freetexturepacker -REPO="odrick/free-tex-packer" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="odrick/free-tex-packer" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/odrick/free-tex-packer/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/freetube b/programs/x86_64/freetube index 4b838422e..ff89ba715 100644 --- a/programs/x86_64/freetube +++ b/programs/x86_64/freetube @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=freetube -REPO="FreeTubeApp/FreeTube" +SITE="FreeTubeApp/FreeTube" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep amd64 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/FreeTubeApp/FreeTube/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=freetube -REPO="FreeTubeApp/FreeTube" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep amd64 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="FreeTubeApp/FreeTube" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/FreeTubeApp/FreeTube/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/freezer-appimage b/programs/x86_64/freezer-appimage index 143ee63ed..be760398a 100644 --- a/programs/x86_64/freezer-appimage +++ b/programs/x86_64/freezer-appimage @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=freezer-appimage -REPO="eNV25/freezer-releases" +SITE="eNV25/freezer-releases" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/eNV25/freezer-releases/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=freezer-appimage -REPO="eNV25/freezer-releases" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="eNV25/freezer-releases" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/eNV25/freezer-releases/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/friction b/programs/x86_64/friction index cd90682bc..621db8588 100644 --- a/programs/x86_64/friction +++ b/programs/x86_64/friction @@ -1,90 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=friction SITE="friction2d/friction" -# CREATE DIRECTORIES -if [ -z "$APP" ]; then exit 1; fi -mkdir -p "/opt/$APP/tmp" "/opt/$APP/icons" && cd "/opt/$APP/tmp" || exit 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 -# ADD THE REMOVER -echo "#!/bin/sh -rm -f /usr/share/applications/AM-$APP.desktop /usr/local/bin/$APP -rm -R -f /opt/$APP" > "/opt/$APP/remove" -chmod a+x "/opt/$APP/remove" - -# DOWNLOAD AND PREPARE THE APP -# $version is also used for updates - -version=$(curl -Ls https://api.github.com/repos/friction2d/friction/releases | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget "$version" -wget "$version.zsync" 2> /dev/null -echo "$version" >> /opt/$APP/version -# Use tar fx ./*tar* for example in this line in case a compressed file is downloaded. +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/friction2d/friction/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. mv ./tmp/*mage ./"$APP" -mv ./tmp/*.zsync ./"$APP".zsync 2> /dev/null -chmod a+x "/opt/$APP/$APP" -rm -R -f ./tmp +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK +# LINK TO PATH ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> "/opt/$APP/AM-updater" << 'EOF' +cat >> ./AM-updater << 'EOF' #!/bin/sh +set -u APP=friction SITE="friction2d/friction" -if [ -z "$APP" ]; then exit 1; fi version0=$(cat "/opt/$APP/version") -version=$(curl -Ls https://api.github.com/repos/friction2d/friction/releases | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if test -f "/opt/$APP/*.zsync"; then - mkdir "/opt/$APP/tmp" - cd "/opt/$APP/tmp" || exit 1 - wget "$version.zsync" 2> /dev/null +version=$(curl -Ls https://api.github.com/repos/friction2d/friction/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - mv ./tmp/*.zsync ./"$APP".zsync - rm -R -f ./tmp - zsync "/opt/$APP/$APP.zsync" - rm -R -f "/opt/$APP/*zs-old" "/opt/$APP/*.part" - chmod a+x "/opt/$APP/$APP" - if [ "$version" != "$version0" ]; then - echo "$version" > /opt/$APP/version - fi + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" else - if [ "$version" = "$version0" ]; then - echo "Update not needed!" && exit 0 - else - notify-send "A new version of $APP is available, please wait" - mkdir "/opt/$APP/tmp" - cd "/opt/$APP/tmp" || exit 1 - wget $version - if ls . | grep mage; then - - cd .. - - if ! test -f ./tmp/*mage; then exit 1; fi - echo "$version" > ./version - mv --backup=t ./tmp/* ./"$APP" - chmod a+x "/opt/$APP/$APP" - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" - fi + echo "Update not needed!" fi EOF -chmod a+x "/opt/$APP/AM-updater" +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -cd "/opt/$APP" || exit 1 -./"$APP" --appimage-extract .DirIcon 1>/dev/null && mv ./squashfs-root/.DirIcon ./DirIcon ./"$APP" --appimage-extract *.desktop 1>/dev/null && mv ./squashfs-root/*.desktop ./"$APP".desktop -./"$APP" --appimage-extract share/applications/*.desktop 1>/dev/null && mv ./squashfs-root/share/applications/*.desktop ./"$APP".desktop -./"$APP" --appimage-extract usr/share/applications/*.desktop 1>/dev/null && mv ./squashfs-root/usr/share/applications/*.desktop ./"$APP".desktop -if [ -L ./DirIcon ]; then - LINKPATH=$(readlink ./DirIcon) - ./"$APP" --appimage-extract "$LINKPATH" && mv ./squashfs-root/"$LINKPATH" ./DirIcon -fi +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 -mv ./"$APP".desktop /usr/share/applications/AM-"$APP".desktop && mv ./DirIcon ./icons/"$APP" 2>/dev/null +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null rm -R -f ./squashfs-root diff --git a/programs/x86_64/friture b/programs/x86_64/friture index 6ee1965ec..d5059340d 100644 --- a/programs/x86_64/friture +++ b/programs/x86_64/friture @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=friture -REPO="tlecomte/friture" +SITE="tlecomte/friture" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/tlecomte/friture/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=friture -REPO="tlecomte/friture" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="tlecomte/friture" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/tlecomte/friture/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/fromscratch b/programs/x86_64/fromscratch index 141cbb299..851a11ebe 100644 --- a/programs/x86_64/fromscratch +++ b/programs/x86_64/fromscratch @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=fromscratch -REPO="Kilian/fromscratch" +SITE="Kilian/fromscratch" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/Kilian/fromscratch/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=fromscratch -REPO="Kilian/fromscratch" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="Kilian/fromscratch" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/Kilian/fromscratch/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/fspy b/programs/x86_64/fspy index 805483851..21fa2257e 100644 --- a/programs/x86_64/fspy +++ b/programs/x86_64/fspy @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=fspy -REPO="stuffmatic/fSpy" +SITE="stuffmatic/fSpy" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/stuffmatic/fSpy/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=fspy -REPO="stuffmatic/fSpy" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="stuffmatic/fSpy" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/stuffmatic/fSpy/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/fukayo b/programs/x86_64/fukayo index 96d6dada8..fdc78551a 100644 --- a/programs/x86_64/fukayo +++ b/programs/x86_64/fukayo @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=fukayo -REPO="JiPaix/Fukayo" +SITE="JiPaix/Fukayo" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/JiPaix/Fukayo/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=fukayo -REPO="JiPaix/Fukayo" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="JiPaix/Fukayo" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/JiPaix/Fukayo/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/gamehub b/programs/x86_64/gamehub index 65f8e483a..f5e292841 100644 --- a/programs/x86_64/gamehub +++ b/programs/x86_64/gamehub @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=gamehub -REPO="tkashkin/GameHub" +SITE="tkashkin/GameHub" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/tkashkin/GameHub/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=gamehub -REPO="tkashkin/GameHub" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="tkashkin/GameHub" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/tkashkin/GameHub/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/gams-studio b/programs/x86_64/gams-studio index 2c3770300..e4e11d7b6 100644 --- a/programs/x86_64/gams-studio +++ b/programs/x86_64/gams-studio @@ -1,114 +1,74 @@ #!/bin/sh -APP=gasm-studio -REPO="GAMS-dev/studio" +# AM INSTALL SCRIPT VERSION 3.5 +set -u +APP=gams-studio +SITE="GAMS-dev/studio" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/GAMS-dev/studio/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash -APP=gasm-studio -REPO="GAMS-dev/studio" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u +APP=gams-studio +SITE="GAMS-dev/studio" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/GAMS-dev/studio/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/ganache b/programs/x86_64/ganache index 08ee4abbd..2d589712a 100644 --- a/programs/x86_64/ganache +++ b/programs/x86_64/ganache @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=ganache -REPO="trufflesuite/ganache-ui" +SITE="trufflesuite/ganache-ui" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/trufflesuite/ganache-ui/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=ganache -REPO="trufflesuite/ganache-ui" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="trufflesuite/ganache-ui" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/trufflesuite/ganache-ui/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/gaphor b/programs/x86_64/gaphor index 6e4e647e7..a236a15c7 100644 --- a/programs/x86_64/gaphor +++ b/programs/x86_64/gaphor @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=gaphor -REPO="gaphor/gaphor" +SITE="gaphor/gaphor" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i x86_64 | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/gaphor/gaphor/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=gaphor -REPO="gaphor/gaphor" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i x86_64 | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="gaphor/gaphor" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/gaphor/gaphor/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/gargoyle-bin b/programs/x86_64/gargoyle-bin index f3816442d..45a409f30 100644 --- a/programs/x86_64/gargoyle-bin +++ b/programs/x86_64/gargoyle-bin @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=gargoyle-bin -REPO="garglk/garglk" +SITE="garglk/garglk" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/garglk/garglk/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=gargoyle-bin -REPO="garglk/garglk" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="garglk/garglk" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/garglk/garglk/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/gaucho b/programs/x86_64/gaucho index 1f2d6866e..a761ad07b 100644 --- a/programs/x86_64/gaucho +++ b/programs/x86_64/gaucho @@ -1,90 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=gaucho SITE="angrykoala/gaucho" -# CREATE DIRECTORIES -if [ -z "$APP" ]; then exit 1; fi -mkdir -p "/opt/$APP/tmp" "/opt/$APP/icons" && cd "/opt/$APP/tmp" || exit 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 -# ADD THE REMOVER -echo "#!/bin/sh -rm -f /usr/share/applications/AM-$APP.desktop /usr/local/bin/$APP -rm -R -f /opt/$APP" > "/opt/$APP/remove" -chmod a+x "/opt/$APP/remove" - -# DOWNLOAD AND PREPARE THE APP -# $version is also used for updates - -version=$(curl -Ls https://api.github.com/repos/angrykoala/gaucho/releases | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget "$version" -wget "$version.zsync" 2> /dev/null -echo "$version" >> /opt/$APP/version -# Use tar fx ./*tar* for example in this line in case a compressed file is downloaded. +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/angrykoala/gaucho/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. mv ./tmp/*mage ./"$APP" -mv ./tmp/*.zsync ./"$APP".zsync 2> /dev/null -chmod a+x "/opt/$APP/$APP" -rm -R -f ./tmp +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK +# LINK TO PATH ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> "/opt/$APP/AM-updater" << 'EOF' +cat >> ./AM-updater << 'EOF' #!/bin/sh +set -u APP=gaucho SITE="angrykoala/gaucho" -if [ -z "$APP" ]; then exit 1; fi version0=$(cat "/opt/$APP/version") -version=$(curl -Ls https://api.github.com/repos/angrykoala/gaucho/releases | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if test -f "/opt/$APP/*.zsync"; then - mkdir "/opt/$APP/tmp" - cd "/opt/$APP/tmp" || exit 1 - wget "$version.zsync" 2> /dev/null +version=$(curl -Ls https://api.github.com/repos/angrykoala/gaucho/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - mv ./tmp/*.zsync ./"$APP".zsync - rm -R -f ./tmp - zsync "/opt/$APP/$APP.zsync" - rm -R -f "/opt/$APP/*zs-old" "/opt/$APP/*.part" - chmod a+x "/opt/$APP/$APP" - if [ "$version" != "$version0" ]; then - echo "$version" > /opt/$APP/version - fi + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" else - if [ "$version" = "$version0" ]; then - echo "Update not needed!" && exit 0 - else - notify-send "A new version of $APP is available, please wait" - mkdir "/opt/$APP/tmp" - cd "/opt/$APP/tmp" || exit 1 - wget $version - if ls . | grep mage; then - - cd .. - - if ! test -f ./tmp/*mage; then exit 1; fi - echo "$version" > ./version - mv --backup=t ./tmp/* ./"$APP" - chmod a+x "/opt/$APP/$APP" - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" - fi + echo "Update not needed!" fi EOF -chmod a+x "/opt/$APP/AM-updater" +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -cd "/opt/$APP" || exit 1 -./"$APP" --appimage-extract .DirIcon 1>/dev/null && mv ./squashfs-root/.DirIcon ./DirIcon ./"$APP" --appimage-extract *.desktop 1>/dev/null && mv ./squashfs-root/*.desktop ./"$APP".desktop -./"$APP" --appimage-extract share/applications/*.desktop 1>/dev/null && mv ./squashfs-root/share/applications/*.desktop ./"$APP".desktop -./"$APP" --appimage-extract usr/share/applications/*.desktop 1>/dev/null && mv ./squashfs-root/usr/share/applications/*.desktop ./"$APP".desktop -if [ -L ./DirIcon ]; then - LINKPATH=$(readlink ./DirIcon) - ./"$APP" --appimage-extract "$LINKPATH" && mv ./squashfs-root/"$LINKPATH" ./DirIcon -fi +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 -mv ./"$APP".desktop /usr/share/applications/AM-"$APP".desktop && mv ./DirIcon ./icons/"$APP" 2>/dev/null +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null rm -R -f ./squashfs-root diff --git a/programs/x86_64/gdesktopsuite b/programs/x86_64/gdesktopsuite index 18be69978..ef3cb87c3 100644 --- a/programs/x86_64/gdesktopsuite +++ b/programs/x86_64/gdesktopsuite @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=gdesktopsuite -REPO="alexkim205/G-Desktop-Suite" +SITE="alexkim205/G-Desktop-Suite" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/alexkim205/G-Desktop-Suite/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=gdesktopsuite -REPO="alexkim205/G-Desktop-Suite" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="alexkim205/G-Desktop-Suite" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/alexkim205/G-Desktop-Suite/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/gdevelop b/programs/x86_64/gdevelop index 36258d87e..f13c71d3b 100644 --- a/programs/x86_64/gdevelop +++ b/programs/x86_64/gdevelop @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=gdevelop -REPO="4ian/GDevelop" +SITE="4ian/GDevelop" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/4ian/GDevelop/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=gdevelop -REPO="4ian/GDevelop" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="4ian/GDevelop" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/4ian/GDevelop/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/gdlauncher-appimage b/programs/x86_64/gdlauncher-appimage index 1eb1f9ae4..9dcb62553 100644 --- a/programs/x86_64/gdlauncher-appimage +++ b/programs/x86_64/gdlauncher-appimage @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=gdlauncher-appimage -REPO="gorilla-devs/GDLauncher" +SITE="gorilla-devs/GDLauncher" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/gorilla-devs/GDLauncher/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=gdlauncher-appimage -REPO="gorilla-devs/GDLauncher" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="gorilla-devs/GDLauncher" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/gorilla-devs/GDLauncher/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/gdm-settings b/programs/x86_64/gdm-settings index 1942f8de5..a05aba901 100644 --- a/programs/x86_64/gdm-settings +++ b/programs/x86_64/gdm-settings @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=gdm-settings -REPO="gdm-settings/gdm-settings" +SITE="gdm-settings/gdm-settings" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -w -v zsync | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/gdm-settings/gdm-settings/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=gdm-settings -REPO="gdm-settings/gdm-settings" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -w -v zsync | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="gdm-settings/gdm-settings" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/gdm-settings/gdm-settings/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/gedit b/programs/x86_64/gedit index 101f7fb75..5c6e47100 100644 --- a/programs/x86_64/gedit +++ b/programs/x86_64/gedit @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=gedit -REPO="ivan-hc/Gedit-appimage" +SITE="ivan-hc/Gedit-appimage" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/ivan-hc/Gedit-appimage/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=gedit -REPO="ivan-hc/Gedit-appimage" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="ivan-hc/Gedit-appimage" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/ivan-hc/Gedit-appimage/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/geforcenow-electron b/programs/x86_64/geforcenow-electron index c47aecee8..1963d295b 100644 --- a/programs/x86_64/geforcenow-electron +++ b/programs/x86_64/geforcenow-electron @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=geforcenow-electron -REPO="hmlendea/gfn-electron" +SITE="hmlendea/gfn-electron" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/hmlendea/gfn-electron/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=geforcenow-electron -REPO="hmlendea/gfn-electron" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="hmlendea/gfn-electron" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/hmlendea/gfn-electron/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/genesis b/programs/x86_64/genesis index 00ba25596..a4932eeb6 100644 --- a/programs/x86_64/genesis +++ b/programs/x86_64/genesis @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=genesis -REPO="GenesisKernel/genesis-front" +SITE="GenesisKernel/genesis-front" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/GenesisKernel/genesis-front/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=genesis -REPO="GenesisKernel/genesis-front" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="GenesisKernel/genesis-front" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/GenesisKernel/genesis-front/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/geofs b/programs/x86_64/geofs index c8046748b..8e4838185 100644 --- a/programs/x86_64/geofs +++ b/programs/x86_64/geofs @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=geofs -REPO="Jminding/GeoFS-Desktop" +SITE="Jminding/GeoFS-Desktop" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/Jminding/GeoFS-Desktop/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=geofs -REPO="Jminding/GeoFS-Desktop" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="Jminding/GeoFS-Desktop" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/Jminding/GeoFS-Desktop/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/geometrize b/programs/x86_64/geometrize index 3e5ef01e2..a68aef7ff 100644 --- a/programs/x86_64/geometrize +++ b/programs/x86_64/geometrize @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=geometrize -REPO="Tw1ddle/geometrize" +SITE="Tw1ddle/geometrize" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/Tw1ddle/geometrize/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=geometrize -REPO="Tw1ddle/geometrize" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="Tw1ddle/geometrize" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/Tw1ddle/geometrize/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/gerbv b/programs/x86_64/gerbv index 38479058b..05aa2818e 100644 --- a/programs/x86_64/gerbv +++ b/programs/x86_64/gerbv @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=gerbv -REPO="m59peacemaker/gerbv-appimage" +SITE="m59peacemaker/gerbv-appimage" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/m59peacemaker/gerbv-appimage/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=gerbv -REPO="m59peacemaker/gerbv-appimage" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="m59peacemaker/gerbv-appimage" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/m59peacemaker/gerbv-appimage/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/getthermal b/programs/x86_64/getthermal index 8cfa397d5..52d20b847 100644 --- a/programs/x86_64/getthermal +++ b/programs/x86_64/getthermal @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=getthermal -REPO="groupgets/GetThermal" +SITE="groupgets/GetThermal" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/groupgets/GetThermal/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=getthermal -REPO="groupgets/GetThermal" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="groupgets/GetThermal" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/groupgets/GetThermal/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/gextractwinicons b/programs/x86_64/gextractwinicons index ff8d942c3..aace71ff5 100644 --- a/programs/x86_64/gextractwinicons +++ b/programs/x86_64/gextractwinicons @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=gextractwinicons -REPO="muflone/gextractwinicons" +SITE="muflone/gextractwinicons" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/muflone/gextractwinicons/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=gextractwinicons -REPO="muflone/gextractwinicons" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="muflone/gextractwinicons" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/muflone/gextractwinicons/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/giada b/programs/x86_64/giada index 42b974c01..cd8f91aa4 100644 --- a/programs/x86_64/giada +++ b/programs/x86_64/giada @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=giada -REPO="monocasual/giada" +SITE="monocasual/giada" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/monocasual/giada/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=giada -REPO="monocasual/giada" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="monocasual/giada" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/monocasual/giada/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/gibs b/programs/x86_64/gibs index 4dffc7841..ce6ee0af2 100644 --- a/programs/x86_64/gibs +++ b/programs/x86_64/gibs @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=gibs -REPO="sierdzio/gibs" +SITE="sierdzio/gibs" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/sierdzio/gibs/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=gibs -REPO="sierdzio/gibs" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="sierdzio/gibs" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/sierdzio/gibs/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/gifcurry b/programs/x86_64/gifcurry index 2dc7011db..d83ff76af 100644 --- a/programs/x86_64/gifcurry +++ b/programs/x86_64/gifcurry @@ -1,99 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=gifcurry -REPO="lettier/gifcurry" +SITE="lettier/gifcurry" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/lettier/gifcurry/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=gifcurry -REPO="lettier/gifcurry" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="lettier/gifcurry" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/lettier/gifcurry/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -echo "[Desktop Entry] -Type=Application -Name=Gifcurry -Comment=The open-source, Haskell-built video editor for GIF makers. -Icon=/opt/$APP/icons/$APP -Categories=AudioVideo;Video;Graphics;Utility; -Terminal=false -Exec=$APP" >> ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/gimp b/programs/x86_64/gimp index ea8594543..a54dd71be 100644 --- a/programs/x86_64/gimp +++ b/programs/x86_64/gimp @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=gimp -REPO="ivan-hc/GIMP-appimage" +SITE="ivan-hc/GIMP-appimage" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i continuous-stable | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/ivan-hc/GIMP-appimage/releases/latest | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=gimp -REPO="ivan-hc/GIMP-appimage" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i continuous-stable | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="ivan-hc/GIMP-appimage" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/ivan-hc/GIMP-appimage/releases/latest | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/gimp-dev b/programs/x86_64/gimp-dev index 7d599f011..3af83d8db 100644 --- a/programs/x86_64/gimp-dev +++ b/programs/x86_64/gimp-dev @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=gimp-dev -REPO="ivan-hc/GIMP-appimage" +SITE="ivan-hc/GIMP-appimage" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i continuous-dev | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/ivan-hc/GIMP-appimage/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | grep -i "dev" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=gimp-dev -REPO="ivan-hc/GIMP-appimage" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i continuous-dev | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="ivan-hc/GIMP-appimage" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/ivan-hc/GIMP-appimage/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | grep -i "dev" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/gimp-git b/programs/x86_64/gimp-git index 8cc3a67f3..48b03a231 100644 --- a/programs/x86_64/gimp-git +++ b/programs/x86_64/gimp-git @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=gimp-git -REPO="ivan-hc/GIMP-appimage" +SITE="ivan-hc/GIMP-appimage" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i continuous-git | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/ivan-hc/GIMP-appimage/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*gimp.*git.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=gimp-git -REPO="ivan-hc/GIMP-appimage" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i continuous-git | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="ivan-hc/GIMP-appimage" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/ivan-hc/GIMP-appimage/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*gimp.*git.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/gimp-hybrid b/programs/x86_64/gimp-hybrid index 1ca6acc92..77aa98069 100644 --- a/programs/x86_64/gimp-hybrid +++ b/programs/x86_64/gimp-hybrid @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=gimp-hybrid -REPO="ivan-hc/GIMP-appimage" +SITE="ivan-hc/GIMP-appimage" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i continuous-hybrid | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/ivan-hc/GIMP-appimage/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | grep -i "hybrid" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=gimp-hybrid -REPO="ivan-hc/GIMP-appimage" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i continuous-hybrid | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="ivan-hc/GIMP-appimage" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/ivan-hc/GIMP-appimage/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | grep -i "hybrid" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/gingko b/programs/x86_64/gingko index 5aa3678a9..e8b7d007a 100644 --- a/programs/x86_64/gingko +++ b/programs/x86_64/gingko @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=gingko -REPO="gingko/client" +SITE="gingko/client" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/gingko/client/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=gingko -REPO="gingko/client" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="gingko/client" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/gingko/client/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/git-good b/programs/x86_64/git-good index adb705af2..2c4af83dd 100644 --- a/programs/x86_64/git-good +++ b/programs/x86_64/git-good @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=git-good -REPO="weedz/git-good" +SITE="weedz/git-good" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/weedz/git-good/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=git-good -REPO="weedz/git-good" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="weedz/git-good" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/weedz/git-good/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/githoard b/programs/x86_64/githoard index 5799f7b2c..32b4783a7 100644 --- a/programs/x86_64/githoard +++ b/programs/x86_64/githoard @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=githoard -REPO="jojobyte/githoard" +SITE="jojobyte/githoard" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/jojobyte/githoard/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=githoard -REPO="jojobyte/githoard" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="jojobyte/githoard" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/jojobyte/githoard/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/github-desktop b/programs/x86_64/github-desktop index 8a8ecc1a2..5174a7cbb 100644 --- a/programs/x86_64/github-desktop +++ b/programs/x86_64/github-desktop @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=github-desktop -REPO="shiftkey/desktop" +SITE="shiftkey/desktop" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/shiftkey/desktop/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=github-desktop -REPO="shiftkey/desktop" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="shiftkey/desktop" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/shiftkey/desktop/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/gitify b/programs/x86_64/gitify index f854c47b0..c3d39e8dd 100644 --- a/programs/x86_64/gitify +++ b/programs/x86_64/gitify @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=gitify -REPO="gitify-app/gitify" +SITE="gitify-app/gitify" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/gitify-app/gitify/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=gitify -REPO="gitify-app/gitify" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="gitify-app/gitify" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/gitify-app/gitify/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root diff --git a/programs/x86_64/gitjournal b/programs/x86_64/gitjournal index 0e8744b3b..62af50ba5 100644 --- a/programs/x86_64/gitjournal +++ b/programs/x86_64/gitjournal @@ -1,114 +1,74 @@ #!/bin/sh +# AM INSTALL SCRIPT VERSION 3.5 +set -u APP=gitjournal -REPO="GitJournal/GitJournal" +SITE="GitJournal/GitJournal" -# CREATE THE FOLDER -mkdir /opt/$APP -cd /opt/$APP +# 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 -# ADD THE REMOVER -echo '#!/bin/sh' >> /opt/$APP/remove -echo "rm -R -f /usr/share/applications/AM-$APP.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove -chmod a+x /opt/$APP/remove - -# DOWNLOAD THE ARCHIVE -mkdir tmp -cd ./tmp - -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -wget $version -echo "$version" >> /opt/$APP/version +# DOWNLOAD AND PREPARE THE APP, $version is also used for updates +version=$(curl -Ls https://api.github.com/repos/GitJournal/GitJournal/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +wget "$version" || exit 1 +#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync +# Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. -mv ./tmp/*mage ./$APP -chmod a+x /opt/$APP/$APP -rmdir ./tmp +mv ./tmp/*mage ./"$APP" +mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null +rm -R -f ./tmp || exit 1 +echo "$version" > ./version +chmod a+x ./"$APP" || exit 1 -# LINK -ln -s /opt/$APP/$APP /usr/local/bin/$APP +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" # SCRIPT TO UPDATE THE PROGRAM -cat >> /opt/$APP/AM-updater << 'EOF' -#!/usr/bin/env bash +cat >> ./AM-updater << 'EOF' +#!/bin/sh +set -u APP=gitjournal -REPO="GitJournal/GitJournal" -version0=$(cat /opt/$APP/version) -version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1) -if [ $version = $version0 ]; then - echo "Update not needed!" -else - notify-send "A new version of $APP is available, please wait" - mkdir /opt/$APP/tmp - cd /opt/$APP/tmp - wget $version - if ls . | grep mage; then +SITE="GitJournal/GitJournal" +version0=$(cat "/opt/$APP/version") +version=$(curl -Ls https://api.github.com/repos/GitJournal/GitJournal/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*mage$" | grep -vi "i386|i686|aarch64|arm64|armv7l" | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" + [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - if test -f ./tmp/*mage; then rm ./version - fi - echo $version >> ./version - mv --backup=t ./tmp/*mage ./$APP - chmod a+x /opt/$APP/$APP - rm -R -f ./tmp ./*~ - fi - notify-send "$APP is updated!" + mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" + [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + chmod a+x ./"$APP" || exit 1 + echo "$version" > ./version + rm -R -f ./*zs-old ./*.part ./tmp ./*~ + notify-send "$APP is updated!" +else + echo "Update not needed!" fi EOF -chmod a+x /opt/$APP/AM-updater +chmod a+x ./AM-updater || exit 1 # LAUNCHER & ICON -app=$(echo $APP | cut -c -3) -cd /opt/$APP -./$APP --appimage-extract *.desktop 1>/dev/null -./$APP --appimage-extract share/applications/*.desktop 1>/dev/null -./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null -mv squashfs-root/*.desktop ./$APP.desktop -mv squashfs-root/share/applications/*.desktop ./$APP.desktop -mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop - mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop -fi -if [ ! -e ./$APP.desktop ]; then - rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null - mv squashfs-root/share/applications/*.desktop ./$APP.desktop -fi -CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1) -sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop -sed -i "s#AppRun#$APP#g" ./$APP.desktop -sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop -sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop -CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1) -sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop - -mkdir icons -./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null -./$APP --appimage-extract share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null -./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null -./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null -mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null -mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null - -rm -R -f /opt/$APP/squashfs-root -mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop - - - - +./"$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 | sed 's|^\./||' 2>/dev/null)" + ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop + fi + if [ -L ./DirIcon ]; then + LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)" + ./"$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 +mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null +rm -R -f ./squashfs-root