robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

phaniumbuild: support variant builds via env-var and cpack overrides #40947a99d0c6810

master
3.5 KiB104 linesraw
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
10if [ -z "$ARCH" ]; then
11  ARCH="$(arch)"
12  export ARCH
13fi
14ARCH_OUTPUT=$ARCH
15
16TAG=$1
17
18# App name
19APP=org.neovim.nvim
20
21ROOT_DIR="$(git rev-parse --show-toplevel)"
22APP_BUILD_DIR="$ROOT_DIR/build"
23APP_DIR="$APP.AppDir"
24
25########################################################################
26# Compile nvim and install it into AppDir
27########################################################################
28
29# Build and install nvim into the AppImage
30make CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" DEPS_CMAKE_FLAGS="${DEPS_CMAKE_FLAGS:-}" CMAKE_EXTRA_FLAGS="${CMAKE_EXTRA_FLAGS:-}"
31cmake --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.
38VERSION=$("$ROOT_DIR"/build/bin/nvim --version | head -n 1 | grep -o 'v.*')
39export VERSION
40
41cd "$APP_BUILD_DIR" || exit
42
43# Only downloads linuxdeploy if the remote file is different from local
44if [ -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
48else
49  curl -Lo "$APP_BUILD_DIR"/linuxdeploy-"$ARCH".AppImage \
50    https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-"$ARCH".AppImage
51fi
52
53chmod +x "$APP_BUILD_DIR"/linuxdeploy-"$ARCH".AppImage
54
55# metainfo is not packaged automatically by linuxdeploy
56mkdir -p "$APP_DIR/usr/share/metainfo/"
57cp "$ROOT_DIR/runtime/$APP.appdata.xml" "$APP_DIR/usr/share/metainfo/"
58
59cd "$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#
69cat << 'EOF' > AppRun
70#!/bin/bash
71
72unset ARGV0
73exec "$(dirname "$(readlink  -f "${0}")")/usr/bin/nvim" ${@+"$@"}
74EOF
75chmod 755 AppRun
76
77cd "$APP_BUILD_DIR" || exit # Get out of AppImage directory.
78
79# We want to be consistent, so always use arm64 over aarch64
80if [[ "$ARCH_OUTPUT" == 'aarch64' ]]; then
81  ARCH_OUTPUT="arm64"
82fi
83
84# Set the name of the file generated by appimage
85export OUTPUT="${OUTPUT:-nvim-linux-$ARCH_OUTPUT.appimage}"
86
87# If it's a release generate the zsync file
88if [ -n "$TAG" ]; then
89  export UPDATE_INFORMATION="gh-releases-zsync|neovim|neovim|$TAG|${OUTPUT}.zsync"
90fi
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/$APP.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
102mv "$ROOT_DIR/build/${OUTPUT:-nvim-linux-$ARCH_OUTPUT.appimage}"* "$ROOT_DIR/build/bin"
103
104echo 'genappimage.sh: finished'