diff --git a/src/vimsrc/devcontainer-feature.json b/src/vimsrc/devcontainer-feature.json index a76d4a8..da750ed 100644 --- a/src/vimsrc/devcontainer-feature.json +++ b/src/vimsrc/devcontainer-feature.json @@ -2,12 +2,57 @@ "name": "VIM", "id": "vim", "version": "0.0.1", - "description": "VIM, from source", + "description": "VIM, from source.", "options": { "version": { "type": "string", - "default": "latest", - "description": "The version of VIM to build" + "default": "9.1.0327", + "description": "The version of VIM to build." + }, + "enable_gui": { + "type": "boolean", + "default": false, + "description": "Enable GUI Version of VIM." + }, + "enable_sound": { + "type": "boolean", + "default": false, + "description": "Enable sound." + }, + "enable_perl": { + "type": "boolean", + "default": false, + "description": "Enable Perl interpreter." + }, + "enable_python": { + "type": "boolean", + "default": false, + "description": "Enable Python interpreter." + }, + "enable_python3": { + "type": "boolean", + "default": false, + "description": "Enable Python 3 interpreter." + }, + "enable_ruby": { + "type": "boolean", + "default": false, + "description": "Enable Ruby interpreter." + }, + "enable_lua": { + "type": "boolean", + "default": false, + "description": "Enable Lua interpreter." + }, + "enable_tcl": { + "type": "boolean", + "default": false, + "description": "Enable Tcl interpreter." + }, + "enable_mzscheme": { + "type": "boolean", + "default": false, + "description": "Enable MZ Scheme interpreter." } } } diff --git a/src/vimsrc/install.sh b/src/vimsrc/install.sh index 2e07653..8e47775 100644 --- a/src/vimsrc/install.sh +++ b/src/vimsrc/install.sh @@ -16,6 +16,38 @@ RACKET_VERSION="8.5" set -e +unset_false_variables() { + if [ "${VIM_ENABLE_GUI}" = "false" ]; then + unset VIM_ENABLE_GUI + fi + if [ "${VIM_ENABLE_SOUND}" = "false" ]; then + unset VIM_ENABLE_SOUND + fi + if [ "${VIM_ENABLE_PERL}" = "false" ]; then + unset VIM_ENABLE_PERL + fi + if [ "${VIM_ENABLE_PYTHON}" = "false" ]; then + unset VIM_ENABLE_PYTHON + fi + if [ "${VIM_ENABLE_PYTHON3}" = "false" ]; then + unset VIM_ENABLE_PYTHON3 + fi + if [ "${VIM_ENABLE_RUBY}" = "false" ]; then + unset VIM_ENABLE_RUBY + fi + if [ "${VIM_ENABLE_LUA}" = "false" ]; then + unset VIM_ENABLE_LUA + fi + if [ "${VIM_ENABLE_TCL}" = "false" ]; then + unset VIM_ENABLE_TCL + fi + if [ "${VIM_ENABLE_MZSCHEME}" = "false" ]; then + unset VIM_ENABLE_MZSCHEME + fi +} + +unset_false_variables + echo "Download, build and install VIM" if [ "$(id -u)" -ne 0 ]; then @@ -30,7 +62,7 @@ export DEBIAN_FRONTEND=noninteractive apt_get_update() { case "${ID}" in debian|ubuntu) - if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + if [ ! -d "/var/lib/apt/lists" ] || [ -z "$(ls -A /var/lib/apt/lists/)" ]; then echo "Running apt-get update..." apt-get update -y fi @@ -144,14 +176,6 @@ requested_version="${VIM_VERSION}" version_list="$(curl -sSL -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/vim/vim/tags" | grep -o '"name": "v[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*"' | sed 's/"name": "v//;s/"//g' | sort -rV)" if [ "${requested_version}" = "latest" ]; then VIM_VERSION="$(echo "${version_list}" | head -n 1)" -else - set +e - VIM_VERSION="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|$)")" - set -e -fi -if [ -z "${VIM_VERSION}" ] || ! echo "${version_list}" | grep "^$(echo "${VIM_VERSION}" | sed 's/\./\\./g')$" > /dev/null 2>&1; then - echo "Invalid VIM version: ${requested_version}" >&2 - exit 1 fi echo "Downloading source for ${VIM_VERSION}..." diff --git a/test/vimsrc/eight.sh b/test/vimsrc/eight.sh new file mode 100644 index 0000000..8bc6ac1 --- /dev/null +++ b/test/vimsrc/eight.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Test a plain install of VIM, version 8.2 + +set -e + +source dev-container-features-test-lib + +check "vim version" vim --version + +# Report result +# If any of the checks above exited with a non-zero exit code, the test will fail. +reportResults diff --git a/test/vimsrc/lua.sh b/test/vimsrc/lua.sh new file mode 100644 index 0000000..8f4c3ff --- /dev/null +++ b/test/vimsrc/lua.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Test an installation of VIM with LUA. + +set -e + +source dev-container-features-test-lib + +check "vim version" vim --version + +# Report result +# If any of the checks above exited with a non-zero exit code, the test will fail. +reportResults diff --git a/test/vimsrc/plain.sh b/test/vimsrc/plain.sh new file mode 100644 index 0000000..a06fc07 --- /dev/null +++ b/test/vimsrc/plain.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Test a plain install of VIM, no added options. + +set -e + +source dev-container-features-test-lib + +check "vim version" vim --version + +# Report result +# If any of the checks above exited with a non-zero exit code, the test will fail. +reportResults diff --git a/test/vimsrc/python.sh b/test/vimsrc/python.sh new file mode 100644 index 0000000..5366ced --- /dev/null +++ b/test/vimsrc/python.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Test an installation of VIM with Python. + +set -e + +source dev-container-features-test-lib + +check "vim version" vim --version + +# Report result +# If any of the checks above exited with a non-zero exit code, the test will fail. +reportResults diff --git a/test/vimsrc/scenarios.json b/test/vimsrc/scenarios.json new file mode 100644 index 0000000..5a26a02 --- /dev/null +++ b/test/vimsrc/scenarios.json @@ -0,0 +1,36 @@ +{ + "plain": { + "image": "ubuntu", + "features": { + "vimsrc": { + "version": "9.1.0327" + } + } + }, + "lua": { + "image": "ubuntu", + "features": { + "vimsrc": { + "version": "9.1.0327", + "enable_lua": true + } + } + }, + "python": { + "image": "ubuntu", + "features": { + "vimsrc": { + "version": "9.1.0327", + "enable_python3": true + } + } + }, + "eight": { + "image": "ubuntu", + "features": { + "vimsrc": { + "version": "8.2.5172" + } + } + } +}