all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alex Kost <alezost@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org
Subject: Re: ui: Move 'show-manifest-transaction' from (guix profiles).
Date: Thu, 09 Oct 2014 10:31:55 +0400	[thread overview]
Message-ID: <8761ftiwis.fsf@gmail.com> (raw)
In-Reply-To: <877g0amj55.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Wed, 08 Oct 2014 21:55:02 +0200")

[-- Attachment #1: Type: text/plain, Size: 1188 bytes --]

Ludovic Courtès (2014-10-08 23:55 +0400) wrote:

> Alex Kost <alezost@gmail.com> skribis:

[...]

> This is another circularity issue.  :-/
>
> There’s:
>
>   (guix store) -> (guix nar) -> (guix ui) -> (guix store) ...
>
> This shouldn’t be a problem, except that occasional uses of #:select
> trigger a bug (see <http://bugs.gnu.org/15540>.)

Ouch, thanks for the explanation.

> I’ve fiddled a bit on top of your patch, but couldn’t find any simple
> fix.
>
> However, back to the initial problem, is this a problem if the error
> conditions are defined in (guix profiles), which is then imported by
> (guix ui)?  This is suboptimal, but this kind of circular reference
> shouldn’t cause any troubles.

Do you mean to "#:select" condition types in (guix ui)?  I tried but it
failed for me even on “make” (the patch I tried and the make output are
attached).  So it looks like even selecting from (guix profile) won't
work in (guix ui) or did I miss something?

What about making an auxiliary (guix conditions) module with all
existing condition types, and use it where needed?  I could try to work
on it if it sounds reasonable.  WDYT?


[-- Attachment #2: 0001-profiles-Add-condition-types-for-profiles-and-genera.patch --]
[-- Type: text/x-diff, Size: 6162 bytes --]

From 6b1c3edea51abb464f4265f36f25c5e314731ac2 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Wed, 8 Oct 2014 17:29:01 +0400
Subject: [PATCH] profiles: Add condition types for profiles and generations.

* guix/profiles.scm (&profile-error, &profile-not-found-error,
  &missing-generation-error): New condition types.
* guix/ui.scm (call-with-error-handling): Handle new types.
* guix/scripts/package.scm (roll-back, guix-package): Raise
  '&profile-not-found-error' where needed.
---
 guix/profiles.scm        | 29 ++++++++++++++++++++++++++++-
 guix/scripts/package.scm | 18 ++++++++++--------
 guix/ui.scm              | 12 ++++++++++++
 3 files changed, 50 insertions(+), 9 deletions(-)

diff --git a/guix/profiles.scm b/guix/profiles.scm
index 18733a6..b1fa50e 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -35,7 +35,18 @@
   #:use-module (srfi srfi-11)
   #:use-module (srfi srfi-19)
   #:use-module (srfi srfi-26)
-  #:export (manifest make-manifest
+  #:use-module (srfi srfi-34)
+  #:use-module (srfi srfi-35)
+  #:export (&profile-error
+            profile-error?
+            profile-error-profile
+            &profile-not-found-error
+            profile-not-found-error?
+            &missing-generation-error
+            missing-generation-error?
+            missing-generation-error-generation
+
+            manifest make-manifest
             manifest?
             manifest-entries
 
@@ -84,6 +95,22 @@
 
 \f
 ;;;
+;;; Condition types.
+;;;
+
+(define-condition-type &profile-error &error
+  profile-error?
+  (profile profile-error-profile))
+
+(define-condition-type &profile-not-found-error &profile-error
+  profile-not-found-error?)
+
+(define-condition-type &missing-generation-error &profile-error
+  missing-generation-error?
+  (generation missing-generation-error-generation))
+
+\f
+;;;
 ;;; Manifests.
 ;;;
 
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index fc9c37b..9f3ed3a 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -38,6 +38,8 @@
   #:use-module (srfi srfi-11)
   #:use-module (srfi srfi-19)
   #:use-module (srfi srfi-26)
+  #:use-module (srfi srfi-34)
+  #:use-module (srfi srfi-35)
   #:use-module (srfi srfi-37)
   #:use-module (gnu packages)
   #:use-module (gnu packages base)
@@ -109,8 +111,8 @@ return PROFILE unchanged.  The goal is to treat '-p ~/.guix-profile' as if
          (previous-number     (previous-generation-number profile number))
          (previous-generation (generation-file-name profile previous-number)))
     (cond ((not (file-exists? profile))                 ; invalid profile
-           (leave (_ "profile '~a' does not exist~%")
-                  profile))
+           (raise (condition (&profile-not-found-error
+                              (profile profile)))))
           ((zero? number)                               ; empty profile
            (format (current-error-port)
                    (_ "nothing to do: already at the empty profile~%")))
@@ -723,8 +725,8 @@ more information.~%"))
             (match-lambda
              (('delete-generations . pattern)
               (cond ((not (file-exists? profile)) ; XXX: race condition
-                     (leave (_ "profile '~a' does not exist~%")
-                            profile))
+                     (raise (condition (&profile-not-found-error
+                                        (profile profile)))))
                     ((string-null? pattern)
                      (delete-generations
                       (%store) profile
@@ -833,8 +835,8 @@ more information.~%"))
              (newline)))
 
          (cond ((not (file-exists? profile)) ; XXX: race condition
-                (leave (_ "profile '~a' does not exist~%")
-                       profile))
+                (raise (condition (&profile-not-found-error
+                                   (profile profile)))))
                ((string-null? pattern)
                 (for-each list-generation (profile-generations profile)))
                ((matching-generations pattern profile)
@@ -915,8 +917,8 @@ more information.~%"))
         (_ #f))))
 
   (let ((opts (parse-options)))
-    (or (process-query opts)
-        (with-error-handling
+    (with-error-handling
+      (or (process-query opts)
           (parameterize ((%store (open-connection)))
             (set-build-options-from-command-line (%store) opts)
 
diff --git a/guix/ui.scm b/guix/ui.scm
index 04345d4..55a8105 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
+;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -27,6 +28,11 @@
   #:use-module (guix derivations)
   #:use-module ((guix build utils) #:select (mkdir-p))
   #:use-module ((guix licenses) #:select (license? license-name))
+  #:use-module ((guix profiles)
+                #:select (profile-not-found-error?
+                          profile-error-profile
+                          missing-generation-error?
+                          missing-generation-error-generation))
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-11)
   #:use-module (srfi srfi-19)
@@ -229,6 +235,12 @@ interpreted."
                       (location->string loc)
                       (package-full-name package)
                       (build-system-name system))))
+            ((profile-not-found-error? c)
+             (leave (_ "profile '~a' does not exist~%")
+                    (profile-error-profile c)))
+            ((missing-generation-error? c)
+             (leave (_ "generation ~a does not exist~%")
+                    (missing-generation-error-generation c)))
             ((nix-connection-error? c)
              (leave (_ "failed to connect to `~a': ~a~%")
                     (nix-connection-error-file c)
-- 
2.1.2


[-- Attachment #3: guix-make-fail --]
[-- Type: text/plain, Size: 3013 bytes --]

make  all-recursive
make[1]: Entering directory '/media/storage/src/guix'
Making all in po/guix
make[2]: Entering directory '/media/storage/src/guix/po/guix'
make[2]: Leaving directory '/media/storage/src/guix/po/guix'
Making all in po/packages
make[2]: Entering directory '/media/storage/src/guix/po/packages'
make[2]: Leaving directory '/media/storage/src/guix/po/packages'
make[2]: Entering directory '/media/storage/src/guix'
/usr/bin/mkdir -p `dirname "guix/profiles.go"` ;			\
LC_ALL=C							\
./pre-inst-env					\
/usr/bin/guild compile -L "." -L "."	\
  -Wformat -Wunbound-variable -Warity-mismatch			\
  --target="i686-pc-linux-gnu"						\
  -o "guix/profiles.go" "guix/profiles.scm"
;;; note: source file ./guix/ui.scm
;;;       newer than compiled /media/storage/src/guix/guix/ui.go
;;; note: source file ./guix/ui.scm
;;;       newer than compiled /home/alexx/.cache/guile/ccache/2.0-LE-4-2.0/media/storage/src/guix/guix/ui.scm.go
Backtrace:
In ice-9/boot-9.scm:
2951: 19 [define-module* (guix profiles) #:filename ...]
2926: 18 [resolve-imports (((guix ui)) ((guix utils)) ((guix records)) ...)]
2864: 17 [resolve-interface (guix ui) #:select ...]
2789: 16 [#<procedure 83896f0 at ice-9/boot-9.scm:2777:4 (name #:optional autoload version #:key ensure)> # ...]
3065: 15 [try-module-autoload (guix ui) #f]
2401: 14 [save-module-excursion #<procedure 866b780 at ice-9/boot-9.scm:3066:17 ()>]
3085: 13 [#<procedure 866b780 at ice-9/boot-9.scm:3066:17 ()>]
In unknown file:
   ?: 12 [primitive-load-path "guix/ui" ...]
In ice-9/eval.scm:
 505: 11 [#<procedure 82c1400 at ice-9/eval.scm:499:4 (exp)> (define-module # # ...)]
In ice-9/psyntax.scm:
1106: 10 [expand-top-sequence ((define-module (guix ui) #:use-module ...)) () ...]
 989: 9 [scan ((define-module (guix ui) #:use-module ...)) () ...]
 279: 8 [scan ((#(syntax-object let # ...) (#) (# #) ...)) () ...]
In ice-9/eval.scm:
 411: 7 [eval # ()]
In ice-9/boot-9.scm:
2951: 6 [define-module* (guix ui) #:filename ...]
2926: 5 [resolve-imports (((guix utils)) ((guix store)) ((guix config)) ...)]
2877: 4 [resolve-interface (guix profiles) #:select ...]
 768: 3 [for-each #<procedure 842a5a0 at ice-9/boot-9.scm:2877:20 (bspec)> #]
2883: 2 [#<procedure 842a5a0 at ice-9/boot-9.scm:2877:20 (bspec)> profile-not-found-error?]
In unknown file:
   ?: 1 [scm-error misc-error #f ...]
In ice-9/boot-9.scm:
 106: 0 [#<procedure 84f54e0 at ice-9/boot-9.scm:97:6 (thrown-k . args)> misc-error ...]

ice-9/boot-9.scm:106:20: In procedure #<procedure 84f54e0 at ice-9/boot-9.scm:97:6 (thrown-k . args)>:
ice-9/boot-9.scm:106:20: no binding `profile-not-found-error?' in module (guix profiles)
Makefile:3871: recipe for target 'guix/profiles.go' failed
make[2]: *** [guix/profiles.go] Error 1
make[2]: Leaving directory '/media/storage/src/guix'
Makefile:3064: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/media/storage/src/guix'
Makefile:1803: recipe for target 'all' failed
make: *** [all] Error 2

  reply	other threads:[~2014-10-09  6:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-08 14:19 ui: Move 'show-manifest-transaction' from (guix profiles) Alex Kost
2014-10-08 17:57 ` Alex Kost
2014-10-08 19:55 ` Ludovic Courtès
2014-10-09  6:31   ` Alex Kost [this message]
2014-10-09 21:03     ` Ludovic Courtès
2014-10-09 22:08   ` Ludovic Courtès
2014-10-10  7:00     ` Alex Kost
2014-10-10 12:15       ` Ludovic Courtès
2014-10-10 15:20         ` Alex Kost
2014-10-11 21:57           ` Ludovic Courtès
2014-10-12  5:39             ` [PATCH 2/2] emacs: Add support for switching generations Alex Kost
2014-10-12 21:04               ` Ludovic Courtès

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

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

  git send-email \
    --in-reply-to=8761ftiwis.fsf@gmail.com \
    --to=alezost@gmail.com \
    --cc=guix-devel@gnu.org \
    --cc=ludo@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.