[1/1] board/raspberrypi/post-build.sh: avoid HDMI login when getty disabled
diff mbox series

Message ID 20191001125028.5094-1-mailist@logilin.fr
State New
Headers show
Series
  • [1/1] board/raspberrypi/post-build.sh: avoid HDMI login when getty disabled
Related show

Commit Message

Christophe Blaess Oct. 1, 2019, 12:50 p.m. UTC
From: Christophe Blaess <christophe.blaess@logilin.fr>

When the "Run a getty after boot" option is disabled, the inittab line
starting getty on serial console is commented out. But the line running
an HDMI login on Raspberry Pi is still enabled.
With this patch the HDMI line is removed.

Co-authored-by: Christophe Blaess <christophe.blaess@logilin.fr>
Co-authored-by: Stephen Bos <stephen.bos@hagergroup.com>

Signed-off-by: Christophe Blaess <christophe.blaess@logilin.fr>
---
 board/raspberrypi/post-build.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Carlos Santos Oct. 3, 2019, 7:04 p.m. UTC | #1
On Tue, Oct 1, 2019 at 9:58 AM Christophe Blaess <mailist@logilin.fr> wrote:
>
> From: Christophe Blaess <christophe.blaess@logilin.fr>
>
> When the "Run a getty after boot" option is disabled, the inittab line
> starting getty on serial console is commented out. But the line running
> an HDMI login on Raspberry Pi is still enabled.
> With this patch the HDMI line is removed.
>
> Co-authored-by: Christophe Blaess <christophe.blaess@logilin.fr>
> Co-authored-by: Stephen Bos <stephen.bos@hagergroup.com>
>
> Signed-off-by: Christophe Blaess <christophe.blaess@logilin.fr>
> ---
>  board/raspberrypi/post-build.sh | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/board/raspberrypi/post-build.sh b/board/raspberrypi/post-build.sh
> index 5e5eb71100..7f4e1cc8bf 100755
> --- a/board/raspberrypi/post-build.sh
> +++ b/board/raspberrypi/post-build.sh
> @@ -3,9 +3,11 @@
>  set -u
>  set -e
>
> -# Add a console on tty1
>  if [ -e ${TARGET_DIR}/etc/inittab ]; then
> -    grep -qE '^tty1::' ${TARGET_DIR}/etc/inittab || \
> -       sed -i '/GENERIC_SERIAL/a\
> +       # Remove tty1 line
> +       sed -i '/^tty1::/d' ${TARGET_DIR}/etc/inittab
> +       # Add a tty1 line if GENERIC_SERIAL is present (and not commented)
> +       sed -i '/^[^#].*GENERIC_SERIAL/a\
>  tty1::respawn:/sbin/getty -L  tty1 0 vt100 # HDMI console' ${TARGET_DIR}/etc/inittab
>  fi
> +
> --
> 2.17.1
>
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

I guess you are using raspberrypi_defconfig as a template for a custom
board configuration. Can't you simply leave
BR2_ROOTFS_POST_BUILD_SCRIPT empty?
Christophe Blaess Oct. 3, 2019, 7:47 p.m. UTC | #2
Hello Carlos,

> I guess you are using raspberrypi_defconfig as a template for a custom
> board configuration. Can't you simply leave
> BR2_ROOTFS_POST_BUILD_SCRIPT empty?

No, I was using raspberry_defconfig on Raspberry Pi 4 as training 
support to show how to use this option on production systems when we 
don't want any getty (only custom code running on background).

I removed serial console by disabling the "Run a getty option.." but the 
HDMI login was still there.

It's ok to remove the BR2_ROOTFS_POST_BUILD_SCRIPT, but I would rather 
have only disabled the getty option. It seemed more elegant to me.
Carlos Santos Oct. 3, 2019, 10:25 p.m. UTC | #3
On Thu, Oct 3, 2019 at 4:54 PM Christophe Blaess <mailist@logilin.fr> wrote:
>
> Hello Carlos,
>
> > I guess you are using raspberrypi_defconfig as a template for a custom
> > board configuration. Can't you simply leave
> > BR2_ROOTFS_POST_BUILD_SCRIPT empty?
>
> No, I was using raspberry_defconfig on Raspberry Pi 4 as training
> support to show how to use this option on production systems when we
> don't want any getty (only custom code running on background).
>
> I removed serial console by disabling the "Run a getty option.." but the
> HDMI login was still there.
>
> It's ok to remove the BR2_ROOTFS_POST_BUILD_SCRIPT, but I would rather
> have only disabled the getty option. It seemed more elegant to me.

I think it's more elegant to solve the problem by means of the
configuration, not by customizing buildroot. The board configurations
an their  post-build and post-mage scripts are mostly examples.

If you need something more sophisticated then it's better to keep them
in a BR2_EXTERNAL, as documented in

    http://www.buildroot.org/downloads/manual/manual.html#customize

Patch
diff mbox series

diff --git a/board/raspberrypi/post-build.sh b/board/raspberrypi/post-build.sh
index 5e5eb71100..7f4e1cc8bf 100755
--- a/board/raspberrypi/post-build.sh
+++ b/board/raspberrypi/post-build.sh
@@ -3,9 +3,11 @@ 
 set -u
 set -e
 
-# Add a console on tty1
 if [ -e ${TARGET_DIR}/etc/inittab ]; then
-    grep -qE '^tty1::' ${TARGET_DIR}/etc/inittab || \
-	sed -i '/GENERIC_SERIAL/a\
+	# Remove tty1 line
+	sed -i '/^tty1::/d' ${TARGET_DIR}/etc/inittab
+	# Add a tty1 line if GENERIC_SERIAL is present (and not commented)
+	sed -i '/^[^#].*GENERIC_SERIAL/a\
 tty1::respawn:/sbin/getty -L  tty1 0 vt100 # HDMI console' ${TARGET_DIR}/etc/inittab
 fi
+