guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#58583] [PATCH 0/1] scripts: package: Forbid installation of the gui


From: Maxim Cournoyer
Subject: [bug#58583] [PATCH 0/1] scripts: package: Forbid installation of the guix package.
Date: Thu, 27 Oct 2022 16:11:11 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux)

Hello,

"(" <paren@disroot.org> writes:

> * guix/scripts/package.scm (package->manifest-entry*): Fail if the
>   package to be installed is guix from the default channel.
> ---
>  guix/scripts/package.scm | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
> index 7ba2661bbb..9f023ea7b5 100644
> --- a/guix/scripts/package.scm
> +++ b/guix/scripts/package.scm
> @@ -12,6 +12,7 @@
>  ;;; Copyright © 2018 Steve Sprang <scs@stevesprang.com>
>  ;;; Copyright © 2022 Josselin Poiret <dev@jpoiret.xyz>
>  ;;; Copyright © 2022 Antero Mejr <antero@mailbox.org>
> +;;; Copyright © 2022 ( <paren@disroot.org>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -699,7 +700,14 @@ (define (store-item->manifest-entry item)
>  
>  (define (package->manifest-entry* package output)
>    "Like 'package->manifest-entry', but attach PACKAGE provenance meta-data to
> -the resulting manifest entry."
> +the resulting manifest entry, and report an error if PACKAGE is the 'guix'
> +package from the default channel."
> +  (when (and (string=? (package-name package) "guix")
> +             (string-prefix? "gnu/" (location-file
> +                                     (package-location package))))
> +    (report-error (G_ "the 'guix' package should not be installed~%"))
> +    (display-hint (G_ "use 'guix pull' to fetch the latest Guix revision"))
> +    (exit 1))
>    (manifest-entry-with-provenance
>     (package->manifest-entry package output)))

Instead of exiting directly here, would it make sense to use
raise-exception with a compounded message and &fix-hint condition?  When
working with the Guix API, I prefer to encounter exceptions rather than
errors + exit.  For a recent example I used, see:
https://issues.guix.gnu.org/58812#5-lineno360.

-- 
Thanks,
Maxim





reply via email to

[Prev in Thread] Current Thread [Next in Thread]