all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Mark H Weaver <mhw@netris.org>
Cc: 25852@debbugs.gnu.org
Subject: bug#25852: Users not updating their installations of Guix
Date: Wed, 10 May 2017 15:12:01 +0200	[thread overview]
Message-ID: <877f1oua8u.fsf@gnu.org> (raw)
In-Reply-To: <87k27wporb.fsf@netris.org> (Mark H. Weaver's message of "Fri, 10 Mar 2017 20:48:24 -0500")

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

Hi there,

Mark H Weaver <mhw@netris.org> skribis:

> ludo@gnu.org (Ludovic Courtès) writes:
>
>> Mark H Weaver <mhw@netris.org> skribis:
>>
>>> We could simply issue a warning if the version of guix currently in use
>>> is more than N hours old, on the assumption that after N hours it's
>>> likely to be stale.  The default value of N might be in the range 48-96
>>> (2-4 days).  A quick perusal through the recent commit log on our master
>>> branch indicates that it's quite rare for 4 days to pass without a
>>> security update.
>>>
>>> What do you think?
>>
>> That sounds like an easy and reasonable approach.
>>
>> I wonder what would be the best place to emit this warning.  Upon ‘guix
>> package -i’ maybe?
>
> Also "guix package -u" and the "guix system" commands that build
> systems.  I suspect that many users run "guix pull" as their normal
> users but never think to run it as root.

If there are no objections, I’ll push the attached patch.  It sets a
default value of 7 days (which I think is already more aggressive that
what many are doing), which can be overridden with
GUIX_DISTRO_AGE_WARNING.

Ludo’.


[-- Attachment #2: Type: text/x-patch, Size: 4364 bytes --]

diff --git a/guix/scripts.scm b/guix/scripts.scm
index da35e71ac..b9fa561f1 100644
--- a/guix/scripts.scm
+++ b/guix/scripts.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013, 2014, 2015, 2017 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014 Deck Pickard <deck.r.pickard@gmail.com>
 ;;; Copyright © 2015, 2016 Alex Kost <alezost@gmail.com>
 ;;;
@@ -27,13 +27,16 @@
   #:use-module (guix packages)
   #:use-module (guix derivations)
   #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-19)
   #:use-module (srfi srfi-37)
   #:use-module (ice-9 match)
   #:export (args-fold*
             parse-command-line
             maybe-build
             build-package
-            build-package-source))
+            build-package-source
+            %distro-age-warning
+            warn-about-old-distro))
 
 ;;; Commentary:
 ;;;
@@ -136,4 +139,39 @@ Show what and how will/would be built."
                      #:dry-run? dry-run?)
         (return (show-derivation-outputs derivation))))))
 
+(define %distro-age-warning
+  ;; The age (in seconds) above which we warn that the distro is too old.
+  (make-parameter (or (and=> (getenv "GUIX_DISTRO_AGE_WARNING")
+                             (compose time-second
+                                      string->duration))
+                      (* 7 24 3600))))
+
+(define* (warn-about-old-distro #:optional (old (%distro-age-warning))
+                                #:key (suggested-command
+                                       "guix package -u"))
+  "Emit a warning if Guix is older than OLD seconds."
+  (let-syntax ((false-if-not-found
+                (syntax-rules ()
+                  ((_ exp)
+                   (catch 'system-error
+                     (lambda ()
+                       exp)
+                     (lambda args
+                       (if (= ENOENT (system-error-errno args))
+                           #f
+                           (apply throw args))))))))
+    (define age
+      (match (false-if-not-found
+              (lstat (string-append (config-directory) "/latest")))
+        (#f    (* 2 old))
+        (stat  (- (time-second (current-time time-utc))
+                  (stat:mtime stat)))))
+
+    (when (>= age old)
+      (warning (G_ "Your Guix installation is getting old.  Consider
+running 'guix pull' followed by '~a' to get up-to-date
+packages and security updates.\n")
+               suggested-command)
+      (newline (guix-warning-port)))))
+
 ;;; scripts.scm ends here
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 92676c222..fbe19d522 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -859,6 +859,9 @@ processed, #f otherwise."
                                   (manifest-transaction-install step2)))))
          (new      (manifest-perform-transaction manifest step3)))
 
+    (unless (null? (manifest-transaction-install step3))
+      (warn-about-old-distro))
+
     (unless (manifest-transaction-null? step3)
       (show-manifest-transaction store manifest step3
                                  #:dry-run? dry-run?)
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 2872bcae6..9c0976750 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -847,6 +847,8 @@ resulting from command-line parsing."
             ((shepherd-graph)
              (export-shepherd-graph os (current-output-port)))
             (else
+             (warn-about-old-distro #:suggested-command
+                                    "guix system reconfigure")
              (perform-action action os
                              #:dry-run? dry?
                              #:derivations-only? (assoc-ref opts
diff --git a/guix/ui.scm b/guix/ui.scm
index e551d48c3..e7cb40927 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -1008,6 +1008,7 @@ following patterns: \"1d\", \"1w\", \"1m\"."
            (make-time time-duration 0
                       (string->number (match:substring match 1)))))
         ((string-match "^([0-9]+)h$" str)
+         =>
          (lambda (match)
            (hours->duration 1 match)))
         ((string-match "^([0-9]+)d$" str)

  reply	other threads:[~2017-05-10 13:13 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-23 21:11 bug#25852: Users not updating their installations of Guix Leo Famulari
2017-02-24  5:42 ` Pjotr Prins
2017-03-02 18:16 ` sirgazil
2017-03-04 20:29 ` Tomáš Čech
2017-03-04 22:43   ` Leo Famulari
2017-03-05  7:56     ` Tomáš Čech
2017-03-05  9:25       ` Pjotr Prins
2017-03-05  9:43         ` Tomáš Čech
2017-03-06 14:52           ` Ricardo Wurmus
2017-03-07  6:54             ` Pjotr Prins
2017-03-06 21:12 ` Ludovic Courtès
2017-03-06 21:34   ` Leo Famulari
2017-03-07  6:33     ` Tomáš Čech
2017-03-07 19:51       ` Leo Famulari
2017-03-07 20:58         ` Tomáš Čech
2017-03-07 22:22           ` Leo Famulari
2017-03-08  6:25             ` Tomáš Čech
2017-03-08  8:45               ` Leo Famulari
2017-03-08  9:24                 ` Tomáš Čech
2017-03-08 18:15                   ` Leo Famulari
2017-03-09  7:38                     ` Efraim Flashner
2017-03-09 10:58               ` Ludovic Courtès
2017-03-09 12:42                 ` Tomáš Čech
2017-03-09 15:42                   ` Ludovic Courtès
2017-03-07  7:32   ` Mark H Weaver
2017-03-07 10:35     ` Ludovic Courtès
2017-03-11  1:48       ` Mark H Weaver
2017-05-10 13:12         ` Ludovic Courtès [this message]
2017-05-10 14:13           ` myglc2
2017-05-10 20:16             ` Ludovic Courtès
2017-05-12  6:06               ` Ricardo Wurmus
2017-05-12  8:29                 ` Ludovic Courtès
2017-05-12 17:10                   ` myglc2

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=877f1oua8u.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=25852@debbugs.gnu.org \
    --cc=mhw@netris.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.