all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Hartmut Goebel <h.goebel@crazy-compilers.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 57460@debbugs.gnu.org
Subject: [bug#57460] [PATCH 00/19] Refresh to specific version
Date: Tue, 1 Nov 2022 16:58:37 +0100	[thread overview]
Message-ID: <e179efe1-44aa-4000-d052-8e170d115a2e@crazy-compilers.com> (raw)
In-Reply-To: <87h70xcdha.fsf_-_@gnu.org>

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

Hi Ludo,

attached please find a new patch addressing this and implementing a 
record time. (Thanks for the tip, this makes the code muche easier.)

-- 
Regards
Hartmut Goebel

| Hartmut Goebel          | h.goebel@crazy-compilers.com               |
| www.crazy-compilers.com | compilers which you thought are impossible |

[-- Attachment #2: v2-0015-refresh-Allow-updating-to-a-specific-version.patch --]
[-- Type: text/x-patch, Size: 5976 bytes --]

From c748a25193d8f9ee29b9d281f542fb1d0d3f4ec1 Mon Sep 17 00:00:00 2001
Message-Id: <c748a25193d8f9ee29b9d281f542fb1d0d3f4ec1.1667318125.git.h.goebel@crazy-compilers.com>
From: Hartmut Goebel <h.goebel@crazy-compilers.com>
Date: Fri, 24 Jun 2022 20:40:57 +0200
Subject: [PATCH v2] refresh: Allow updating to a specific version.

* guix/scripts/refresh.scm (options->packages)[args-packages]: Handle version
  specification in package name arguments.
  (update-package): Add #:version argument and pass it on to called functions.
  (guix-refresh): When updating, pass the specified version (if any) to
  update-package.
  [package-list-without-versions, package-list-with-versions]: New functions.
---
 guix/scripts/refresh.scm | 49 ++++++++++++++++++++++++++++++----------
 1 file changed, 37 insertions(+), 12 deletions(-)

diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index 14329751f8..8333d1783c 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -9,6 +9,7 @@
 ;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
 ;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
+;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -33,6 +34,7 @@
   #:use-module (guix utils)
   #:use-module (guix packages)
   #:use-module (guix profiles)
+  #:use-module (guix records)
   #:use-module (guix upstream)
   #:use-module (guix graph)
   #:use-module (guix scripts graph)
@@ -181,7 +183,7 @@ specified with `--select'.\n"))
   (newline)
   (show-bug-report-information))
 
-(define (options->packages opts)
+(define (options->package-specs opts)
   "Return the list of packages requested by OPTS, honoring options like
 '--recursive'."
   (define core-package?
@@ -224,7 +226,7 @@ update would trigger a complete rebuild."
                          (('argument . spec)
                           ;; Take either the specified version or the
                           ;; latest one.
-                          (specification->package spec))
+                          (specification->package-spec spec))
                          (('expression . exp)
                           (read/eval-package-expression exp))
                          (_ #f))
@@ -254,6 +256,25 @@ update would trigger a complete rebuild."
       (with-monad %store-monad
         (return packages))))
 
+\f
+;;;
+;;; Utilities.
+;;;
+
+(define-record-type* <package-spec> package-spec make-package-spec
+  package-spec?
+  (package   package-spec-package) ; package
+  (target    package-spec-target)) ; target version
+
+(define (specification->package-spec spec)
+  "Given SPEC, a package name like \"guile@2.0=2.0.8\", return a
+<package-spec> record with two fields: the package to upgrade, and the
+target version."
+  (match (string-rindex spec #\=)
+    (#f  (make-package-spec (specification->package spec) #f))
+    (idx (make-package-spec (specification->package (substring spec 0 idx))
+                            (substring spec (1+ idx))))))
+
 \f
 ;;;
 ;;; Updates.
@@ -298,7 +319,7 @@ update would trigger a complete rebuild."
            (G_ "no updater for ~a~%")
            (package-name package)))
 
-(define* (update-package store package updaters
+(define* (update-package store package version updaters
                          #:key (key-download 'interactive) warn?)
   "Update the source file that defines PACKAGE with the new version.
 KEY-DOWNLOAD specifies a download policy for missing OpenPGP keys; allowed
@@ -307,7 +328,7 @@ warn about packages that have no matching updater."
   (if (lookup-updater package updaters)
       (let ((version output source
                      (package-update store package updaters
-                                     #:key-download key-download))
+                                     #:key-download key-download #:version version))
             (loc (or (package-field-location package 'version)
                      (package-location package))))
         (when version
@@ -540,12 +561,12 @@ all are dependent packages: ~{~a~^ ~}~%")
     (with-error-handling
       (with-store store
         (run-with-store store
-          (mlet %store-monad ((packages (options->packages opts)))
+          (mlet %store-monad ((package-specs (options->package-specs opts)))
             (cond
              (list-dependent?
-              (list-dependents packages))
+              (list-dependents (map package-spec-package package-specs)))
              (list-transitive?
-              (list-transitive packages))
+              (list-transitive (map package-spec-package package-specs)))
              (update?
               (parameterize ((%openpgp-key-server
                               (or (assoc-ref opts 'key-server)
@@ -558,13 +579,17 @@ all are dependent packages: ~{~a~^ ~}~%")
                                   (string-append (config-directory)
                                                  "/upstream/trustedkeys.kbx"))))
                 (for-each
-                 (cut update-package store <> updaters
-                      #:key-download key-download
-                      #:warn? warn?)
-                 packages)
+                 (lambda (package-spec)
+                   (update-package store
+                                   (package-spec-package package-spec)
+                                   (package-spec-target package-spec)
+                                   updaters
+                                   #:key-download key-download
+                                   #:warn? warn?))
+                 package-specs)
                 (return #t)))
              (else
               (for-each (cut check-for-package-update <> updaters
                              #:warn? warn?)
-                        packages)
+                        (map package-spec-package package-specs))
               (return #t)))))))))
-- 
2.30.6


  reply	other threads:[~2022-11-01 17:22 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-28 13:15 [bug#57460] [PATCH 00/19] Refresh to specific version Hartmut Goebel
2022-08-28 13:18 ` [bug#57460] [PATCH 01/20] upstream-updater: Rename record field Hartmut Goebel
2022-08-28 13:18 ` [bug#57460] [PATCH 02/20] import: cpan: Remove unused exports Hartmut Goebel
2022-08-28 13:18 ` [bug#57460] [PATCH 03/20] updaters: Issue error-message if version is given: Hartmut Goebel
2022-08-28 13:18 ` [bug#57460] [PATCH 04/20] import: sourceforge: Issue error-message if version is given Hartmut Goebel
2022-08-28 13:22   ` Maxime Devos
2022-08-28 13:18 ` [bug#57460] [PATCH 05/20] refresh: Allow updating to a specific version (gnu-maintenance) Hartmut Goebel
2022-09-24  9:17   ` [bug#57460] [PATCH 00/19] Refresh to specific version Ludovic Courtès
2022-08-28 13:18 ` [bug#57460] [PATCH 06/20] refresh: Allow updating to a specific version (crate) Hartmut Goebel
2022-09-24  9:19   ` [bug#57460] [PATCH 00/19] Refresh to specific version Ludovic Courtès
2022-08-28 13:18 ` [bug#57460] [PATCH 07/20] refresh: Allow updating to a specific version (egg) Hartmut Goebel
2022-08-28 13:18 ` [bug#57460] [PATCH 08/20] refresh: Allow updating to a specific version (git) Hartmut Goebel
2022-09-24  9:24   ` [bug#57460] [PATCH 00/19] Refresh to specific version Ludovic Courtès
2022-08-28 13:18 ` [bug#57460] [PATCH 09/20] refresh: Allow updating to a specific version (github) Hartmut Goebel
2022-09-24  9:26   ` [bug#57460] [PATCH 00/19] Refresh to specific version Ludovic Courtès
2022-08-28 13:18 ` [bug#57460] [PATCH 10/20] refresh: Allow updating to a specific version (gnome) Hartmut Goebel
2022-09-24  9:29   ` [bug#57460] [PATCH 00/19] Refresh to specific version Ludovic Courtès
2022-09-24 10:25     ` Maxime Devos
2022-09-24 16:31       ` Ludovic Courtès
2022-08-28 13:18 ` [bug#57460] [PATCH 11/20] refresh: Allow updating to a specific version (hexpm) Hartmut Goebel
2022-08-28 13:18 ` [bug#57460] [PATCH 12/20] refresh: Allow updating to a specific version (kde) Hartmut Goebel
2022-09-24  9:34   ` [bug#57460] [PATCH 00/19] Refresh to specific version Ludovic Courtès
2022-08-28 13:18 ` [bug#57460] [PATCH 13/20] refresh: Allow updating to a specific version (launchpad) Hartmut Goebel
2022-08-28 13:18 ` [bug#57460] [PATCH 14/20] refresh: Allow updating to a specific version (pypi) Hartmut Goebel
2022-08-28 13:18 ` [bug#57460] [PATCH 15/20] refresh: Allow updating to a specific version (script) Hartmut Goebel
2022-08-28 13:26   ` Maxime Devos
2022-09-24  9:45   ` [bug#57460] [PATCH 00/19] Refresh to specific version Ludovic Courtès
2022-11-01 15:58     ` Hartmut Goebel [this message]
2022-11-22  7:33       ` Ludovic Courtès
2022-08-28 13:18 ` [bug#57460] [PATCH 16/20] refresh: Allow updating to a specific version (upstream) Hartmut Goebel
2022-08-28 13:18 ` [bug#57460] [PATCH 17/20] refresh: Allow updating to a specific version (documentation) Hartmut Goebel
2022-08-28 13:18 ` [bug#57460] [PATCH 18/20] TEMP REMOVE import: git: Restrict to non-github origins Hartmut Goebel
2022-08-28 17:26   ` Liliana Marie Prikler
2022-08-28 13:18 ` [bug#57460] [PATCH 19/20] TEMP REMOVE upstream: Output names of importers tried Hartmut Goebel
2022-08-28 13:18 ` [bug#57460] [PATCH 20/20] TEMP REMOVE Add test-script for refesh-with-version Hartmut Goebel
2022-08-28 13:30 ` [bug#57460] [PATCH 00/19] Refresh to specific version Maxime Devos
2022-09-24  9:48   ` Ludovic Courtès
2022-11-01 16:02     ` Hartmut Goebel
2022-12-20  9:34 ` [bug#57460] [PATCH v3 00/18] " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 01/18] upstream-updater: Rename record field Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 02/18] import: cpan: Remove unused exports Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 03/18] import: Issue error-message if version is given Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 04/18] import: sourceforge: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 05/18] gnu-maintenance: Allow updating to a specific version Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 06/18] import: crate: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 07/18] import: egg: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 08/18] import: gem: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 09/18] import: git: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 10/18] import: github: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 11/18] import: gnome: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 12/18] import: hexpm: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 13/18] import: kde: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 14/18] import: launchpad: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 15/18] import: pypi: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 16/18] refresh: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 17/18] upstream: " Hartmut Goebel
2022-12-20  9:34   ` [bug#57460] [PATCH v3 18/18] doc: Describe how to update " Hartmut Goebel
2022-12-23 22:42     ` [bug#57460] [PATCH 00/19] Refresh to " Ludovic Courtès
2022-12-23 22:45   ` Ludovic Courtès
2022-12-26 16:42     ` bug#57460: " Hartmut Goebel

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=e179efe1-44aa-4000-d052-8e170d115a2e@crazy-compilers.com \
    --to=h.goebel@crazy-compilers.com \
    --cc=57460@debbugs.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.