From mboxrd@z Thu Jan 1 00:00:00 1970 From: Timothy Sample Subject: bug#33922: failing git-annex build Date: Sat, 12 Jan 2019 10:54:55 -0500 Message-ID: <87tvid98hc.fsf@ngyro.com> References: <87h8evvjr2.fsf@kyleam.com> <87bm53gs9w.fsf@elephly.net> <87ftuazoz5.fsf@ngyro.com> <87muo6nwyr.fsf@elephly.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([209.51.188.92]:35777) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1giLdk-0007IM-UQ for bug-guix@gnu.org; Sat, 12 Jan 2019 10:56:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1giLdj-0000Nw-Rh for bug-guix@gnu.org; Sat, 12 Jan 2019 10:56:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:57781) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1giLdi-0000NG-R7 for bug-guix@gnu.org; Sat, 12 Jan 2019 10:56:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1giLdi-0003KU-Fn for bug-guix@gnu.org; Sat, 12 Jan 2019 10:56:02 -0500 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <87muo6nwyr.fsf@elephly.net> (Ricardo Wurmus's message of "Sat, 12 Jan 2019 08:42:20 +0100") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Ricardo Wurmus Cc: 33922@debbugs.gnu.org Hi Ricardo, Ricardo Wurmus writes: > Hi Tim, > > thanks for the patch. > >> From bb29ee8ccc656b86039127b31fd8b79533927053 Mon Sep 17 00:00:00 2001 >> From: Timothy Sample >> 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 =3D packages db") >> + (string-append "pkgsCabalFormat =3D sortBy" >> + " (comparing (display . installedUnitId)= )" >> + " (packages db)"))))) > > This sorts the list =E2=80=9CpkgsCabalFormat=E2=80=9D in =E2=80=9CupdateD= BCache=E2=80=9D by the display > value of the =E2=80=9CinstalledUnitId=E2=80=9D field of each package. Ac= cording to the > documentation at [1], the UnitId type has an Ord instance, so you > probably don=E2=80=99t need =E2=80=9Cdisplay=E2=80=9D; you don=E2=80=99t = need to sort strings but can > sort the UnitId values directly. > > [1]: > https://www.haskell.org/cabal/release/latest/doc/API/Cabal/Distribution-T= ypes-UnitId.html#t:UnitId Whoops! I remember checking for an Ord instance, but I must of missed it. The documentation is embarrassingly clear. :p > I=E2=80=99m not sure about using installedUnitId here. Is this field uni= que? > =E2=80=9CsourcePackageId=E2=80=9D is the combination of package name and = version. I > don=E2=80=99t understand the UnitId documentation, so I can=E2=80=99t say= if that value > is any better. Based on what I see in the source code and in the cache files themselves, this is best field. However, I am just guessing and testing here. Discussion around this gets into territory I=E2=80=99m unfamiliar wi= th (I=E2=80=99ve never heard of a =E2=80=9CBackpack=E2=80=9D, for instance). > I wonder if it would be better to sort the result of > =E2=80=9CgetDirectoryContents=E2=80=9D instead. As far as I understand, = this is the > cause of non-determinism here. The function =E2=80=9CreadParseDatabase= =E2=80=9D (which > contains the =E2=80=9CgetDirectoryContents=E2=80=9D call) is used in mult= iple places > throughout =E2=80=9Cghc-pkg/Main.hs=E2=80=9D. > > The most appropriate line to modify would then be this: > > confs =3D map (path ) $ filter (".conf" `isSuffixOf`) fs > > where =E2=80=9Cfs=E2=80=9D is the list of FilePath values (strings). I t= hink you can > just do this: > > confs =3D map (path ) $ filter (".conf" `isSuffixOf`) (sort fs) > > because =E2=80=9Cfs=E2=80=9D is of type [FilePath], which is [String], wh= ich is sortable > via =E2=80=9Csort=E2=80=9D as String has an Ord instance. > > What do you think? I thought about this approach, but I was worried it wouldn=E2=80=99t be so = easy. What you suggest looks pretty straight-forward though. I will test everything with this approach and report back. If it works, I agree that it is better. Thanks for the careful review! -- Tim