uv 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/sh
  2. # AM INSTALL SCRIPT VERSION 3.5
  3. set -u
  4. APP=uv
  5. SITE="astral-sh/uv"
  6. # CREATE DIRECTORIES AND ADD REMOVER
  7. [ -n "$APP" ] && mkdir -p "/opt/$APP/tmp" "/opt/$APP/icons" && cd "/opt/$APP/tmp" || exit 1
  8. printf "#!/bin/sh\nset -e\nrm -f /usr/local/bin/$APP /usr/local/bin/uvx\nrm -R -f /opt/$APP" > ../remove
  9. #printf '\n%s' "rm -f /usr/local/share/applications/$APP-AM.desktop" >> ../remove
  10. chmod a+x ../remove || exit 1
  11. # DOWNLOAD AND PREPARE THE APP, $version is also used for updates
  12. version=$(curl -Ls https://api.github.com/repos/astral-sh/uv/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*" | grep -i "i686.*linux.*musl.*tar.gz$" | head -1)
  13. wget "$version" || exit 1
  14. [ -e ./*7z ] && 7z x ./*7z && rm -f ./*7z
  15. [ -e ./*tar.* ] && tar fx ./*tar.* && rm -f ./*tar.*
  16. [ -e ./*zip ] && unzip -qq ./*zip 1>/dev/null && rm -f ./*zip
  17. cd ..
  18. if [ -d ./tmp/* 2>/dev/null ]; then mv ./tmp/*/* ./; else mv ./tmp/* ./"$APP" 2>/dev/null || mv ./tmp/* ./; fi
  19. rm -R -f ./tmp || exit 1
  20. echo "$version" > ./version
  21. chmod a+x ./$APP || exit 1
  22. # LINK TO PATH
  23. ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP"
  24. ln -s "/opt/$APP/uvx" "/usr/local/bin/uvx"
  25. # SCRIPT TO UPDATE THE PROGRAM
  26. cat >> ./AM-updater << 'EOF'
  27. #!/bin/sh
  28. set -u
  29. APP=uv
  30. SITE="astral-sh/uv"
  31. version0=$(cat "/opt/$APP/version")
  32. version=$(curl -Ls https://api.github.com/repos/astral-sh/uv/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*" | grep -i "i686.*linux.*musl.*tar.gz$" | head -1)
  33. [ -n "$version" ] || { echo "Error getting link"; exit 1; }
  34. if [ "$version" != "$version0" ]; then
  35. mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1
  36. notify-send "A new version of $APP is available, please wait"
  37. wget "$version" || exit 1
  38. [ -e ./*7z ] && 7z x ./*7z && rm -f ./*7z
  39. [ -e ./*tar.* ] && tar fx ./*tar.* && rm -f ./*tar.*
  40. [ -e ./*zip ] && unzip -qq ./*zip 1>/dev/null && rm -f ./*zip
  41. cd ..
  42. if [ -d ./tmp/* 2>/dev/null ]; then mv --backup=t ./tmp/*/* ./; else mv --backup=t ./tmp/* ./"$APP" 2>/dev/null || mv --backup=t ./tmp/* ./; fi
  43. chmod a+x ./"$APP" || exit 1
  44. echo "$version" > ./version
  45. rm -R -f ./tmp ./*~
  46. notify-send "$APP is updated!"
  47. else
  48. echo "Update not needed!"
  49. fi
  50. EOF
  51. chmod a+x ./AM-updater || exit 1