Skip to content

Instantly share code, notes, and snippets.

@rexroof
Created November 23, 2021 20:59
Show Gist options
  • Save rexroof/0fff9f78c51ab302a830e4ec94b30e5a to your computer and use it in GitHub Desktop.
Save rexroof/0fff9f78c51ab302a830e4ec94b30e5a to your computer and use it in GitHub Desktop.
build neovim in container. supports docker/podman and arch/ubuntu
#!/bin/bash
set -e
SRCDIR="${HOME}/github/neovim"
VERSION_ID=latest
. /etc/os-release
if command -v podman ;then
PODMAN=$(command -v podman)
DOCKERFILE="Containerfile"
fi
if command -v docker ;then
PODMAN=$(command -v docker)
DOCKERFILE="Dockerfile"
fi
if [ -z "$PODMAN" ] ; then
echo podman/docker not found
exit 1
fi
OS_IMAGE="ubuntu"
if [ "$ID" = "arch" ] ; then
OS_IMAGE="archlinux"
fi
if [ ! -d "$SRCDIR" ] ; then
git clone https://github.com/neovim/neovim $SRCDIR
fi
cd $SRCDIR
git fetch --all
git pull
rm -f make-n-pack.sh
cat <<'END' > make-n-pack.sh
make distclean
make -j6
# make -j4 CMAKE_BUILD_TYPE=RelWithDebInfo
rm -f neovim-build.tgz
make install
tar -C /usr/local/ -zcf neovim-build.tgz .
END
rm -f $DOCKERFILE
cat <<'END' > $DOCKERFILE
ARG OS_IMAGE="ubuntu"
ARG OS_VERSION="20.04"
FROM docker.io/library/$OS_IMAGE:$OS_VERSION
ARG DEBIAN_FRONTEND="noninteractive"
ARG TZ="America/Detroit"
RUN . /etc/os-release && if [ "$ID" = "ubuntu" ] ; then apt-get update \
&& apt-get install -y \
ninja-build gettext libtool \
libtool-bin autoconf automake \
cmake g++ pkg-config unzip curl \
doxygen ; fi
RUN . /etc/os-release && if [ "$ID" = "arch" ] ; then \
pacman -Sy --noconfirm base-devel cmake unzip ninja tree-sitter curl ; fi
WORKDIR /src
CMD [ "sh", "make-n-pack.sh" ]
END
$PODMAN build --no-cache --build-arg OS_VERSION=${VERSION_ID} \
--build-arg OS_IMAGE=${OS_IMAGE} -t buildneovim .
rm -f neovim-build.tgz
$PODMAN run --rm -it -v $PWD:/src buildneovim
sudo tar -C /usr/local/ -zxvf neovim-build.tgz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment