From 4e70ecc94259f231e3d4d40fa251ab730869e09d Mon Sep 17 00:00:00 2001 From: Ivan Davidov Date: Sat, 16 Jun 2018 12:04:54 +0300 Subject: [PATCH] Added Google's Go programming language (golang) as overlay bundle. --- src/.config | 1 + src/README | 3 ++ src/minimal_overlay/bundles/golang/.config | 5 +++ src/minimal_overlay/bundles/golang/01_get.sh | 38 +++++++++++++++++++ .../bundles/golang/02_install.sh | 32 ++++++++++++++++ src/minimal_overlay/bundles/golang/bundle.sh | 10 +++++ .../bundles/golang/bundle_deps | 1 + 7 files changed, 90 insertions(+) create mode 100644 src/minimal_overlay/bundles/golang/.config create mode 100755 src/minimal_overlay/bundles/golang/01_get.sh create mode 100755 src/minimal_overlay/bundles/golang/02_install.sh create mode 100755 src/minimal_overlay/bundles/golang/bundle.sh create mode 100644 src/minimal_overlay/bundles/golang/bundle_deps diff --git a/src/.config b/src/.config index e54431a3e..ca32b0988 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. +# golang - Google's Go programming language. # graalvm - VM for Java, JavaScript, Python, Ruby, R, LLVM. # java - Oracle JRE or JDK. Manual preparations are required. # kbd - keyboard utilities. diff --git a/src/README b/src/README index 7243c33ae..8af0d2a8a 100644 --- a/src/README +++ b/src/README @@ -63,6 +63,9 @@ Currently available overlay bundles: workloads on RAM or disks. 'fio' is essential for troubleshooting data I/O bottlenecks. + Golang - Go is an open source programming language that makes it easy + to build simple, reliable, and efficient software. + 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 diff --git a/src/minimal_overlay/bundles/golang/.config b/src/minimal_overlay/bundles/golang/.config new file mode 100644 index 000000000..9eaf1cf42 --- /dev/null +++ b/src/minimal_overlay/bundles/golang/.config @@ -0,0 +1,5 @@ +# You can find the latest Golang archives here: +# +# http://golang.org/dl +# +GOLANG_URL=https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz diff --git a/src/minimal_overlay/bundles/golang/01_get.sh b/src/minimal_overlay/bundles/golang/01_get.sh new file mode 100755 index 000000000..cf2e886db --- /dev/null +++ b/src/minimal_overlay/bundles/golang/01_get.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +set -e + +. ../../common.sh + +# Read the common configuration properties. +DOWNLOAD_URL=`read_property GOLANG_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 Golang bundle file. The '-c' option allows the download to resume. + echo "Downloading Golang bundle from $DOWNLOAD_URL" + wget -c $DOWNLOAD_URL +else + echo "Using local Golang bundle $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE" +fi + +# Delete folder with previously extracted Felix. +echo "Removing Golang work area. This may take a while." +rm -rf $WORK_DIR/overlay/$BUNDLE_NAME +mkdir $WORK_DIR/overlay/$BUNDLE_NAME + +# Extract Golang to folder 'work/overlay/golang'. +# Full path will be something like 'work/overlay/golang/go'. +tar -xvf $ARCHIVE_FILE -C $WORK_DIR/overlay/$BUNDLE_NAME + +cd $SRC_DIR diff --git a/src/minimal_overlay/bundles/golang/02_install.sh b/src/minimal_overlay/bundles/golang/02_install.sh new file mode 100755 index 000000000..484871846 --- /dev/null +++ b/src/minimal_overlay/bundles/golang/02_install.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +set -e + +. ../../common.sh + +cd $WORK_DIR/overlay/$BUNDLE_NAME +mv `ls -d *` $BUNDLE_NAME + +mkdir opt +mv $BUNDLE_NAME opt + +mkdir -p usr/local +cd $WORK_DIR/overlay/$BUNDLE_NAME/usr/local +ln -s ../../opt/$BUNDLE_NAME go + +mkdir $WORK_DIR/overlay/$BUNDLE_NAME/bin +cd $WORK_DIR/overlay/$BUNDLE_NAME/bin + +for FILE in $(ls ../usr/local/go/bin) +do + ln -s ../usr/local/go/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 "Golang has been installed." + +cd $SRC_DIR diff --git a/src/minimal_overlay/bundles/golang/bundle.sh b/src/minimal_overlay/bundles/golang/bundle.sh new file mode 100755 index 000000000..0be2a10d3 --- /dev/null +++ b/src/minimal_overlay/bundles/golang/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/golang/bundle_deps b/src/minimal_overlay/bundles/golang/bundle_deps new file mode 100644 index 000000000..e264da94c --- /dev/null +++ b/src/minimal_overlay/bundles/golang/bundle_deps @@ -0,0 +1 @@ +glibc_libpthread