script to dump RO and RW VPDs into /var/log/vpd-log.conf.

This work originally is done in src/platform/init/vpd-log.conf.
But somehow OOBE OEM customization code needs to read the log file in the
begin of OOBE, we extract this function into a standalone script for
chromeos_startup to call.

More CLs will follow up this change.

Change-Id: I107a2a6c44ec6b4dee4de2c1b8b45cca846dd6fe

BUG=chromium-os:12355
TEST=Tested on machine.

Review URL: http://codereview.chromium.org/6676022
(cherry picked from commit c2452fce2a7a6246ca2980dc2f29916392165748)

R=dpolukhin@chromium.org

Review URL: http://codereview.chromium.org/6683041
diff --git a/util/dump_vpd_log b/util/dump_vpd_log
new file mode 100755
index 0000000..d97bb6e
--- /dev/null
+++ b/util/dump_vpd_log
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# Helper function to dump VPD RO/RW content into /var/log/vpd_2.0.txt
+#
+# Used in:
+#  + OOBE reads this log file for the default locale setting.
+#  + chrome://system reads this log file.
+#
+TMP="/tmp/vpd_2.0.txt"
+VPD_2_0="/var/log/vpd_2.0.txt"
+
+if [ "$1" = "--force" ]; then
+  force=1
+else
+  force=0
+fi
+
+# Since we don't change the VPD data too often, only create the log file
+# if it does not exist.
+if [ ! -f $VPD_2_0 -o $force -eq 1 ]; then
+  rm -f $TMP
+  (vpd -i "RO_VPD" -l || echo "RO VPD execute error.") >> $TMP
+  (vpd -i "RW_VPD" -l || echo "RW VPD execute error.") >> $TMP
+  chmod go-stwx $TMP
+  mv -f $TMP $VPD_2_0
+fi
+