packages: Better preserve object identity when rewriting.
authorLudovic Courtès <ludo@gnu.org>
Tue, 20 Oct 2020 07:18:07 +0000 (09:18 +0200)
committerLudovic Courtès <ludo@gnu.org>
Tue, 20 Oct 2020 14:30:15 +0000 (16:30 +0200)
commit8db4ebb0cd9bfdcf1aea63eb8d20eb6af0c87c93
tree8510a314aad6e64e3709ba231ecb13d7959549cf
parent2bd60ca1fb1b3a830ee644369b9a7f8c8b5d0404
packages: Better preserve object identity when rewriting.

Fixes a bug whereby the presence of propagated inputs could lead to two
non-eq? but actually equal packages in a bag's inputs.  The problem
would manifest itself when running, for instance:

  guix build inkscape -d --with-graft=glib=glib-networking --no-grafts

The resulting derivation would differ due from that without
'--with-graft'.  This was due to the fact that glib propagates libffi;
this instance of libffi was not rewritten even though other instances in
the graph were rewritten.  Thus, glib would end up with two non-eq?
libffi instances, which in turn would lead to duplicate entries in its
'%build-inputs' variable.

Fixes <https://bugs.gnu.org/43890>.

* guix/packages.scm (package-mapping)[rewrite]: Remove call to 'cut?'
and call 'replace' unconditionally.
[replace]: Add 'cut?' case.
* tests/guix-build.sh: Add test combining '--no-grafts' and
'--with-graft'.
* tests/packages.scm ("package-input-rewriting/spec, identity")
("package-input-rewriting, identity"): New tests.
guix/packages.scm
tests/guix-build.sh
tests/packages.scm