GNU bug report logs - #32184
‘guix pack --bootstrap’ is ineffective

Previous Next

Package: guix;

Reported by: ludo <at> gnu.org (Ludovic Courtès)

Date: Tue, 17 Jul 2018 09:25:01 UTC

Severity: normal

To reply to this bug, email your comments to 32184 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#32184; Package guix. (Tue, 17 Jul 2018 09:25:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to ludo <at> gnu.org (Ludovic Courtès):
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Tue, 17 Jul 2018 09:25:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: bug-guix <at> gnu.org
Cc: Chris Marusich <cmmarusich <at> gmail.com>
Subject: ‘guix pack --bootstrap’ is
 ineffective
Date: Tue, 17 Jul 2018 11:24:32 +0200
[Message part 1 (text/plain, inline)]
Hello,

While preparing the 0.15 release I realized that ‘guix pack --bootstrap’
had become ineffective.  Concretely, ‘tests/guix-pack.sh’ would attempt
to build the world.

This is a consequence of c45477d2a1a651485feede20fe0f3d15aec48b39, which
introduced a dependency on guile-sqlite3 in derivations that build
packs, even if they don’t actually produce a ‘db.sqlite’ file in there.

I started looking for solutions, which led me to the patch below.
That’s quite intrusive and it doesn’t work because then we have a
similar issue with (guix hash) trying to dlopen libgcrypt.

I’m not sure how to best address it.  Another approach would be to do
away with ‘--bootstrap’ and instead write those tests as “system tests”
in a VM, though that’s maybe less satisfactory.

Thoughts?

Thanks,
Ludo’.

[Message part 2 (text/x-patch, inline)]
diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm
index 6d5d745bc..45eeb2e7b 100644
--- a/guix/scripts/pack.scm
+++ b/guix/scripts/pack.scm
@@ -98,8 +98,25 @@ found."
 
 (define guile-sqlite3&co
   ;; Guile-SQLite3 and its propagated inputs.
-  (cons guile-sqlite3
-        (package-transitive-propagated-inputs guile-sqlite3)))
+  (make-parameter
+   (cons guile-sqlite3
+         (package-transitive-propagated-inputs guile-sqlite3))))
+
+(define guile-sqlite3/mock
+  ;; Mock of Guile-SQLite3 used by '--bootstrap', for testing purposes.
+  (computed-file "guile-sqlite3-mock"
+                 (with-imported-modules '((guix build utils))
+                   #~(begin
+                       (use-modules (guix build utils))
+
+                       (let ((modules (string-append
+                                       #$output "/share/guile/site/2.0")))
+                         (mkdir-p modules)
+                         (call-with-output-file (string-append modules
+                                                               "/sqlite3.scm")
+                           (lambda (port)
+                             (display "(define-module (sqlite3))\n" port))))))
+                 #:guile %bootstrap-guile))
 
 (define* (self-contained-tarball name profile
                                  #:key target
@@ -134,7 +151,7 @@ added to the pack."
                                   (guix build store-copy)
                                   (gnu build install))
                                 #:select? not-config?))
-      (with-extensions guile-sqlite3&co
+      (with-extensions (guile-sqlite3&co)
         #~(begin
             (use-modules (guix build utils)
                          ((guix build union) #:select (relative-file-name))
@@ -267,7 +284,7 @@ added to the pack."
                                   (guix build store-copy)
                                   (gnu build install))
                                 #:select? not-config?))
-      (with-extensions guile-sqlite3&co
+      (with-extensions (guile-sqlite3&co)
         #~(begin
             (use-modules (guix build utils)
                          (gnu build install)
@@ -717,6 +734,9 @@ Create a bundle of PACKAGE.\n"))
       (set-build-options-from-command-line store opts)
 
       (parameterize ((%graft? (assoc-ref opts 'graft?))
+                     (guile-sqlite3&co (if (assoc-ref opts 'bootstrap?)
+                                           (list guile-sqlite3/mock)
+                                           (guile-sqlite3&co)))
                      (%guile-for-build (package-derivation
                                         store
                                         (if (assoc-ref opts 'bootstrap?)

Information forwarded to bug-guix <at> gnu.org:
bug#32184; Package guix. (Wed, 18 Jul 2018 06:13:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Chris Marusich <cmmarusich <at> gmail.com>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: bug-guix <at> gnu.org
Subject: Re: ‘guix pack --bootstrap’
 is ineffective
Date: Tue, 17 Jul 2018 23:11:56 -0700
[Message part 1 (text/plain, inline)]
ludo <at> gnu.org (Ludovic Courtès) writes:

> While preparing the 0.15 release I realized that ‘guix pack --bootstrap’
> had become ineffective.  Concretely, ‘tests/guix-pack.sh’ would attempt
> to build the world.
>
> This is a consequence of c45477d2a1a651485feede20fe0f3d15aec48b39w, which
> introduced a dependency on guile-sqlite3 in derivations that build
> packs, even if they don’t actually produce a ‘db.sqlite’ file in there.
>
> I started looking for solutions, which led me to the patch below.
> That’s quite intrusive and it doesn’t work because then we have a
> similar issue with (guix hash) trying to dlopen libgcrypt.
>
> [...]
>
> diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm
> index 6d5d745bc..45eeb2e7b 100644
> --- a/guix/scripts/pack.scm
> +++ b/guix/scripts/pack.scm
>
> [...]
> 
> @@ -717,6 +734,9 @@ Create a bundle of PACKAGE.\n"))
>        (set-build-options-from-command-line store opts)
>  
>        (parameterize ((%graft? (assoc-ref opts 'graft?))
> +                     (guile-sqlite3&co (if (assoc-ref opts 'bootstrap?)
> +                                           (list guile-sqlite3/mock)
> +                                           (guile-sqlite3&co)))
>                       (%guile-for-build (package-derivation
>                                          store
>                                          (if (assoc-ref opts 'bootstrap?)

You mentioned that you felt this change is "quite intrusive."  How is
this more intrusive than using parameters for %graft? and
%guile-for-build to control how things get built?  At first blush, this
seems no worse than what we already doing here.

You also mentioned that the proposed patch doesn't actually work, since
we run into a similar problem with (guix hash) trying to dlopen
libgcrypt.  I applied your patch and ran the test, and I think I see
what you mean.  Somehow (I have to admit, I'm not sure how), the normal
libgcrypt gets pulled in by the derivation, so we have to build it...
Although I suppose it isn't ideal, maybe we can get away with working
around it via similar parameterize tricks?

If the intent of --bootstrap is to enable the tool to run quickly in
tests, then it seems we MUST either find a way to substitute every heavy
dependency (including libgcrypt) with a light replacement (e.g. the
guile-sqlite3/mock you made), or find another way to short-circuit the
build.

Basically, we're manually doing dependency injection here depending on
whether or not --bootstrap was given, right?  Instead of parameterizing
the dependencies, what if we used a dependency injector (or "oracle", or
"container", or whatever you want to call it) that, when invoked, would
give us the dependency that is appropriate for the current context?
Perhaps we could control the context via a single parameter.  For
example, something like this:

    (parameterize ((test-environment? #t))
      (injector-get-dependency guile))

would return the bootstrap guile, but something like this:

    (parameterize ((test-environment? #f))
      (injector-get-dependency guile))

would return the usual guile.  This isn't much different from using
parameters like we're already doing, except that it might save us from
having to remember multiple parameters, and it might make the code
cleaner by hiding the dependency selection/construction logic behind the
injector abstraction.

What do you think of that idea?

> I’m not sure how to best address it.  Another approach would be to do
> away with ‘--bootstrap’ and instead write those tests as “system tests”
> in a VM, though that’s maybe less satisfactory.

If we ran these tests in a VM as "system tests" (instead of turning
guile-sqlite3&co into a parameter), would we still need to build the
world?

-- 
Chris
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-guix <at> gnu.org:
bug#32184; Package guix. (Thu, 26 Jul 2018 13:28:01 GMT) Full text and rfc822 format available.

Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Chris Marusich <cmmarusich <at> gmail.com>
Cc: bug-guix <at> gnu.org
Subject: Re: ‘guix pack --bootstrap’
 is ineffective
Date: Thu, 26 Jul 2018 15:26:50 +0200
Hi Chris,

Chris Marusich <cmmarusich <at> gmail.com> skribis:

> Basically, we're manually doing dependency injection here depending on
> whether or not --bootstrap was given, right?  Instead of parameterizing
> the dependencies, what if we used a dependency injector (or "oracle", or
> "container", or whatever you want to call it) that, when invoked, would
> give us the dependency that is appropriate for the current context?
> Perhaps we could control the context via a single parameter.  For
> example, something like this:
>
>     (parameterize ((test-environment? #t))
>       (injector-get-dependency guile))
>
> would return the bootstrap guile, but something like this:
>
>     (parameterize ((test-environment? #f))
>       (injector-get-dependency guile))
>
> would return the usual guile.  This isn't much different from using
> parameters like we're already doing, except that it might save us from
> having to remember multiple parameters, and it might make the code
> cleaner by hiding the dependency selection/construction logic behind the
> injector abstraction.
>
> What do you think of that idea?

Yes, that makes sense.  Or we could simply have something like:

  (define (lookup-package name)
    (if (test-environment?)
        (match name
          ("guile" …)
          …)
        (match name
          …)))

Another option that comes to mind is using the little-known
‘map-derivation’ procedure: we would compute the ‘guix pack’ derivation
as usual, but at the end we’d call ‘map-derivation’ to replace
libgcrypt.drv, guile-sqlite3.drv, etc. with dummy variants.  That might
turn out to be more complicated that the above solution, though.

Ludo’.




Information forwarded to bug-guix <at> gnu.org:
bug#32184; Package guix. (Fri, 19 Oct 2018 16:44:02 GMT) Full text and rfc822 format available.

Message #14 received at 32184 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Chris Marusich <cmmarusich <at> gmail.com>
Cc: 32184 <at> debbugs.gnu.org
Subject: Re: bug#32184: ‘guix pack --bootstrap’ is ineffective
Date: Fri, 19 Oct 2018 18:43:14 +0200
Hi Chris,

Chris Marusich <cmmarusich <at> gmail.com> skribis:

> ludo <at> gnu.org (Ludovic Courtès) writes:
>
>> While preparing the 0.15 release I realized that ‘guix pack --bootstrap’
>> had become ineffective.  Concretely, ‘tests/guix-pack.sh’ would attempt
>> to build the world.
>>
>> This is a consequence of c45477d2a1a651485feede20fe0f3d15aec48b39w, which
>> introduced a dependency on guile-sqlite3 in derivations that build
>> packs, even if they don’t actually produce a ‘db.sqlite’ file in there.

[...]

> Basically, we're manually doing dependency injection here depending on
> whether or not --bootstrap was given, right?  Instead of parameterizing
> the dependencies, what if we used a dependency injector (or "oracle", or
> "container", or whatever you want to call it) that, when invoked, would
> give us the dependency that is appropriate for the current context?
> Perhaps we could control the context via a single parameter.  For
> example, something like this:
>
>     (parameterize ((test-environment? #t))
>       (injector-get-dependency guile))
>
> would return the bootstrap guile, but something like this:
>
>     (parameterize ((test-environment? #f))
>       (injector-get-dependency guile))
>
> would return the usual guile.  This isn't much different from using
> parameters like we're already doing, except that it might save us from
> having to remember multiple parameters, and it might make the code
> cleaner by hiding the dependency selection/construction logic behind the
> injector abstraction.
>
> What do you think of that idea?

It was sad to see these tests were not running so I decided to bite the
bullet.  :-)

In commit 19c924af4f3726688ca155a905ebf1cb9acdfca2, I went for a
different solution: now these ‘guix pack’ tests run using the user’s
store (normally /gnu/store) rather than the test store
($builddir/test-tmp), when possible.

This allows us to run these tests and possibly write other more complex
tests.

WDYT?

At this point I think we can remove ‘--bootstrap’ from ‘guix pack’
altogether.

Thoughts?

Thanks,
Ludo’.




This bug report was last modified 5 years and 183 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.