unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#74952: [PATCH] guix-install.sh: Use "command -v nologin" instead of "which nologin".
@ 2024-12-18 20:35 Simon Josefsson via Bug reports for GNU Guix
  2024-12-18 21:55 ` Leo Famulari
  0 siblings, 1 reply; 2+ messages in thread
From: Simon Josefsson via Bug reports for GNU Guix @ 2024-12-18 20:35 UTC (permalink / raw)
  To: 74952


[-- Attachment #1.1: Type: text/plain, Size: 262 bytes --]

Hi!

In a small container image, I do not have the 'which' tool installed.  I
believe 'command -v' is always available since it is /bin/sh standard.
How about changing the idiom for user/group additions from 'which' to
'command -v'?  See attached patch.

/Simon

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-guix-install.sh-Use-command-v-nologin-instead-of-whi.patch --]
[-- Type: text/x-diff, Size: 2721 bytes --]

From 2bc261126a84a4a9a33acea9f107ad4bdef929d0 Mon Sep 17 00:00:00 2001
From: Simon Josefsson <simon@josefsson.org>
Date: Wed, 18 Dec 2024 21:30:10 +0100
Subject: [PATCH] guix-install.sh: Use "command -v nologin" instead of "which
 nologin".

* doc/guix.texi (Build Environment Setup): Change.
* etc/guix-install.sh (sys_create_build_user): Likewise.
* gnu/machine/digital-ocean.scm (guix-infect): Update.
---
 doc/guix.texi                 | 6 +++---
 etc/guix-install.sh           | 4 ++--
 gnu/machine/digital-ocean.scm | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index f7b7569887..46ceb71cde 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -944,9 +944,9 @@ Bash syntax and the @code{shadow} commands):
 # groupadd --system guixbuild
 # for i in $(seq -w 1 10);
   do
-    useradd -g guixbuild -G guixbuild           \
-            -d /var/empty -s $(which nologin)   \
-            -c "Guix build user $i" --system    \
+    useradd -g guixbuild -G guixbuild              \
+            -d /var/empty -s $(command -v nologin) \
+            -c "Guix build user $i" --system       \
             guixbuilder$i;
   done
 @end example
diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index f07b2741bb..44b3e62ed2 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -435,12 +435,12 @@ sys_create_build_user()
         if id "guixbuilder${i}" &>/dev/null; then
             _msg "${INF}user is already in the system, reset"
             usermod -g guixbuild -G guixbuild${KVMGROUP}     \
-                    -d /var/empty -s "$(which nologin)" \
+                    -d /var/empty -s "$(command -v nologin)" \
                     -c "Guix build user $i"             \
                     "guixbuilder${i}";
         else
             useradd -g guixbuild -G guixbuild${KVMGROUP}     \
-                    -d /var/empty -s "$(which nologin)" \
+                    -d /var/empty -s "$(command -v nologin)" \
                     -c "Guix build user $i" --system    \
                     "guixbuilder${i}";
             _msg "${PAS}user added <guixbuilder${i}>"
diff --git a/gnu/machine/digital-ocean.scm b/gnu/machine/digital-ocean.scm
index d0f0bbe4cb..5fa679ab8c 100644
--- a/gnu/machine/digital-ocean.scm
+++ b/gnu/machine/digital-ocean.scm
@@ -260,7 +260,7 @@ (define os
 groupadd --system guixbuild
 for i in `seq -w 1 10`; do
    useradd -g guixbuild -G guixbuild         \
-           -d /var/empty -s `which nologin`  \
+           -d /var/empty -s `command -v nologin`  \
            -c \"Guix build user $i\" --system  \
            guixbuilder$i;
 done;
-- 
2.46.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 255 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#74952: [PATCH] guix-install.sh: Use "command -v nologin" instead of "which nologin".
  2024-12-18 20:35 bug#74952: [PATCH] guix-install.sh: Use "command -v nologin" instead of "which nologin" Simon Josefsson via Bug reports for GNU Guix
@ 2024-12-18 21:55 ` Leo Famulari
  0 siblings, 0 replies; 2+ messages in thread
From: Leo Famulari @ 2024-12-18 21:55 UTC (permalink / raw)
  To: 74952

On Wed, Dec 18, 2024 at 09:35:27PM +0100, Simon Josefsson via Bug reports for GNU Guix wrote:
> Hi!
> 
> In a small container image, I do not have the 'which' tool installed.  I
> believe 'command -v' is always available since it is /bin/sh standard.
> How about changing the idiom for user/group additions from 'which' to
> 'command -v'?  See attached patch.

Agreed, I don't think we need to require `which` here.

It can also be removed from REQUIRE in 'etc/guix-install.sh'.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-12-18 21:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-18 20:35 bug#74952: [PATCH] guix-install.sh: Use "command -v nologin" instead of "which nologin" Simon Josefsson via Bug reports for GNU Guix
2024-12-18 21:55 ` Leo Famulari

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).