From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: bug#33922: failing git-annex build Date: Sat, 12 Jan 2019 08:42:20 +0100 Message-ID: <87muo6nwyr.fsf@elephly.net> References: <87h8evvjr2.fsf@kyleam.com> <87bm53gs9w.fsf@elephly.net> <87ftuazoz5.fsf@ngyro.com> 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]:41069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1giDwd-0000v8-FG for bug-guix@gnu.org; Sat, 12 Jan 2019 02:43:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1giDwc-0006rD-CP for bug-guix@gnu.org; Sat, 12 Jan 2019 02:43:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:57208) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1giDwc-0006qu-3U for bug-guix@gnu.org; Sat, 12 Jan 2019 02:43:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1giDwb-0002BY-Vc for bug-guix@gnu.org; Sat, 12 Jan 2019 02:43:01 -0500 Sender: "Debbugs-submit" Resent-Message-ID: In-reply-to: <87ftuazoz5.fsf@ngyro.com> 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: Timothy Sample Cc: 33922@debbugs.gnu.org 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=9CupdateDBC= ache=E2=80=9D by the display value of the =E2=80=9CinstalledUnitId=E2=80=9D field of each package. Acco= rding 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 ne= ed to sort strings but can sort the UnitId values directly. [1]: https://www.haskell.org/cabal/release/latest/doc/API/Cabal/Distributio= n-Types-UnitId.html#t:UnitId I=E2=80=99m not sure about using installedUnitId here. Is this field uniqu= e? =E2=80=9CsourcePackageId=E2=80=9D is the combination of package name and ve= rsion. I don=E2=80=99t understand the UnitId documentation, so I can=E2=80=99t say i= f that value is any better. I wonder if it would be better to sort the result of =E2=80=9CgetDirectoryContents=E2=80=9D instead. As far as I understand, th= is 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 multip= le 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 thi= nk 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], whic= h is sortable via =E2=80=9Csort=E2=80=9D as String has an Ord instance. What do you think? -- Ricardo