diff --git a/src/.config b/src/.config index 9d729c418..40c8920e7 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 + + #################################################### @@ -150,10 +157,11 @@ COPY_SOURCE_ISO=true # java - installs Oracle's JRE or JDK. Manual preparations are required. # felix - Apache Felix OSGi framework. # mll_utils - set of executable utilities (mll-*). +# lua - scripting language # # Refer to the README file for more information. # -#OVERLAY_BUNDLES=glibc_full,links,dropbear,java,felix,mll_utils +#OVERLAY_BUNDLES=glibc_full,links,dropbear,java,felix,mll_utils,lua #OVERLAY_BUNDLES=mll_utils # This property enables the standard penguin boot logo in the upper left corner diff --git a/src/README b/src/README index 80a8d0930..f0f32fbf8 100644 --- a/src/README +++ b/src/README @@ -50,7 +50,7 @@ Currently available overlay bundles: This overlay bundle requires GLIBC. * Felix OSGi - Apache Felix OSGi framework. Requires ~2MB additional space. Use - the "felix-start" command to run the Apache Felix OSGi framework. + the "felix-start" command to run the Apache Felix OSGi framework. This overlay bundle requires JRE or JDK. @@ -60,6 +60,9 @@ Currently available overlay bundles: This overlay bundle is currently experimental and its build process depends on the host machine. +* Lua - The Lua Scripting Language 5.3. Requires ~ 800kb additional + space. Use the "lua" command to run an interactive lua interpreter + ### ### ### I only provide the build scripts. It's entirely up to you to configure and @@ -72,4 +75,3 @@ The build proces is slow, so be prepared to wait. In the end you should have the ISO image file "minimal_linux_live.iso" in the same folder where you started the build process. You can burn the ISO image on CD/DVD or (better) run it with PC emulator like QEMU or VirtualBox. - 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..9169d6a43 --- /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 posix -j $NUM_JOBS CFLAGS="$CFLAGS --sysroot=$MAIN_SRC_DIR/work/glibc/glibc_prepared/" + +make install -j $NUM_JOBS INSTALL_TOP=../../lua_installed/usr + +echo "Reducing Lua size..." +strip -g ../lua_installed/bin/* 2>/dev/null + +mkdir -p $MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr/ +cp -r ../lua_installed/usr/* $MAIN_SRC_DIR/work/src/minimal_overlay/rootfs/usr + +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