Repository: neovim/neovim
File: scripts/genappimage.sh (Shell)

Code before:
# metainfo is not packaged automatically by linuxdeploy
mkdir -p "$APP_DIR/usr/share/metainfo/"
cp "$ROOT_DIR/runtime/nvim.appdata.xml" "$APP_DIR/usr/share/metainfo/"

cd "$APP_DIR" || exit

########################################################################
# AppDir complete. Now package it as an AppImage.
########################################################################

# Appimage set the ARGV0 environment variable. This causes problems in zsh.
# To prevent this, we use wrapper script to unset ARGV0 as AppRun.
# See https://github.com/AppImage/AppImageKit/issues/852
#
cat << 'EOF' > AppRun
#!/bin/bash

unset ARGV0
exec "$(dirname "$(readlink  -f "${0}")")/usr/bin/nvim" ${@+"$@"}
EOF
chmod 755 AppRun

cd "$APP_BUILD_DIR" || exit # Get out of AppImage directory.

# We want to be consistent, so always use arm64 over aarch64
if [[ "$ARCH" == 'aarch64' ]]; then
  ARCH_OUTPUT="arm64"
  export ARCH_OUTPUT
fi

# Set the name of the file generated by appimage
export OUTPUT=nvim-linux-"$ARCH_OUTPUT".appimage

# If it's a release generate the zsync file
if [ -n "$TAG" ]; then
  export UPDATE_INFORMATION="gh-releases-zsync|neovim|neovim|$TAG|nvim-linux-$ARCH_OUTPUT.appimage.zsync"
fi

# Generate AppImage.
#   - Expects: $ARCH, $APP, $VERSION env vars
#   - Expects: ./$APP.AppDir/ directory
#   - Produces: ./nvim-linux-$ARCH_OUTPUT.appimage
./linuxdeploy-"$ARCH".AppImage --appdir $APP.AppDir -d "$ROOT_DIR"/runtime/nvim.desktop -i \
"$ROOT_DIR/runtime/nvim.png" --output appimage

# Moving the final executable to a different folder so it isn't in the
# way for a subsequent build.

mv "$ROOT_DIR"/build/nvim-linux-"$ARCH_OUTPUT".appimage* "$ROOT_DIR"/build/bin

echo 'genappimage.sh: finished'

Review comment (suggestion):
since you set ARCH_OUTPUT=ARCH above, seems clearer to check ARCH_OUTPUT here?
```suggestion
if [[ "$ARCH_OUTPUT" == 'aarch64' ]]; then
```

Code after:
# metainfo is not packaged automatically by linuxdeploy
mkdir -p "$APP_DIR/usr/share/metainfo/"
cp "$ROOT_DIR/runtime/nvim.appdata.xml" "$APP_DIR/usr/share/metainfo/"

cd "$APP_DIR" || exit

########################################################################
# AppDir complete. Now package it as an AppImage.
########################################################################

# Appimage set the ARGV0 environment variable. This causes problems in zsh.
# To prevent this, we use wrapper script to unset ARGV0 as AppRun.
# See https://github.com/AppImage/AppImageKit/issues/852
#
cat << 'EOF' > AppRun
#!/bin/bash

unset ARGV0
exec "$(dirname "$(readlink  -f "${0}")")/usr/bin/nvim" ${@+"$@"}
EOF
chmod 755 AppRun

cd "$APP_BUILD_DIR" || exit # Get out of AppImage directory.

# We want to be consistent, so always use arm64 over aarch64
if [[ "$ARCH_OUTPUT" == 'aarch64' ]]; then
  ARCH_OUTPUT="arm64"
fi

# Set the name of the file generated by appimage
export OUTPUT=nvim-linux-"$ARCH_OUTPUT".appimage

# If it's a release generate the zsync file
if [ -n "$TAG" ]; then
  export UPDATE_INFORMATION="gh-releases-zsync|neovim|neovim|$TAG|nvim-linux-$ARCH_OUTPUT.appimage.zsync"
fi

# Generate AppImage.
#   - Expects: $ARCH, $APP, $VERSION env vars
#   - Expects: ./$APP.AppDir/ directory
#   - Produces: ./nvim-linux-$ARCH_OUTPUT.appimage
./linuxdeploy-"$ARCH".AppImage --appdir $APP.AppDir -d "$ROOT_DIR"/runtime/nvim.desktop -i \
"$ROOT_DIR/runtime/nvim.png" --output appimage

# Moving the final executable to a different folder so it isn't in the
# way for a subsequent build.

mv "$ROOT_DIR"/build/nvim-linux-"$ARCH_OUTPUT".appimage* "$ROOT_DIR"/build/bin

echo 'genappimage.sh: finished'