#!/bin/sh global SRC_DIR := $[pwd] # Grab everything after the '=' character. global DOWNLOAD_URL := $[grep -i DROPBEAR_SOURCE_URL .config | cut -f2 -d'=] # Grab everything after the last '/' character. global ARCHIVE_FILE := $(DOWNLOAD_URL##*/) # Read the 'USE_LOCAL_SOURCE' property from '.config' global USE_LOCAL_SOURCE := $[grep -i USE_LOCAL_SOURCE .config | cut -f2 -d'=] if test $USE_LOCAL_SOURCE = "true" -a ! -f $SRC_DIR/source/overlay/$ARCHIVE_FILE { echo "Source bundle $SRC_DIR/source/overlay/$ARCHIVE_FILE is missing and will be downloaded." global USE_LOCAL_SOURCE := '"false'" } cd source/overlay if test ! $USE_LOCAL_SOURCE = "true" { # Downloading Dropbear source bundle file. The '-c' option allows the download to resume. echo "Downloading Links source bundle from $DOWNLOAD_URL" wget -c $DOWNLOAD_URL } else { echo "Using local Dropbear source bundle $SRC_DIR/source/overlay/$ARCHIVE_FILE" } # Delete folder with previously extracted Dropbear. echo "Removing Dropbear work area. This may take a while..." rm -rf ../../work/overlay/dropbear mkdir ../../work/overlay/dropbear # Extract Dropbear to folder 'work/overlay/dropbear'. # Full path will be something like 'work/overlay/dropbear/dropbear-2016.73'. tar -xvf $ARCHIVE_FILE -C ../../work/overlay/dropbear cd $SRC_DIR (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:SRC_DIR) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(pwd)})]) left_token: spids: [5 7] ) } spids: [4] ) ] spids: [4] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DOWNLOAD_URL) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(grep)} {(-i)} {(DROPBEAR_SOURCE_URL)} {(.config)}) (C {(cut)} {(-f2)} {(-d) (SQ <"=">)}) ] negated: False ) ] ) left_token: spids: [14 33] ) } spids: [13] ) ] spids: [13] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ARCHIVE_FILE) op: Equal rhs: { (BracedVarSub token: suffix_op: (StringUnary op_id:VOp1_DPound arg_word:{("*") (Lit_Slash /)}) spids: [40 45] ) } spids: [39] ) ] spids: [39] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:USE_LOCAL_SOURCE) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(grep)} {(-i)} {(USE_LOCAL_SOURCE)} {(.config)}) (C {(cut)} {(-f2)} {(-d) (SQ <"=">)}) ] negated: False ) ] ) left_token: spids: [53 72] ) ) } spids: [51] ) ] spids: [51] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(DQ ($ VSub_Name "$USE_LOCAL_SOURCE"))} {(Lit_Other "=")} {(DQ (true))} {(-a)} {(KW_Bang "!")} {(-f)} {($ VSub_Name "$SRC_DIR") (/source/overlay/) ($ VSub_Name "$ARCHIVE_FILE")} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(echo)} { (DQ ("Source bundle ") ($ VSub_Name "$SRC_DIR") (/source/overlay/) ($ VSub_Name "$ARCHIVE_FILE") (" is missing and will be downloaded.") ) } ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:USE_LOCAL_SOURCE) op: Equal rhs: {(DQ (false))} spids: [118] ) ] spids: [118] ) ] spids: [-1 104] ) ] spids: [-1 123] ) (C {(cd)} {(source/overlay)}) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(KW_Bang "!")} {(DQ ($ VSub_Name "$USE_LOCAL_SOURCE"))} {(Lit_Other "=")} {(DQ (true))} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(echo)} {(DQ ("Downloading Links source bundle from ") ($ VSub_Name "$DOWNLOAD_URL"))}) (C {(wget)} {(-c)} {($ VSub_Name "$DOWNLOAD_URL")}) ] spids: [-1 151] ) ] else_action: [ (C {(echo)} { (DQ ("Using local Dropbear source bundle ") ($ VSub_Name "$SRC_DIR") (/source/overlay/) ($ VSub_Name "$ARCHIVE_FILE") ) } ) ] spids: [172 184] ) (C {(echo)} {(DQ ("Removing Dropbear work area. This may take a while..."))}) (C {(rm)} {(-rf)} {(../../work/overlay/dropbear)}) (C {(mkdir)} {(../../work/overlay/dropbear)}) (C {(tar)} {(-xvf)} {($ VSub_Name "$ARCHIVE_FILE")} {(-C)} {(../../work/overlay/dropbear)}) (C {(cd)} {($ VSub_Name "$SRC_DIR")}) ] )