mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH 0/3] Using second offline update service beside rc-once in PTXDIST
@ 2017-06-06 15:28 Gavin Schenk
  2017-06-06 15:28 ` [ptxdist] [PATCH 1/3] rc-once: Use /etc/rc.once.d as link target in all rc-once scripts Gavin Schenk
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Gavin Schenk @ 2017-06-06 15:28 UTC (permalink / raw)
  To: ptxdist; +Cc: Gavin Schenk

Make it possible to have multible update-services beside rc-once using 
systemd offline update mechanism as described here:
https://www.freedesktop.org/software/systemd/man/systemd.offline-updates

The basic idea is, that rc-once checks where /system-update points to
and only runs, if it points to /etc/rc-once.d or etc/rc-once.d.
In all other cases it just exits without error.

Gavin Schenk (3):
  rc-once: Use /etc/rc.once.d as link target in all rc-once scripts
  rc-once: Use readlink to check where /system-update points to.
  rc-once: Moved deletion of /system-update into function run_rc_once()

 projectroot/usr/lib/init/rc-once.sh         | 6 ++++++
 projectroot/usr/lib/systemd/systemd-rc-once | 4 +---
 projectroot/usr/sbin/enable-rc-once         | 2 +-
 rules/rc-once.in                            | 3 +++
 4 files changed, 11 insertions(+), 4 deletions(-)

-- 
2.13.0


Eckelmann AG
Vorstand: Dipl.-Ing. Peter Frankenbach (Sprecher) Dipl.-Wi.-Ing. Philipp Eckelmann
Dr.-Ing. Marco Münchhof Dr.-Ing. Frank Uhlemann
Vorsitzender des Aufsichtsrats: Hubertus G. Krossa
Stv. Vorsitzender des Aufsichtsrats: Dr.-Ing. Gerd Eckelmann
Sitz der Gesellschaft: Berliner Str. 161, 65205 Wiesbaden, Amtsgericht Wiesbaden HRB 12636
http://www.eckelmann.de 


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ptxdist] [PATCH 1/3] rc-once: Use /etc/rc.once.d as link target in all rc-once scripts
  2017-06-06 15:28 [ptxdist] [PATCH 0/3] Using second offline update service beside rc-once in PTXDIST Gavin Schenk
@ 2017-06-06 15:28 ` Gavin Schenk
  2017-06-06 15:58   ` Michael Olbrich
  2017-06-06 15:28 ` [ptxdist] [PATCH 2/3] rc-once: Use readlink to check where /system-update points to Gavin Schenk
  2017-06-06 15:28 ` [ptxdist] [PATCH 3/3] rc-once: Moved deletion of /system-update into function run_rc_once() Gavin Schenk
  2 siblings, 1 reply; 11+ messages in thread
From: Gavin Schenk @ 2017-06-06 15:28 UTC (permalink / raw)
  To: ptxdist; +Cc: Gavin Schenk

Signed-off-by: Gavin Schenk <g.schenk@eckelmann.de>
---
 projectroot/usr/sbin/enable-rc-once | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/projectroot/usr/sbin/enable-rc-once b/projectroot/usr/sbin/enable-rc-once
index 892b1df44..22410b954 100644
--- a/projectroot/usr/sbin/enable-rc-once
+++ b/projectroot/usr/sbin/enable-rc-once
@@ -6,6 +6,6 @@ rm -f "$DESTDIR/etc/rc.once.d/.done/rc-once"
 
 if [ -f "$DESTDIR/usr/lib/systemd/system/rc-once.service" ]; then
 	if [ ! -e $DESTDIR/system-update ]; then
-		ln -sf etc/rc.once.d $DESTDIR/system-update
+		ln -sf /etc/rc.once.d $DESTDIR/system-update
 	fi
 fi
-- 
2.13.0


Eckelmann AG
Vorstand: Dipl.-Ing. Peter Frankenbach (Sprecher) Dipl.-Wi.-Ing. Philipp Eckelmann
Dr.-Ing. Marco Münchhof Dr.-Ing. Frank Uhlemann
Vorsitzender des Aufsichtsrats: Hubertus G. Krossa
Stv. Vorsitzender des Aufsichtsrats: Dr.-Ing. Gerd Eckelmann
Sitz der Gesellschaft: Berliner Str. 161, 65205 Wiesbaden, Amtsgericht Wiesbaden HRB 12636
http://www.eckelmann.de 


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ptxdist] [PATCH 2/3] rc-once: Use readlink to check where /system-update points to.
  2017-06-06 15:28 [ptxdist] [PATCH 0/3] Using second offline update service beside rc-once in PTXDIST Gavin Schenk
  2017-06-06 15:28 ` [ptxdist] [PATCH 1/3] rc-once: Use /etc/rc.once.d as link target in all rc-once scripts Gavin Schenk
@ 2017-06-06 15:28 ` Gavin Schenk
  2017-06-06 16:00   ` Michael Olbrich
  2017-06-06 15:28 ` [ptxdist] [PATCH 3/3] rc-once: Moved deletion of /system-update into function run_rc_once() Gavin Schenk
  2 siblings, 1 reply; 11+ messages in thread
From: Gavin Schenk @ 2017-06-06 15:28 UTC (permalink / raw)
  To: ptxdist; +Cc: Gavin Schenk

rc-once ist based on systemd offline update mechanism.
https://www.freedesktop.org/software/systemd/man/systemd.offline-updates

To make it possible to have multiple update services beside rc-once the
script should check where the link /system-update points to.

rc-once will only run if the link points to etc/rc-once.d or
/etc/rc-once.d.

Signed-off-by: Gavin Schenk <g.schenk@eckelmann.de>
---
 projectroot/usr/lib/init/rc-once.sh | 5 +++++
 rules/rc-once.in                    | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/projectroot/usr/lib/init/rc-once.sh b/projectroot/usr/lib/init/rc-once.sh
index 8689a32bc..d225ad5c2 100644
--- a/projectroot/usr/lib/init/rc-once.sh
+++ b/projectroot/usr/lib/init/rc-once.sh
@@ -6,6 +6,11 @@ STAMP="$DONE_DIR/rc-once"
 
 run_rc_once() {
 	failed=0
+	UPDATE_TARGET=$(readlink -f /system-update)
+	if [ "$UPDATE_TARGET" != '/etc/rc.once.d' -a "$UPDATE_TARGET" != 'etc/rc.once.d' ]; then
+		echo "skipping rc.once.d services..."
+		return $failed
+	fi
 	echo "running rc.once.d services..."
 	cd "$RC_ONCE_DIR" || exit 1
 	mkdir -p "$DONE_DIR"
diff --git a/rules/rc-once.in b/rules/rc-once.in
index 849c71f06..6db4a02fc 100644
--- a/rules/rc-once.in
+++ b/rules/rc-once.in
@@ -3,6 +3,9 @@
 config RC_ONCE
 	tristate
 	prompt "rc.once"
+	select BUSYBOX_FEATURE_READLINK_FOLLOW	if BUSYBOX_READLINK
+	select COREUTILS			if !BUSYBOX_READLINK
+	select COREUTILS_READLINK		if !BUSYBOX_READLINK
 	help
 	  Some services need a one time initialization when the system starts
 	  up the first time after creating and installing the root filesystem.
-- 
2.13.0


Eckelmann AG
Vorstand: Dipl.-Ing. Peter Frankenbach (Sprecher) Dipl.-Wi.-Ing. Philipp Eckelmann
Dr.-Ing. Marco Münchhof Dr.-Ing. Frank Uhlemann
Vorsitzender des Aufsichtsrats: Hubertus G. Krossa
Stv. Vorsitzender des Aufsichtsrats: Dr.-Ing. Gerd Eckelmann
Sitz der Gesellschaft: Berliner Str. 161, 65205 Wiesbaden, Amtsgericht Wiesbaden HRB 12636
http://www.eckelmann.de 


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [ptxdist] [PATCH 3/3] rc-once: Moved deletion of /system-update into function run_rc_once()
  2017-06-06 15:28 [ptxdist] [PATCH 0/3] Using second offline update service beside rc-once in PTXDIST Gavin Schenk
  2017-06-06 15:28 ` [ptxdist] [PATCH 1/3] rc-once: Use /etc/rc.once.d as link target in all rc-once scripts Gavin Schenk
  2017-06-06 15:28 ` [ptxdist] [PATCH 2/3] rc-once: Use readlink to check where /system-update points to Gavin Schenk
@ 2017-06-06 15:28 ` Gavin Schenk
  2017-06-06 16:02   ` Michael Olbrich
  2 siblings, 1 reply; 11+ messages in thread
From: Gavin Schenk @ 2017-06-06 15:28 UTC (permalink / raw)
  To: ptxdist; +Cc: Gavin Schenk

Signed-off-by: Gavin Schenk <g.schenk@eckelmann.de>
---
 projectroot/usr/lib/init/rc-once.sh         | 1 +
 projectroot/usr/lib/systemd/systemd-rc-once | 4 +---
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/projectroot/usr/lib/init/rc-once.sh b/projectroot/usr/lib/init/rc-once.sh
index d225ad5c2..a9c08c48a 100644
--- a/projectroot/usr/lib/init/rc-once.sh
+++ b/projectroot/usr/lib/init/rc-once.sh
@@ -12,6 +12,7 @@ run_rc_once() {
 		return $failed
 	fi
 	echo "running rc.once.d services..."
+	rm -f /system-update
 	cd "$RC_ONCE_DIR" || exit 1
 	mkdir -p "$DONE_DIR"
 	for script in *; do
diff --git a/projectroot/usr/lib/systemd/systemd-rc-once b/projectroot/usr/lib/systemd/systemd-rc-once
index ff7f7d3dc..5dfecf2aa 100644
--- a/projectroot/usr/lib/systemd/systemd-rc-once
+++ b/projectroot/usr/lib/systemd/systemd-rc-once
@@ -8,9 +8,7 @@ start() {
 		systemctl rescue
 		exit 1
 	fi
-	if run_rc_once; then
-		rm -f /system-update
-	fi
+	run_rc_once
 	systemctl daemon-reexec
 	sleep 1
 	touch /var/lib/systemd/clock
-- 
2.13.0


Eckelmann AG
Vorstand: Dipl.-Ing. Peter Frankenbach (Sprecher) Dipl.-Wi.-Ing. Philipp Eckelmann
Dr.-Ing. Marco Münchhof Dr.-Ing. Frank Uhlemann
Vorsitzender des Aufsichtsrats: Hubertus G. Krossa
Stv. Vorsitzender des Aufsichtsrats: Dr.-Ing. Gerd Eckelmann
Sitz der Gesellschaft: Berliner Str. 161, 65205 Wiesbaden, Amtsgericht Wiesbaden HRB 12636
http://www.eckelmann.de 


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [ptxdist] [PATCH 1/3] rc-once: Use /etc/rc.once.d as link target in all rc-once scripts
  2017-06-06 15:28 ` [ptxdist] [PATCH 1/3] rc-once: Use /etc/rc.once.d as link target in all rc-once scripts Gavin Schenk
@ 2017-06-06 15:58   ` Michael Olbrich
  0 siblings, 0 replies; 11+ messages in thread
From: Michael Olbrich @ 2017-06-06 15:58 UTC (permalink / raw)
  To: ptxdist

Hi,

Can we change systemd-rc-once to use etc/rc.once.d instead? This way, the
link is valid on the server when working with nfsroot.

Michael

On Tue, Jun 06, 2017 at 05:28:47PM +0200, Gavin Schenk wrote:
> Signed-off-by: Gavin Schenk <g.schenk@eckelmann.de>
> ---
>  projectroot/usr/sbin/enable-rc-once | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/projectroot/usr/sbin/enable-rc-once b/projectroot/usr/sbin/enable-rc-once
> index 892b1df44..22410b954 100644
> --- a/projectroot/usr/sbin/enable-rc-once
> +++ b/projectroot/usr/sbin/enable-rc-once
> @@ -6,6 +6,6 @@ rm -f "$DESTDIR/etc/rc.once.d/.done/rc-once"
>  
>  if [ -f "$DESTDIR/usr/lib/systemd/system/rc-once.service" ]; then
>  	if [ ! -e $DESTDIR/system-update ]; then
> -		ln -sf etc/rc.once.d $DESTDIR/system-update
> +		ln -sf /etc/rc.once.d $DESTDIR/system-update
>  	fi
>  fi
> -- 
> 2.13.0
> 
> 
> Eckelmann AG
> Vorstand: Dipl.-Ing. Peter Frankenbach (Sprecher) Dipl.-Wi.-Ing. Philipp Eckelmann
> Dr.-Ing. Marco Münchhof Dr.-Ing. Frank Uhlemann
> Vorsitzender des Aufsichtsrats: Hubertus G. Krossa
> Stv. Vorsitzender des Aufsichtsrats: Dr.-Ing. Gerd Eckelmann
> Sitz der Gesellschaft: Berliner Str. 161, 65205 Wiesbaden, Amtsgericht Wiesbaden HRB 12636
> http://www.eckelmann.de 
> 
> 
> _______________________________________________
> ptxdist mailing list
> ptxdist@pengutronix.de

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [ptxdist] [PATCH 2/3] rc-once: Use readlink to check where /system-update points to.
  2017-06-06 15:28 ` [ptxdist] [PATCH 2/3] rc-once: Use readlink to check where /system-update points to Gavin Schenk
@ 2017-06-06 16:00   ` Michael Olbrich
  2017-06-06 16:25     ` Uwe Kleine-König
  0 siblings, 1 reply; 11+ messages in thread
From: Michael Olbrich @ 2017-06-06 16:00 UTC (permalink / raw)
  To: ptxdist

On Tue, Jun 06, 2017 at 05:28:48PM +0200, Gavin Schenk wrote:
> rc-once ist based on systemd offline update mechanism.
> https://www.freedesktop.org/software/systemd/man/systemd.offline-updates
> 
> To make it possible to have multiple update services beside rc-once the
> script should check where the link /system-update points to.
> 
> rc-once will only run if the link points to etc/rc-once.d or
> /etc/rc-once.d.
> 
> Signed-off-by: Gavin Schenk <g.schenk@eckelmann.de>
> ---
>  projectroot/usr/lib/init/rc-once.sh | 5 +++++
>  rules/rc-once.in                    | 3 +++
>  2 files changed, 8 insertions(+)
> 
> diff --git a/projectroot/usr/lib/init/rc-once.sh b/projectroot/usr/lib/init/rc-once.sh
> index 8689a32bc..d225ad5c2 100644
> --- a/projectroot/usr/lib/init/rc-once.sh
> +++ b/projectroot/usr/lib/init/rc-once.sh
> @@ -6,6 +6,11 @@ STAMP="$DONE_DIR/rc-once"
>  
>  run_rc_once() {
>  	failed=0
> +	UPDATE_TARGET=$(readlink -f /system-update)

This needs quotes in case the link target contains spaces.

> +	if [ "$UPDATE_TARGET" != '/etc/rc.once.d' -a "$UPDATE_TARGET" != 'etc/rc.once.d' ]; then

I'm quite sure that 'readlink -f' always returns an absolute path. So
either remove the '-f' (and the select below) or the second check.

Michael

> +		echo "skipping rc.once.d services..."
> +		return $failed
> +	fi
>  	echo "running rc.once.d services..."
>  	cd "$RC_ONCE_DIR" || exit 1
>  	mkdir -p "$DONE_DIR"
> diff --git a/rules/rc-once.in b/rules/rc-once.in
> index 849c71f06..6db4a02fc 100644
> --- a/rules/rc-once.in
> +++ b/rules/rc-once.in
> @@ -3,6 +3,9 @@
>  config RC_ONCE
>  	tristate
>  	prompt "rc.once"
> +	select BUSYBOX_FEATURE_READLINK_FOLLOW	if BUSYBOX_READLINK
> +	select COREUTILS			if !BUSYBOX_READLINK
> +	select COREUTILS_READLINK		if !BUSYBOX_READLINK
>  	help
>  	  Some services need a one time initialization when the system starts
>  	  up the first time after creating and installing the root filesystem.
> -- 
> 2.13.0
> 
> 
> Eckelmann AG
> Vorstand: Dipl.-Ing. Peter Frankenbach (Sprecher) Dipl.-Wi.-Ing. Philipp Eckelmann
> Dr.-Ing. Marco Münchhof Dr.-Ing. Frank Uhlemann
> Vorsitzender des Aufsichtsrats: Hubertus G. Krossa
> Stv. Vorsitzender des Aufsichtsrats: Dr.-Ing. Gerd Eckelmann
> Sitz der Gesellschaft: Berliner Str. 161, 65205 Wiesbaden, Amtsgericht Wiesbaden HRB 12636
> http://www.eckelmann.de 
> 
> 
> _______________________________________________
> ptxdist mailing list
> ptxdist@pengutronix.de

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [ptxdist] [PATCH 3/3] rc-once: Moved deletion of /system-update into function run_rc_once()
  2017-06-06 15:28 ` [ptxdist] [PATCH 3/3] rc-once: Moved deletion of /system-update into function run_rc_once() Gavin Schenk
@ 2017-06-06 16:02   ` Michael Olbrich
  2017-06-07  6:29     ` Schenk, Gavin
  0 siblings, 1 reply; 11+ messages in thread
From: Michael Olbrich @ 2017-06-06 16:02 UTC (permalink / raw)
  To: ptxdist

On Tue, Jun 06, 2017 at 05:28:49PM +0200, Gavin Schenk wrote:
> Signed-off-by: Gavin Schenk <g.schenk@eckelmann.de>
> ---
>  projectroot/usr/lib/init/rc-once.sh         | 1 +
>  projectroot/usr/lib/systemd/systemd-rc-once | 4 +---
>  2 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/projectroot/usr/lib/init/rc-once.sh b/projectroot/usr/lib/init/rc-once.sh
> index d225ad5c2..a9c08c48a 100644
> --- a/projectroot/usr/lib/init/rc-once.sh
> +++ b/projectroot/usr/lib/init/rc-once.sh
> @@ -12,6 +12,7 @@ run_rc_once() {
>  		return $failed
>  	fi
>  	echo "running rc.once.d services..."
> +	rm -f /system-update

This script is also used for bbinit, where /system-update means nothing. An
this changes the semantics: Currently /system-update remains is a rc-once
script fails. That no longer happens with this change.

Michael

>  	cd "$RC_ONCE_DIR" || exit 1
>  	mkdir -p "$DONE_DIR"
>  	for script in *; do
> diff --git a/projectroot/usr/lib/systemd/systemd-rc-once b/projectroot/usr/lib/systemd/systemd-rc-once
> index ff7f7d3dc..5dfecf2aa 100644
> --- a/projectroot/usr/lib/systemd/systemd-rc-once
> +++ b/projectroot/usr/lib/systemd/systemd-rc-once
> @@ -8,9 +8,7 @@ start() {
>  		systemctl rescue
>  		exit 1
>  	fi
> -	if run_rc_once; then
> -		rm -f /system-update
> -	fi
> +	run_rc_once
>  	systemctl daemon-reexec
>  	sleep 1
>  	touch /var/lib/systemd/clock
> -- 
> 2.13.0
> 
> 
> Eckelmann AG
> Vorstand: Dipl.-Ing. Peter Frankenbach (Sprecher) Dipl.-Wi.-Ing. Philipp Eckelmann
> Dr.-Ing. Marco Münchhof Dr.-Ing. Frank Uhlemann
> Vorsitzender des Aufsichtsrats: Hubertus G. Krossa
> Stv. Vorsitzender des Aufsichtsrats: Dr.-Ing. Gerd Eckelmann
> Sitz der Gesellschaft: Berliner Str. 161, 65205 Wiesbaden, Amtsgericht Wiesbaden HRB 12636
> http://www.eckelmann.de 
> 
> 
> _______________________________________________
> ptxdist mailing list
> ptxdist@pengutronix.de

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [ptxdist] [PATCH 2/3] rc-once: Use readlink to check where /system-update points to.
  2017-06-06 16:00   ` Michael Olbrich
@ 2017-06-06 16:25     ` Uwe Kleine-König
  2017-06-06 16:49       ` Michael Olbrich
  0 siblings, 1 reply; 11+ messages in thread
From: Uwe Kleine-König @ 2017-06-06 16:25 UTC (permalink / raw)
  To: ptxdist

On Tue, Jun 06, 2017 at 06:00:51PM +0200, Michael Olbrich wrote:
> On Tue, Jun 06, 2017 at 05:28:48PM +0200, Gavin Schenk wrote:
> > rc-once ist based on systemd offline update mechanism.
> > https://www.freedesktop.org/software/systemd/man/systemd.offline-updates
> > 
> > To make it possible to have multiple update services beside rc-once the
> > script should check where the link /system-update points to.
> > 
> > rc-once will only run if the link points to etc/rc-once.d or
> > /etc/rc-once.d.
> > 
> > Signed-off-by: Gavin Schenk <g.schenk@eckelmann.de>
> > ---
> >  projectroot/usr/lib/init/rc-once.sh | 5 +++++
> >  rules/rc-once.in                    | 3 +++
> >  2 files changed, 8 insertions(+)
> > 
> > diff --git a/projectroot/usr/lib/init/rc-once.sh b/projectroot/usr/lib/init/rc-once.sh
> > index 8689a32bc..d225ad5c2 100644
> > --- a/projectroot/usr/lib/init/rc-once.sh
> > +++ b/projectroot/usr/lib/init/rc-once.sh
> > @@ -6,6 +6,11 @@ STAMP="$DONE_DIR/rc-once"
> >  
> >  run_rc_once() {
> >  	failed=0
> > +	UPDATE_TARGET=$(readlink -f /system-update)
> 
> This needs quotes in case the link target contains spaces.

I think that's wrong. It only needs quoting when being used:

	$ cat test.sh 
	#!/bin/sh

	tmpdir=$(mktemp -d)

	touch "$tmpdir/file with	spaces";

	FILE=$(ls $tmpdir)

	echo "$FILE"

	rm -rf $tmpdir

	$ bash test.sh  | hexdump -C
	00000000  66 69 6c 65 20 77 69 74  68 09 73 70 61 63 65 73  |file with.spaces|
	00000010  0a                                                |.|
	00000011

That being said, quotes don't hurt either.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [ptxdist] [PATCH 2/3] rc-once: Use readlink to check where /system-update points to.
  2017-06-06 16:25     ` Uwe Kleine-König
@ 2017-06-06 16:49       ` Michael Olbrich
  2017-06-06 21:54         ` Uwe Kleine-König
  0 siblings, 1 reply; 11+ messages in thread
From: Michael Olbrich @ 2017-06-06 16:49 UTC (permalink / raw)
  To: ptxdist

On Tue, Jun 06, 2017 at 06:25:09PM +0200, Uwe Kleine-König wrote:
> On Tue, Jun 06, 2017 at 06:00:51PM +0200, Michael Olbrich wrote:
> > On Tue, Jun 06, 2017 at 05:28:48PM +0200, Gavin Schenk wrote:
> > > rc-once ist based on systemd offline update mechanism.
> > > https://www.freedesktop.org/software/systemd/man/systemd.offline-updates
> > > 
> > > To make it possible to have multiple update services beside rc-once the
> > > script should check where the link /system-update points to.
> > > 
> > > rc-once will only run if the link points to etc/rc-once.d or
> > > /etc/rc-once.d.
> > > 
> > > Signed-off-by: Gavin Schenk <g.schenk@eckelmann.de>
> > > ---
> > >  projectroot/usr/lib/init/rc-once.sh | 5 +++++
> > >  rules/rc-once.in                    | 3 +++
> > >  2 files changed, 8 insertions(+)
> > > 
> > > diff --git a/projectroot/usr/lib/init/rc-once.sh b/projectroot/usr/lib/init/rc-once.sh
> > > index 8689a32bc..d225ad5c2 100644
> > > --- a/projectroot/usr/lib/init/rc-once.sh
> > > +++ b/projectroot/usr/lib/init/rc-once.sh
> > > @@ -6,6 +6,11 @@ STAMP="$DONE_DIR/rc-once"
> > >  
> > >  run_rc_once() {
> > >  	failed=0
> > > +	UPDATE_TARGET=$(readlink -f /system-update)
> > 
> > This needs quotes in case the link target contains spaces.
> 
> I think that's wrong. It only needs quoting when being used:
> 
> 	$ cat test.sh 
> 	#!/bin/sh
> 
> 	tmpdir=$(mktemp -d)
> 
> 	touch "$tmpdir/file with	spaces";
> 
> 	FILE=$(ls $tmpdir)
> 
> 	echo "$FILE"
> 
> 	rm -rf $tmpdir
> 
> 	$ bash test.sh  | hexdump -C
> 	00000000  66 69 6c 65 20 77 69 74  68 09 73 70 61 63 65 73  |file with.spaces|
> 	00000010  0a                                                |.|
> 	00000011
> 
> That being said, quotes don't hurt either.

This is strange. I see the same thing, but the bash man-page says:
"If the substitution appears within double quotes, word splitting and
pathname expansion are not performed on the results."
So I'd assume, that word splitting and pathname expansion are performed if
no quotes are used, but that doesn't seem to happen.

Michael

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [ptxdist] [PATCH 2/3] rc-once: Use readlink to check where /system-update points to.
  2017-06-06 16:49       ` Michael Olbrich
@ 2017-06-06 21:54         ` Uwe Kleine-König
  0 siblings, 0 replies; 11+ messages in thread
From: Uwe Kleine-König @ 2017-06-06 21:54 UTC (permalink / raw)
  To: ptxdist

Hello Michael,

On Tue, Jun 06, 2017 at 06:49:08PM +0200, Michael Olbrich wrote:
> On Tue, Jun 06, 2017 at 06:25:09PM +0200, Uwe Kleine-König wrote:
> > On Tue, Jun 06, 2017 at 06:00:51PM +0200, Michael Olbrich wrote:
> > > On Tue, Jun 06, 2017 at 05:28:48PM +0200, Gavin Schenk wrote:
> > > > rc-once ist based on systemd offline update mechanism.
> > > > https://www.freedesktop.org/software/systemd/man/systemd.offline-updates
> > > > 
> > > > To make it possible to have multiple update services beside rc-once the
> > > > script should check where the link /system-update points to.
> > > > 
> > > > rc-once will only run if the link points to etc/rc-once.d or
> > > > /etc/rc-once.d.
> > > > 
> > > > Signed-off-by: Gavin Schenk <g.schenk@eckelmann.de>
> > > > ---
> > > >  projectroot/usr/lib/init/rc-once.sh | 5 +++++
> > > >  rules/rc-once.in                    | 3 +++
> > > >  2 files changed, 8 insertions(+)
> > > > 
> > > > diff --git a/projectroot/usr/lib/init/rc-once.sh b/projectroot/usr/lib/init/rc-once.sh
> > > > index 8689a32bc..d225ad5c2 100644
> > > > --- a/projectroot/usr/lib/init/rc-once.sh
> > > > +++ b/projectroot/usr/lib/init/rc-once.sh
> > > > @@ -6,6 +6,11 @@ STAMP="$DONE_DIR/rc-once"
> > > >  
> > > >  run_rc_once() {
> > > >  	failed=0
> > > > +	UPDATE_TARGET=$(readlink -f /system-update)
> > > 
> > > This needs quotes in case the link target contains spaces.
> > 
> > I think that's wrong. It only needs quoting when being used:
> > 
> > 	$ cat test.sh 
> > 	#!/bin/sh
> > 
> > 	tmpdir=$(mktemp -d)
> > 
> > 	touch "$tmpdir/file with	spaces";
> > 
> > 	FILE=$(ls $tmpdir)
> > 
> > 	echo "$FILE"
> > 
> > 	rm -rf $tmpdir
> > 
> > 	$ bash test.sh  | hexdump -C
> > 	00000000  66 69 6c 65 20 77 69 74  68 09 73 70 61 63 65 73  |file with.spaces|
> > 	00000010  0a                                                |.|
> > 	00000011
> > 
> > That being said, quotes don't hurt either.
> 
> This is strange. I see the same thing, but the bash man-page says:
> "If the substitution appears within double quotes, word splitting and
> pathname expansion are not performed on the results."
> So I'd assume, that word splitting and pathname expansion are performed if
> no quotes are used, but that doesn't seem to happen.

They are, but only if these are applied in the current context. For
variable assignment we have:

	A variable may be assigned to by a statement of the form

		name=[value]

	[...] All values undergo tilde expansion, parameter and variable
	expansion, command substitution, arithmetic expansion, and quote
	removal [...].

The quotes are indeed important if you do:

	somecommand $(ls $tmpdir)

which in the setup of my script above would pass three arguments to
somecommand while

	somecommand "$(ls $tmpdir)"

would only result in a single argument.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [ptxdist] [PATCH 3/3] rc-once: Moved deletion of /system-update into function run_rc_once()
  2017-06-06 16:02   ` Michael Olbrich
@ 2017-06-07  6:29     ` Schenk, Gavin
  0 siblings, 0 replies; 11+ messages in thread
From: Schenk, Gavin @ 2017-06-07  6:29 UTC (permalink / raw)
  To: ptxdist

Hi Michael,

> > diff --git a/projectroot/usr/lib/init/rc-once.sh
> > b/projectroot/usr/lib/init/rc-once.sh
> > index d225ad5c2..a9c08c48a 100644
> > --- a/projectroot/usr/lib/init/rc-once.sh
> > +++ b/projectroot/usr/lib/init/rc-once.sh
> > @@ -12,6 +12,7 @@ run_rc_once() {
> >  		return $failed
> >  	fi
> >  	echo "running rc.once.d services..."
> > +	rm -f /system-update
> 
> This script is also used for bbinit, where /system-update means nothing.
> An this changes the semantics: Currently /system-update remains is a rc-
> once script fails. That no longer happens with this change.
> 
Ok I understand.

Regards Gavin


Eckelmann AG
Vorstand: Dipl.-Ing. Peter Frankenbach (Sprecher) Dipl.-Wi.-Ing. Philipp Eckelmann
Dr.-Ing. Marco Münchhof Dr.-Ing. Frank Uhlemann
Vorsitzender des Aufsichtsrats: Hubertus G. Krossa
Stv. Vorsitzender des Aufsichtsrats: Dr.-Ing. Gerd Eckelmann
Sitz der Gesellschaft: Berliner Str. 161, 65205 Wiesbaden, Amtsgericht Wiesbaden HRB 12636
http://www.eckelmann.de 

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-06-07  6:29 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-06 15:28 [ptxdist] [PATCH 0/3] Using second offline update service beside rc-once in PTXDIST Gavin Schenk
2017-06-06 15:28 ` [ptxdist] [PATCH 1/3] rc-once: Use /etc/rc.once.d as link target in all rc-once scripts Gavin Schenk
2017-06-06 15:58   ` Michael Olbrich
2017-06-06 15:28 ` [ptxdist] [PATCH 2/3] rc-once: Use readlink to check where /system-update points to Gavin Schenk
2017-06-06 16:00   ` Michael Olbrich
2017-06-06 16:25     ` Uwe Kleine-König
2017-06-06 16:49       ` Michael Olbrich
2017-06-06 21:54         ` Uwe Kleine-König
2017-06-06 15:28 ` [ptxdist] [PATCH 3/3] rc-once: Moved deletion of /system-update into function run_rc_once() Gavin Schenk
2017-06-06 16:02   ` Michael Olbrich
2017-06-07  6:29     ` Schenk, Gavin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox