[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#57031] [PATCH v2 2/2] scripts: Warn the first time pull or package
From: |
zimoun |
Subject: |
[bug#57031] [PATCH v2 2/2] scripts: Warn the first time pull or package is run as root. |
Date: |
Wed, 26 Oct 2022 20:14:49 +0200 |
Hi,
On Sun, 11 Sep 2022 at 20:59, "\( via Guix-patches" via <guix-patches@gnu.org>
wrote:
> * guix/scripts/pull.scm (guix-pull): Warn the first time it's being
> run as root.
> * guix/scripts/package.scm (guix-package*): Likewise if the new
> `root-hint?' argument is `#t'.
> (guix-package): Use `#:root-hint? #t' in invocation of `guix-package*'.
> * guix/scripts/install.scm (guix-install): Likewise.
> * guix/scripts/remove.scm (guix-remove): Likewise.
> * guix/scripts/remove.scm (guix-upgrade): Likewise.
>
> A pretty common beginner mistake, it seems, is assuming that since
> every other package manager you've used requires root for installing,
> removing, and upgrading packages, Guix must too.
>
> This commit tries to make it harder to make such an assumption, by
> making commands such as `pull`, `package`, and `upgrade` display
> a warning the first time they are run as root.
This patch LGTM aside…
> - (guix-package* opts))
> + (guix-package* opts #:root-hint? #t))
[...]
> - (guix-package* opts))
> + (guix-package* opts #:root-hint? #t))
[...]
> -(define (guix-package* opts)
> +(define* (guix-package* opts #:key (root-hint? #f))
Why this ’root-hint?’ argument? Is it useful or can we drop it?
> + (when (and root-hint?
> + (not (hint-given? 'package-root-hint))
> + (zero? (getuid)))
> + (record-hint 'package-root-hint)
> + (warning (G_ "this command is user-specific, so running it as root \
> +will affect only the 'root' user~%")))
[...]
> + (when (and (not (hint-given? 'pull-root-hint))
> + (zero? (getuid)))
> + (record-hint 'pull-root-hint)
> + (warning (G_ "this command is user-specific, so running it as root \
> +will affect only the 'root' user~%")))
It looks pretty similar. Is it possible to avoid the duplication?
Cheers,
simon
- [bug#57031] [PATCH v2 2/2] scripts: Warn the first time pull or package is run as root.,
zimoun <=