diff options
author | Rob Landley <rob@landley.net> | 2020-05-05 13:56:29 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2020-05-05 13:56:29 -0500 |
commit | 99dfb770358781d41c056aaf3569437002aa9e76 (patch) | |
tree | 84be9f57d9b7824a6cfe0b274d27a3554aa04aba /scripts/root/plumbing | |
parent | eae46378f7bfe5f39c717da8eac2a50230509342 (diff) | |
download | toybox-99dfb770358781d41c056aaf3569437002aa9e76.tar.gz |
Teach mkroot to cross compile additional packages, with dropbear as example.
scripts/mkroot.sh CROSS=sh4 LINUX=~/linux dropbear
No, I'm not going down the rathole of adding lots of packages, but this
shows _how_ to do it if you want to. The hooks are there. They don't have
to be in scripts/root, that's just a default search location, you can provide
a path on the command line or have them be in the $PATH.
Diffstat (limited to 'scripts/root/plumbing')
-rwxr-xr-x | scripts/root/plumbing | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/scripts/root/plumbing b/scripts/root/plumbing new file mode 100755 index 00000000..0bb735ee --- /dev/null +++ b/scripts/root/plumbing @@ -0,0 +1,45 @@ +#!/bin/echo run this from "make root" + +# Plumbing to download files + +[ -z "$ROOT" ] && echo "no" && exit 1 +mkdir -p "${DOWNLOAD:=$PWD/root_download}" || exit 1 + +### Functions to download, extract, and clean up after source packages. + +# Usage: download HASH URL +# Grabs source from URL confirming SHA1 hash (Basically == "wget $2") +# You can stick extracted source in $DOWNLOAD and build will use that instead +download() { + FILE="$(basename "$2")" + [ -d "$DOWNLOAD/${FILE/-*/}" ] && echo "$FILE" local && return 0 + X=0; while true; do + [ "$(sha1sum < "$DOWNLOAD/$FILE" 2>/dev/null)" == "$1 -" ] && + echo "$FILE" confirmed && break + rm -f $DOWNLOAD/${FILE/-[0-9]*/}-[0-9]* || break + [ $X -eq 0 ] && X=1 || exit 1 + wget "$2" -O "$DOWNLOAD/$FILE" + done +} + +# Usage: setupfor PACKAGE +# Extracts source tarball (or snapshot a repo) to create disposable build dir. +# Basically "tar xvzCf $MYBUILD $DOWNLOAD/$1.tar.gz && cd $NEWDIR" +setupfor() { + PACKAGE="$(basename "$1")" + announce "$PACKAGE" && cd "$MYBUILD" && rm -rf "$PACKAGE" || exit 1 + if [ -d "$DOWNLOAD/$PACKAGE" ]; then + cp -la "$DOWNLOAD/$PACKAGE/." "$PACKAGE" && cd "$PACKAGE" || exit 1 + else + tar xvaf "$DOWNLOAD/$PACKAGE"-*.t* && cd "$PACKAGE"-* || exit 1 + fi +} + +# Usage: cleanup +# Delete setupfor's dir, exiting if build failed (basically "rm -rf $PACKAGE") +cleanup() { + [ $? -ne 0 ] && exit 1 + [ -z "$PACKAGE" ] && exit 1 + [ ! -z "$NO_CLEANUP" ] && return + cd .. && rm -rf "$PACKAGE"* || exit 1 +} |