From 8db6dff74af9333e69e995badda1216fb5c9569a Mon Sep 17 00:00:00 2001 From: bauen1 Date: Fri, 10 Feb 2017 16:57:33 +0100 Subject: [PATCH 1/5] 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 From cbd214a5d993494c07beab74554f3d073abaab32 Mon Sep 17 00:00:00 2001 From: bauen1 Date: Tue, 14 Feb 2017 14:57:20 +0100 Subject: [PATCH 2/5] Added note about dependence on glibc --- src/minimal_overlay/bundles/lua/02_build.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/minimal_overlay/bundles/lua/02_build.sh b/src/minimal_overlay/bundles/lua/02_build.sh index cf3860d9f..6ac7b7de5 100755 --- a/src/minimal_overlay/bundles/lua/02_build.sh +++ b/src/minimal_overlay/bundles/lua/02_build.sh @@ -42,5 +42,10 @@ 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." +echo "*******************************************************************************" +echo "*** NOTE: ***" +echo "*** lua currently depends on glibc to be present for dynamic linking ***" +echo "*** So make sure to build and include glibc_full ***" +echo "*******************************************************************************" cd $SRC_DIR From 4471c1aab40943f12c6b441833d6f3d56aaefc10 Mon Sep 17 00:00:00 2001 From: bauen1 Date: Fri, 24 Feb 2017 22:30:54 +0100 Subject: [PATCH 3/5] Added the lua bundle to the documentation --- src/README | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/README b/src/README index 80a8d0930..7de82b775 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,12 @@ 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 ~ 1.5MB additional + space. Use the "lua" command to run an interactive lua interpreter + + This overlay bundle requires GLIBC. + + ### ### ### I only provide the build scripts. It's entirely up to you to configure and @@ -72,4 +78,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. - From 53b332a41df91307cb23a7648d8ee41a41fffdc6 Mon Sep 17 00:00:00 2001 From: bauen1 Date: Fri, 24 Feb 2017 22:42:25 +0100 Subject: [PATCH 4/5] Tweaks --- src/.config | 3 ++- src/README | 2 +- src/minimal_overlay/bundles/lua/02_build.sh | 10 +++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/.config b/src/.config index 801eeefaa..40c8920e7 100644 --- a/src/.config +++ b/src/.config @@ -157,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 7de82b775..1d920115e 100644 --- a/src/README +++ b/src/README @@ -60,7 +60,7 @@ 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 ~ 1.5MB additional +* Lua - The Lua Scripting Language 5.3. Requires ~ 800kb additional space. Use the "lua" command to run an interactive lua interpreter This overlay bundle requires GLIBC. diff --git a/src/minimal_overlay/bundles/lua/02_build.sh b/src/minimal_overlay/bundles/lua/02_build.sh index 6ac7b7de5..9b743d336 100755 --- a/src/minimal_overlay/bundles/lua/02_build.sh +++ b/src/minimal_overlay/bundles/lua/02_build.sh @@ -31,15 +31,15 @@ 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 posix -j $NUM_JOBS CFLAGS="$CFLAGS --sysroot=$MAIN_SRC_DIR/work/glibc/glibc_prepared/" -make install -j $NUM_JOBS INSTALL_TOP=../../lua_installed/usr/local +make install -j $NUM_JOBS INSTALL_TOP=../../lua_installed/usr echo "Reducing Lua size..." -strip -g ../lua_installed/usr/local/bin/* 2>/dev/null +strip -g ../lua_installed/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 +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." echo "*******************************************************************************" From 51a3916ae71e471b1a02995a80fe4e02ea3c371d Mon Sep 17 00:00:00 2001 From: bauen1 Date: Sat, 25 Feb 2017 09:16:46 +0100 Subject: [PATCH 5/5] removed the dependency on glibc --- src/README | 3 --- src/minimal_overlay/bundles/lua/02_build.sh | 5 ----- 2 files changed, 8 deletions(-) diff --git a/src/README b/src/README index 1d920115e..f0f32fbf8 100644 --- a/src/README +++ b/src/README @@ -63,9 +63,6 @@ Currently available overlay bundles: * Lua - The Lua Scripting Language 5.3. Requires ~ 800kb additional space. Use the "lua" command to run an interactive lua interpreter - This overlay bundle requires GLIBC. - - ### ### ### I only provide the build scripts. It's entirely up to you to configure and diff --git a/src/minimal_overlay/bundles/lua/02_build.sh b/src/minimal_overlay/bundles/lua/02_build.sh index 9b743d336..9169d6a43 100755 --- a/src/minimal_overlay/bundles/lua/02_build.sh +++ b/src/minimal_overlay/bundles/lua/02_build.sh @@ -42,10 +42,5 @@ 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." -echo "*******************************************************************************" -echo "*** NOTE: ***" -echo "*** lua currently depends on glibc to be present for dynamic linking ***" -echo "*** So make sure to build and include glibc_full ***" -echo "*******************************************************************************" cd $SRC_DIR