summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xgenerate-ubi52
1 files changed, 52 insertions, 0 deletions
diff --git a/generate-ubi b/generate-ubi
new file mode 100755
index 000000000..3f839f115
--- /dev/null
+++ b/generate-ubi
@@ -0,0 +1,52 @@
+#!/bin/bash
+set -eo pipefail
+
+help=$'Generate PNOR UBI image from a PNOR SquashFS Tarball
+
+Generates a UBI, Unsorted Block Images, PNOR image from a PNOR SquashFS Tarball.
+The PNOR SquashFS Tarball is generated from the generate-squashfs script.
+
+usage: generate-ubi [OPTION] <PNOR SquashFS Tarball>...
+
+Options:
+ -f, --file <file> Specify destination file. Defaults to
+ `pwd`/<PNOR Tarball FILE, removing .squashfs.tar>.ubi.mtd
+ (For example, "generate-ubi my.pnor.squashfs.tar"
+ would generate `pwd`/my.pnor.ubi.mtd output.)
+ -h, --help Display this help text and exit.
+'
+
+while [[ $# -gt 0 ]]; do
+ key="$1"
+ case $key in
+ -f|--file)
+ outfile="$2"
+ shift 2
+ ;;
+ -h|--help)
+ echo "$help"
+ exit
+ ;;
+ *)
+ tarball="$1"
+ shift 1
+ ;;
+ esac
+done
+
+if [ ! -f "${tarball}" ]; then
+ echo "Please enter a PNOR SquashFS Tarball."
+ echo "To generate PNOR SquashFS Tarball see generate-squashfs"
+ echo "$help"
+ exit 1
+fi
+
+if [[ -z $outfile ]]; then
+ # Remove .squashfs.tar from end if present and add .ubi.mtd
+ outfile=`pwd`/${tarball%".squashfs.tar"}.ubi.mtd
+else
+ if [[ $outfile != /* ]]; then
+ outfile=`pwd`/$outfile
+ fi
+fi
+
OpenPOWER on IntegriCloud