Hi,
It seems like some effort has been put into this already, because i was
able
to build reproducible ISO files as long as i built them from the same
system.
However, when building from two different systems, one with glibc and
one with
musl, their different qsort implementations would sometimes affect the
output.
To debug this i wanted to reproduce it on a single system, so i wrote
the
following simple "qsort" which is very unstable. It's just an insertion
sort
that reverses all equal elements:
#include <stdint.h>
#include <string.h>
#include <stdio.h>
void qsort(void *base, size_t nel, size_t width, int (*compar)(const
void *, const void *)) {
char *array = base;
for (size_t i = 1; i < nel; ++i) {
char elem[4096];
memcpy(&elem[0], &array[i * width], width);
size_t curr = i;
do {
void *prev = &array[(curr - 1) * width];
if (compar(&elem[0], prev) > 0) break; // Would normally be
>=, but we don't want stability.
memcpy(&array[curr * width], prev, width);
} while(--curr > 0);
memcpy(&array[curr * width], &elem[0], width);
}
}
This allowed me to swap out the libc qsort with
LD_PRELOAD=./my_qsort.so
I could then reproduce the problem with the following xorriso command,
by
running it with and without my qsort:
SOURCE_DATE_EPOCH=0 TZ=UTC0 LC_ALL=C xorriso -as mkisofs -V TEST -o
test.iso --norock -graft-points "files=/usr/include/linux" --
-alter_date_r b =0 / --
This helped me find two issues which i have attempted to create patches
for.
Henrik Lindström (2):
Make ECMA-119 tree sorting deterministic
Make the filelist weight sort stable
libisofs/ecma119.c | 4 ++--
libisofs/ecma119_tree.c | 21 ++++++++++++++++++++-
libisofs/filesrc.c | 6 +++++-
libisofs/filesrc.h | 10 ++++++----
4 files changed, 33 insertions(+), 8 deletions(-)