Gitian builds: use 'sort' in deterministic way #4274

issue gdm85 opened this issue on June 2, 2014
  1. gdm85 commented at 8:46 PM on June 2, 2014: contributor

    I have come to a solution to the first of my issues with a deterministic build in LXC containers: while trying to figure out why the source archive would have a different hash, I noticed that the sort output of the VirtualBox VM would differ from the sort output of the LXC container VM. See this gist.

    The solution is fairly simple: instead of sort, use numeric sorting + stable:

    sort -n -s
    

    From the man page:

      -n, --numeric-sort
                  compare according to string numerical value
      -s, --stable
                  stabilize sort by disabling last-resort comparison
    

    With my testcase (connecting via ssh and doing a sort) using these 2 options gave me same results on both LXC and VM.

    The change needs to be applied to the gitian-linux.yml (and actually everywhere else the sort command is being used!), and yes - it will change the hashes, but for the better of determinism.

  2. gdm85 commented at 10:50 PM on June 2, 2014: contributor

    IRC user coryfields is helping me to troubleshoot this issue, trying to correlate it with potential locale problems. In this regard, I think the guide should better not advise to choose any locale/timezone during the host installation, or better a bug in separate project gitian-builder could be submitted to pretend that LXC environments never get polluted from parent

  3. laanwj added the label Build system on Jun 3, 2014
  4. laanwj commented at 6:38 AM on June 3, 2014: member

    Yes, good point on using a locale independent sort everywhere. I already stumbled on that once but solved it some other way.

    Can you submit this as a pull?

  5. gdm85 commented at 6:48 AM on June 3, 2014: contributor

    @laanwj sure, let me couple this with a docs fix for #4269 in a single PR

  6. gdm85 cross-referenced this on Jun 3, 2014 from issue A few documentation fixes + added link to my Docker/LXC gitian-builder guide by gdm85
  7. gdm85 commented at 9:55 AM on June 3, 2014: contributor

    the docs fix is in that PR, let me know if we still want a commit for deterministic sort. It will help developers, but has surely less importance than the LC_* pollution issue.

  8. gdm85 commented at 5:05 AM on June 11, 2014: contributor

    I am closing this since https://github.com/devrandom/gitian-builder/issues/56 fixes this and other issues second a different approach

  9. gdm85 closed this on Jun 11, 2014

  10. bitcoin locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-20 06:55 UTC