Message ID | 1506367382-7240-1-git-send-email-ayoub.zaki@embexus.com |
---|---|
State | Accepted |
Headers | show |
Series | [meta-swupdate,v2] Add systemd swupdate mechanism for usb media | expand |
Hi, > In case of using swupdate with systemd this add the possibility of > updating a device automatically when inserting an usb media containing > a valid update artifact: > > -swupdate-usb.rules: trigger swupdate-usb@ service by passing device name as argument > > -swupdate-progress.service: start progress tool that monitor update status > and reboot the device if update is succesful > > -swupdate-usb@.service: mount the media device, pass the update artficat if existing > on usb media via client tool. In case of failure the media is umounted > > Note that swupdate-usb@.service unit has a require dependency on swupdate-progress.service > which means the the latter is started first. > > Signed-off-by: Ayoub Zaki <ayoub.zaki@embexus.com> > --- > recipes-support/swupdate/swupdate.inc | 12 ++++++++++++ > recipes-support/swupdate/swupdate/swupdate-progress.service | 7 +++++++ > recipes-support/swupdate/swupdate/swupdate-usb.rules | 2 ++ > recipes-support/swupdate/swupdate/swupdate-usb@.service | 8 ++++++++ > 4 files changed, 29 insertions(+) > create mode 100644 recipes-support/swupdate/swupdate/swupdate-progress.service > create mode 100644 recipes-support/swupdate/swupdate/swupdate-usb.rules > create mode 100644 recipes-support/swupdate/swupdate/swupdate-usb@.service > > diff --git a/recipes-support/swupdate/swupdate.inc b/recipes-support/swupdate/swupdate.inc > index 123aa9d..9cd6bb0 100644 > --- a/recipes-support/swupdate/swupdate.inc > +++ b/recipes-support/swupdate/swupdate.inc > @@ -11,6 +11,9 @@ SRC_URI = "git://github.com/sbabic/swupdate.git;protocol=git \ > file://defconfig \ > file://swupdate \ > file://swupdate.service \ > + file://swupdate-usb.rules \ > + file://swupdate-usb@.service \ > + file://swupdate-progress.service \ > " > > SRCREV = "${AUTOREV}" > @@ -114,9 +117,18 @@ do_install () { > > install -d ${D}${systemd_unitdir}/system > install -m 644 ${WORKDIR}/swupdate.service ${D}${systemd_unitdir}/system > + install -m 644 ${WORKDIR}/swupdate-usb@.service ${D}${systemd_unitdir}/system > + install -m 644 ${WORKDIR}/swupdate-progress.service ${D}${systemd_unitdir}/system > + > + > + if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then > + install -d ${D}${sysconfdir}/udev/rules.d > + install -m 0644 ${WORKDIR}/swupdate-usb.rules ${D}${sysconfdir}/udev/rules.d/ > + fi > } > > INITSCRIPT_NAME = "swupdate" > INITSCRIPT_PARAMS = "defaults 70" > > SYSTEMD_SERVICE_${PN} = "swupdate.service" > +SYSTEMD_SERVICE_${PN} += swupdate-usb@.service swupdate-progress.service" > diff --git a/recipes-support/swupdate/swupdate/swupdate-progress.service b/recipes-support/swupdate/swupdate/swupdate-progress.service > new file mode 100644 > index 0000000..7167425 > --- /dev/null > +++ b/recipes-support/swupdate/swupdate/swupdate-progress.service > @@ -0,0 +1,7 @@ > +[Unit] > +Description=swupdate progress service > +Requires=swupdate.service > + > +[Service] > +Type=forking > +ExecStart=/usr/bin/swupdate-progress -r -w > diff --git a/recipes-support/swupdate/swupdate/swupdate-usb.rules b/recipes-support/swupdate/swupdate/swupdate-usb.rules > new file mode 100644 > index 0000000..7a9aa76 > --- /dev/null > +++ b/recipes-support/swupdate/swupdate/swupdate-usb.rules > @@ -0,0 +1,2 @@ > +ACTION=="add", KERNEL=="sd*", SUBSYSTEM=="block", ENV{ID_FS_USAGE}=="filesystem", TAG+="systemd", ENV{SYSTEMD_WANTS}="swupdate-usb@%k.service" > + > diff --git a/recipes-support/swupdate/swupdate/swupdate-usb@.service b/recipes-support/swupdate/swupdate/swupdate-usb@.service > new file mode 100644 > index 0000000..eda9d15 > --- /dev/null > +++ b/recipes-support/swupdate/swupdate/swupdate-usb@.service > @@ -0,0 +1,8 @@ > +[Unit] > +Description=usb media swupdate service > +Requires=swupdate-progress.service > + > +[Service] > +ExecStartPre=/bin/mount /dev/%I /mnt > +ExecStart=/bin/sh -c "swupdate-client -v /mnt/*.swu" > +ExecStopPost=/bin/umount /mnt > -- > 2.7.4 > Just as a note, once the patches regarding systemd support are merged, you may depend on swupdate.socket for your purposes. As well, you may socket-activate SWUpdate. Kind regards, Christian
On Tuesday, September 26, 2017 at 10:34:44 AM UTC+2, Christian Storm wrote: > > Hi, > > > In case of using swupdate with systemd this add the possibility of > > updating a device automatically when inserting an usb media containing > > a valid update artifact: > > > > -swupdate-usb.rules: trigger swupdate-usb@ service by passing device > name as argument > > > > -swupdate-progress.service: start progress tool that monitor update > status > > and reboot the device if update is > succesful > > > > -swupdate-usb@.service: mount the media device, pass the update > artficat if existing > > on usb media via client tool. In case of > failure the media is umounted > > > > Note that swupdate-usb@.service unit has a require dependency on > swupdate-progress.service > > which means the the latter is started first. > > > > Signed-off-by: Ayoub Zaki <ayoub...@embexus.com <javascript:>> > > --- > > recipes-support/swupdate/swupdate.inc | 12 > ++++++++++++ > > recipes-support/swupdate/swupdate/swupdate-progress.service | 7 > +++++++ > > recipes-support/swupdate/swupdate/swupdate-usb.rules | 2 ++ > > recipes-support/swupdate/swupdate/swupdate-usb@.service | 8 > ++++++++ > > 4 files changed, 29 insertions(+) > > create mode 100644 > recipes-support/swupdate/swupdate/swupdate-progress.service > > create mode 100644 recipes-support/swupdate/swupdate/swupdate-usb.rules > > create mode 100644 > recipes-support/swupdate/swupdate/swupdate-usb@.service > > > > diff --git a/recipes-support/swupdate/swupdate.inc > b/recipes-support/swupdate/swupdate.inc > > index 123aa9d..9cd6bb0 100644 > > --- a/recipes-support/swupdate/swupdate.inc > > +++ b/recipes-support/swupdate/swupdate.inc > > @@ -11,6 +11,9 @@ SRC_URI = "git:// > github.com/sbabic/swupdate.git;protocol=git \ > > file://defconfig \ > > file://swupdate \ > > file://swupdate.service \ > > + file://swupdate-usb.rules \ > > + file://swupdate-usb@.service \ > > + file://swupdate-progress.service \ > > " > > > > SRCREV = "${AUTOREV}" > > @@ -114,9 +117,18 @@ do_install () { > > > > install -d ${D}${systemd_unitdir}/system > > install -m 644 ${WORKDIR}/swupdate.service > ${D}${systemd_unitdir}/system > > + install -m 644 ${WORKDIR}/swupdate-usb@.service > ${D}${systemd_unitdir}/system > > + install -m 644 ${WORKDIR}/swupdate-progress.service > ${D}${systemd_unitdir}/system > > + > > + > > + if > ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then > > + install -d ${D}${sysconfdir}/udev/rules.d > > + install -m 0644 ${WORKDIR}/swupdate-usb.rules > ${D}${sysconfdir}/udev/rules.d/ > > + fi > > } > > > > INITSCRIPT_NAME = "swupdate" > > INITSCRIPT_PARAMS = "defaults 70" > > > > SYSTEMD_SERVICE_${PN} = "swupdate.service" > > +SYSTEMD_SERVICE_${PN} += swupdate-usb@.service > swupdate-progress.service" > > diff --git a/recipes-support/swupdate/swupdate/swupdate-progress.service > b/recipes-support/swupdate/swupdate/swupdate-progress.service > > new file mode 100644 > > index 0000000..7167425 > > --- /dev/null > > +++ b/recipes-support/swupdate/swupdate/swupdate-progress.service > > @@ -0,0 +1,7 @@ > > +[Unit] > > +Description=swupdate progress service > > +Requires=swupdate.service > > + > > +[Service] > > +Type=forking > > +ExecStart=/usr/bin/swupdate-progress -r -w > > diff --git a/recipes-support/swupdate/swupdate/swupdate-usb.rules > b/recipes-support/swupdate/swupdate/swupdate-usb.rules > > new file mode 100644 > > index 0000000..7a9aa76 > > --- /dev/null > > +++ b/recipes-support/swupdate/swupdate/swupdate-usb.rules > > @@ -0,0 +1,2 @@ > > +ACTION=="add", KERNEL=="sd*", SUBSYSTEM=="block", > ENV{ID_FS_USAGE}=="filesystem", TAG+="systemd", > ENV{SYSTEMD_WANTS}="swupdate-usb@%k.service" > > + > > diff --git a/recipes-support/swupdate/swupdate/swupdate-usb@.service > b/recipes-support/swupdate/swupdate/swupdate-usb@.service > > new file mode 100644 > > index 0000000..eda9d15 > > --- /dev/null > > +++ b/recipes-support/swupdate/swupdate/swupdate-usb@.service > > @@ -0,0 +1,8 @@ > > +[Unit] > > +Description=usb media swupdate service > > +Requires=swupdate-progress.service > > + > > +[Service] > > +ExecStartPre=/bin/mount /dev/%I /mnt > > +ExecStart=/bin/sh -c "swupdate-client -v /mnt/*.swu" > > +ExecStopPost=/bin/umount /mnt > > -- > > 2.7.4 > > > > > Just as a note, once the patches regarding systemd support are merged, > you may depend on swupdate.socket for your purposes. As well, you may > socket-activate SWUpdate. > AbsoIutely I agree !
On 25/09/2017 21:23, Ayoub Zaki wrote: > In case of using swupdate with systemd this add the possibility of > updating a device automatically when inserting an usb media containing > a valid update artifact: > > -swupdate-usb.rules: trigger swupdate-usb@ service by passing device name as argument > > -swupdate-progress.service: start progress tool that monitor update status > and reboot the device if update is succesful > > -swupdate-usb@.service: mount the media device, pass the update artficat if existing > on usb media via client tool. In case of failure the media is umounted > > Note that swupdate-usb@.service unit has a require dependency on swupdate-progress.service > which means the the latter is started first. > > Signed-off-by: Ayoub Zaki <ayoub.zaki@embexus.com> > --- > recipes-support/swupdate/swupdate.inc | 12 ++++++++++++ > recipes-support/swupdate/swupdate/swupdate-progress.service | 7 +++++++ > recipes-support/swupdate/swupdate/swupdate-usb.rules | 2 ++ > recipes-support/swupdate/swupdate/swupdate-usb@.service | 8 ++++++++ > 4 files changed, 29 insertions(+) > create mode 100644 recipes-support/swupdate/swupdate/swupdate-progress.service > create mode 100644 recipes-support/swupdate/swupdate/swupdate-usb.rules > create mode 100644 recipes-support/swupdate/swupdate/swupdate-usb@.service > > diff --git a/recipes-support/swupdate/swupdate.inc b/recipes-support/swupdate/swupdate.inc > index 123aa9d..9cd6bb0 100644 > --- a/recipes-support/swupdate/swupdate.inc > +++ b/recipes-support/swupdate/swupdate.inc > @@ -11,6 +11,9 @@ SRC_URI = "git://github.com/sbabic/swupdate.git;protocol=git \ > file://defconfig \ > file://swupdate \ > file://swupdate.service \ > + file://swupdate-usb.rules \ > + file://swupdate-usb@.service \ > + file://swupdate-progress.service \ > " > > SRCREV = "${AUTOREV}" > @@ -114,9 +117,18 @@ do_install () { > > install -d ${D}${systemd_unitdir}/system > install -m 644 ${WORKDIR}/swupdate.service ${D}${systemd_unitdir}/system > + install -m 644 ${WORKDIR}/swupdate-usb@.service ${D}${systemd_unitdir}/system > + install -m 644 ${WORKDIR}/swupdate-progress.service ${D}${systemd_unitdir}/system > + > + > + if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then > + install -d ${D}${sysconfdir}/udev/rules.d > + install -m 0644 ${WORKDIR}/swupdate-usb.rules ${D}${sysconfdir}/udev/rules.d/ > + fi > } > > INITSCRIPT_NAME = "swupdate" > INITSCRIPT_PARAMS = "defaults 70" > > SYSTEMD_SERVICE_${PN} = "swupdate.service" > +SYSTEMD_SERVICE_${PN} += swupdate-usb@.service swupdate-progress.service" > diff --git a/recipes-support/swupdate/swupdate/swupdate-progress.service b/recipes-support/swupdate/swupdate/swupdate-progress.service > new file mode 100644 > index 0000000..7167425 > --- /dev/null > +++ b/recipes-support/swupdate/swupdate/swupdate-progress.service > @@ -0,0 +1,7 @@ > +[Unit] > +Description=swupdate progress service > +Requires=swupdate.service > + > +[Service] > +Type=forking > +ExecStart=/usr/bin/swupdate-progress -r -w > diff --git a/recipes-support/swupdate/swupdate/swupdate-usb.rules b/recipes-support/swupdate/swupdate/swupdate-usb.rules > new file mode 100644 > index 0000000..7a9aa76 > --- /dev/null > +++ b/recipes-support/swupdate/swupdate/swupdate-usb.rules > @@ -0,0 +1,2 @@ > +ACTION=="add", KERNEL=="sd*", SUBSYSTEM=="block", ENV{ID_FS_USAGE}=="filesystem", TAG+="systemd", ENV{SYSTEMD_WANTS}="swupdate-usb@%k.service" > + > diff --git a/recipes-support/swupdate/swupdate/swupdate-usb@.service b/recipes-support/swupdate/swupdate/swupdate-usb@.service > new file mode 100644 > index 0000000..eda9d15 > --- /dev/null > +++ b/recipes-support/swupdate/swupdate/swupdate-usb@.service > @@ -0,0 +1,8 @@ > +[Unit] > +Description=usb media swupdate service > +Requires=swupdate-progress.service > + > +[Service] > +ExecStartPre=/bin/mount /dev/%I /mnt > +ExecStart=/bin/sh -c "swupdate-client -v /mnt/*.swu" > +ExecStopPost=/bin/umount /mnt > Applied to -master, -pyro, thanks ! Best regards, Stefano Babic
On 25/09/2017 21:23, Ayoub Zaki wrote: > In case of using swupdate with systemd this add the possibility of > updating a device automatically when inserting an usb media containing > a valid update artifact: > > -swupdate-usb.rules: trigger swupdate-usb@ service by passing device name as argument > > -swupdate-progress.service: start progress tool that monitor update status > and reboot the device if update is succesful > > -swupdate-usb@.service: mount the media device, pass the update artficat if existing > on usb media via client tool. In case of failure the media is umounted > > Note that swupdate-usb@.service unit has a require dependency on swupdate-progress.service > which means the the latter is started first. > > Signed-off-by: Ayoub Zaki <ayoub.zaki@embexus.com> > --- > recipes-support/swupdate/swupdate.inc | 12 ++++++++++++ > recipes-support/swupdate/swupdate/swupdate-progress.service | 7 +++++++ > recipes-support/swupdate/swupdate/swupdate-usb.rules | 2 ++ > recipes-support/swupdate/swupdate/swupdate-usb@.service | 8 ++++++++ > 4 files changed, 29 insertions(+) > create mode 100644 recipes-support/swupdate/swupdate/swupdate-progress.service > create mode 100644 recipes-support/swupdate/swupdate/swupdate-usb.rules > create mode 100644 recipes-support/swupdate/swupdate/swupdate-usb@.service > > diff --git a/recipes-support/swupdate/swupdate.inc b/recipes-support/swupdate/swupdate.inc > index 123aa9d..9cd6bb0 100644 > --- a/recipes-support/swupdate/swupdate.inc > +++ b/recipes-support/swupdate/swupdate.inc > @@ -11,6 +11,9 @@ SRC_URI = "git://github.com/sbabic/swupdate.git;protocol=git \ > file://defconfig \ > file://swupdate \ > file://swupdate.service \ > + file://swupdate-usb.rules \ > + file://swupdate-usb@.service \ > + file://swupdate-progress.service \ > " > > SRCREV = "${AUTOREV}" > @@ -114,9 +117,18 @@ do_install () { > > install -d ${D}${systemd_unitdir}/system > install -m 644 ${WORKDIR}/swupdate.service ${D}${systemd_unitdir}/system > + install -m 644 ${WORKDIR}/swupdate-usb@.service ${D}${systemd_unitdir}/system > + install -m 644 ${WORKDIR}/swupdate-progress.service ${D}${systemd_unitdir}/system > + > + > + if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then > + install -d ${D}${sysconfdir}/udev/rules.d > + install -m 0644 ${WORKDIR}/swupdate-usb.rules ${D}${sysconfdir}/udev/rules.d/ > + fi > } > > INITSCRIPT_NAME = "swupdate" > INITSCRIPT_PARAMS = "defaults 70" > > SYSTEMD_SERVICE_${PN} = "swupdate.service" > +SYSTEMD_SERVICE_${PN} += swupdate-usb@.service swupdate-progress.service" ^---- " is missing, I got errror I have already applied it, so I fix this myself - I will send the patch, too, but I will apply it to avoid to leave the build broken. Best regards, Stefano > diff --git a/recipes-support/swupdate/swupdate/swupdate-progress.service b/recipes-support/swupdate/swupdate/swupdate-progress.service > new file mode 100644 > index 0000000..7167425 > --- /dev/null > +++ b/recipes-support/swupdate/swupdate/swupdate-progress.service > @@ -0,0 +1,7 @@ > +[Unit] > +Description=swupdate progress service > +Requires=swupdate.service > + > +[Service] > +Type=forking > +ExecStart=/usr/bin/swupdate-progress -r -w > diff --git a/recipes-support/swupdate/swupdate/swupdate-usb.rules b/recipes-support/swupdate/swupdate/swupdate-usb.rules > new file mode 100644 > index 0000000..7a9aa76 > --- /dev/null > +++ b/recipes-support/swupdate/swupdate/swupdate-usb.rules > @@ -0,0 +1,2 @@ > +ACTION=="add", KERNEL=="sd*", SUBSYSTEM=="block", ENV{ID_FS_USAGE}=="filesystem", TAG+="systemd", ENV{SYSTEMD_WANTS}="swupdate-usb@%k.service" > + > diff --git a/recipes-support/swupdate/swupdate/swupdate-usb@.service b/recipes-support/swupdate/swupdate/swupdate-usb@.service > new file mode 100644 > index 0000000..eda9d15 > --- /dev/null > +++ b/recipes-support/swupdate/swupdate/swupdate-usb@.service > @@ -0,0 +1,8 @@ > +[Unit] > +Description=usb media swupdate service > +Requires=swupdate-progress.service > + > +[Service] > +ExecStartPre=/bin/mount /dev/%I /mnt > +ExecStart=/bin/sh -c "swupdate-client -v /mnt/*.swu" > +ExecStopPost=/bin/umount /mnt >
On 29.09.2017 18:14, Stefano Babic wrote: > On 25/09/2017 21:23, Ayoub Zaki wrote: >> In case of using swupdate with systemd this add the possibility of >> updating a device automatically when inserting an usb media containing >> a valid update artifact: >> >> -swupdate-usb.rules: trigger swupdate-usb@ service by passing device name as argument >> >> -swupdate-progress.service: start progress tool that monitor update status >> and reboot the device if update is succesful >> >> -swupdate-usb@.service: mount the media device, pass the update artficat if existing >> on usb media via client tool. In case of failure the media is umounted >> >> Note that swupdate-usb@.service unit has a require dependency on swupdate-progress.service >> which means the the latter is started first. >> >> Signed-off-by: Ayoub Zaki <ayoub.zaki@embexus.com> >> --- >> recipes-support/swupdate/swupdate.inc | 12 ++++++++++++ >> recipes-support/swupdate/swupdate/swupdate-progress.service | 7 +++++++ >> recipes-support/swupdate/swupdate/swupdate-usb.rules | 2 ++ >> recipes-support/swupdate/swupdate/swupdate-usb@.service | 8 ++++++++ >> 4 files changed, 29 insertions(+) >> create mode 100644 recipes-support/swupdate/swupdate/swupdate-progress.service >> create mode 100644 recipes-support/swupdate/swupdate/swupdate-usb.rules >> create mode 100644 recipes-support/swupdate/swupdate/swupdate-usb@.service >> >> diff --git a/recipes-support/swupdate/swupdate.inc b/recipes-support/swupdate/swupdate.inc >> index 123aa9d..9cd6bb0 100644 >> --- a/recipes-support/swupdate/swupdate.inc >> +++ b/recipes-support/swupdate/swupdate.inc >> @@ -11,6 +11,9 @@ SRC_URI = "git://github.com/sbabic/swupdate.git;protocol=git \ >> file://defconfig \ >> file://swupdate \ >> file://swupdate.service \ >> + file://swupdate-usb.rules \ >> + file://swupdate-usb@.service \ >> + file://swupdate-progress.service \ >> " >> >> SRCREV = "${AUTOREV}" >> @@ -114,9 +117,18 @@ do_install () { >> >> install -d ${D}${systemd_unitdir}/system >> install -m 644 ${WORKDIR}/swupdate.service ${D}${systemd_unitdir}/system >> + install -m 644 ${WORKDIR}/swupdate-usb@.service ${D}${systemd_unitdir}/system >> + install -m 644 ${WORKDIR}/swupdate-progress.service ${D}${systemd_unitdir}/system >> + >> + >> + if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then >> + install -d ${D}${sysconfdir}/udev/rules.d >> + install -m 0644 ${WORKDIR}/swupdate-usb.rules ${D}${sysconfdir}/udev/rules.d/ >> + fi >> } >> >> INITSCRIPT_NAME = "swupdate" >> INITSCRIPT_PARAMS = "defaults 70" >> >> SYSTEMD_SERVICE_${PN} = "swupdate.service" >> +SYSTEMD_SERVICE_${PN} += swupdate-usb@.service swupdate-progress.service" > ^---- " is missing, I got errror > > I have already applied it, so I fix this myself - I will send the patch, > too, but I will apply it to avoid to leave the build broken. Oops Thanks! I was thinking if I should move those files to swupdate-tools package instead of swupdate ? > > Best regards, > Stefano > > >> diff --git a/recipes-support/swupdate/swupdate/swupdate-progress.service b/recipes-support/swupdate/swupdate/swupdate-progress.service >> new file mode 100644 >> index 0000000..7167425 >> --- /dev/null >> +++ b/recipes-support/swupdate/swupdate/swupdate-progress.service >> @@ -0,0 +1,7 @@ >> +[Unit] >> +Description=swupdate progress service >> +Requires=swupdate.service >> + >> +[Service] >> +Type=forking >> +ExecStart=/usr/bin/swupdate-progress -r -w >> diff --git a/recipes-support/swupdate/swupdate/swupdate-usb.rules b/recipes-support/swupdate/swupdate/swupdate-usb.rules >> new file mode 100644 >> index 0000000..7a9aa76 >> --- /dev/null >> +++ b/recipes-support/swupdate/swupdate/swupdate-usb.rules >> @@ -0,0 +1,2 @@ >> +ACTION=="add", KERNEL=="sd*", SUBSYSTEM=="block", ENV{ID_FS_USAGE}=="filesystem", TAG+="systemd", ENV{SYSTEMD_WANTS}="swupdate-usb@%k.service" >> + >> diff --git a/recipes-support/swupdate/swupdate/swupdate-usb@.service b/recipes-support/swupdate/swupdate/swupdate-usb@.service >> new file mode 100644 >> index 0000000..eda9d15 >> --- /dev/null >> +++ b/recipes-support/swupdate/swupdate/swupdate-usb@.service >> @@ -0,0 +1,8 @@ >> +[Unit] >> +Description=usb media swupdate service >> +Requires=swupdate-progress.service >> + >> +[Service] >> +ExecStartPre=/bin/mount /dev/%I /mnt >> +ExecStart=/bin/sh -c "swupdate-client -v /mnt/*.swu" >> +ExecStopPost=/bin/umount /mnt >> >
Hi Ayoub, On 29/09/2017 18:21, Ayoub Zaki wrote: > > >> I have already applied it, so I fix this myself - I will send the patch, >> too, but I will apply it to avoid to leave the build broken. > Oops Thanks! > I was thinking if I should move those files to swupdate-tools package > instead of swupdate ? swupdate-tools contains the additional binaries, that is utilities. I think this should not be there. But it looks better to not constraint to install this for everybody, because it is project specific - what about to move it into a separate (new) package ? Regards, Stefano
On 29.09.2017 18:29, Stefano Babic wrote: > Hi Ayoub, > > On 29/09/2017 18:21, Ayoub Zaki wrote: >> >>> I have already applied it, so I fix this myself - I will send the patch, >>> too, but I will apply it to avoid to leave the build broken. >> Oops Thanks! >> I was thinking if I should move those files to swupdate-tools package >> instead of swupdate ? > swupdate-tools contains the additional binaries, that is utilities. I > think this should not be there. But it looks better to not constraint to > install this for everybody, because it is project specific - what about > to move it into a separate (new) package ? you are right! it make sens to move it to a new package: for expl. swupdate-usb ? I will resend a patch. regards
diff --git a/recipes-support/swupdate/swupdate.inc b/recipes-support/swupdate/swupdate.inc index 123aa9d..9cd6bb0 100644 --- a/recipes-support/swupdate/swupdate.inc +++ b/recipes-support/swupdate/swupdate.inc @@ -11,6 +11,9 @@ SRC_URI = "git://github.com/sbabic/swupdate.git;protocol=git \ file://defconfig \ file://swupdate \ file://swupdate.service \ + file://swupdate-usb.rules \ + file://swupdate-usb@.service \ + file://swupdate-progress.service \ " SRCREV = "${AUTOREV}" @@ -114,9 +117,18 @@ do_install () { install -d ${D}${systemd_unitdir}/system install -m 644 ${WORKDIR}/swupdate.service ${D}${systemd_unitdir}/system + install -m 644 ${WORKDIR}/swupdate-usb@.service ${D}${systemd_unitdir}/system + install -m 644 ${WORKDIR}/swupdate-progress.service ${D}${systemd_unitdir}/system + + + if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then + install -d ${D}${sysconfdir}/udev/rules.d + install -m 0644 ${WORKDIR}/swupdate-usb.rules ${D}${sysconfdir}/udev/rules.d/ + fi } INITSCRIPT_NAME = "swupdate" INITSCRIPT_PARAMS = "defaults 70" SYSTEMD_SERVICE_${PN} = "swupdate.service" +SYSTEMD_SERVICE_${PN} += swupdate-usb@.service swupdate-progress.service" diff --git a/recipes-support/swupdate/swupdate/swupdate-progress.service b/recipes-support/swupdate/swupdate/swupdate-progress.service new file mode 100644 index 0000000..7167425 --- /dev/null +++ b/recipes-support/swupdate/swupdate/swupdate-progress.service @@ -0,0 +1,7 @@ +[Unit] +Description=swupdate progress service +Requires=swupdate.service + +[Service] +Type=forking +ExecStart=/usr/bin/swupdate-progress -r -w diff --git a/recipes-support/swupdate/swupdate/swupdate-usb.rules b/recipes-support/swupdate/swupdate/swupdate-usb.rules new file mode 100644 index 0000000..7a9aa76 --- /dev/null +++ b/recipes-support/swupdate/swupdate/swupdate-usb.rules @@ -0,0 +1,2 @@ +ACTION=="add", KERNEL=="sd*", SUBSYSTEM=="block", ENV{ID_FS_USAGE}=="filesystem", TAG+="systemd", ENV{SYSTEMD_WANTS}="swupdate-usb@%k.service" + diff --git a/recipes-support/swupdate/swupdate/swupdate-usb@.service b/recipes-support/swupdate/swupdate/swupdate-usb@.service new file mode 100644 index 0000000..eda9d15 --- /dev/null +++ b/recipes-support/swupdate/swupdate/swupdate-usb@.service @@ -0,0 +1,8 @@ +[Unit] +Description=usb media swupdate service +Requires=swupdate-progress.service + +[Service] +ExecStartPre=/bin/mount /dev/%I /mnt +ExecStart=/bin/sh -c "swupdate-client -v /mnt/*.swu" +ExecStopPost=/bin/umount /mnt
In case of using swupdate with systemd this add the possibility of updating a device automatically when inserting an usb media containing a valid update artifact: -swupdate-usb.rules: trigger swupdate-usb@ service by passing device name as argument -swupdate-progress.service: start progress tool that monitor update status and reboot the device if update is succesful -swupdate-usb@.service: mount the media device, pass the update artficat if existing on usb media via client tool. In case of failure the media is umounted Note that swupdate-usb@.service unit has a require dependency on swupdate-progress.service which means the the latter is started first. Signed-off-by: Ayoub Zaki <ayoub.zaki@embexus.com> --- recipes-support/swupdate/swupdate.inc | 12 ++++++++++++ recipes-support/swupdate/swupdate/swupdate-progress.service | 7 +++++++ recipes-support/swupdate/swupdate/swupdate-usb.rules | 2 ++ recipes-support/swupdate/swupdate/swupdate-usb@.service | 8 ++++++++ 4 files changed, 29 insertions(+) create mode 100644 recipes-support/swupdate/swupdate/swupdate-progress.service create mode 100644 recipes-support/swupdate/swupdate/swupdate-usb.rules create mode 100644 recipes-support/swupdate/swupdate/swupdate-usb@.service