Patchwork [meta-oe,1/1] systemd-serialgetty: use a wrapper script to find getty

login
register
mail settings
Submitter Otavio Salvador
Date Nov. 28, 2011, 12:52 p.m.
Message ID <e32fd0221c36927758fffdda5b4235c39fb5b3d0.1322484731.git.otavio@ossystems.com.br>
Download mbox | patch
Permalink /patch/15469/
State New, archived
Headers show

Comments

Otavio Salvador - Nov. 28, 2011, 12:52 p.m.
The following binaries are checked:

  /sbin/agetty
  /sbin/mingetty
  /sbin/getty

So this works out of box in most cases and doesn't enforce one getty
as dependency.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---
 .../recipes-core/systemd/systemd-serialgetty.bb    |   13 ++++++++++---
 .../systemd-serialgetty/serial-getty@.service      |    2 +-
 .../systemd-serialgetty/systemd-serialgetty        |   13 +++++++++++++
 3 files changed, 24 insertions(+), 4 deletions(-)
 create mode 100755 meta-oe/recipes-core/systemd/systemd-serialgetty/systemd-serialgetty
Martin Jansa - Nov. 28, 2011, 2 p.m.
On Mon, Nov 28, 2011 at 12:52:39PM +0000, Otavio Salvador wrote:
> The following binaries are checked:
> 
>   /sbin/agetty
>   /sbin/mingetty
>   /sbin/getty
> 
> So this works out of box in most cases and doesn't enforce one getty
> as dependency.

FWIW: I have 2 patches for tinylogin and util-linux-agetty to provide
/sbin/getty u-a

openembedded-core-contrib/shr
util-linux: use u-a to provide /sbin/getty from util-linux-agetty
tinylogin: use u-a for getty so we can provide /sbin/getty from util-linux-agetty too
http://git.openembedded.org/openembedded-core-contrib/commit/?h=shr&id=f6aa6fc06af906ab7ee374d544b81f1ef9948403
http://git.openembedded.org/openembedded-core-contrib/commit/?h=shr&id=e34e002f33660591705cd7b21e3a815382a50b3e

I didn't send pull request with them, because I'm still waiting for
previous pull request (with libsdl changes) to be applied.

We can add u-a to mingetty and solve whole problem even for sysvinit
etc...

Cheers,

> 
> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
> ---
>  .../recipes-core/systemd/systemd-serialgetty.bb    |   13 ++++++++++---
>  .../systemd-serialgetty/serial-getty@.service      |    2 +-
>  .../systemd-serialgetty/systemd-serialgetty        |   13 +++++++++++++
>  3 files changed, 24 insertions(+), 4 deletions(-)
>  create mode 100755 meta-oe/recipes-core/systemd/systemd-serialgetty/systemd-serialgetty
> 
> diff --git a/meta-oe/recipes-core/systemd/systemd-serialgetty.bb b/meta-oe/recipes-core/systemd/systemd-serialgetty.bb
> index 2b88d0c..c79ae84 100644
> --- a/meta-oe/recipes-core/systemd/systemd-serialgetty.bb
> +++ b/meta-oe/recipes-core/systemd/systemd-serialgetty.bb
> @@ -2,12 +2,13 @@ DESCRIPTION = "Systemd serial config"
>  LICENSE = "GPLv2+"
>  LIC_FILES_CHKSUM = "file://${WORKDIR}/LICENSE;md5=751419260aa954499f7abaabaa882bbe"
>  
> -PR = "r1"
> +PR = "r2"
>  
>  SERIAL_CONSOLE ?= "115200 ttyS0"
>  
>  SRC_URI = "file://LICENSE \
> -           file://serial-getty@.service"
> +           file://serial-getty@.service \
> +           file://systemd-serialgetty"
>  
>  def get_baudrate(bb, d):
>      return bb.data.getVar('SERIAL_CONSOLE', d, 1).split()[0]
> @@ -22,6 +23,9 @@ do_install() {
>  		install -d ${D}${sysconfdir}/systemd/system/getty.target.wants/
>  		install ${WORKDIR}/serial-getty@.service ${D}${base_libdir}/systemd/system/
>  
> +		# Install wrapper that looks for available getty binary
> +		install -m 755 ${WORKDIR}/systemd-serialgetty ${D}${base_libdir}/systemd/
> +
>  		# enable the service
>  		ln -sf ${base_libdir}/systemd/system/serial-getty@.service \
>  			${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty@${@get_console(bb, d)}.service
> @@ -34,5 +38,8 @@ RRECOMMENDS_${PN} = ""
>  RDEPENDS_${PN} = "systemd"
>  
>  # This is a machine specific file
> -FILES_${PN} = "${base_libdir}/systemd/system/serial-getty@.service ${sysconfdir}"
> +FILES_${PN} = "${base_libdir}/systemd/systemd-serialgetty \
> +               ${base_libdir}/systemd/system/serial-getty@.service \
> +               ${sysconfdir} \
> +               "
>  PACKAGE_ARCH = "${MACHINE_ARCH}"
> diff --git a/meta-oe/recipes-core/systemd/systemd-serialgetty/serial-getty@.service b/meta-oe/recipes-core/systemd/systemd-serialgetty/serial-getty@.service
> index daf0dac..ee60a37 100644
> --- a/meta-oe/recipes-core/systemd/systemd-serialgetty/serial-getty@.service
> +++ b/meta-oe/recipes-core/systemd/systemd-serialgetty/serial-getty@.service
> @@ -17,7 +17,7 @@ Before=getty.target
>  
>  [Service]
>  Environment=TERM=vt100
> -ExecStart=-/sbin/getty @BAUDRATE@ %I
> +ExecStart=-/lib/systemd/systemd-serialgetty @BAUDRATE@ %I
>  Restart=always
>  RestartSec=0
>  UtmpIdentifier=%I
> diff --git a/meta-oe/recipes-core/systemd/systemd-serialgetty/systemd-serialgetty b/meta-oe/recipes-core/systemd/systemd-serialgetty/systemd-serialgetty
> new file mode 100755
> index 0000000..688b4b4
> --- /dev/null
> +++ b/meta-oe/recipes-core/systemd/systemd-serialgetty/systemd-serialgetty
> @@ -0,0 +1,13 @@
> +#!/bin/sh
> +
> +for g in /sbin/agetty \
> +         /sbin/mingetty \
> +         /sbin/getty; do
> +	if [ -x "$g" ]; then
> +		$g $@
> +		exit 0
> +	fi
> +done
> +
> +echo "Failed to find the getty binary to use."
> +exit 1
> -- 
> 1.7.2.5
> 
> 
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel
Otavio Salvador - Nov. 28, 2011, 2:33 p.m.
On Mon, Nov 28, 2011 at 12:00, Martin Jansa <martin.jansa@gmail.com> wrote:

> ...
>
FWIW: I have 2 patches for tinylogin and util-linux-agetty to provide
> /sbin/getty u-a
>
> openembedded-core-contrib/shr
> util-linux: use u-a to provide /sbin/getty from util-linux-agetty
> tinylogin: use u-a for getty so we can provide /sbin/getty from
> util-linux-agetty too
>
> http://git.openembedded.org/openembedded-core-contrib/commit/?h=shr&id=f6aa6fc06af906ab7ee374d544b81f1ef9948403
>
> http://git.openembedded.org/openembedded-core-contrib/commit/?h=shr&id=e34e002f33660591705cd7b21e3a815382a50b3e
>
> I didn't send pull request with them, because I'm still waiting for
> previous pull request (with libsdl changes) to be applied.
>
> We can add u-a to mingetty and solve whole problem even for sysvinit
> etc...
>

Please do that then. It would be nice to have this pull request ASAP so I
can put those into my local repo.

Patch

diff --git a/meta-oe/recipes-core/systemd/systemd-serialgetty.bb b/meta-oe/recipes-core/systemd/systemd-serialgetty.bb
index 2b88d0c..c79ae84 100644
--- a/meta-oe/recipes-core/systemd/systemd-serialgetty.bb
+++ b/meta-oe/recipes-core/systemd/systemd-serialgetty.bb
@@ -2,12 +2,13 @@  DESCRIPTION = "Systemd serial config"
 LICENSE = "GPLv2+"
 LIC_FILES_CHKSUM = "file://${WORKDIR}/LICENSE;md5=751419260aa954499f7abaabaa882bbe"
 
-PR = "r1"
+PR = "r2"
 
 SERIAL_CONSOLE ?= "115200 ttyS0"
 
 SRC_URI = "file://LICENSE \
-           file://serial-getty@.service"
+           file://serial-getty@.service \
+           file://systemd-serialgetty"
 
 def get_baudrate(bb, d):
     return bb.data.getVar('SERIAL_CONSOLE', d, 1).split()[0]
@@ -22,6 +23,9 @@  do_install() {
 		install -d ${D}${sysconfdir}/systemd/system/getty.target.wants/
 		install ${WORKDIR}/serial-getty@.service ${D}${base_libdir}/systemd/system/
 
+		# Install wrapper that looks for available getty binary
+		install -m 755 ${WORKDIR}/systemd-serialgetty ${D}${base_libdir}/systemd/
+
 		# enable the service
 		ln -sf ${base_libdir}/systemd/system/serial-getty@.service \
 			${D}${sysconfdir}/systemd/system/getty.target.wants/serial-getty@${@get_console(bb, d)}.service
@@ -34,5 +38,8 @@  RRECOMMENDS_${PN} = ""
 RDEPENDS_${PN} = "systemd"
 
 # This is a machine specific file
-FILES_${PN} = "${base_libdir}/systemd/system/serial-getty@.service ${sysconfdir}"
+FILES_${PN} = "${base_libdir}/systemd/systemd-serialgetty \
+               ${base_libdir}/systemd/system/serial-getty@.service \
+               ${sysconfdir} \
+               "
 PACKAGE_ARCH = "${MACHINE_ARCH}"
diff --git a/meta-oe/recipes-core/systemd/systemd-serialgetty/serial-getty@.service b/meta-oe/recipes-core/systemd/systemd-serialgetty/serial-getty@.service
index daf0dac..ee60a37 100644
--- a/meta-oe/recipes-core/systemd/systemd-serialgetty/serial-getty@.service
+++ b/meta-oe/recipes-core/systemd/systemd-serialgetty/serial-getty@.service
@@ -17,7 +17,7 @@  Before=getty.target
 
 [Service]
 Environment=TERM=vt100
-ExecStart=-/sbin/getty @BAUDRATE@ %I
+ExecStart=-/lib/systemd/systemd-serialgetty @BAUDRATE@ %I
 Restart=always
 RestartSec=0
 UtmpIdentifier=%I
diff --git a/meta-oe/recipes-core/systemd/systemd-serialgetty/systemd-serialgetty b/meta-oe/recipes-core/systemd/systemd-serialgetty/systemd-serialgetty
new file mode 100755
index 0000000..688b4b4
--- /dev/null
+++ b/meta-oe/recipes-core/systemd/systemd-serialgetty/systemd-serialgetty
@@ -0,0 +1,13 @@ 
+#!/bin/sh
+
+for g in /sbin/agetty \
+         /sbin/mingetty \
+         /sbin/getty; do
+	if [ -x "$g" ]; then
+		$g $@
+		exit 0
+	fi
+done
+
+echo "Failed to find the getty binary to use."
+exit 1