genappimage.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/bin/bash
  2. ########################################################################
  3. # Package the binaries built as an AppImage
  4. # By Simon Peter 2016
  5. # For more information, see http://appimage.org/
  6. ########################################################################
  7. # App arch, used by generate_appimage.
  8. if [ -z "$ARCH" ]; then
  9. ARCH="$(arch)"
  10. export ARCH
  11. fi
  12. TAG=$1
  13. # App name, used by generate_appimage.
  14. APP=nvim
  15. ROOT_DIR="$(git rev-parse --show-toplevel)"
  16. APP_BUILD_DIR="$ROOT_DIR/build"
  17. APP_DIR="$APP.AppDir"
  18. ########################################################################
  19. # Compile nvim and install it into AppDir
  20. ########################################################################
  21. # Build and install nvim into the AppImage
  22. make CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}"
  23. cmake --install build --prefix="$APP_BUILD_DIR/${APP_DIR}/usr"
  24. ########################################################################
  25. # Get helper functions and move to AppDir
  26. ########################################################################
  27. # App version, used by generate_appimage.
  28. VERSION=$("$ROOT_DIR"/build/bin/nvim --version | head -n 1 | grep -o 'v.*')
  29. export VERSION
  30. cd "$APP_BUILD_DIR" || exit
  31. # Only downloads linuxdeploy if the remote file is different from local
  32. if [ -e "$APP_BUILD_DIR"/linuxdeploy-x86_64.AppImage ]; then
  33. curl -Lo "$APP_BUILD_DIR"/linuxdeploy-x86_64.AppImage \
  34. -z "$APP_BUILD_DIR"/linuxdeploy-x86_64.AppImage \
  35. https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
  36. else
  37. curl -Lo "$APP_BUILD_DIR"/linuxdeploy-x86_64.AppImage \
  38. https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
  39. fi
  40. chmod +x "$APP_BUILD_DIR"/linuxdeploy-x86_64.AppImage
  41. # metainfo is not packaged automatically by linuxdeploy
  42. mkdir -p "$APP_DIR/usr/share/metainfo/"
  43. cp "$ROOT_DIR/runtime/nvim.appdata.xml" "$APP_DIR/usr/share/metainfo/"
  44. cd "$APP_DIR" || exit
  45. ########################################################################
  46. # AppDir complete. Now package it as an AppImage.
  47. ########################################################################
  48. # Appimage set the ARGV0 environment variable. This causes problems in zsh.
  49. # To prevent this, we use wrapper script to unset ARGV0 as AppRun.
  50. # See https://github.com/AppImage/AppImageKit/issues/852
  51. #
  52. cat << 'EOF' > AppRun
  53. #!/bin/bash
  54. unset ARGV0
  55. exec "$(dirname "$(readlink -f "${0}")")/usr/bin/nvim" ${@+"$@"}
  56. EOF
  57. chmod 755 AppRun
  58. cd "$APP_BUILD_DIR" || exit # Get out of AppImage directory.
  59. # Set the name of the file generated by appimage
  60. export OUTPUT=nvim.appimage
  61. # If it's a release generate the zsync file
  62. if [ -n "$TAG" ]; then
  63. export UPDATE_INFORMATION="gh-releases-zsync|neovim|neovim|$TAG|nvim.appimage.zsync"
  64. fi
  65. # Generate AppImage.
  66. # - Expects: $ARCH, $APP, $VERSION env vars
  67. # - Expects: ./$APP.AppDir/ directory
  68. # - Produces: ./nvim.appimage
  69. ./linuxdeploy-x86_64.AppImage --appdir $APP.AppDir -d "$ROOT_DIR"/runtime/nvim.desktop -i \
  70. "$ROOT_DIR/runtime/nvim.png" --output appimage
  71. # Moving the final executable to a different folder so it isn't in the
  72. # way for a subsequent build.
  73. mv "$ROOT_DIR"/build/nvim.appimage* "$ROOT_DIR"/build/bin
  74. echo 'genappimage.sh: finished'