diff mbox series

[bug#58583,v2] scripts: package: Forbid installation of the guix package.

Message ID 20221017122254.16230-1-paren@disroot.org
State New
Headers show
Series [bug#58583,v2] scripts: package: Forbid installation of the guix package. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

\( Oct. 17, 2022, 12:22 p.m. UTC
* guix/scripts/package.scm (package->manifest-entry*): Fail if the
  package to be installed is guix from the default channel.
---
 guix/scripts/package.scm | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Tobias Geerinckx-Rice Oct. 17, 2022, 4:24 p.m. UTC | #1
Hullo.

"( via Guix-patches" via 写道:
> * guix/scripts/package.scm (package->manifest-entry*): Fail if 
> the
>   package to be installed is guix from the default channel.

♥

As noted elsewhere, I've come to support this, er, straightforward 
approach.  It might offend some readers, so let's leave this open 
for comment a bit longer.

I should like to merge it before 1.4, though.

> +    (report-error (G_ "the 'guix' package should not be 
> installed"))
> +    (newline (current-error-port))

I would write (report-error "…~%") sans (newline).  If you 
intentionally didn't, let's explicitly discuss that.

Kind regards,

T G-R
\( Oct. 17, 2022, 4:43 p.m. UTC | #2
Heya,

On Mon Oct 17, 2022 at 5:24 PM BST, Tobias Geerinckx-Rice wrote:
> > +    (report-error (G_ "the 'guix' package should not be 
> > installed"))
> > +    (newline (current-error-port))
>
> I would write (report-error "…~%") sans (newline).  If you 
> intentionally didn't, let's explicitly discuss that.

Agh, silly me. I'll correct that in a moment.

    -- (
diff mbox series

Patch

diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 7ba2661bbb..d0feb2063a 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,15 @@  (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"))
+    (newline (current-error-port))
+    (display-hint (G_ "use 'guix pull' to fetch the latest Guix revision"))
+    (exit 1))
   (manifest-entry-with-provenance
    (package->manifest-entry package output)))