kbuild: use hostname -s along uname to obtain LINUX_COMPILE_HOST
PATCH 1/1 kbuild: use hostname -s along uname to obtain LINUX_COMPILE_HOST
From: Francesco Duca <[email protected]>
* On some systems (e.g. macOS), using commands like 'uname -n' or 'hostname' will print something similar to "hostname.domain" ("Francescos-Air.fritz.box" for example), which is very annoying. What works instead is 'hostname -s', which will only write hostname without the domain ("Francescos-Air" for example),
but also keep 'uname -n', as some systems as Arch Linux does not have 'hostname' as command.
* This commit is complementary to 1e66d50ad3a1dbf0169b14d502be59a4b1213149 ("kbuild: Use uname for LINUX_COMPILE_HOST detection")
--- scripts/mkcompile_h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/mkcompile_h +1 -1
@@ -34,7 +34,7 @@ else LINUX_COMPILE_BY=$KBUILD_BUILD_USER fi if test -z "$KBUILD_BUILD_HOST"; then - LINUX_COMPILE_HOST=`uname -n` + LINUX_COMPILE_HOST=$(hostname -s || uname -n) else LINUX_COMPILE_HOST=$KBUILD_BUILD_HOST fi
Signature · 1 line
2.32.0 (Apple Git-132)
Quoted 5 lines · FraSharp
From: Francesco Duca <[email protected]>
* On some systems (e.g. macOS), using commands like 'uname -n' or 'hostname' will print something similar to "hostname.domain"
Not only macOS, but also on Linux systems such as Fedora, Debian.
'uname -s' or 'hostname' prints "hostname.domain"
Quoted 1 line
("Francescos-Air.fritz.box" for example), which is very annoying.
I do not think so.
Quoted 4 lines
What works instead is 'hostname -s', which will only write hostname without the domain ("Francescos-Air" for example),
but also keep 'uname -n', as some systems as Arch Linux does not have 'hostname' as command.
If so, on Arch Linux, will this patch spit
hostname: command not found
error message because "2>/dev/null" is missing ?
And, the intention of this patch is,
print Francescos-Air if the 'hostname -s' command is available, but Francescos-Air.fritz.box otherwise, correct ?
Quoted 26 lines
* This commit is complementary to
1e66d50ad3a1dbf0169b14d502be59a4b1213149("kbuild: Use uname forLINUX_COMPILE_HOSTdetection")Signed-off-by Francesco Duca <[email protected]>--- scripts/mkcompile_h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/mkcompile_h +1
-2@@ -34,7 +34,7 @@ else LINUX_COMPILE_BY=$KBUILD_BUILD_USER fi if test -z "$KBUILD_BUILD_HOST"; then - LINUX_COMPILE_HOST=`uname -n` + LINUX_COMPILE_HOST=$(hostname -s || uname -n) else LINUX_COMPILE_HOST=$KBUILD_BUILD_HOST fi --2.32.0 (Apple Git-132)
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 5 lines · Masahiro Yamada
Quoted 3 lines · FraSharp
From: Francesco Duca <[email protected]>
Quoted 7 lines
Quoted 2 lines
* On some systems (e.g. macOS), using commands like 'uname -n' or 'hostname' will print something similar to "hostname.domain"
Not only macOS, but also on Linux systems such as Fedora, Debian.
'uname -s' or 'hostname' prints "hostname.domain"
I mean,
'uname -n' or 'hostname' prints "hostname.domain"
Quoted 58 lines
Quoted 4 lines
("Francescos-Air.fritz.box" for example), which is very annoying.
I do not think so.
Quoted 4 lines
What works instead is 'hostname -s', which will only write hostname without the domain ("Francescos-Air" for example),
but also keep 'uname -n', as some systems as Arch Linux does not have 'hostname' as command.If so, on Arch Linux, will this patch spit
hostname: command not found
error message because "2>/dev/null" is missing ?And, the intention of this patch is,
print Francescos-Air if the 'hostname -s' command is available, but Francescos-Air.fritz.box otherwise, correct ?Quoted 24 lines
* This commit is complementary to
1e66d50ad3a1dbf0169b14d502be59a4b1213149("kbuild: Use uname forLINUX_COMPILE_HOSTdetection")Signed-off-by Francesco Duca <[email protected]>--- scripts/mkcompile_h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/mkcompile_h +1
-2@@ -34,7 +34,7 @@ else LINUX_COMPILE_BY=$KBUILD_BUILD_USER fi if test -z "$KBUILD_BUILD_HOST"; then - LINUX_COMPILE_HOST=`uname -n` + LINUX_COMPILE_HOST=$(hostname -s || uname -n) else LINUX_COMPILE_HOST=$KBUILD_BUILD_HOST fi --Quoted 2 lines
2.32.0 (Apple Git-132)
--
Best Regards
Masahiro Yamada
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 3 lines
And, the intention of this patch is,
print Francescos-Air if the 'hostname -s' command is available, but Francescos-Air.fritz.box otherwise, correct ?
Yes exactly, this is the intention of this patch
Quoted 1 line
error message because "2>/dev/null" is missing ?
It is missing indeed, i forgot to add it.
I will send a new v2 patch in a while
Quoted 84 lines · Masahiro Yamada
Quoted 5 lines · Masahiro Yamada
Quoted 3 lines · FraSharp
From: Francesco Duca <[email protected]>
Quoted 7 lines
Quoted 2 lines
* On some systems (e.g. macOS), using commands like 'uname -n' or 'hostname' will print something similar to "hostname.domain"
Not only macOS, but also on Linux systems such as Fedora, Debian.
'uname -s' or 'hostname' prints "hostname.domain"
I mean,
'uname -n' or 'hostname' prints "hostname.domain"
Quoted 58 lines
Quoted 4 lines
("Francescos-Air.fritz.box" for example), which is very annoying.
I do not think so.
Quoted 4 lines
What works instead is 'hostname -s', which will only write hostname without the domain ("Francescos-Air" for example),
but also keep 'uname -n', as some systems as Arch Linux does not have 'hostname' as command.If so, on Arch Linux, will this patch spit
hostname: command not found
error message because "2>/dev/null" is missing ?And, the intention of this patch is,
print Francescos-Air if the 'hostname -s' command is available, but Francescos-Air.fritz.box otherwise, correct ?Quoted 24 lines
* This commit is complementary to
1e66d50ad3a1dbf0169b14d502be59a4b1213149("kbuild: Use uname forLINUX_COMPILE_HOSTdetection")Signed-off-by Francesco Duca <[email protected]>--- scripts/mkcompile_h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/mkcompile_h +1
-2@@ -34,7 +34,7 @@ else LINUX_COMPILE_BY=$KBUILD_BUILD_USER fi if test -z "$KBUILD_BUILD_HOST"; then - LINUX_COMPILE_HOST=`uname -n` + LINUX_COMPILE_HOST=$(hostname -s || uname -n) else LINUX_COMPILE_HOST=$KBUILD_BUILD_HOST fi --Quoted 2 lines
2.32.0 (Apple Git-132)
--
Best Regards
Masahiro YamadaSignature · 2 lines
Best Regards Masahiro Yamada
Masahiro Yamada
NAKQuoted 7 lines · Francesco Duca
Quoted 4 lines
And, the intention of this patch is,
print Francescos-Air if the 'hostname -s' command is available, but Francescos-Air.fritz.box otherwise, correct ?Yes exactly, this is the intention of this patch
Quoted 48 lines
Quoted 1 line
error message because "2>/dev/null" is missing ?
It is missing indeed, i forgot to add it.
I will send a new v2 patch in a while
Quoted 41 lines · Masahiro Yamada
Quoted 5 lines · Masahiro Yamada
Quoted 3 lines · FraSharp
From: Francesco Duca <[email protected]>
Quoted 7 lines
Quoted 2 lines
* On some systems (e.g. macOS), using commands like 'uname -n' or 'hostname' will print something similar to "hostname.domain"
Not only macOS, but also on Linux systems such as Fedora, Debian.
'uname -s' or 'hostname' prints "hostname.domain"
I mean,
'uname -n' or 'hostname' prints "hostname.domain"
Quoted 21 lines
Quoted 4 lines
("Francescos-Air.fritz.box" for example), which is very annoying.
I do not think so.
Quoted 4 lines
What works instead is 'hostname -s', which will only write hostname without the domain ("Francescos-Air" for example),
but also keep 'uname -n', as some systems as Arch Linux does not have 'hostname' as command.If so, on Arch Linux, will this patch spit
hostname: command not found
error message because "2>/dev/null" is missing ?And, the intention of this patch is,
print Francescos-Air if the 'hostname -s' command is available, but Francescos-Air.fritz.box otherwise, correct ?
I do not see a good reason to output different strings on different distributions.
( <hostname> on Debian vs <hostname>.<domainname> on Arch Linux)
<hostname>.<domainname> is just fine.
As I said, it is not annoying.
NACK.
Quoted 40 lines
Quoted 40 lines
Quoted 37 lines
Quoted 30 lines
* This commit is complementary to
1e66d50ad3a1dbf0169b14d502be59a4b1213149("kbuild: Use uname forLINUX_COMPILE_HOSTdetection")Signed-off-by Francesco Duca <[email protected]>--- scripts/mkcompile_h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/mkcompile_h +1
-2@@ -34,7 +34,7 @@ else LINUX_COMPILE_BY=$KBUILD_BUILD_USER fi if test -z "$KBUILD_BUILD_HOST"; then - LINUX_COMPILE_HOST=`uname -n` + LINUX_COMPILE_HOST=$(hostname -s || uname -n) else LINUX_COMPILE_HOST=$KBUILD_BUILD_HOST fi --Quoted 2 lines
2.32.0 (Apple Git-132)
--
Best Regards
Masahiro Yamada
Quoted 3 lines
Quoted 3 lines
--
Best Regards
Masahiro Yamada
--
Best Regards
Masahiro Yamada
Quoted 1 line
( <hostname> on Debian vs <hostname>.<domainname> on Arch Linux)
Actually, every time i compiled a kernel (on Arch/Ubuntu), KBUILD_BUILD_HOST it's always <hostname> without <domainname>, while on macOS, KBUILD_BUILD_HOST is <hostname>.<domainname>
Quoted 1 line
As I said, it is not annoying.
I said it is annoying just because <hostname>.<domainname> is set on macOS only and not on Linux (Arch or Ubuntu).
Now, it may be a "me only" problem, so i'm not sure, but from my experience it only happens on macOS.
Quoted 121 lines · Masahiro Yamada
Quoted 7 lines · Francesco Duca
Quoted 4 lines
And, the intention of this patch is,
print Francescos-Air if the 'hostname -s' command is available, but Francescos-Air.fritz.box otherwise, correct ?Yes exactly, this is the intention of this patch
Quoted 48 lines
Quoted 1 line
error message because "2>/dev/null" is missing ?
It is missing indeed, i forgot to add it.
I will send a new v2 patch in a while
Quoted 41 lines · Masahiro Yamada
Quoted 5 lines · Masahiro Yamada
Quoted 3 lines · FraSharp
From: Francesco Duca <[email protected]>
Quoted 7 lines
Quoted 2 lines
* On some systems (e.g. macOS), using commands like 'uname -n' or 'hostname' will print something similar to "hostname.domain"
Not only macOS, but also on Linux systems such as Fedora, Debian.
'uname -s' or 'hostname' prints "hostname.domain"
I mean,
'uname -n' or 'hostname' prints "hostname.domain"
Quoted 21 lines
Quoted 4 lines
("Francescos-Air.fritz.box" for example), which is very annoying.
I do not think so.
Quoted 4 lines
What works instead is 'hostname -s', which will only write hostname without the domain ("Francescos-Air" for example),
but also keep 'uname -n', as some systems as Arch Linux does not have 'hostname' as command.If so, on Arch Linux, will this patch spit
hostname: command not found
error message because "2>/dev/null" is missing ?And, the intention of this patch is,
print Francescos-Air if the 'hostname -s' command is available, but Francescos-Air.fritz.box otherwise, correct ?I do not see a good reason to output different strings on different distributions.
( <hostname> on Debian vs <hostname>.<domainname> on Arch Linux)<hostname>.<domainname> is just fine.
As I said, it is not annoying.NACK.
Quoted 40 lines
Quoted 40 lines
Quoted 37 lines
Quoted 30 lines
* This commit is complementary to
1e66d50ad3a1dbf0169b14d502be59a4b1213149("kbuild: Use uname forLINUX_COMPILE_HOSTdetection")Signed-off-by Francesco Duca <[email protected]>--- scripts/mkcompile_h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/mkcompile_h +1
-2@@ -34,7 +34,7 @@ else LINUX_COMPILE_BY=$KBUILD_BUILD_USER fi if test -z "$KBUILD_BUILD_HOST"; then - LINUX_COMPILE_HOST=`uname -n` + LINUX_COMPILE_HOST=$(hostname -s || uname -n) else LINUX_COMPILE_HOST=$KBUILD_BUILD_HOST fi --Quoted 2 lines
2.32.0 (Apple Git-132)
--
Best Regards
Masahiro YamadaQuoted 3 lines
Quoted 3 lines
--
Best Regards
Masahiro Yamada--
Best Regards
Masahiro Yamada
PATCH v2 1/1 kbuild: use hostname -s along uname to obtain LINUX_COMPILE_HOST
In reply to FraSharp* On some systems (e.g. macOS, Debian, Fedora), using commands like 'uname -n' or 'hostname' will print something similar to "hostname.domain" ("Francescos-Air.fritz.box" for example), which is very annoying. What works instead is 'hostname -s', which will only write hostname without the domain ("Francescos-Air" for example),
but also keep 'uname -n', as some systems as Arch Linux does not have 'hostname' as command.
* This commit is complementary to 1e66d50ad3a1dbf0169b14d502be59a4b1213149 ("kbuild: Use uname for LINUX_COMPILE_HOST detection")
--- scripts/mkcompile_h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/mkcompile_h +1 -1
@@ -34,7 +34,7 @@ else LINUX_COMPILE_BY=$KBUILD_BUILD_USER fi if test -z "$KBUILD_BUILD_HOST"; then - LINUX_COMPILE_HOST=`uname -n` + LINUX_COMPILE_HOST=$(hostname -s 2>/dev/null || uname -n) else LINUX_COMPILE_HOST=$KBUILD_BUILD_HOST fi
Signature · 1 line
2.32.0 (Apple Git-132)
Nathan Chancellor
maintainerHi Francesco,
Quoted 33 lines · FraSharp
* On some systems (e.g. macOS, Debian, Fedora), using commands like 'uname -n' or 'hostname' will print something similar to "hostname.domain" ("Francescos-Air.fritz.box" for example), which is very annoying. What works instead is 'hostname -s', which will only write hostname without the domain ("Francescos-Air" for example),
but also keep 'uname -n', as some systems as Arch Linux does not have 'hostname' as command.* This commit is complementary to
1e66d50ad3a1dbf0169b14d502be59a4b1213149("kbuild: Use uname forLINUX_COMPILE_HOSTdetection")Signed-off-by Francesco Duca <[email protected]>--- scripts/mkcompile_h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/mkcompile_h +1
-1@@ -34,7 +34,7 @@ else LINUX_COMPILE_BY=$KBUILD_BUILD_USER fi if test -z "$KBUILD_BUILD_HOST"; then - LINUX_COMPILE_HOST=`uname -n` + LINUX_COMPILE_HOST=$(hostname -s 2>/dev/null || uname -n) else LINUX_COMPILE_HOST=$KBUILD_BUILD_HOST fiSignature · 1 line
2.32.0 (Apple Git-132)
I personally think this is going to output something objectively worse for my use case. I use containers for my main workflow, which have a hostname of "container name" and domain name of "host's hostname".
For example:
$ uname -n thelio-3990X
$ distrobox enter dev-arch
$ uname -n dev-arch.thelio-3990X
With the move to 'hostname -s' by default, I lose the information about the main host machine, so I am unable to tell exactly which container built the image:
$ hostname -s dev-arch
While moving to containers is supposed to help eliminate the need to know about a particular machine because it should be the same environment, it is still relevant because I build certain tools on some machines and not others and I am not necessarily updating each container on the same timeline, so it is still useful to have this information included in the kernel image for tracking purposes.
Given this is a purely a subjective/cosmetic issue, why can you not just add something like
export KBUILD_BUILD_HOST=$(hostname -s)
in your shell's start up file, so that the hostname is in the format that you desire?
Cheers,
Nathan