neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

genappimage.sh (3530B)


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