From cbdaa63284ae61964c6862bf4299fa517ab94761 Mon Sep 17 00:00:00 2001 From: Michael McMahon Date: Tue, 14 Nov 2017 16:28:58 -0500 Subject: [PATCH] Add coreutils overlay bundle --- src/.config | 9 +++- src/README | 2 + .../bundles/coreutils/01_get.sh | 41 +++++++++++++++++++ .../bundles/coreutils/02_build.sh | 38 +++++++++++++++++ .../bundles/coreutils/bundle.sh | 9 ++++ 5 files changed, 98 insertions(+), 1 deletion(-) create mode 100755 src/minimal_overlay/bundles/coreutils/01_get.sh create mode 100755 src/minimal_overlay/bundles/coreutils/02_build.sh create mode 100755 src/minimal_overlay/bundles/coreutils/bundle.sh diff --git a/src/.config b/src/.config index 23f091f50..b04a47495 100644 --- a/src/.config +++ b/src/.config @@ -47,6 +47,12 @@ SYSLINUX_SOURCE_URL=http://kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.0 # CLOUD_FOUNDRY_CLI_URL=http://cli.run.pivotal.io/stable?release=linux64-binary&source=github +# You can find the latest coreutils source bundles here: +# +# http://ftp.gnu.org/gnu/coreutils/ +# +COREUTILS_SOURCE_URL=http://ftp.gnu.org/gnu/coreutils/coreutils-8.28.tar.xz + # You can find the latest Dropbear source bundles here: # # http://matt.ucc.asn.au/dropbear/dropbear.html @@ -200,6 +206,7 @@ COPY_SOURCE_ISO=true # # glibc_full - all core GNU C libraries (useful if other software is included). # cf_cli - CLoud Foundry CLI (command line interface). +# coreutils - set of commonly used GNU executable utilities. # dhcp - DHCP and DNS functionality. # dropbear - SSH server and client. # felix - Apache Felix OSGi framework. @@ -217,7 +224,7 @@ COPY_SOURCE_ISO=true # # Refer to the README file for more information. # -#OVERLAY_BUNDLES=glibc_full,cf_cli,dhcp,dropbear,felix,java,links,lua,mll_utils,nano,ncurses,nweb,static_get,util_linux,zlib +#OVERLAY_BUNDLES=glibc_full,cf_cli,coreutils,dhcp,dropbear,felix,java,links,lua,mll_utils,nano,ncurses,nweb,static_get,util_linux,zlib #OVERLAY_BUNDLES=glibc_full,dhcp,felix,links,openjdk,zlib # This property enables the standard penguin boot logo in the upper left corner diff --git a/src/README b/src/README index d4ac800e4..b726fb841 100644 --- a/src/README +++ b/src/README @@ -27,6 +27,8 @@ Currently available overlay bundles: This overlay bundle depends on the GLIBC build process. +* coreutils - set of commonly used GNU executable utilities. + * dhcp - DHCP and DNS functionality to connect to the Internet. * Dropbear - SSH server/client. Requires ~1MB additional space. The build diff --git a/src/minimal_overlay/bundles/coreutils/01_get.sh b/src/minimal_overlay/bundles/coreutils/01_get.sh new file mode 100755 index 000000000..9576e211f --- /dev/null +++ b/src/minimal_overlay/bundles/coreutils/01_get.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +SRC_DIR=$(pwd) + +. ../../common.sh + +# Grab everything after the '=' character. +DOWNLOAD_URL=$(grep -i COREUTILS_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 coreutils source bundle file. The '-c' option allows the download to resume. + echo "Downloading coreutils source bundle from $DOWNLOAD_URL" + wget -c $DOWNLOAD_URL +else + echo "Using local coreutils source bundle $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE" +fi + +# Delete folder with previously extracted coreutils. +echo "Removing coreutils work area. This may take a while..." +rm -rf $WORK_DIR/overlay/coreutils +mkdir $WORK_DIR/overlay/coreutils + +# Extract coreutils to folder 'work/overlay/coreutils'. +# Full path will be something like 'work/overlay/coreutils/coreutils-8.28'. +tar -xvf $ARCHIVE_FILE -C $WORK_DIR/overlay/coreutils + +cd $SRC_DIR + diff --git a/src/minimal_overlay/bundles/coreutils/02_build.sh b/src/minimal_overlay/bundles/coreutils/02_build.sh new file mode 100755 index 000000000..a8d22973d --- /dev/null +++ b/src/minimal_overlay/bundles/coreutils/02_build.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +SRC_DIR=$(pwd) + +. ../../common.sh + +cd $WORK_DIR/overlay/coreutils + +DESTDIR="$PWD/coreutils_installed" + +# Change to the coreutils source directory which ls finds, e.g. 'coreutils-8.28'. +cd $(ls -d coreutils-*) + +echo "Preparing coreutils work area. This may take a while..." +make -j $NUM_JOBS clean + +rm -rf $DESTDIR + +echo "Configuring coreutils..." +CFLAGS="$CFLAGS" ./configure \ + --prefix=/usr + +echo "Building coreutils..." +make -j $NUM_JOBS + +echo "Installing coreutils..." +make -j $NUM_JOBS install DESTDIR=$DESTDIR + +echo "Reducing coreutils size..." +strip -g $DESTDIR/usr/bin/* + +ROOTFS="$WORK_DIR/src/minimal_overlay/rootfs" + +cp -r $DESTDIR/* $ROOTFS + +echo "coreutils has been installed." + +cd $SRC_DIR diff --git a/src/minimal_overlay/bundles/coreutils/bundle.sh b/src/minimal_overlay/bundles/coreutils/bundle.sh new file mode 100755 index 000000000..6284178ab --- /dev/null +++ b/src/minimal_overlay/bundles/coreutils/bundle.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +SRC_DIR=$(pwd) + +time sh 01_get.sh +time sh 02_build.sh + +cd $SRC_DIR +