all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* guix system delete-generations -- advice?
@ 2017-02-14 20:04 Thomas Danckaert
  2017-02-14 20:14 ` Thomas Danckaert
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Danckaert @ 2017-02-14 20:04 UTC (permalink / raw)
  To: guix-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 5096 bytes --]

Hi Guix,
I added `guix system delete-generations' in my git checkout, WIP patch
attached.  I had started to adapt the corresponding code from `guix
package delete-generations', but then realized that
`delete-matching-generations` from (guix scripts package) contains
everything that's needed (could it be moved to (guix ui)?).
One thing I'm not satisfied with is this: `reinstall-grub' does not
reproduce custom grub menu entries added in the (grub-configuration)
section of a system's bootloader configuration.  So users with a
dual boot system, who run =?utf-8?B?4oCcZ3VpeA==?= system
 =?utf-8?B?ZGVsZXRlLWdlbmVyYXRpb25z4oCd?= will lose
their non-GuixSD grub entries, until they run =?utf-8?B?4oCcZ3VpeA==?=
 system reconfigure
...” again.  The existing =?utf-8?B?4oCcZ3VpeA==?= system
 =?utf-8?B?c3dpdGNoLWdlbmVyYXRpb27igJ0=?= has the same problem.
Is there a way to retrieve the current custom grub entries, other than
 providing a system configuration, or, I hardly dare say it out loud,
 parsing grub.cfg? How could this be improved?
cheers,
Thomas
ps I also noticed that passing an empty string ("") as a command line
 argument to many guix commands returns a guile backtrace, e.g. guix system
 list-generations "". I find this a little messy, or is it a feature?
Mime-Version: 1.0
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0001-WIP-guix-system-delete-generations.patch"

From 9dc5a9bfee970e24fd2e65615220f80fb8436c6b Mon Sep 17 00:00:00 2001
From: Thomas Danckaert <post@thomasdanckaert.be>
Date: Sat, 11 Feb 2017 18:32:42 +0100
Subject: [PATCH] WIP guix system delete-generations.

TODO: how to properly generate grub.cfg?
---
 guix/scripts/package.scm |  2 +-
 guix/scripts/system.scm  | 19 +++++++++++++++++--
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 9e5b7f3c7..49233708f 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -152,7 +152,7 @@ GENERATIONS is a list of generation numbers."
   (for-each (cut delete-generation* store profile <>)
             generations))
 
-(define (delete-matching-generations store profile pattern)
+(define-public (delete-matching-generations store profile pattern)
   "Delete from PROFILE all the generations matching PATTERN.  PATTERN must be
 a string denoting a set of generations: the empty list means \"all generations
 but the current one\", a number designates a generation, and other patterns
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 144a7fd37..a4e219d70 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -31,6 +31,7 @@
   #:use-module (guix records)
   #:use-module (guix profiles)
   #:use-module (guix scripts)
+  #:use-module ((guix scripts package) #:prefix package:)
   #:use-module (guix scripts build)
   #:use-module (guix graph)
   #:use-module (guix scripts graph)
@@ -548,6 +549,12 @@ PATTERN, a string.  When PATTERN is #f, display all the system generations."
         (else
          (leave (_ "invalid syntax: ~a~%") pattern))))
 
+(define* (delete-generations store pattern #:optional (profile %system-profile))
+  "Delete all system generations matching PATTERN, a string, but never delete
+the current generation.  Regenerate grub.cfg if we have deleted something."
+  (package:delete-matching-generations store profile pattern)
+  (reinstall-grub store (generation-number profile))) ; TODO: this removes custom grub menu entries.
+
 \f
 ;;;
 ;;; Action.
@@ -712,6 +719,8 @@ Some ACTIONS support additional ARGS.\n"))
   (display (_ "\
    list-generations list the system generations\n"))
   (display (_ "\
+   delete-generations delete system generations\n"))
+  (display (_ "\
    build            build the operating system without installing anything\n"))
   (display (_ "\
    container        build a container that shares the host's store\n"))
@@ -880,6 +889,12 @@ argument list and OPTS is the option alist."
        (list-generations pattern)))
     ;; The following commands need to use the store, but they do not need an
     ;; operating system configuration file.
+    ((delete-generations)
+     (let ((pattern (match args
+                      ((pattern) pattern)
+                      (x (leave (_ "wrong number of arguments~%"))))))
+       (with-store store
+         (delete-generations store pattern))))
     ((switch-generation)
      (let ((pattern (match args
                       ((pattern) pattern)
@@ -906,8 +921,8 @@ argument list and OPTS is the option alist."
         (let ((action (string->symbol arg)))
           (case action
             ((build container vm vm-image disk-image reconfigure init
-              extension-graph shepherd-graph list-generations roll-back
-              switch-generation)
+              extension-graph shepherd-graph list-generations delete-generations
+              roll-back switch-generation)
              (alist-cons 'action action result))
             (else (leave (_ "~a: unknown action~%") action))))))
 
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: guix system delete-generations -- advice?
  2017-02-14 20:04 guix system delete-generations -- advice? Thomas Danckaert
@ 2017-02-14 20:14 ` Thomas Danckaert
  2017-03-07 14:42   ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Danckaert @ 2017-02-14 20:14 UTC (permalink / raw)
  To: guix-devel

(I somehow messed up the encoding/body of previous message, so here it
is again. my apologies)

I added `guix system delete-generations' in my git checkout, WIP patch
attached.  I had started to adapt the corresponding code from `guix
package delete-generations', but then realized that
`delete-matching-generations` from (guix scripts package) contains
everything that's needed (could it be moved to (guix ui)?).

One thing I'm not satisfied with is this: `reinstall-grub' does not
reproduce custom grub menu entries added in the (grub-configuration)
section of a system's bootloader configuration.  So users with a
dual-boot system lose theire non-GuixSD grub entries after running
“guix system delete-generations” (until they run “guix system
reconfigure” again).  The existing “guix system switch-generation” has
the same problem.

Is there a way to retrieve the current custom grub entries, other than
providing a system configuration, or, I hardly dare say it out loud,
parsing grub.cfg? How could this be improved?

cheers, Thomas

ps I also noticed that passing an empty string ("") as a command line
argument to many guix commands returns a guile backtrace, e.g. guix
system list-generations "". I find this a little messy, or is it a
feature?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: guix system delete-generations -- advice?
  2017-02-14 20:14 ` Thomas Danckaert
@ 2017-03-07 14:42   ` Ludovic Courtès
  2017-03-07 16:53     ` Thomas Danckaert
  0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2017-03-07 14:42 UTC (permalink / raw)
  To: Thomas Danckaert; +Cc: guix-devel

Hi Thomas, and apologies for the delay!

Thomas Danckaert <post@thomasdanckaert.be> skribis:

> I added `guix system delete-generations' in my git checkout, WIP patch
> attached.  I had started to adapt the corresponding code from `guix
> package delete-generations', but then realized that
> `delete-matching-generations` from (guix scripts package) contains
> everything that's needed (could it be moved to (guix ui)?).
>
> One thing I'm not satisfied with is this: `reinstall-grub' does not
> reproduce custom grub menu entries added in the (grub-configuration)
> section of a system's bootloader configuration.  So users with a
> dual-boot system lose theire non-GuixSD grub entries after running
> “guix system delete-generations” (until they run “guix system
> reconfigure” again).  The existing “guix system switch-generation” has
> the same problem.
>
> Is there a way to retrieve the current custom grub entries, other than
> providing a system configuration, or, I hardly dare say it out loud,
> parsing grub.cfg? How could this be improved?

Very good point, it’s really a shortcoming.

To fix it we could add the extra entries to <boot-parameters> (which
you can see as /run/current-system/parameters.)  See what I mean?

As for how to proceed, I’m fine either way: we could commit your ‘guix
system delete-generation’ patch first, with the understanding that it
has the bug you describe, and then fix the bug; or we could do it the
other way around.

WDYT?

> ps I also noticed that passing an empty string ("") as a command line
> argument to many guix commands returns a guile backtrace, e.g. guix
> system list-generations "". I find this a little messy, or is it a
> feature?

Doh!  It’s a bug in Guile’s (srfi srfi-37).  Could you send it to
bug-guile@gnu.org?

Thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: guix system delete-generations -- advice?
  2017-03-07 14:42   ` Ludovic Courtès
@ 2017-03-07 16:53     ` Thomas Danckaert
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Danckaert @ 2017-03-07 16:53 UTC (permalink / raw)
  To: ludo; +Cc: guix-devel

From: ludo@gnu.org (Ludovic Courtès)
Subject: Re: guix system delete-generations -- advice?
Date: Tue, 07 Mar 2017 15:42:44 +0100

>> One thing I'm not satisfied with is this: `reinstall-grub' does not
>> reproduce custom grub menu entries added in the 
>> (grub-configuration)
>> section of a system's bootloader configuration.
>> [...]
>> Is there a way to retrieve the current custom grub entries, other 
>> than
>> providing a system configuration, or, I hardly dare say it out 
>> loud,
>> parsing grub.cfg? How could this be improved?
>
> Very good point, it’s really a shortcoming.
>
> To fix it we could add the extra entries to <boot-parameters> (which
> you can see as /run/current-system/parameters.)  See what I mean?

Yes, that should work!

> As for how to proceed, I’m fine either way: we could commit your 
> ‘guix
> system delete-generation’ patch first, with the understanding that 
> it
> has the bug you describe, and then fix the bug; or we could do it 
> the
> other way around.

I'd prefer to fix the bug first.  My patch is a bit messy anyway (I 
just made (delete-matching-generations) an exported function in (guix 
scripts package)), and without the grub fix, it doesn't really 
improve things a lot.

> [...]
> Doh!  It’s a bug in Guile’s (srfi srfi-37).  Could you send it to
> bug-guile@gnu.org?

Done!

Thomas

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-03-07 16:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-14 20:04 guix system delete-generations -- advice? Thomas Danckaert
2017-02-14 20:14 ` Thomas Danckaert
2017-03-07 14:42   ` Ludovic Courtès
2017-03-07 16:53     ` Thomas Danckaert

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.