dannyp11 / squashfs4.3

This fork adds -no-date option that makes mksquashfs create squash file with no make date info. Thus, if the content stays the same, result squash file has the same cksum
GNU General Public License v2.0
3 stars 4 forks source link

Sync with upstream branch #1

Open ajette opened 5 years ago

ajette commented 5 years ago

Have you considered submitting this upstream? It looks like right now the merge would be painful because I think you originally cloned off of sourceforge and there are some spacing issues. I think your changes, which is such a simple code change but so incredibly useful, can be generally represented against https://github.com/plougher/squashfs-tools with:

diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
index d696a51..d5a369f 100644
--- a/squashfs-tools/mksquashfs.c
+++ b/squashfs-tools/mksquashfs.c
@@ -100,6 +100,7 @@ int old_exclude = TRUE;
 int use_regex = FALSE;
 int nopad = FALSE;
 int exit_on_error = FALSE;
+int no_date = FALSE;
 static off_t squashfs_start_offset = 0;

 long long global_uid = -1, global_gid = -1;
@@ -3113,7 +3114,7 @@ void dir_scan(squashfs_inode *inode, char *pathname,
                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 = (!no_date)? time(NULL) : 0;
                buf.st_dev = 0;
                buf.st_ino = 0;
                dir_ent->inode = lookup_inode2(&buf, PSEUDO_FILE_OTHER, 0);
@@ -3556,7 +3557,7 @@ void dir_scan2(struct dir_info *dir, struct pseudo *pseudo)
                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 = (!no_date)? time(NULL) : 0;
                buf.st_ino = pseudo_ino ++;

                if(pseudo_ent->dev->type == 'd') {
@@ -5565,6 +5566,12 @@ print_compressor_options:
                else if(strcmp(argv[i], "-keep-as-directory") == 0)
                        keep_as_directory = TRUE;

+               else if (strcmp(argv[i], "-no-date") == 0) {
+                       no_date = TRUE;
+                       delete = TRUE;
+                       no_fragments = TRUE;
+               }
+
                else if(strcmp(argv[i], "-exit-on-error") == 0)
                        exit_on_error = TRUE;

@@ -5620,6 +5627,9 @@ printOptions:
                        ERROR("\t\t\tdirectory containing that directory, "
                                "rather than the\n");
                        ERROR("\t\t\tcontents of the directory\n");
+                       ERROR("-no-date\t\tdo not store the date in the squash file\n");
+                       ERROR("\t\t\t(-noappend and -no-fragments is also activated)\n");
+                       ERROR("\t\t\tthis way, the squash always has the same cksum\n");
                        ERROR("\nFilesystem filter options:\n");
                        ERROR("-p <pseudo-definition>\tAdd pseudo file "
                                "definition\n");
@@ -6048,7 +6058,7 @@ printOptions:
        sBlk.flags = SQUASHFS_MKFLAGS(noI, noD, noF, noX, noId, no_fragments,
                always_use_fragments, duplicate_checking, exportable,
                no_xattrs, comp_opts);
-       sBlk.mkfs_time = time(NULL);
+       sBlk.mkfs_time = (!no_date) ? time(NULL) : 0;

        disable_info();
drieks commented 5 years ago

kernel.org is the correct upstream