diff mbox series

[meta-swupdate] initscripts-swupdate-usb: Mark init with update alternatives

Message ID 20200319064601.2070321-1-raj.khem@gmail.com
State Accepted
Headers show
Series [meta-swupdate] initscripts-swupdate-usb: Mark init with update alternatives | expand

Commit Message

Khem Raj March 19, 2020, 6:46 a.m. UTC
When using busybox init as main image's init system, postinsts for
busybox fails in swupdate-image because it tries to create link for
/sbin/init but it cant't because /sbin/init is already created by this
recipe but is not marked update alternative and build fails obscurely

ERROR: swupdate-image-1.0-r0 do_rootfs: Postinstall scriptlets of ['busybox'] have failed. If the intention is to defer them to first boot,
then please place them into pkg_postinst_ontarget_${PN} ().
Deferring to first boot via 'exit 1' is no longer supported.

but the real error is inside log.do_rootfs

pdate-alternatives: Error: not linking /mnt/b/yoe/build/tmp/work/raspberrypi4_64-yoe-linux-musl/swupdate-image/1.0-r0/rootfs/sbin/init to /bin/busybox.nosuid since /mnt/b/yoe/build/tmp/work/raspberrypi4_64-yoe-linux-musl/swupdate-image/1.0-r0/rootfs/sbin/init exists and is not a link

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 .../initscripts-swupdate/initscripts-swupdate-usb.bb     | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Stefano Babic March 19, 2020, 9:36 a.m. UTC | #1
Hi Khem,

On 19.03.20 07:46, Khem Raj wrote:
> When using busybox init as main image's init system, postinsts for
> busybox fails in swupdate-image because it tries to create link for
> /sbin/init but it cant't because /sbin/init is already created by this
> recipe but is not marked update alternative and build fails obscurely
> 
> ERROR: swupdate-image-1.0-r0 do_rootfs: Postinstall scriptlets of ['busybox'] have failed. If the intention is to defer them to first boot,
> then please place them into pkg_postinst_ontarget_${PN} ().
> Deferring to first boot via 'exit 1' is no longer supported.
> 
> but the real error is inside log.do_rootfs
> 
> pdate-alternatives: Error: not linking /mnt/b/yoe/build/tmp/work/raspberrypi4_64-yoe-linux-musl/swupdate-image/1.0-r0/rootfs/sbin/init to /bin/busybox.nosuid since /mnt/b/yoe/build/tmp/work/raspberrypi4_64-yoe-linux-musl/swupdate-image/1.0-r0/rootfs/sbin/init exists and is not a link
> 
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
>  .../initscripts-swupdate/initscripts-swupdate-usb.bb     | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/recipes-core/initscripts-swupdate/initscripts-swupdate-usb.bb b/recipes-core/initscripts-swupdate/initscripts-swupdate-usb.bb
> index 25d6754..4b1dbbe 100644
> --- a/recipes-core/initscripts-swupdate/initscripts-swupdate-usb.bb
> +++ b/recipes-core/initscripts-swupdate/initscripts-swupdate-usb.bb
> @@ -11,15 +11,20 @@ RPROVIDES_${PN} += "virtual/initscripts-swupdate"
>  
>  S = "${WORKDIR}"
>  
> +inherit allarch update-alternatives
> +
>  do_install () {
>  	install -d ${D}/${sysconfdir}/init.d
>  	install -d ${D}${base_sbindir}
>  	install -m 755 ${S}/rcS.swupdate ${D}${base_sbindir}/init
>  }
>  
> +ALTERNATIVE_PRIORITY = "300"
> +ALTERNATIVE_${PN} = "init"
> +ALTERNATIVE_LINK_NAME[init] = "${base_sbindir}/init"
> +ALTERNATIVE_PRIORITY[init] = "60"
> +

Good catch, thanks for this ! (I have surely never tested in this
configuration).

Acked-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano

>  PACKAGES = "${PN}"
>  FILES_${PN} = "/"
>  
> -inherit allarch
> -
>  CONFFILES_${PN} = ""
>
Stefano Babic March 23, 2020, 9:56 a.m. UTC | #2
On 19.03.20 07:46, Khem Raj wrote:
> When using busybox init as main image's init system, postinsts for
> busybox fails in swupdate-image because it tries to create link for
> /sbin/init but it cant't because /sbin/init is already created by this
> recipe but is not marked update alternative and build fails obscurely
> 
> ERROR: swupdate-image-1.0-r0 do_rootfs: Postinstall scriptlets of ['busybox'] have failed. If the intention is to defer them to first boot,
> then please place them into pkg_postinst_ontarget_${PN} ().
> Deferring to first boot via 'exit 1' is no longer supported.
> 
> but the real error is inside log.do_rootfs
> 
> pdate-alternatives: Error: not linking /mnt/b/yoe/build/tmp/work/raspberrypi4_64-yoe-linux-musl/swupdate-image/1.0-r0/rootfs/sbin/init to /bin/busybox.nosuid since /mnt/b/yoe/build/tmp/work/raspberrypi4_64-yoe-linux-musl/swupdate-image/1.0-r0/rootfs/sbin/init exists and is not a link
> 
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
>  .../initscripts-swupdate/initscripts-swupdate-usb.bb     | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/recipes-core/initscripts-swupdate/initscripts-swupdate-usb.bb b/recipes-core/initscripts-swupdate/initscripts-swupdate-usb.bb
> index 25d6754..4b1dbbe 100644
> --- a/recipes-core/initscripts-swupdate/initscripts-swupdate-usb.bb
> +++ b/recipes-core/initscripts-swupdate/initscripts-swupdate-usb.bb
> @@ -11,15 +11,20 @@ RPROVIDES_${PN} += "virtual/initscripts-swupdate"
>  
>  S = "${WORKDIR}"
>  
> +inherit allarch update-alternatives
> +
>  do_install () {
>  	install -d ${D}/${sysconfdir}/init.d
>  	install -d ${D}${base_sbindir}
>  	install -m 755 ${S}/rcS.swupdate ${D}${base_sbindir}/init
>  }
>  
> +ALTERNATIVE_PRIORITY = "300"
> +ALTERNATIVE_${PN} = "init"
> +ALTERNATIVE_LINK_NAME[init] = "${base_sbindir}/init"
> +ALTERNATIVE_PRIORITY[init] = "60"
> +
>  PACKAGES = "${PN}"
>  FILES_${PN} = "/"
>  
> -inherit allarch
> -
>  CONFFILES_${PN} = ""
> 
Applied to -master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/recipes-core/initscripts-swupdate/initscripts-swupdate-usb.bb b/recipes-core/initscripts-swupdate/initscripts-swupdate-usb.bb
index 25d6754..4b1dbbe 100644
--- a/recipes-core/initscripts-swupdate/initscripts-swupdate-usb.bb
+++ b/recipes-core/initscripts-swupdate/initscripts-swupdate-usb.bb
@@ -11,15 +11,20 @@  RPROVIDES_${PN} += "virtual/initscripts-swupdate"
 
 S = "${WORKDIR}"
 
+inherit allarch update-alternatives
+
 do_install () {
 	install -d ${D}/${sysconfdir}/init.d
 	install -d ${D}${base_sbindir}
 	install -m 755 ${S}/rcS.swupdate ${D}${base_sbindir}/init
 }
 
+ALTERNATIVE_PRIORITY = "300"
+ALTERNATIVE_${PN} = "init"
+ALTERNATIVE_LINK_NAME[init] = "${base_sbindir}/init"
+ALTERNATIVE_PRIORITY[init] = "60"
+
 PACKAGES = "${PN}"
 FILES_${PN} = "/"
 
-inherit allarch
-
 CONFFILES_${PN} = ""