genappimage.sh 3.2 KB

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