diff --git a/src/.config b/src/.config index de5d6cda9..58cd0324d 100644 --- a/src/.config +++ b/src/.config @@ -135,6 +135,7 @@ OVERLAY_TYPE=folder # dropbear - SSH server and client. # felix - Apache Felix OSGi framework. # fio - I/O load generator. +# graalvm - VM for Java, JavaScript, Python, Ruby, R, LLVM. # java - Oracle JRE or JDK. Manual preparations are required. # kbd - keyboard utilities. # kernel_modules - default MLL kernel modules and 'mdev' hotplug manager. diff --git a/src/README b/src/README index 3f57edb43..8d595a36e 100644 --- a/src/README +++ b/src/README @@ -63,6 +63,11 @@ Currently available overlay bundles: workloads on RAM or disks. 'fio' is essential for troubleshooting data I/O bottlenecks. + GraalVM - Universal virtual machine for running applications written + in JavaScript, Python, Ruby, R, JVM-based languages like + Java, Scala, Clojure, Kotlin, and LLVM-based languages such + as C and C++. + JRE / JDK - Oracle JRE/JDK. This overlay bundle requires some manual preparation steps. Refer to the 'JAVA_ARCHIVE' property in the '.config' file for more information. This overlay bundle diff --git a/src/minimal_overlay/bundles/graalvm/.config b/src/minimal_overlay/bundles/graalvm/.config new file mode 100644 index 000000000..947a9dc95 --- /dev/null +++ b/src/minimal_overlay/bundles/graalvm/.config @@ -0,0 +1,17 @@ +# You can find the latest GraalVM archives here: +# +# http://github.com/oracle/graal +# +GRAALVM_URL=http://github.com/oracle/graal/releases/download/vm-1.0.0-rc1/graalvm-ce-1.0.0-rc1-linux-amd64.tar.gz + +# List of additional languages to install. The full catalog can be found here: +# +# https://www.graalvm.org/1.0.0-rc1/component-catalog/graal-updater-component-catalog.properties +# +# The corresponding languages and their executables: +# +# org.graalvm.ruby the main executable is 'ruby' or 'truffleruby' +# org.graalvm.pythn the main executable is 'graalpython' +# org.graalvm.r the main executable is 'R' or 'Rscript' +# +GRAALVM_LANGUAGES=python,ruby,r diff --git a/src/minimal_overlay/bundles/graalvm/01_get.sh b/src/minimal_overlay/bundles/graalvm/01_get.sh new file mode 100755 index 000000000..82a40658b --- /dev/null +++ b/src/minimal_overlay/bundles/graalvm/01_get.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +set -e + +. ../../common.sh + +# Read the common configuration properties. +DOWNLOAD_URL=`read_property GRAALVM_URL` +USE_LOCAL_SOURCE=`read_property USE_LOCAL_SOURCE` + +# Grab everything after the last '/' character. +ARCHIVE_FILE=${DOWNLOAD_URL##*/} + +if [ "$USE_LOCAL_SOURCE" = "true" -a ! -f $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE ] ; then + echo "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 GraalVM bundle file. The '-c' option allows the download to resume. + echo "Downloading GraalVM bundle from $DOWNLOAD_URL" + wget -c $DOWNLOAD_URL +else + echo "Using local GraalVM bundle $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE" +fi + +# Delete folder with previously extracted Felix. +echo "Removing GraalVM work area. This may take a while." +rm -rf $WORK_DIR/overlay/$BUNDLE_NAME +mkdir $WORK_DIR/overlay/$BUNDLE_NAME + +# Extract GraalVM to folder 'work/overlay/graalvm'. +# Full path will be something like 'work/overlay/graalvm/graalvm-1.0.0-rc1'. +tar -xvf $ARCHIVE_FILE -C $WORK_DIR/overlay/$BUNDLE_NAME + +cd $SRC_DIR diff --git a/src/minimal_overlay/bundles/graalvm/02_install.sh b/src/minimal_overlay/bundles/graalvm/02_install.sh new file mode 100755 index 000000000..0f4e0b90d --- /dev/null +++ b/src/minimal_overlay/bundles/graalvm/02_install.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +set -e + +. ../../common.sh + +cd $WORK_DIR/overlay/$BUNDLE_NAME +mv `ls -d *` $BUNDLE_NAME + +mkdir opt +mv graalvm opt + +# Remove the unnecessary Java sources which just take valuable space. +rm -f opt/graalvm/src.zip + +mkdir $WORK_DIR/overlay/$BUNDLE_NAME/bin +cd $WORK_DIR/overlay/$BUNDLE_NAME/bin + +# Read the additional languages to install. +GRAALVM_LANGUAGES=`read_property GRAALVM_LANGUAGES` + +LANGUAGES_LIST="$(echo $GRAALVM_LANGUAGES | tr ',' ' ')" + +# Install the additional languages +for LANGUAGE in $LANGUAGES_LIST +do + ./../opt/$BUNDLE_NAME/bin/gu -c install org.graalvm.$LANGUAGE +done + +for FILE in $(ls ../opt/$BUNDLE_NAME/bin) +do + ln -s ../opt/$BUNDLE_NAME/bin/$FILE $FILE +done + +# With '--remove-destination' all possibly existing soft links in +# '$OVERLAY_ROOTFS' will be overwritten correctly. +cp -r --remove-destination $WORK_DIR/overlay/$BUNDLE_NAME/* \ + $OVERLAY_ROOTFS + +echo "GraalVM has been installed." + +cd $SRC_DIR diff --git a/src/minimal_overlay/bundles/graalvm/bundle.sh b/src/minimal_overlay/bundles/graalvm/bundle.sh new file mode 100755 index 000000000..0be2a10d3 --- /dev/null +++ b/src/minimal_overlay/bundles/graalvm/bundle.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e + +. ../../common.sh + +./01_get.sh +./02_install.sh + +cd $SRC_DIR diff --git a/src/minimal_overlay/bundles/graalvm/bundle_deps b/src/minimal_overlay/bundles/graalvm/bundle_deps new file mode 100644 index 000000000..61861db9e --- /dev/null +++ b/src/minimal_overlay/bundles/graalvm/bundle_deps @@ -0,0 +1,2 @@ +glibc_full +zlib