From 8db6dff74af9333e69e995badda1216fb5c9569a Mon Sep 17 00:00:00 2001 From: bauen1 Date: Fri, 10 Feb 2017 16:57:33 +0100 Subject: [PATCH] Added a lua overlay bundle --- src/.config | 7 ++++ src/minimal_overlay/bundles/lua/01_get.sh | 43 +++++++++++++++++++ src/minimal_overlay/bundles/lua/02_build.sh | 46 +++++++++++++++++++++ src/minimal_overlay/bundles/lua/bundle.sh | 8 ++++ 4 files changed, 104 insertions(+) create mode 100755 src/minimal_overlay/bundles/lua/01_get.sh create mode 100755 src/minimal_overlay/bundles/lua/02_build.sh create mode 100755 src/minimal_overlay/bundles/lua/bundle.sh diff --git a/src/.config b/src/.config index 9d729c418..801eeefaa 100644 --- a/src/.config +++ b/src/.config @@ -67,6 +67,13 @@ FELIX_SOURCE_URL=http://www-us.apache.org/dist/felix/org.apache.felix.main.distr #JAVA_ARCHIVE=/absolute/path/to/java.archive.tar.gz #JAVA_ARCHIVE=/home/ivan/Downloads/jdk-8u111-linux-x64.tar.gz +# You can find the latest Lua source bundes here: +# +# https://www.lua.org/ftp/ +# +LUA_SOURCE_URL=https://www.lua.org/ftp/lua-5.3.4.tar.gz + + #################################################### diff --git a/src/minimal_overlay/bundles/lua/01_get.sh b/src/minimal_overlay/bundles/lua/01_get.sh new file mode 100755 index 000000000..1891f4c2f --- /dev/null +++ b/src/minimal_overlay/bundles/lua/01_get.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +SRC_DIR=$(pwd) + +# Find the main source directory +cd ../../.. +MAIN_SRC_DIR=$(pwd) +cd $SRC_DIR + +# Grab everything after the '=' character. +DOWNLOAD_URL=$(grep -i LUA_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 the Lua bundle file. The '-c' option allows the download to resume. + echo "Downloading the Lua source bundle from $DOWNLOAD_URL" + wget -c $DOWNLOAD_URL +else + echo "Using local Lua source bundle $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE" +fi + +# Delete folder with previously extracted Lua. +echo "Removing Lua work area. This may take a while..." +rm -rf ../../work/overlay/lua +mkdir ../../work/overlay/lua + +# Extract lua to folder 'work/overlay/lua'. +# Full path will be something like 'work/overlay/lua/lua-5.3.4'. +tar -xvf $ARCHIVE_FILE -C ../../work/overlay/lua + +cd $SRC_DIR diff --git a/src/minimal_overlay/bundles/lua/02_build.sh b/src/minimal_overlay/bundles/lua/02_build.sh new file mode 100755 index 000000000..cf3860d9f --- /dev/null +++ b/src/minimal_overlay/bundles/lua/02_build.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +# TODO: compile the gnu readline library for line editing support + +SRC_DIR=$(pwd) + +# Find the main source directory +cd ../../.. +MAIN_SRC_DIR=$(pwd) +cd $SRC_DIR + +# Read the 'JOB_FACTOR' property from '.config' +JOB_FACTOR="$(grep -i ^JOB_FACTOR $MAIN_SRC_DIR/.config | cut -f2 -d'=')" + +# Read the 'CFLAGS' property from '.config' +CFLAGS="$(grep -i ^CFLAGS $MAIN_SRC_DIR/.config | cut -f2 -d'=')" + +# Find the number of available CPU cores. +NUM_CORES=$(grep ^processor /proc/cpuinfo | wc -l) + +# Calculate the number of 'make' jobs to be used later. +NUM_JOBS=$((NUM_CORES * JOB_FACTOR)) + +cd $MAIN_SRC_DIR/work/overlay/lua + +# Change to the Lua source directory which ls finds, e.g. 'lua-5.3.4'. +cd $(ls -d lua-*) + +echo "Preparing Lua work area. This may take a while..." +make clean -j $NUM_JOBS 2>/dev/null +rm -rf ../lua_installed + +echo "Building Lua..." +make generic -j $NUM_JOBS CFLAGS="$CFLAGS --sysroot=$MAIN_SRC_DIR/work/glibc/glibc_prepared/" + +make install -j $NUM_JOBS INSTALL_TOP=../../lua_installed/usr/local + +echo "Reducing Lua size..." +strip -g ../lua_installed/usr/local/bin/* 2>/dev/null + +mkdir -p $MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/local +cp -r ../lua_installed/usr/local/* $MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/local + +echo "Lua has been installed." + +cd $SRC_DIR diff --git a/src/minimal_overlay/bundles/lua/bundle.sh b/src/minimal_overlay/bundles/lua/bundle.sh new file mode 100755 index 000000000..143589c27 --- /dev/null +++ b/src/minimal_overlay/bundles/lua/bundle.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +SRC_DIR=$(pwd) + +time sh 01_get.sh +time sh 02_build.sh + +cd $SRC_DIR