Skip to contentSkip to conversation

update-rc.d.bbclass: Fix host/target test in postinst

PATCH Superseded Jacob Kroon 3 participants 6 messages Oct 26, 2013 – Oct 27, 2013

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 update-rc.d.bbclass: Fix host/target test in postinst

When running the postinst script I get a shell warning:

sh: argument expected

and the service is never stopped. This patch fixes the warning message and stops the service.

---
 meta/classes/update-rc.d.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/update-rc.d.bbclass +1 -1
index e14659d..835b717 100644
@@ -16,7 +16,7 @@ updatercd_postinst() {
 # test if there is a previous init script there, ie, we are updating the package
 # if so, we stop the service and remove it before we install from the new package
 if type update-rc.d >/dev/null 2>/dev/null; then
-	if [ -z "$D" -a `test -f "${INIT_D_DIR}/${INITSCRIPT_NAME}"` ]; then
+	if [ -z "$D" -a "test -f ${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
 		${INIT_D_DIR}/${INITSCRIPT_NAME} stop
 	fi
 	if [ -n "$D" ]; then
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 6 lines · Jacob Kroon

When running the postinst script I get a shell warning:

sh: argument expected

and the service is never stopped. This patch fixes the warning message and stops the service.

This patch does not look right to me?
If length of $(D) is zero the condition will *always* be true. Instead of actually testing the existence of "${INIT_D_DIR}/${INITSCRIPT_NAME}" it is now simply converted to a string. What did I miss ;)

Thanks.
Hans

Quoted 18 lines
---
 meta/classes/update-rc.d.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/update-rc.d.bbclass +1 -1
index e14659d..835b717 100644
@@ -16,7 +16,7 @@ updatercd_postinst() {
 # test if there is a previous init script there, ie, we are updating the package
 # if so, we stop the service and remove it before we install from the new package
 if type update-rc.d >/dev/null 2>/dev/null; then
-	if [ -z "$D" -a `test -f "${INIT_D_DIR}/${INITSCRIPT_NAME}"` ]; then
+	if [ -z "$D" -a "test -f ${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
 		${INIT_D_DIR}/${INITSCRIPT_NAME} stop
 	fi
 	if [ -n "$D" ]; then
#2 lore raw

Hi Hans,
I'm far from being a scripting-expert, so I just did what I could in order to get rid of the warning and stop the service.
Sending this patch was just a way to raise some attention to the bug and get some discussion going :-)
If there are other ways one should proceed instead of sending "broken" patches to the mailing list I will do so in the future. Regards
Jacob

Quoted 43 lines · Hans Beckerus
Quoted 6 lines · Jacob Kroon

When running the postinst script I get a shell warning:

sh: argument expected

and the service is never stopped. This patch fixes the warning message and stops the service.

This patch does not look right to me?
If length of $(D) is zero the condition will *always* be true. Instead of actually testing the existence of "${INIT_D_DIR}/${INITSCRIPT_NAME}" it is now simply converted to a string. What did I miss ;)

Thanks.
Hans

Review

Quoted 6 lines
---
 meta/classes/update-rc.d.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/meta/classes/update-rc.d.bbclass

meta/classes/update-rc.d.bbclass updatercd_postinst() { · line 16

Quoted 5 lines

index e14659d..835b717 100644

meta/classes/update-rc.d.bbclass +0 -0
@@ -16,7 +16,7 @@ updatercd_postinst() {
 # test if there is a previous init script there, ie, we are updating

the package

meta/classes/update-rc.d.bbclass updatercd_postinst() { · line 17

Quoted 1 line
meta/classes/update-rc.d.bbclass +0 -0
 # if so, we stop the service and remove it before we install from the

new package

meta/classes/update-rc.d.bbclass updatercd_postinst() { · line 19

Quoted 2 lines
meta/classes/update-rc.d.bbclass +0 -1
 if type update-rc.d >/dev/null 2>/dev/null; then
-     if [ -z "$D" -a `test -f "${INIT_D_DIR}/${INITSCRIPT_NAME}"` ];

then

meta/classes/update-rc.d.bbclass updatercd_postinst() { · line 22

Quoted 4 lines
meta/classes/update-rc.d.bbclass +1 -0
+     if [ -z "$D" -a "test -f ${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
              ${INIT_D_DIR}/${INITSCRIPT_NAME} stop
      fi
      if [ -n "$D" ]; then

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Signature · 1 line
  -- Jacob
#3 lore raw
Quoted 5 lines · Jacob Kroon

Hi Hans,
I'm far from being a scripting-expert, so I just did what I could in order to get rid of the warning and stop the service.
Sending this patch was just a way to raise some attention to the bug and get some discussion going :-)

No problem ;)
Try this instead

if [ -z "$D" -a -f "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
echo stop
fi

Thanks.
Hans

Quoted 58 lines

If there are other ways one should proceed instead of sending "broken" patches to the mailing list I will do so in the future.
Regards
Jacob

On Sun, Oct 27, 2013 at 8:18 AM, Hans Beckerus <[email protected] <mailto:[email protected]>> wrote:

On 2013-10-27 12:36, Jacob Kroon wrote:
> When running the postinst script I get a shell warning:
>
> sh: argument expected
>
> and the service is never stopped. This patch fixes the warning > message and stops the service.
This patch does not look right to me?
If length of $(D) is zero the condition will *always* be true. Instead of actually testing the existence of "${INIT_D_DIR}/${INITSCRIPT_NAME}" it is now simply converted to a string. What did I miss ;)

Thanks.
Hans

> Signed-off-by: Jacob Kroon <[email protected]
<mailto:[email protected]>>
> ---
> meta/classes/update-rc.d.bbclass | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/meta/classes/update-rc.d.bbclass
b/meta/classes/update-rc.d.bbclass
> index e14659d..835b717 100644
> --- a/meta/classes/update-rc.d.bbclass
> +++ b/meta/classes/update-rc.d.bbclass
> @@ -16,7 +16,7 @@ updatercd_postinst() {
> # test if there is a previous init script there, ie, we are updating the
package
> # if so, we stop the service and remove it before we install from the
new package
> if type update-rc.d >/dev/null 2>/dev/null; then
> - if [ -z "$D" -a test -f "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
> + if [ -z "$D" -a "test -f ${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
> ${INIT_D_DIR}/${INITSCRIPT_NAME} stop
> fi
> if [ -n "$D" ]; then

_______________________________________________
Openembedded-core mailing list [email protected] <mailto:[email protected]>
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Signature · 1 line
   -- Jacob
#4 lore raw
Quoted 11 lines

27 okt 2013 kl. 08:51 skrev Hans Beckerus <[email protected]>:

Quoted 6 lines · Jacob Kroon

Hi Hans,
I'm far from being a scripting-expert, so I just did what I could in order to get rid of the warning and stop the service.
Sending this patch was just a way to raise some attention to the bug and get some discussion going :-)

Quoted 7 lines

No problem ;)
Try this instead

if [ -z "$D" -a -f "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
echo stop
fi

...and of course replace the 'echo stop' with the previous real call to the init script. This was only to test the syntax.

Quoted 62 lines

Thanks.
Hans

Quoted 58 lines

If there are other ways one should proceed instead of sending "broken" patches to the mailing list I will do so in the future.
Regards
Jacob

Quoted 7 lines · On Sun, Oct 27, 2013 at 8:18 AM, Hans Beckerus <[email protected]…
   On 2013-10-27 12:36, Jacob Kroon wrote:

When running the postinst script I get a shell warning:

sh: argument expected

and the service is never stopped. This patch fixes the warning message and stops the service.

This patch does not look right to me?
If length of $(D) is zero the condition will *always* be true. Instead of actually testing the existence of "${INIT_D_DIR}/${INITSCRIPT_NAME}" it is now simply converted to a string. What did I miss ;)

Thanks.
Hans

Quoted 1 line

<mailto:[email protected]>>

Review

Quoted 5 lines

---
meta/classes/update-rc.d.bbclass | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/meta/classes/update-rc.d.bbclass

meta/classes/update-rc.d.bbclass updatercd_postinst() { · line 16

Quoted 5 lines

index e14659d..835b717 100644

meta/classes/update-rc.d.bbclass +0 -0
@@ -16,7 +16,7 @@ updatercd_postinst() {
 # test if there is a previous init script there, ie, we are updating the

package

meta/classes/update-rc.d.bbclass updatercd_postinst() { · line 17

Quoted 1 line
meta/classes/update-rc.d.bbclass +0 -0
 # if so, we stop the service and remove it before we install from the

new package

meta/classes/update-rc.d.bbclass updatercd_postinst() { · line 22

Quoted 6 lines

if type update-rc.d >/dev/null 2>/dev/null; then

meta/classes/update-rc.d.bbclass +1 -1
-     if [ -z "$D" -a `test -f "${INIT_D_DIR}/${INITSCRIPT_NAME}"` ]; then
+     if [ -z "$D" -a "test -f ${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then
             ${INIT_D_DIR}/${INITSCRIPT_NAME} stop
     fi
     if [ -n "$D" ]; then

_______________________________________________
Openembedded-core mailing list [email protected] <mailto:[email protected]>
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Signature · 1 line
  -- Jacob
#5 lore raw
In reply to Jacob Kroon
Quoted 17 lines · Jacob Kroon

When running the postinst script I get a shell warning:

sh: argument expected

and the service is never stopped. This patch fixes the warning message and stops the service.

---
 meta/classes/update-rc.d.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/update-rc.d.bbclass +0 -0
index e14659d..835b717 100644

meta/classes/update-rc.d.bbclass updatercd_postinst() { · line 19

Quoted 5 lines
meta/classes/update-rc.d.bbclass +1 -1
@@ -16,7 +16,7 @@ updatercd_postinst() {
 # test if there is a previous init script there, ie, we are updating the package
 # if so, we stop the service and remove it before we install from the new package
 if type update-rc.d >/dev/null 2>/dev/null; then
-	if [ -z "$D" -a `test -f "${INIT_D_DIR}/${INITSCRIPT_NAME}"` ]; then
+	if [ -z "$D" -a "test -f ${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then

I guess you want

+ if [ -z "$D" -a -f "${INIT_D_DIR}/${INITSCRIPT_NAME}" ]; then

here

Quoted 10 lines
meta/classes/update-rc.d.bbclass +0 -0
 		${INIT_D_DIR}/${INITSCRIPT_NAME} stop
 	fi
 	if [ -n "$D" ]; then
Signature · 6 lines
1.8.3.1

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]