Untar tarball and check for squashfs file

Untar the tarball and then check for existence of
pnor.xz.squashfs file.
A PNOR SquashFS Tarball must have a pnor.xz.squashfs file.
A similar check is done is in the openpower item updater.

Change-Id: Id6e63ee088941044ecc22282bd5abd6358d17d87
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/generate-ubi b/generate-ubi
index 3f839f1..6299073 100755
--- a/generate-ubi
+++ b/generate-ubi
@@ -50,3 +50,21 @@
   fi
 fi
 
+echo "Generating PNOR UBI image."
+
+squashfs_file_name="pnor.xz.squashfs"
+
+# Scratch directory for untarring and config file
+scratch_dir=`mktemp -d`
+
+# Untar tarball
+tar -xvf ${tarball} -C ${scratch_dir} ${squashfs_file_name}
+
+# All valid PNOR SquashFS Tarballs have a file named "pnor.xz.squashfs"
+if [ ! -f "${scratch_dir}/${squashfs_file_name}" ]; then
+  echo "No \"${squashfs_file_name}\" file in the tarball!"
+  rm -r "${scratch_dir}"
+  exit 1
+fi
+
+rm -r "${scratch_dir}"