calibre.sh 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/sh
  2. APP=calibre
  3. # DOWNLOADING THE DEPENDENCES
  4. if test -f ./appimagetool; then
  5. echo " appimagetool already exists" 1> /dev/null
  6. else
  7. echo " Downloading appimagetool..."
  8. wget -q "$(wget -q https://api.github.com/repos/probonopd/go-appimage/releases -O - | sed 's/"/ /g; s/ /\n/g' | grep -o 'https.*continuous.*tool.*86_64.*mage$')" -O appimagetool
  9. fi
  10. chmod a+x ./appimagetool
  11. #CREATE THE APPDIR
  12. mkdir -p "$APP".AppDir/
  13. # DOWNLOAD THE ARCHIVE
  14. DOWNLOAD_URL=$(curl -Ls https://api.github.com/repos/kovidgoyal/calibre/releases | sed 's/[()",{} ]/\n/g' | grep -v "i386\|i686\|aarch64\|arm64\|armv7l" | grep -i "http.*x86_64.txz$" | head -1)
  15. if wget --version | head -1 | grep -q ' 1.'; then
  16. wget -q --no-verbose --show-progress --progress=bar "$DOWNLOAD_URL"
  17. else
  18. wget "$DOWNLOAD_URL"
  19. fi
  20. # EXTRACT THE ARCHIVE
  21. tar fx ./*txz* -C ./"$APP".AppDir/
  22. # CREATE THE LAUNCHER
  23. cat >> ./"$APP".AppDir/"$APP".desktop << 'EOF'
  24. [Desktop Entry]
  25. Categories=Office;
  26. Comment[en_US]=E-book library management: Convert, view, share, catalogue all your e-books
  27. Comment=E-book library management: Convert, view, share, catalogue all your e-books
  28. Exec=AppRun
  29. GenericName[en_US]=E-book library management
  30. GenericName=E-book library management
  31. Icon=calibre
  32. MimeType=application/vnd.openxmlformats-officedocument.wordprocessingml.document;image/vnd.djvu;application/x-mobi8-ebook;application/x-cbr;text/fb2+xml;application/pdf;application/x-cbc;application/vnd.ms-word.document.macroenabled.12;text/rtf;application/epub+zip;application/x-cbz;text/plain;application/x-sony-bbeb;application/oebps-package+xml;application/x-cb7;application/x-mobipocket-ebook;application/ereader;text/html;text/x-markdown;application/xhtml+xml;application/vnd.oasis.opendocument.text;application/x-mobipocket-subscription;x-scheme-handler/calibre;
  33. Name=calibre
  34. Type=Application
  35. X-DBUS-ServiceName=
  36. X-DBUS-StartupType=
  37. X-KDE-SubstituteUID=false
  38. X-KDE-Username=
  39. EOF
  40. # ADD THE ICON AT THE ROOT OF THA APPDIR
  41. cp ./"$APP".AppDir/resources/content-server/calibre.png ./"$APP".AppDir/calibre.png
  42. # CREATE THE APPRUN
  43. cat >> ./"$APP".AppDir/AppRun << 'EOF'
  44. #!/bin/sh
  45. HERE="$(dirname "$(readlink -f "${0}")")"
  46. exec "${HERE}"/calibre "$@"
  47. EOF
  48. chmod a+x ./"$APP".AppDir/AppRun
  49. # CONVERT THE APPDIR TO AN APPIMAGE
  50. echo "\nConverting the AppDir to an AppImage...\n"
  51. ARCH=x86_64 VERSION=$(./appimagetool -v | grep -o '[[:digit:]]*') ./appimagetool -s ./"$APP".AppDir 2>&1 | grep "Architecture\|Creating\|====\|Exportable"