diff mbox series

kbuild: use hostname -s along uname to obtain LINUX_COMPILE_HOST

Message ID 20220330182329.52310-1-s23265@iisve.it (mailing list archive)
State New
Headers show
Series kbuild: use hostname -s along uname to obtain LINUX_COMPILE_HOST | expand

Commit Message

Francesco Duca March 30, 2022, 6:23 p.m. UTC
From: Francesco Duca <s23265@iisve.it>

* 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")

Signed-off-by: Francesco Duca <s23265@iisve.it>
---
 scripts/mkcompile_h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Masahiro Yamada April 1, 2022, 2:04 p.m. UTC | #1
On Thu, Mar 31, 2022 at 3:23 AM FraSharp <f.duca00@gmail.com> wrote:
>
> From: Francesco Duca <s23265@iisve.it>
>
> * 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"




>   ("Francescos-Air.fritz.box" for example), which is very annoying.

I do not think so.


>   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  ?






>
> * This commit is complementary to
>   1e66d50ad3a1dbf0169b14d502be59a4b1213149
>   ("kbuild: Use uname for LINUX_COMPILE_HOST detection")
>
> Signed-off-by: Francesco Duca <s23265@iisve.it>
> ---
>  scripts/mkcompile_h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
> index ca40a5258..6054e3eee 100755
> --- a/scripts/mkcompile_h
> +++ b/scripts/mkcompile_h
> @@ -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)
>
Masahiro Yamada April 1, 2022, 2:19 p.m. UTC | #2
On Fri, Apr 1, 2022 at 11:04 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> On Thu, Mar 31, 2022 at 3:23 AM FraSharp <f.duca00@gmail.com> wrote:
> >
> > From: Francesco Duca <s23265@iisve.it>
> >
> > * 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"



>
>
>
> >   ("Francescos-Air.fritz.box" for example), which is very annoying.
>
> I do not think so.
>
>
> >   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  ?
>
>
>
>
>
>
> >
> > * This commit is complementary to
> >   1e66d50ad3a1dbf0169b14d502be59a4b1213149
> >   ("kbuild: Use uname for LINUX_COMPILE_HOST detection")
> >
> > Signed-off-by: Francesco Duca <s23265@iisve.it>
> > ---
> >  scripts/mkcompile_h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
> > index ca40a5258..6054e3eee 100755
> > --- a/scripts/mkcompile_h
> > +++ b/scripts/mkcompile_h
> > @@ -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)
> >
>
>
> --
> Best Regards
> Masahiro Yamada
Francesco Duca April 1, 2022, 3:06 p.m. UTC | #3
>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

>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

On Fri, Apr 01, 2022 at 11:19:22PM +0900, Masahiro Yamada wrote:
> On Fri, Apr 1, 2022 at 11:04 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > On Thu, Mar 31, 2022 at 3:23 AM FraSharp <f.duca00@gmail.com> wrote:
> > >
> > > From: Francesco Duca <s23265@iisve.it>
> > >
> > > * 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"
> 
> 
> 
> >
> >
> >
> > >   ("Francescos-Air.fritz.box" for example), which is very annoying.
> >
> > I do not think so.
> >
> >
> > >   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  ?
> >
> >
> >
> >
> >
> >
> > >
> > > * This commit is complementary to
> > >   1e66d50ad3a1dbf0169b14d502be59a4b1213149
> > >   ("kbuild: Use uname for LINUX_COMPILE_HOST detection")
> > >
> > > Signed-off-by: Francesco Duca <s23265@iisve.it>
> > > ---
> > >  scripts/mkcompile_h | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
> > > index ca40a5258..6054e3eee 100755
> > > --- a/scripts/mkcompile_h
> > > +++ b/scripts/mkcompile_h
> > > @@ -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)
> > >
> >
> >
> > --
> > Best Regards
> > Masahiro Yamada
> 
> 
> 
> -- 
> Best Regards
> Masahiro Yamada
Masahiro Yamada April 1, 2022, 3:22 p.m. UTC | #4
On Sat, Apr 2, 2022 at 12:06 AM Francesco Duca <f.duca00@gmail.com> wrote:
>
> >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
>
> >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
>
> On Fri, Apr 01, 2022 at 11:19:22PM +0900, Masahiro Yamada wrote:
> > On Fri, Apr 1, 2022 at 11:04 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > >
> > > On Thu, Mar 31, 2022 at 3:23 AM FraSharp <f.duca00@gmail.com> wrote:
> > > >
> > > > From: Francesco Duca <s23265@iisve.it>
> > > >
> > > > * 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"
> >
> >
> >
> > >
> > >
> > >
> > > >   ("Francescos-Air.fritz.box" for example), which is very annoying.
> > >
> > > I do not think so.
> > >
> > >
> > > >   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.






> > >
> > >
> > >
> > >
> > >
> > >
> > > >
> > > > * This commit is complementary to
> > > >   1e66d50ad3a1dbf0169b14d502be59a4b1213149
> > > >   ("kbuild: Use uname for LINUX_COMPILE_HOST detection")
> > > >
> > > > Signed-off-by: Francesco Duca <s23265@iisve.it>
> > > > ---
> > > >  scripts/mkcompile_h | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
> > > > index ca40a5258..6054e3eee 100755
> > > > --- a/scripts/mkcompile_h
> > > > +++ b/scripts/mkcompile_h
> > > > @@ -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)
> > > >
> > >
> > >
> > > --
> > > Best Regards
> > > Masahiro Yamada
> >
> >
> >
> > --
> > Best Regards
> > Masahiro Yamada



--
Best Regards
Masahiro Yamada
Francesco Duca April 1, 2022, 3:39 p.m. UTC | #5
> ( <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>

> 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.

On Sat, Apr 02, 2022 at 12:22:55AM +0900, Masahiro Yamada wrote:
> On Sat, Apr 2, 2022 at 12:06 AM Francesco Duca <f.duca00@gmail.com> wrote:
> >
> > >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
> >
> > >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
> >
> > On Fri, Apr 01, 2022 at 11:19:22PM +0900, Masahiro Yamada wrote:
> > > On Fri, Apr 1, 2022 at 11:04 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > > >
> > > > On Thu, Mar 31, 2022 at 3:23 AM FraSharp <f.duca00@gmail.com> wrote:
> > > > >
> > > > > From: Francesco Duca <s23265@iisve.it>
> > > > >
> > > > > * 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"
> > >
> > >
> > >
> > > >
> > > >
> > > >
> > > > >   ("Francescos-Air.fritz.box" for example), which is very annoying.
> > > >
> > > > I do not think so.
> > > >
> > > >
> > > > >   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.
> 
> 
> 
> 
> 
> 
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > >
> > > > > * This commit is complementary to
> > > > >   1e66d50ad3a1dbf0169b14d502be59a4b1213149
> > > > >   ("kbuild: Use uname for LINUX_COMPILE_HOST detection")
> > > > >
> > > > > Signed-off-by: Francesco Duca <s23265@iisve.it>
> > > > > ---
> > > > >  scripts/mkcompile_h | 2 +-
> > > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
> > > > > index ca40a5258..6054e3eee 100755
> > > > > --- a/scripts/mkcompile_h
> > > > > +++ b/scripts/mkcompile_h
> > > > > @@ -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)
> > > > >
> > > >
> > > >
> > > > --
> > > > Best Regards
> > > > Masahiro Yamada
> > >
> > >
> > >
> > > --
> > > Best Regards
> > > Masahiro Yamada
> 
> 
> 
> --
> Best Regards
> Masahiro Yamada
diff mbox series

Patch

diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
index ca40a5258..6054e3eee 100755
--- a/scripts/mkcompile_h
+++ b/scripts/mkcompile_h
@@ -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