support/misc/relocate-sdk.sh: allow relocating to any directory

Currently, relocate-sdk.sh must be run _after_ relocating the SDK. There
are cases where it is useful to already prepare the SDK _before_
relocating. For example, it allows to prepare a tarball that the user
has to extract to a specific, pre-defined location and nothing more than
that, which is simpler for the user than requiring the script to be run.
In addition, it hides the build directory that was used by the SDK
builder (somewhat).

Add an optional argument to relocate-sdk.sh that gives the target
directory.

Signed-off-by: Gleb Mazovetskiy <glex.spb@gmail.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
This commit is contained in:
Gleb Mazovetskiy 2020-03-28 23:49:44 +00:00 committed by Arnout Vandecappelle (Essensium/Mind)
parent 9d7abbfed8
commit dd8f8f8e89

View File

@ -1,15 +1,20 @@
#!/bin/sh #!/bin/sh
#
if [ "$#" -ne 0 ]; then if [ "$#" -gt 1 ]; then
echo "Run this script to relocate the buildroot SDK at that location" echo "Usage: $0 [path]"
echo "Run this script to relocate the buildroot SDK to the current location"
echo "If [path] is given, sets the location to [path] (without moving it)"
exit 1 exit 1
fi fi
LOCFILE="share/buildroot/sdk-location" cd "$(dirname "$(readlink -f "$0")")"
FILEPATH="$(readlink -f "$0")" if [ "$#" -eq 1 ]; then
NEWPATH="$(dirname "${FILEPATH}")" NEWPATH="$1"
else
NEWPATH="${PWD}"
fi
cd "${NEWPATH}" LOCFILE="share/buildroot/sdk-location"
if [ ! -r "${LOCFILE}" ]; then if [ ! -r "${LOCFILE}" ]; then
echo "Previous location of the buildroot SDK not found!" echo "Previous location of the buildroot SDK not found!"
exit 1 exit 1