diff --git a/src/minimal_overlay/bundles/ncurses/01_get.sh b/src/minimal_overlay/bundles/ncurses/01_get.sh new file mode 100644 index 000000000..3d0315215 --- /dev/null +++ b/src/minimal_overlay/bundles/ncurses/01_get.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +SRC_DIR=$(pwd) + +. ../../common.sh + +# Grab everything after the '=' character. +DOWNLOAD_URL=$(grep -i NCURSES_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 ncurses source bundle file. The '-c' option allows the download to resume. + echo "Downloading ncurses source bundle from $DOWNLOAD_URL" + wget -c $DOWNLOAD_URL +else + echo "Using local ncurses source bundle $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE" +fi + +# Delete folder with previously extracted ncurses. +echo "Removing ncurses work area. This may take a while..." +rm -rf $WORK_DIR/overlay/ncurses +mkdir $WORK_DIR/overlay/ncurses + +# Extract ncurses to folder 'work/overlay/ncurses'. +# Full path will be something like 'work/overlay/ncurses/ncurses-6.0'. +tar -xvf $ARCHIVE_FILE -C $WORK_DIR/overlay/ncurses + +cd $SRC_DIR diff --git a/src/minimal_overlay/bundles/ncurses/02_build.sh b/src/minimal_overlay/bundles/ncurses/02_build.sh new file mode 100644 index 000000000..f1bfef294 --- /dev/null +++ b/src/minimal_overlay/bundles/ncurses/02_build.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +SRC_DIR=$(pwd) + +. ../../common.sh + +cd $WORK_DIR/overlay/ncurses + +DESTDIR="$PWD/ncurses_installed" + +# Change to the ncurses source directory which ls finds, e.g. 'ncurses-6.0'. +cd $(ls -d ncurses-*) + +echo "Preparing ncurses work area. This may take a while..." +make -j $NUM_JOBS clean + +rm -rf $DESTDIR + +# Remove static library +sed -i '/LIBTOOL_INSTALL/d' c++/Makefile.in +# http://www.linuxfromscratch.org/lfs/view/development/chapter06/ncurses.html + +# Configure Ncurses +echo "Configuring Ncurses..." +./configure \ + --prefix=/usr \ + --with-termlib \ + --with-shared \ + --with-terminfo-dirs=/lib/terminfo \ + --with-default-terminfo-dirs=/lib/terminfo \ + --without-normal \ + --without-debug \ + --without-cxx-binding \ + --with-abi-version=5 \ + CFLAGS="-Os -s -fno-stack-protector -U_FORTIFY_SOURCE" \ + CPPFLAGS="-P" + +# Most configuration switches are from AwlsomeAlex +# https://github.com/AwlsomeAlex/AwlsomeLinux/blob/59d59730703b058081a2371076a807590cacb31e/src/overlay_ncurses.sh + +# CPPFLAGS fixes a bug with Ubuntu 16.04 +# https://trac.sagemath.org/ticket/19762 + +echo "Building ncurses..." +make -j $NUM_JOBS + +echo "Installing ncurses..." +make -j $NUM_JOBS install DESTDIR=$DESTDIR + +echo "Reducing ncurses size..." +strip -g $DESTDIR/usr/bin/* + +ROOTFS="$WORK_DIR/src/minimal_overlay/rootfs" + +cp -r $DESTDIR/usr/* $ROOTFS + +echo "ncurses has been installed." + +cd $SRC_DIR + diff --git a/src/minimal_overlay/bundles/ncurses/bundle.sh b/src/minimal_overlay/bundles/ncurses/bundle.sh new file mode 100644 index 000000000..6284178ab --- /dev/null +++ b/src/minimal_overlay/bundles/ncurses/bundle.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +SRC_DIR=$(pwd) + +time sh 01_get.sh +time sh 02_build.sh + +cd $SRC_DIR +