diff --git a/src/.config b/src/.config index 63fc607c7..03907bc2b 100644 --- a/src/.config +++ b/src/.config @@ -127,6 +127,12 @@ STATIC_GET_SOURCE_URL=http://s.minos.io/s # UTIL_LINUX_SOURCE_URL=https://www.kernel.org/pub/linux/utils/util-linux/v2.31/util-linux-2.31.tar.gz +# You can find the latest vim source bundles here: +# +# https://github.com/vim/vim/releases +# +VIM_SOURCE_URL=https://github.com/vim/vim/archive/v8.0.1298.tar.gz + # You can find the latest ZLIB source bundles here: # # http://zlib.net @@ -226,11 +232,12 @@ COPY_SOURCE_ISO=true # openjdk - installs Open JDK. All operations are automated. # static_get - portable binaries for Linux (http://s.minos.io). # util_linux - set of executable utilities distributed by the Linux Kernel Org. +# vim - an advanced text editor. # zlib - DEFLATE compression/decompression library. # # Refer to the README file for more information. # -#OVERLAY_BUNDLES=glibc_full,cf_cli,coreutils,dhcp,dropbear,felix,java,kbd,links,lua,mll_utils,nano,ncurses,nweb,static_get,util_linux,zlib +#OVERLAY_BUNDLES=glibc_full,cf_cli,coreutils,dhcp,dropbear,felix,java,kbd,links,lua,mll_utils,nano,ncurses,nweb,openjdk,static_get,util_linux,vim,zlib #OVERLAY_BUNDLES=glibc_full,dhcp,felix,links,openjdk,zlib # This property enables the standard penguin boot logo in the upper left corner diff --git a/src/README b/src/README index 6ae778d27..673b12652 100644 --- a/src/README +++ b/src/README @@ -91,6 +91,12 @@ Currently available overlay bundles: Some packages in this overlay bundle require ncurses. +* vim - An advanced text editor that seeks to provide the power of + the de-facto Unix editor 'Vi', with a more complete feature + set. + + This package will create symlinks on top of vi. + * ZLIB - Software library used for data compression. diff --git a/src/minimal_overlay/bundles/vim/01_get.sh b/src/minimal_overlay/bundles/vim/01_get.sh new file mode 100755 index 000000000..2a3369e2a --- /dev/null +++ b/src/minimal_overlay/bundles/vim/01_get.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +SRC_DIR=$(pwd) + +. ../../common.sh + +# Grab everything after the '=' character. +DOWNLOAD_URL=$(grep -i VIM_SOURCE_URL $MAIN_SRC_DIR/.config | cut -f2 -d'=') + +# Grab everything after the last '/' character. +ARCHIVE_FILE=${DOWNLOAD_URL##*/} + +# Read the 'USE_LOCAL_SOURCE' property from '.config' +USE_LOCAL_SOURCE="$(grep -i USE_LOCAL_SOURCE $MAIN_SRC_DIR/.config | cut -f2 -d'=')" + +if [ "$USE_LOCAL_SOURCE" = "true" -a ! -f $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE ] ; then + echo "Source bundle $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE is missing and will be downloaded." + USE_LOCAL_SOURCE="false" +fi + +cd $MAIN_SRC_DIR/source/overlay + +if [ ! "$USE_LOCAL_SOURCE" = "true" ] ; then + # Downloading vim source bundle file. The '-c' option allows the download to resume. + echo "Downloading vim source bundle from $DOWNLOAD_URL" + wget -c $DOWNLOAD_URL +else + echo "Using local vim source bundle $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE" +fi + +# Delete folder with previously extracted vim. +echo "Removing vim work area. This may take a while..." +rm -rf $WORK_DIR/overlay/vim +mkdir $WORK_DIR/overlay/vim + +# Extract vim to folder 'work/overlay/vim'. +# Full path will be something like 'work/overlay/vim/vim-8.0.1298'. +tar -xvf $ARCHIVE_FILE -C $WORK_DIR/overlay/vim + +cd $SRC_DIR + diff --git a/src/minimal_overlay/bundles/vim/02_build.sh b/src/minimal_overlay/bundles/vim/02_build.sh new file mode 100755 index 000000000..20a7c8c1a --- /dev/null +++ b/src/minimal_overlay/bundles/vim/02_build.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +SRC_DIR=$(pwd) + +. ../../common.sh + +cd $WORK_DIR/overlay/vim + +DESTDIR="$PWD/vim_installed" + +# Change to the vim source directory which ls finds, e.g. 'vim-8.0.1298'. +cd $(ls -d vim-*) + +echo "Preparing vim work area. This may take a while..." +make -j $NUM_JOBS clean + +rm -rf $DESTDIR + +echo "Setting vimrc location..." +echo '#define SYS_VIMRC_FILE "/etc/vimrc"' >> src/feature.h + +echo "Configuring vim..." +CFLAGS="$CFLAGS" ./configure \ + --prefix=/usr + +echo "Building vim..." +make -j $NUM_JOBS + +echo "Installing vim..." +make -j $NUM_JOBS install DESTDIR=$DESTDIR + +echo "Generating vimrc..." +mkdir -p $DESTDIR/etc +cat > $DESTDIR/etc/vimrc << "EOF" +" Begin /etc/vimrc + +set nocompatible +set backspace=2 +set mouse=r +syntax on +set background=dark + +" End /etc/vimrc +EOF + +echo "Symlinking vim to vi..." +ln -sv vim $DESTDIR/usr/bin/vi +mkdir -p $DESTDIR/bin +ln -sv vim $DESTDIR/bin/vi + +echo "Reducing vim size..." +strip -g $DESTDIR/usr/bin/* + +ROOTFS="$WORK_DIR/src/minimal_overlay/rootfs" + +cp -r $DESTDIR/* $ROOTFS + +echo "vim has been installed." + +cd $SRC_DIR + diff --git a/src/minimal_overlay/bundles/vim/bundle.sh b/src/minimal_overlay/bundles/vim/bundle.sh new file mode 100755 index 000000000..ffd32c002 --- /dev/null +++ b/src/minimal_overlay/bundles/vim/bundle.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +SRC_DIR=$(pwd) + +./01_get.sh +./02_build.sh + +cd $SRC_DIR +