genappimage.sh 3.4 KB

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