Add PNOR version to metadata file

Get the PNOR version from the VERSION partition and add to the
metadata file. The version will be used to compute the PNOR id
and set the version property.

Change-Id: I5081964c3238c1a2f1f45949bbdd629ab92f35ef
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/generate-squashfs b/generate-squashfs
index 14515e4..4c53290 100755
--- a/generate-squashfs
+++ b/generate-squashfs
@@ -50,8 +50,10 @@
 # Needed to get the READONLY and PRESERVED flags
 # TODO: Get READONLY and PRESERVED flags from pflash instead.
 pflash --partition=part --read=${scratch_dir}/part -F ${pnorfile}
-
+pflash --partition=VERSION --read=${scratch_dir}/VERSION -F ${pnorfile}
 {
+  version=$(head -n 1 ${scratch_dir}/VERSION)
+  echo "version=$version"
   while read line; do
     if [[ $line == "ID="* ]]; then
         # This line looks like
@@ -81,7 +83,8 @@
         # Save the partition name
         partitions+=(${fields[1]})
     fi
-  done < <(pflash --info -F ${pnorfile} | grep -v -i "part")
+  # Don't need part, version, or backup_part partitions
+  done < <(pflash --info -F ${pnorfile} | grep -v -i "part\|version")
 } > ${scratch_dir}/${tocfile}
 
 for partition in "${partitions[@]}"; do