Notes for khronos-opengl-man4 - reproducible builds result

Version annotated: 1.0~svn31251-1
Bugs noted: 823452P: "opengl-4-html-doc: please make the build reproducible (randomness)"
823453P: "khronos-opengl-man4: get-orig-source should use a peg revision"
Comments: The -doc package's HTML index is unreproducible: the order of the keys 'glMemoryBarrier' and 'memoryBarrier' differs.

The index is generated by html/makeindex.py¹.
It is sorted case-insensitively (see 'key=str.lower' argument on line 241),
and 'gl' prefixes are removed prior to sorting (see makeKey()) — that's why glMemoryBarrier is in the M's.

The relevant codepath is genDict() [callsite on line 310] → sortedKeys() → list.sort().
While list.sort() is a stable sort, the list prior to sorting contains the keys in the order
dict.keys() provides them (where the local variable 'dict' is the global variable 'refIndex', not __builtins__.dict);
since refIndex is a __builtins__.dict, its .keys() method returns keys in an unpredictable order.

The fix would be to make sortedKeys() sort refIndex's keys deterministically, e.g.,
by changing line 236 to «for key in sorted(dict.keys()):» (a case-sensitive sort, unlike
the one later in the function, since the dict will contain keys that are equal up to
case: 'memoryBarrier' and 'MemoryBarrier'), or by changing line 241 to
use «key=lambda dictkey: (dictkey.lower(), dictkey)».

Note that using OrderedDict by itself won't suffice, since the keys are
added in os.listdir() order, i.e., in readdir() order.

Note: since the root problem is dependency on both readdir() and dict iteration order, this
problem is non-deterministic.

¹ https://sources.debian.net/src/khronos-opengl-man4/1.0~svn31251-1/html/makeindex.py/

----

Separate issue (#823453): the 'get-orig-source' debian/rules target may bitrot.
 

Our notes about issues affecting packages are stored in notes.git and are targeted at packages in Debian in 'unstable/amd64' (unless they say otherwise).