generate-squashfs: output file name improvements
Changes the behavior of generate-squashfs to generate a default
output file name based on the input file if no output file is
specified. Also adds support for relative output file paths.
Resolves openbmc/openbmc#1760
Change-Id: Ib46d8d1ca9f54c937c0475b7dd90b0cb2b5a8a71
Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
diff --git a/generate-squashfs b/generate-squashfs
index 4a82b40..0bb112e 100755
--- a/generate-squashfs
+++ b/generate-squashfs
@@ -11,13 +11,15 @@
Options:
-f, --file <file> Specify destination file. Defaults to
- `pwd`/pnor.squashfs.tar if unspecified.
+ `pwd`/<PNOR FILE>.pnor.squashfs.tar if unspecified.
+ (For example, "generate-squashfs my.pnor" would
+ generate `pwd`/my.pnor.squashfs.tar output.)
-h, --help Display this help text and exit.
'
let ffs_entry_size=128
let miscflags_offset=112
-outfile=`pwd`"/pnor.squashfs.tar"
+outfile=""
declare -a partitions=()
tocfile="pnor.toc"
@@ -45,6 +47,18 @@
exit 1
fi
+if [[ -z $outfile ]]; then
+ if [[ ${pnorfile##*.} == "pnor" ]]; then
+ outfile=`pwd`/${pnorfile##*/}.squashfs.tar
+ else
+ outfile=`pwd`/${pnorfile##*/}.pnor.squashfs.tar
+ fi
+else
+ if [[ $outfile != /* ]]; then
+ outfile=`pwd`/$outfile
+ fi
+fi
+
scratch_dir=`mktemp -d`
echo "Parsing PNOR TOC..."