diff options
author | John Crispin <john@openwrt.org> | 2015-12-11 15:07:15 +0000 |
---|---|---|
committer | John Crispin <john@openwrt.org> | 2015-12-11 15:07:15 +0000 |
commit | fd1c1b491828bb66eb2aa06b2c9f4a4e86ce661b (patch) | |
tree | 2caa409227f84f5368ca8ec5a338f158dc1a6aa6 | |
parent | 725fc09cec4c310d06ca17267775acc5c9aa4033 (diff) | |
download | mtk-20170518-fd1c1b491828bb66eb2aa06b2c9f4a4e86ce661b.zip mtk-20170518-fd1c1b491828bb66eb2aa06b2c9f4a4e86ce661b.tar.gz mtk-20170518-fd1c1b491828bb66eb2aa06b2c9f4a4e86ce661b.tar.bz2 |
tools/squashfs: add argument -fixed-time to set all timestamps
-fixed-time <timestamp> set mkfs-timestamp and file-mtime to this timestamp.
Reproducible builds requires the removal of all timestamp or setting all to a specific one.
Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
SVN-Revision: 47858
-rw-r--r-- | tools/squashfs/patches/120-add-fixed-timestamp-support.patch | 79 | ||||
-rw-r--r-- | tools/squashfs4/patches/200-add-fixed-timestamp-option.patch | 84 |
2 files changed, 163 insertions, 0 deletions
diff --git a/tools/squashfs/patches/120-add-fixed-timestamp-support.patch b/tools/squashfs/patches/120-add-fixed-timestamp-support.patch new file mode 100644 index 0000000..e2f4bb2 --- /dev/null +++ b/tools/squashfs/patches/120-add-fixed-timestamp-support.patch @@ -0,0 +1,79 @@ +--- a/squashfs-tools/mksquashfs.c ++++ b/squashfs-tools/mksquashfs.c +@@ -117,6 +117,9 @@ unsigned int inode_bytes = 0, inode_size + char *data_cache = NULL; + unsigned int cache_bytes = 0, cache_size = 0, inode_count = 0; + ++/* override all timestamps */ ++time_t fixed_time = -1; ++ + /* in memory directory data */ + #define I_COUNT_SIZE 128 + #define DIR_ENTRIES 32 +@@ -1554,6 +1557,11 @@ void dir_scan(squashfs_inode *inode, cha + perror(buffer); + return; + } ++ ++ /* override timestamp of lstat if fixed_time is given */ ++ if(fixed_time != -1) ++ inode_info->buf.st_mtime = fixed_time; ++ + if(sorted) + sort_files_and_write(dir_info); + dir_scan2(inode, dir_info); +@@ -1582,6 +1590,10 @@ struct dir_info *dir_scan1(char *pathnam + perror(buffer); + continue; + } ++ ++ if(fixed_time != -1) ++ buf.st_mtime = fixed_time; ++ + if(excluded(filename, &buf)) + continue; + +@@ -1621,6 +1633,9 @@ int dir_scan2(squashfs_inode *inode, str + char *dir_name = dir_ent->name; + unsigned int inode_number = ((buf->st_mode & S_IFMT) == S_IFDIR) ? dir_ent->inode->inode_number : dir_ent->inode->inode_number + dir_inode_no; + ++ if(fixed_time != -1) ++ buf->st_mtime = fixed_time; ++ + if(dir_ent->inode->inode == SQUASHFS_INVALID_BLK) { + switch(buf->st_mode & S_IFMT) { + case S_IFREG: +@@ -1898,6 +1913,16 @@ int main(int argc, char *argv[]) + exit(1); + } + } ++ } else if(strcmp(argv[i], "-fixed-time") == 0) { ++ if(++i == argc) { ++ ERROR("%s: -fixed-time missing a timestamp\n", argv[0]); ++ exit(1); ++ } ++ fixed_time = strtoll(argv[i], &b, 10); ++ if(*b != '\0') { ++ ERROR("%s: -fixed-time has an invalid number\n", argv[0]); ++ exit(1); ++ } + } else if(strcmp(argv[i], "-noI") == 0 || + strcmp(argv[i], "-noInodeCompression") == 0) + noI = TRUE; +@@ -1967,6 +1992,7 @@ printOptions: + ERROR("-all-root\t\tmake all files owned by root\n"); + ERROR("-force-uid uid\t\tset all file uids to uid\n"); + ERROR("-force-gid gid\t\tset all file gids to gid\n"); ++ ERROR("-fixed-time timestamp\tset all timestamps to timestamp\n"); + ERROR("-le\t\t\tcreate a little endian filesystem\n"); + ERROR("-be\t\t\tcreate a big endian filesystem\n"); + ERROR("-nopad\t\t\tdo not pad filesystem to a multiple of 4K\n"); +@@ -2190,7 +2216,7 @@ printOptions: + sBlk.block_size = block_size; + sBlk.block_log = block_log; + sBlk.flags = SQUASHFS_MKFLAGS(noI, noD, check_data, noF, no_fragments, always_use_fragments, duplicate_checking); +- sBlk.mkfs_time = time(NULL); ++ sBlk.mkfs_time = fixed_time != -1 ? fixed_time : time(NULL); + + restore_filesystem: + write_fragment(); diff --git a/tools/squashfs4/patches/200-add-fixed-timestamp-option.patch b/tools/squashfs4/patches/200-add-fixed-timestamp-option.patch new file mode 100644 index 0000000..7ac1765 --- /dev/null +++ b/tools/squashfs4/patches/200-add-fixed-timestamp-option.patch @@ -0,0 +1,84 @@ +Index: squashfs4.2/squashfs-tools/mksquashfs.c +=================================================================== +--- squashfs4.2.orig/squashfs-tools/mksquashfs.c ++++ squashfs4.2/squashfs-tools/mksquashfs.c +@@ -175,6 +175,9 @@ unsigned int cache_bytes = 0, cache_size + /* inode lookup table */ + squashfs_inode *inode_lookup_table = NULL; + ++/* override all timestamps */ ++time_t fixed_time = -1; ++ + /* in memory directory data */ + #define I_COUNT_SIZE 128 + #define DIR_ENTRIES 32 +@@ -2452,6 +2455,8 @@ again: + restat: + fstat(file, &buf2); + close(file); ++ if (fixed_time != -1) ++ buf2.st_mtime = fixed_time; + if(read_size != buf2.st_size) { + memcpy(buf, &buf2, sizeof(struct stat)); + file_buffer->error = 2; +@@ -3612,7 +3617,7 @@ void dir_scan(squashfs_inode *inode, cha + buf.st_mode = S_IRWXU | S_IRWXG | S_IRWXO | S_IFDIR; + buf.st_uid = getuid(); + buf.st_gid = getgid(); +- buf.st_mtime = time(NULL); ++ buf.st_mtime = fixed_time != -1 ? fixed_time : time(NULL); + buf.st_dev = 0; + buf.st_ino = 0; + dir_ent->inode = lookup_inode(&buf); +@@ -3623,6 +3628,8 @@ void dir_scan(squashfs_inode *inode, cha + pathname, strerror(errno)); + return; + } ++ if(fixed_time != -1) ++ buf.st_mtime = fixed_time; + dir_ent->inode = lookup_inode(&buf); + } + +@@ -3677,6 +3684,8 @@ struct dir_info *dir_scan1(char *pathnam + filename, strerror(errno)); + continue; + } ++ if(fixed_time != -1) ++ buf.st_mtime = fixed_time; + + if((buf.st_mode & S_IFMT) != S_IFREG && + (buf.st_mode & S_IFMT) != S_IFDIR && +@@ -3795,7 +3804,7 @@ struct dir_info *dir_scan2(struct dir_in + buf.st_gid = pseudo_ent->dev->gid; + buf.st_rdev = makedev(pseudo_ent->dev->major, + pseudo_ent->dev->minor); +- buf.st_mtime = time(NULL); ++ buf.st_mtime = fixed_time != -1 ? fixed_time : time(NULL); + buf.st_ino = pseudo_ino ++; + + if(pseudo_ent->dev->type == 'f') { +@@ -4674,6 +4683,15 @@ int main(int argc, char *argv[]) + progress = FALSE; + else if(strcmp(argv[i], "-no-exports") == 0) + exportable = FALSE; ++ else if(strcmp(argv[i], "-fixed-time") == 0) { ++ if((++i == argc) || (fixed_time = ++ strtoll(argv[i], &b, 10), *b != '\0')) { ++ ERROR("%s: -fixed-time missing or invalid " ++ "timestamp\n", argv[0]); ++ ++ exit(1); ++ } ++ } + else if(strcmp(argv[i], "-processors") == 0) { + if((++i == argc) || (processors = + strtol(argv[i], &b, 10), *b != '\0')) { +@@ -5314,7 +5332,7 @@ printOptions: + sBlk.flags = SQUASHFS_MKFLAGS(noI, noD, noF, noX, no_fragments, + always_use_fragments, duplicate_checking, exportable, + no_xattrs, comp_opts); +- sBlk.mkfs_time = time(NULL); ++ sBlk.mkfs_time = fixed_time != -1 ? fixed_time : time(NULL); + + restore_filesystem: + if(progress && estimated_uncompressed) { |