I have a folder which i want to create tgz file and compute its sha256:
The folder is converted to tgz using following command
"tar -c -C #{Shellwords.escape dir} #{Shellwords.escape basename} " \
"--owner=0 --group=0 --mtime='2000-01-01 00:00:00' | gzip -n > #{Shellwords.escape file}"
Now i ran the above process using 2 separate users and it gave me 2 files: 1 and 2
Both tgz files differ in sizes:
-rw-r--r--@ 1 myuser \Domain Users 9024 Jul 31 14:28 1.tgz
-rw-r--r--@ 1 myuser \Domain Users 9037 Jul 31 14:29 2.tgz
If i try to compute diff between files i dont see any diff.Diff was obtained using following command.
diff <(tar -tvf 1.tgz | sort) <(tar -tvf 2.tgz | sort)
If i compute sha256 using ruby of these 2 files , then it differs.
The question is : Why do i get difference in tgz files when running from diffenrent users.
EDIT: After reading the comments and some googling i found that the order in which the files are added is not fixed everytime.
see this https://reproducible-builds.org/docs/archives/#file-ordering.
I will try this and add details.