allow fixing timestamps when building ext4 filesystem

When building an image, make_ext4fs currently sets the timestamps in
the image to the timestamps of the source files.  Allow this time to
be overridden with a fixed value provided on the command line, to make
it easier to reproduce bit-identical images from a target_files zip.

Change-Id: I52ddab4575a334ee52404f4d5d1c61b55513c618
diff --git a/ext4_utils/mkuserimg.sh b/ext4_utils/mkuserimg.sh
index c44129e..6ef0294 100755
--- a/ext4_utils/mkuserimg.sh
+++ b/ext4_utils/mkuserimg.sh
@@ -1,11 +1,11 @@
-#!/bin/bash -x
+#!/bin/bash
 #
 # To call this script, make sure make_ext4fs is somewhere in PATH
 
 function usage() {
 cat<<EOT
 Usage:
-mkuserimg.sh [-s] SRC_DIR OUTPUT_FILE EXT_VARIANT MOUNT_POINT SIZE [FILE_CONTEXTS]
+mkuserimg.sh [-s] SRC_DIR OUTPUT_FILE EXT_VARIANT MOUNT_POINT SIZE [-T TIMESTAMP] [FILE_CONTEXTS]
 EOT
 }
 
@@ -17,7 +17,7 @@
   shift
 fi
 
-if [ $# -ne 5 -a $# -ne 6 ]; then
+if [ $# -lt 5 -o $# -gt 8 ]; then
   usage
   exit 1
 fi
@@ -32,7 +32,14 @@
 EXT_VARIANT=$3
 MOUNT_POINT=$4
 SIZE=$5
-FC=$6
+shift; shift; shift; shift; shift
+
+TIMESTAMP=-1
+if [[ "$1" == "-T" ]]; then
+  TIMESTAMP=$2
+  shift; shift
+fi
+FC=$1
 
 case $EXT_VARIANT in
   ext4) ;;
@@ -53,7 +60,7 @@
     FCOPT="-S $FC"
 fi
 
-MAKE_EXT4FS_CMD="make_ext4fs $ENABLE_SPARSE_IMAGE $FCOPT -l $SIZE -a $MOUNT_POINT $OUTPUT_FILE $SRC_DIR"
+MAKE_EXT4FS_CMD="make_ext4fs $ENABLE_SPARSE_IMAGE -T $TIMESTAMP $FCOPT -l $SIZE -a $MOUNT_POINT $OUTPUT_FILE $SRC_DIR"
 echo $MAKE_EXT4FS_CMD
 $MAKE_EXT4FS_CMD
 if [ $? -ne 0 ]; then