unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Ricardo Wurmus <rekado@elephly.net>
To: Timothy Sample <samplet@ngyro.com>
Cc: 33922@debbugs.gnu.org
Subject: bug#33922: failing git-annex build
Date: Sat, 12 Jan 2019 08:42:20 +0100	[thread overview]
Message-ID: <87muo6nwyr.fsf@elephly.net> (raw)
In-Reply-To: <87ftuazoz5.fsf@ngyro.com>


Hi Tim,

thanks for the patch.

> From bb29ee8ccc656b86039127b31fd8b79533927053 Mon Sep 17 00:00:00 2001
> From: Timothy Sample <samplet@ngyro.com>
> Date: Wed, 2 Jan 2019 16:40:48 -0500
> Subject: [PATCH] gnu: ghc: Sort packages before writing binary cache.
>
> This improves the reproducibility of packages built with the Haskell
> build system.
>
> * gnu/packages/haskell.scm (ghc)[arguments]: Add a phase that patches
> 'ghc-pkg' so that it sorts packages before generating a binary cache.

Okay.

> +         ;; This phase patches the 'ghc-pkg' command so that it sorts
> +         ;; the list of packages in the binary cache it generates.
> +         (add-after 'unpack 'patch-ghc-pkg
> +           (lambda _
> +             (substitute* "utils/ghc-pkg/Main.hs"
> +               (("import Data.List")
> +                (string-append "import Data.List\n"
> +                               "import Data.Ord (comparing)"))
> +               (("pkgsCabalFormat = packages db")
> +                (string-append "pkgsCabalFormat = sortBy"
> +                               " (comparing (display . installedUnitId))"
> +                               " (packages db)")))))

This sorts the list “pkgsCabalFormat” in “updateDBCache” by the display
value of the “installedUnitId” field of each package.  According to the
documentation at [1], the UnitId type has an Ord instance, so you
probably don’t need “display”; you don’t need to sort strings but can
sort the UnitId values directly.

[1]: https://www.haskell.org/cabal/release/latest/doc/API/Cabal/Distribution-Types-UnitId.html#t:UnitId

I’m not sure about using installedUnitId here.  Is this field unique?
“sourcePackageId” is the combination of package name and version.  I
don’t understand the UnitId documentation, so I can’t say if that value
is any better.

I wonder if it would be better to sort the result of
“getDirectoryContents” instead.  As far as I understand, this is the
cause of non-determinism here.  The function “readParseDatabase” (which
contains the “getDirectoryContents” call) is used in multiple places
throughout “ghc-pkg/Main.hs”.

The most appropriate line to modify would then be this:

    confs = map (path </>) $ filter (".conf" `isSuffixOf`) fs

where “fs” is the list of FilePath values (strings).  I think you can
just do this:

    confs = map (path </>) $ filter (".conf" `isSuffixOf`) (sort fs)

because “fs” is of type [FilePath], which is [String], which is sortable
via “sort” as String has an Ord instance.

What do you think?

--
Ricardo

  parent reply	other threads:[~2019-01-12  7:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87h8evvjr2.fsf@kyleam.com>
     [not found] ` <87bm53gs9w.fsf@elephly.net>
2019-01-02 22:14   ` bug#33922: failing git-annex build Timothy Sample
2019-01-05 20:12     ` Kyle Meyer
2019-01-12  7:42     ` Ricardo Wurmus [this message]
2019-01-12 15:54       ` Timothy Sample
2019-01-15 18:48         ` Timothy Sample
2019-01-17 17:33           ` Ricardo Wurmus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87muo6nwyr.fsf@elephly.net \
    --to=rekado@elephly.net \
    --cc=33922@debbugs.gnu.org \
    --cc=samplet@ngyro.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).