[v2,3/3] rng-tools: armonize systemd and sysvinit files

Submitted by nick83ola on June 6, 2019, 3:18 p.m. | Patch ID: 162017

Details

Message ID 20190606151814.5114-3-nick83ola@gmail.com
State New
Headers show

Commit Message

nick83ola June 6, 2019, 3:18 p.m.
this commit will permit to have a default file
both in the systemd and in the sysvinit file

Also reorganize the install_append function

Signed-off-by: Nicola Lunghi <nick83ola@gmail.com>
---
 .../rng-tools/rng-tools/default               |  3 +--
 meta/recipes-support/rng-tools/rng-tools/init | 21 ++++++-----------
 .../rng-tools/rng-tools/rngd.service          |  4 ++--
 .../rng-tools/rng-tools_6.7.bb                | 23 ++++++++-----------
 4 files changed, 19 insertions(+), 32 deletions(-)

Patch hide | download patch | download mbox

diff --git a/meta/recipes-support/rng-tools/rng-tools/default b/meta/recipes-support/rng-tools/rng-tools/default
index ab7cd9327f..b9f8e03635 100644
--- a/meta/recipes-support/rng-tools/rng-tools/default
+++ b/meta/recipes-support/rng-tools/rng-tools/default
@@ -1,2 +1 @@ 
-# Specify rng device
-RNG_DEVICE=/dev/hwrng
+EXTRA_ARGS="-r /dev/hwrng"
diff --git a/meta/recipes-support/rng-tools/rng-tools/init b/meta/recipes-support/rng-tools/rng-tools/init
index 7cf78393a4..13f0ecd37c 100644
--- a/meta/recipes-support/rng-tools/rng-tools/init
+++ b/meta/recipes-support/rng-tools/rng-tools/init
@@ -1,26 +1,19 @@ 
-#! /bin/sh 
+#!/bin/sh
 #
 # This is an init script for openembedded
-# Copy it to /etc/init.d/rng-tools and type
+# Copy it to @SYSCONFDIR@/init.d/rng-tools and type
 # > update-rc.d rng-tools defaults 60
 #
 
-rngd=/usr/sbin/rngd
+rngd=@SBINDIR@/rngd
 test -x "$rngd" || exit 1
 
-if [ -e /etc/default/rng-tools ]; then
-    . /etc/default/rng-tools
-fi
-
-if [ -n "$RNG_DEVICE" ]; then
-    EXTRA_ARGS="-- -r $RNG_DEVICE"
-fi
-
+[ -r @SYSCONFDIR@/default/rng-tools ] && . "@SYSCONFDIR@/default/rng-tools"
 
 case "$1" in
   start)
     echo -n "Starting random number generator daemon"
-    start-stop-daemon -S -q -x $rngd $EXTRA_ARGS
+    start-stop-daemon -S -q -x $rngd -- $EXTRA_ARGS
     echo "."
     ;;
   stop)
@@ -38,11 +31,11 @@  case "$1" in
     start-stop-daemon -K -q -n rngd
     echo "."
     echo -n "Starting random number generator daemon"
-    start-stop-daemon -S -q -x $rngd $EXTRA_ARGS
+    start-stop-daemon -S -q -x $rngd -- $EXTRA_ARGS
     echo "."
     ;;
   *)
-    echo "Usage: /etc/init.d/rng-tools {start|stop|reload|restart|force-reload}"
+    echo "Usage: @SYSCONFDIR@/init.d/rng-tools {start|stop|reload|restart|force-reload}"
     exit 1
 esac
 
diff --git a/meta/recipes-support/rng-tools/rng-tools/rngd.service b/meta/recipes-support/rng-tools/rng-tools/rngd.service
index f0355db14f..b1a78527be 100644
--- a/meta/recipes-support/rng-tools/rng-tools/rngd.service
+++ b/meta/recipes-support/rng-tools/rng-tools/rngd.service
@@ -5,8 +5,8 @@  After=systemd-udev-settle.service
 Before=sysinit.target
 
 [Service]
-ExecStart=@SBINDIR@/rngd -f -r /dev/hwrng
-SuccessExitStatus=66
+EnvironmentFile=-@SYSCONFDIR@/default/rng-tools
+ExecStart=@SBINDIR@/rngd -f $EXTRA_ARGS
 
 [Install]
 WantedBy=multi-user.target
diff --git a/meta/recipes-support/rng-tools/rng-tools_6.7.bb b/meta/recipes-support/rng-tools/rng-tools_6.7.bb
index 9cc5951345..12cda9ae1e 100644
--- a/meta/recipes-support/rng-tools/rng-tools_6.7.bb
+++ b/meta/recipes-support/rng-tools/rng-tools_6.7.bb
@@ -50,18 +50,13 @@  do_configure_prepend() {
 }
 
 do_install_append() {
-    install -d "${D}${sysconfdir}/init.d"
-    install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/rng-tools
-    sed -i -e 's,/etc/,${sysconfdir}/,' -e 's,/usr/sbin/,${sbindir}/,' \
-        ${D}${sysconfdir}/init.d/rng-tools
-
-    # Only install the default script when 'sysvinit' is in DISTRO_FEATURES.
-    if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
-        install -d "${D}${sysconfdir}/default"
-        install -m 0644 ${WORKDIR}/default ${D}${sysconfdir}/default/rng-tools
-    fi
-
-    install -d ${D}${systemd_unitdir}/system
-    install -m 644 ${WORKDIR}/rngd.service ${D}${systemd_unitdir}/system
-    sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_unitdir}/system/rngd.service
+    install -Dm 0644 ${WORKDIR}/default ${D}${sysconfdir}/default/rng-tools
+    install -Dm 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/rng-tools
+    install -Dm 0644 ${WORKDIR}/rngd.service \
+                     ${D}${systemd_system_unitdir}/rngd.service
+    sed -i \
+        -e 's,@SYSCONFDIR@,${sysconfdir},' \
+        -e 's,@SBINDIR@,${sbindir},' \
+        ${D}${sysconfdir}/init.d/rng-tools \
+        ${D}${systemd_system_unitdir}/rngd.service
 }

Comments

Ross Burton June 6, 2019, 4:21 p.m.
Do you mean "harmonise?"

Ross

On Thu, 6 Jun 2019 at 16:18, Nicola Lunghi <nick83ola@gmail.com> wrote:
>
> this commit will permit to have a default file
> both in the systemd and in the sysvinit file
>
> Also reorganize the install_append function
>
> Signed-off-by: Nicola Lunghi <nick83ola@gmail.com>
> ---
>  .../rng-tools/rng-tools/default               |  3 +--
>  meta/recipes-support/rng-tools/rng-tools/init | 21 ++++++-----------
>  .../rng-tools/rng-tools/rngd.service          |  4 ++--
>  .../rng-tools/rng-tools_6.7.bb                | 23 ++++++++-----------
>  4 files changed, 19 insertions(+), 32 deletions(-)
>
> diff --git a/meta/recipes-support/rng-tools/rng-tools/default b/meta/recipes-support/rng-tools/rng-tools/default
> index ab7cd9327f..b9f8e03635 100644
> --- a/meta/recipes-support/rng-tools/rng-tools/default
> +++ b/meta/recipes-support/rng-tools/rng-tools/default
> @@ -1,2 +1 @@
> -# Specify rng device
> -RNG_DEVICE=/dev/hwrng
> +EXTRA_ARGS="-r /dev/hwrng"
> diff --git a/meta/recipes-support/rng-tools/rng-tools/init b/meta/recipes-support/rng-tools/rng-tools/init
> index 7cf78393a4..13f0ecd37c 100644
> --- a/meta/recipes-support/rng-tools/rng-tools/init
> +++ b/meta/recipes-support/rng-tools/rng-tools/init
> @@ -1,26 +1,19 @@
> -#! /bin/sh
> +#!/bin/sh
>  #
>  # This is an init script for openembedded
> -# Copy it to /etc/init.d/rng-tools and type
> +# Copy it to @SYSCONFDIR@/init.d/rng-tools and type
>  # > update-rc.d rng-tools defaults 60
>  #
>
> -rngd=/usr/sbin/rngd
> +rngd=@SBINDIR@/rngd
>  test -x "$rngd" || exit 1
>
> -if [ -e /etc/default/rng-tools ]; then
> -    . /etc/default/rng-tools
> -fi
> -
> -if [ -n "$RNG_DEVICE" ]; then
> -    EXTRA_ARGS="-- -r $RNG_DEVICE"
> -fi
> -
> +[ -r @SYSCONFDIR@/default/rng-tools ] && . "@SYSCONFDIR@/default/rng-tools"
>
>  case "$1" in
>    start)
>      echo -n "Starting random number generator daemon"
> -    start-stop-daemon -S -q -x $rngd $EXTRA_ARGS
> +    start-stop-daemon -S -q -x $rngd -- $EXTRA_ARGS
>      echo "."
>      ;;
>    stop)
> @@ -38,11 +31,11 @@ case "$1" in
>      start-stop-daemon -K -q -n rngd
>      echo "."
>      echo -n "Starting random number generator daemon"
> -    start-stop-daemon -S -q -x $rngd $EXTRA_ARGS
> +    start-stop-daemon -S -q -x $rngd -- $EXTRA_ARGS
>      echo "."
>      ;;
>    *)
> -    echo "Usage: /etc/init.d/rng-tools {start|stop|reload|restart|force-reload}"
> +    echo "Usage: @SYSCONFDIR@/init.d/rng-tools {start|stop|reload|restart|force-reload}"
>      exit 1
>  esac
>
> diff --git a/meta/recipes-support/rng-tools/rng-tools/rngd.service b/meta/recipes-support/rng-tools/rng-tools/rngd.service
> index f0355db14f..b1a78527be 100644
> --- a/meta/recipes-support/rng-tools/rng-tools/rngd.service
> +++ b/meta/recipes-support/rng-tools/rng-tools/rngd.service
> @@ -5,8 +5,8 @@ After=systemd-udev-settle.service
>  Before=sysinit.target
>
>  [Service]
> -ExecStart=@SBINDIR@/rngd -f -r /dev/hwrng
> -SuccessExitStatus=66
> +EnvironmentFile=-@SYSCONFDIR@/default/rng-tools
> +ExecStart=@SBINDIR@/rngd -f $EXTRA_ARGS
>
>  [Install]
>  WantedBy=multi-user.target
> diff --git a/meta/recipes-support/rng-tools/rng-tools_6.7.bb b/meta/recipes-support/rng-tools/rng-tools_6.7.bb
> index 9cc5951345..12cda9ae1e 100644
> --- a/meta/recipes-support/rng-tools/rng-tools_6.7.bb
> +++ b/meta/recipes-support/rng-tools/rng-tools_6.7.bb
> @@ -50,18 +50,13 @@ do_configure_prepend() {
>  }
>
>  do_install_append() {
> -    install -d "${D}${sysconfdir}/init.d"
> -    install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/rng-tools
> -    sed -i -e 's,/etc/,${sysconfdir}/,' -e 's,/usr/sbin/,${sbindir}/,' \
> -        ${D}${sysconfdir}/init.d/rng-tools
> -
> -    # Only install the default script when 'sysvinit' is in DISTRO_FEATURES.
> -    if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
> -        install -d "${D}${sysconfdir}/default"
> -        install -m 0644 ${WORKDIR}/default ${D}${sysconfdir}/default/rng-tools
> -    fi
> -
> -    install -d ${D}${systemd_unitdir}/system
> -    install -m 644 ${WORKDIR}/rngd.service ${D}${systemd_unitdir}/system
> -    sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_unitdir}/system/rngd.service
> +    install -Dm 0644 ${WORKDIR}/default ${D}${sysconfdir}/default/rng-tools
> +    install -Dm 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/rng-tools
> +    install -Dm 0644 ${WORKDIR}/rngd.service \
> +                     ${D}${systemd_system_unitdir}/rngd.service
> +    sed -i \
> +        -e 's,@SYSCONFDIR@,${sysconfdir},' \
> +        -e 's,@SBINDIR@,${sbindir},' \
> +        ${D}${sysconfdir}/init.d/rng-tools \
> +        ${D}${systemd_system_unitdir}/rngd.service
>  }
> --
> 2.20.1
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core