[elbe-devel] [PATCH] rfs: invert logic for getty setup

Torben Hohn torben.hohn at linutronix.de
Wed Aug 7 09:49:07 CEST 2019


On Tue, Aug 06, 2019 at 09:32:03PM +0200, John Ogness wrote:
> elbe tries both SysV and systemd methods for setting up getty.
> However, the tries are written such that an error is generated,
> even if the situation is normal. Invert the logic so that
> error messages are only generated if there is really a problem.
> 
> Signed-off-by: John Ogness <john.ogness at linutronix.de>

i have never been happy with the use of shell code, where its not
necessary.

I just kept this, because we never touched this code.

we have a Filesystem object there.

so we can just do:

if self.rfs.exists('/etc/inittab'):
	self.rfs.append_file('/etc/inittab', 
	                     'T0:23:respawn:/sbin/getty -L %s %s vt100\n' % (serial_con, serial_baud))


same for the symlink. there is Filesystem.symink()


> ---
>  Let's get rid of these "normal" error messages!
> 
>  elbepack/rfs.py |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/elbepack/rfs.py b/elbepack/rfs.py
> index 97aa48b..dca69c6 100644
> --- a/elbepack/rfs.py
> +++ b/elbepack/rfs.py
> @@ -344,7 +344,7 @@ class BuildEnv (object):
>              if serial_baud:
>                  self.log.chroot(
>                      self.rfs.path,
> -                    """/bin/sh -c '[ -f /etc/inittab ] && """
> +                    """/bin/sh -c '[ ! -f /etc/inittab ] || """
>                      """echo "T0:23:respawn:/sbin/getty -L %s %s vt100" >> """
>                      """/etc/inittab'""" % (serial_con, serial_baud),
>                      allow_fail=True)

you also did not remove the allow_fail=True


> @@ -352,7 +352,7 @@ class BuildEnv (object):
>                  self.log.chroot(
>                      self.rfs.path,
>                      """/bin/sh -c """
> -                    """'[ -f /lib/systemd/system/serial-getty at .service ] && """
> +                    """'[ ! -f /lib/systemd/system/serial-getty at .service ] || """
>                      """ln -s /lib/systemd/system/serial-getty at .service """
>                      """/etc/systemd/system/getty.target.wants/"""
>                      """serial-getty@%s.service'""" % serial_con,
> -- 
> 1.7.10.4
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner



More information about the elbe-devel mailing list