From 651f6905c70b201c4fb929db1e60ebcf39b98b0d Mon Sep 17 00:00:00 2001 From: Michael McMahon Date: Mon, 13 Nov 2017 17:22:47 -0500 Subject: [PATCH] Create 01-get.sh --- src/minimal_overlay/bundles/nano/01-get.sh | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/minimal_overlay/bundles/nano/01-get.sh diff --git a/src/minimal_overlay/bundles/nano/01-get.sh b/src/minimal_overlay/bundles/nano/01-get.sh new file mode 100644 index 000000000..daae2653a --- /dev/null +++ b/src/minimal_overlay/bundles/nano/01-get.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +SRC_DIR=$(pwd) + +. ../../common.sh + +# Grab everything after the '=' character. +DOWNLOAD_URL=$(grep -i NANO_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 nano source bundle file. The '-c' option allows the download to resume. + echo "Downloading nano source bundle from $DOWNLOAD_URL" + wget -c $DOWNLOAD_URL +else + echo "Using local nano source bundle $MAIN_SRC_DIR/source/overlay/$ARCHIVE_FILE" +fi + +# Delete folder with previously extracted nano. +echo "Removing nano work area. This may take a while..." +rm -rf $WORK_DIR/overlay/nano +mkdir $WORK_DIR/overlay/nano + +# Extract nano to folder 'work/overlay/nano'. +# Full path will be something like 'work/overlay/nano/nano-2.8.7'. +tar -xvf $ARCHIVE_FILE -C $WORK_DIR/overlay/nano + +cd $SRC_DIR