support/scripts: add generic genimage script
authorPhelip Etienne <etienne.phelip@savoirfairelinux.com>
Wed, 29 Mar 2017 14:51:17 +0000 (10:51 -0400)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Sat, 1 Apr 2017 13:50:22 +0000 (15:50 +0200)
This script is a wrapper for the genimage tool used by most boards.
The board postimage script can now call this script instead of invoking
genimage command themselves.

Signed-off-by: Etienne Phelip <etienne.phelip@savoirfairelinux.com>
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
support/scripts/genimage.sh [new file with mode: 0755]

diff --git a/support/scripts/genimage.sh b/support/scripts/genimage.sh
new file mode 100755 (executable)
index 0000000..0ed0e8b
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+die() {
+  echo "Error: $@" >&2
+  exit 1
+}
+
+GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
+
+while getopts c: OPT ; do
+       case "${OPT}" in
+       c) GENIMAGE_CFG="${OPTARG}";;
+       :) die "option '${OPTARG}' expects a mandatory argument\n";;
+       \?) die "unknown option '${OPTARG}'\n";;
+       esac
+done
+
+[ -n "${GENIMAGE_CFG}" ] || die "Missing argument"
+
+rm -rf "${GENIMAGE_TMP}"
+
+genimage \
+       --rootpath "${TARGET_DIR}"     \
+       --tmppath "${GENIMAGE_TMP}"    \
+       --inputpath "${BINARIES_DIR}"  \
+       --outputpath "${BINARIES_DIR}" \
+       --config "${GENIMAGE_CFG}"