From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark H Weaver Subject: [PATCH] guix package: Add '--do-not-upgrade' option Date: Tue, 14 Apr 2015 03:04:13 -0400 Message-ID: <87wq1fb382.fsf@netris.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52588) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yhusw-0006v6-7W for guix-devel@gnu.org; Tue, 14 Apr 2015 03:03:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yhusr-0001Re-SY for guix-devel@gnu.org; Tue, 14 Apr 2015 03:03:49 -0400 Received: from world.peace.net ([50.252.239.5]:37700) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yhusr-0001Ra-Nq for guix-devel@gnu.org; Tue, 14 Apr 2015 03:03:45 -0400 List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org --=-=-= Content-Type: text/plain This adds a --do-not-upgrade option to 'guix package'. One issue is that if you write: guix package -u --do-not-upgrade icecat then this will be interpreted as: guix package -u icecat --do-not-upgrade The reason is that -u is specified as taking an optional argument, and it will take one even if it comes after some other options. We could fix this by specifying that -u/--upgrade does _not_ take an optional argument, instead relying on the 'arg-handler' logic to interpret arguments. The downside is that this would no longer be allowed: guix package --upgrade= instead it would have to be written without the '=', like this: guix package --upgrade What do you think? Anyway, here is my current patch which still has the issue described above, so you must write "guix package -u . --do-not-upgrade icecat". Mark --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=0001-guix-package-Add-do-not-upgrade-option.patch Content-Transfer-Encoding: quoted-printable Content-Description: [PATCH] guix package: Add '--do-not-upgrade' option >From 1ddc901ae8bbe0bb0b41b380a1f2c1c368602beb Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Thu, 26 Mar 2015 17:25:09 -0400 Subject: [PATCH] guix package: Add '--do-not-upgrade' option. * guix/scripts/package.scm (%options): Add the '--do-not-upgrade' option. (show-help): Document it. (options->installable): Add 'do-not-upgrade-regexps' variable. Use it in 'packages-to-upgrade'. * doc/guix.texi (Invoking guix package): Document the '--do-not-upgrade' option. --- doc/guix.texi | 12 +++++++++++- guix/scripts/package.scm | 20 +++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 872caa8..1bd2a84 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -947,13 +947,23 @@ and/or output name in addition to the package name. = For instance, @itemx -u [@var{regexp} @dots{}] Upgrade all the installed packages. If one or more @var{regexp}s are specified, upgrade only installed packages whose name matches a -@var{regexp}. +@var{regexp}. Also see the @code{--do-not-upgrade} option below. =20 Note that this upgrades package to the latest version of packages found in the distribution currently installed. To update your distribution, you should regularly run @command{guix pull} (@pxref{Invoking guix pull}). =20 +@item --do-not-upgrade[=3D@var{regexp} @dots{}] +When used together with the @code{--upgrade} option, do @emph{not} +upgrade any packages whose name matches a @var{regexp}. For example, to +upgrade all packages in the current profile except those containing the +substring ``emacs'': + +@example +$ guix package --upgrade . --do-not-upgrade emacs +@end example + @item --roll-back Roll back to the previous @dfn{generation} of the profile---i.e., undo the last transaction. diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 09ae782..53813c1 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -1,7 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2012, 2013, 2014, 2015 Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2013 Nikita Karetnikov -;;; Copyright =C2=A9 2013 Mark H Weaver +;;; Copyright =C2=A9 2013, 2015 Mark H Weaver ;;; Copyright =C2=A9 2014 Alex Kost ;;; ;;; This file is part of GNU Guix. @@ -465,6 +465,8 @@ Install, remove, or upgrade PACKAGES in a single transa= ction.\n")) (display (_ " -u, --upgrade[=3DREGEXP] upgrade all the installed packages matching REG= EXP")) (display (_ " + --do-not-upgrade[=3DREGEXP] do not upgrade any packages matching REG= EXP")) + (display (_ " --roll-back roll back to the previous generation")) (display (_ " --search-paths display needed environment variable definitions")) @@ -543,6 +545,13 @@ Install, remove, or upgrade PACKAGES in a single trans= action.\n")) ;; would upgrade everything. (delete '(upgrade . #f) result)) arg-handler)))) + (option '("do-not-upgrade") #f #t + (lambda (opt name arg result arg-handler) + (let arg-handler ((arg arg) (result result)) + (values (if arg + (alist-cons 'do-not-upgrade arg result) + result) + arg-handler)))) (option '("roll-back") #f #f (lambda (opt name arg result arg-handler) (values (alist-cons 'roll-back? #t result) @@ -621,6 +630,13 @@ return the new list of manifest entries." (_ #f)) opts)) =20 + (define do-not-upgrade-regexps + (filter-map (match-lambda + (('do-not-upgrade . regexp) + (make-regexp regexp)) + (_ #f)) + opts)) + (define packages-to-upgrade (match upgrade-regexps (() @@ -630,6 +646,8 @@ return the new list of manifest entries." (($ name version output path _) (and (any (cut regexp-exec <> name) upgrade-regexps) + (not (any (cut regexp-exec <> name) + do-not-upgrade-regexps)) (upgradeable? name version path) (let ((output (or output "out"))) (call-with-values --=20 2.2.1 --=-=-=--