summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJin Qian <jinqian@google.com>2017-08-28 17:28:49 -0700
committerTao Bao <tbao@google.com>2017-09-27 14:48:26 -0700
commit18a2974d6cf3c26ec82cb0b660f9a322369cadb6 (patch)
treeaed6d14adf91461528e5787b1a52038cbfc5099a
parent98e42725761e4df326851f08a491f553619debdf (diff)
downloadextras-18a2974d6cf3c26ec82cb0b660f9a322369cadb6.tar.gz
ext4_utils: make file system image reproducible
Add flags to set filesystem uuid, hash_seed and mke2fs time. Bug: 64994964 Change-Id: I38369a3a9dfffefead11c4b8fdd1e6984e61b938 (cherry picked from commit 407a7de4c499ede24dbbeb22d2efe6490a974b0d)
-rwxr-xr-xext4_utils/mkuserimg_mke2fs.sh35
1 files changed, 30 insertions, 5 deletions
diff --git a/ext4_utils/mkuserimg_mke2fs.sh b/ext4_utils/mkuserimg_mke2fs.sh
index 64b1fe3f..ea73ff70 100755
--- a/ext4_utils/mkuserimg_mke2fs.sh
+++ b/ext4_utils/mkuserimg_mke2fs.sh
@@ -8,7 +8,8 @@ Usage:
mkuserimg.sh [-s] SRC_DIR OUTPUT_FILE EXT_VARIANT MOUNT_POINT SIZE [-j <journal_size>]
[-T TIMESTAMP] [-C FS_CONFIG] [-D PRODUCT_OUT] [-B BLOCK_LIST_FILE]
[-d BASE_ALLOC_FILE_IN ] [-A BASE_ALLOC_FILE_OUT ] [-L LABEL]
- [-i INODES ] [-e ERASE_BLOCK_SIZE] [-o FLASH_BLOCK_SIZE] [FILE_CONTEXTS]
+ [-i INODES ] [-e ERASE_BLOCK_SIZE] [-o FLASH_BLOCK_SIZE]
+ [-U MKE2FS_UUID] [-S MKE2FS_HASH_SEED] [FILE_CONTEXTS]
EOT
}
@@ -17,6 +18,7 @@ BLOCKSIZE=4096
MKE2FS_OPTS=""
MKE2FS_EXTENDED_OPTS=""
E2FSDROID_OPTS=""
+E2FSPROGS_FAKE_TIME=""
if [ "$1" = "-s" ]; then
MKE2FS_EXTENDED_OPTS+="android_sparse"
@@ -53,6 +55,7 @@ fi
if [[ "$1" == "-T" ]]; then
E2FSDROID_OPTS+=" -T $2"
+ E2FSPROGS_FAKE_TIME=$2
shift; shift
fi
@@ -108,6 +111,19 @@ if [[ "$1" == "-o" ]]; then
shift; shift
fi
+if [[ "$1" == "-U" ]]; then
+ MKE2FS_OPTS+=" -U $2"
+ shift; shift
+fi
+
+if [[ "$1" == "-S" ]]; then
+ if [[ $MKE2FS_EXTENDED_OPTS ]]; then
+ MKE2FS_EXTENDED_OPTS+=","
+ fi
+ MKE2FS_EXTENDED_OPTS+="hash_seed=$2"
+ shift; shift
+fi
+
if [[ $MKE2FS_EXTENDED_OPTS ]]; then
MKE2FS_OPTS+=" -E $MKE2FS_EXTENDED_OPTS"
fi
@@ -141,16 +157,25 @@ SIZE=$((SIZE / BLOCKSIZE))
# truncate output file since mke2fs will keep verity section in existing file
cat /dev/null >$OUTPUT_FILE
+MAKE_EXT4FS_ENV="MKE2FS_CONFIG=./system/extras/ext4_utils/mke2fs.conf"
+if [[ $E2FSPROGS_FAKE_TIME ]]; then
+ MAKE_EXT4FS_ENV+=" E2FSPROGS_FAKE_TIME=$E2FSPROGS_FAKE_TIME"
+fi
+
MAKE_EXT4FS_CMD="mke2fs $MKE2FS_OPTS -t $EXT_VARIANT -b $BLOCKSIZE $OUTPUT_FILE $SIZE"
-echo $MAKE_EXT4FS_CMD
-MKE2FS_CONFIG=./system/extras/ext4_utils/mke2fs.conf $MAKE_EXT4FS_CMD
+echo $MAKE_EXT4FS_ENV $MAKE_EXT4FS_CMD
+env $MAKE_EXT4FS_ENV $MAKE_EXT4FS_CMD
if [ $? -ne 0 ]; then
exit 4
fi
+if [[ $E2FSPROGS_FAKE_TIME ]]; then
+ E2FSDROID_ENV="E2FSPROGS_FAKE_TIME=$E2FSPROGS_FAKE_TIME"
+fi
+
E2FSDROID_CMD="e2fsdroid $E2FSDROID_OPTS -f $SRC_DIR -a $MOUNT_POINT $OUTPUT_FILE"
-echo $E2FSDROID_CMD
-$E2FSDROID_CMD
+echo $E2FSDROID_ENV $E2FSDROID_CMD
+env $E2FSDROID_ENV $E2FSDROID_CMD
if [ $? -ne 0 ]; then
rm -f $OUTPUT_FILE
exit 4