Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a sysext for vim-huge #78

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions create_vim-huge_sysext.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env bash
set -euo pipefail

export ARCH="${ARCH-x86-64}"
SCRIPTFOLDER="$(dirname "$(readlink -f "$0")")"

if [ $# -lt 2 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "Usage: $0 VERSION SYSEXTNAME"
echo "The script will download the vim version you choose (e.g. 9.0.1678 ), build a static binary and create a sysext squashfs image with the name SYSEXTNAME.raw in the current folder."
echo "A temporary directory named SYSEXTNAME in the current folder will be created and deleted again."
echo "All files in the sysext image will be owned by root."
echo "The build process requires docker"
"${SCRIPTFOLDER}"/bake.sh --help
exit 1
fi

VERSION="$1"
SYSEXTNAME="$2"

if ! command -v docker &>/dev/null; then
echo Missing docker in path
exit 1
fi

SUFFIX=
if [ "${ARCH}" = "x86-64" ] || [ "${ARCH}" = "x86_64" ]; then
ARCH=amd64
elif [ "${ARCH}" = "aarch64" ] || [ "${ARCH}" = "arm64" ]; then
ARCH="arm64"
SUFFIX="v8"
fi
IMG=docker.io/"${ARCH}${SUFFIX}"/alpine:3.19
mkdir -p "${SYSEXTNAME}"
cat >"${SYSEXTNAME}"/build.sh <<EOF
#!/bin/sh
set -euo pipefail
cd /opt && wget https://github.com/vim/vim/archive/v${VERSION}.tar.gz && tar xfz v${VERSION}.tar.gz && cd vim-${VERSION}
apk --no-cache add gcc make musl-dev ncurses-static autoconf automake alpine-sdk
LDFLAGS="-static" ./configure --prefix=/usr --sysconfdir /etc/ --disable-channel --disable-gpm --disable-gtktest --disable-gui --disable-netbeans --disable-nls --disable-selinux --disable-smack --disable-sysmouse --disable-xsmp --enable-multibyte --with-features=huge --without-x --with-tlib=ncursesw --mandir=/tmp --docdir=/tmp
make -j16
make DESTDIR=/install_root install
rm -rfv /install_root/usr/share/applications /install_root/usr/share/icons /install_root/usr/share/man
chown \$(stat -c %u:%g /install_root/build.sh) /install_root -R
EOF
chmod +x "${SYSEXTNAME}"/build.sh
docker run -v "${PWD}/${SYSEXTNAME}":/install_root/ --rm "${IMG}" /bin/sh -c /install_root/build.sh
rm -f "${SYSEXTNAME}"/build.sh
cat > "${SYSEXTNAME}"/usr/share/vim/vimrc <<-"EOF"
" Vim will load $VIMRUNTIME/defaults.vim if the user does not have a vimrc.
" This happens after /etc/vim/vimrc(.local) are loaded, so it will override
" any settings in these files.
" Thus we source the default and disable load defaults afterwords so we can override
" options in these files.
" Use :verbose set $option? or :scriptnames to see the where any option is being set from
if filereadable("/usr/share/vim/vim90/defaults.vim")
source /usr/share/vim/vim90/defaults.vim
endif
let g:skip_defaults_vim = 1

" Read vimrc.local from /etc if it exists. (read-write root images)
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif

" Useful config for editing yaml files
set ai ts=2 sw=2 et
set pastetoggle=<F3>
set ignorecase
set mouse-=a
inoremap <S-Tab> <C-d>
map <silent> <F5> :set cursorcolumn!<CR>
set maxmempattern=50000
EOF

RELOAD=1 "${SCRIPTFOLDER}"/bake.sh "${SYSEXTNAME}"
rm -rf "${SYSEXTNAME}"