diff mbox series

[meta-swupdate,09/12] swupdate: improve systemd config

Message ID 20191023211101.16591-10-adrian.freihofer@siemens.com
State Changes Requested
Headers show
Series simplify swupdate config | expand

Commit Message

Freihofer, Adrian Oct. 23, 2019, 9:10 p.m. UTC
For most projects starting swupdate requires some logic implemented
in shell scripts. Therefore swupdate is now started by a shell script
also in case of systemd is anabled in DISTRO_FEATURES.

The new swupdate startup script sources code snippets located in
/usr/lib/swupdate/conf.d and in /etc/swupdate/conf.d. The snippets are
executed in alphabetical order. The idea is that files in /usr are added
at build time and files in /etc might be added or modified at run-time.
If two scripts, one in /etc and one in /usr have the same file name, the
script in /usr gets skipped completely. This allows to disable code in
/usr, which is probably mounted ro, at runtime.

Code snippets are automatically generated at build-time, depending on
the configuration created by swupdate's menuconfig. But code snippets
may be created manually and added via bbappend to the
/usr/lib/swupdate/conf.d folder.

All modes (file, webserver, webclient) of swupdate are supported.
Different variables might be defined by the code snippets added to the
named folders:
- SWUPDATE_ARGS
- SWUPDATE_WEBSERVER_ARGS
- SWUPDATE_DOWNLOAD_ARGS

Finally swupdate gets started by a line similar to:

  exec /usr/bin/swupdate $SWUPDATE_ARGS \
                         -w "$SWUPDATE_WEBSERVER_ARGS" \
                         -u "$SWUPDATE_DOWNLOAD_ARGS"

The default set of configuraton and service files is now installed by
the "make install" target of the swupdate Makefile. The service files
which are not used for the latest git version of swupdate are moved
to swupdate-2019.04 folder.

Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
 .../swupdate-progress.service                      |  0
 .../swupdate-usb.rules                             |  0
 .../swupdate-usb@.service                          |  0
 .../swupdate.service                               |  0
 .../systemd-tmpfiles-swupdate.conf                 |  0
 recipes-support/swupdate/swupdate.inc              | 40 +++++++++-------------
 recipes-support/swupdate/swupdate_2019.04.bb       |  8 +++++
 recipes-support/swupdate/swupdate_git.bb           |  4 +++
 8 files changed, 29 insertions(+), 23 deletions(-)
 rename recipes-support/swupdate/{swupdate => swupdate-2019.04}/swupdate-progress.service (100%)
 rename recipes-support/swupdate/{swupdate => swupdate-2019.04}/swupdate-usb.rules (100%)
 rename recipes-support/swupdate/{swupdate => swupdate-2019.04}/swupdate-usb@.service (100%)
 rename recipes-support/swupdate/{swupdate => swupdate-2019.04}/swupdate.service (100%)
 rename recipes-support/swupdate/{swupdate => swupdate-2019.04}/systemd-tmpfiles-swupdate.conf (100%)

Comments

Stefan Herbrechtsmeier Oct. 24, 2019, 8:47 a.m. UTC | #1
Am 23.10.19 um 23:10 schrieb Adrian Freihofer:
> For most projects starting swupdate requires some logic implemented
> in shell scripts. Therefore swupdate is now started by a shell script
> also in case of systemd is anabled in DISTRO_FEATURES.
> 
> The new swupdate startup script sources code snippets located in
> /usr/lib/swupdate/conf.d and in /etc/swupdate/conf.d. The snippets are
> executed in alphabetical order. The idea is that files in /usr are added
> at build time and files in /etc might be added or modified at run-time.
> If two scripts, one in /etc and one in /usr have the same file name, the
> script in /usr gets skipped completely. This allows to disable code in
> /usr, which is probably mounted ro, at runtime.
> 
> Code snippets are automatically generated at build-time, depending on
> the configuration created by swupdate's menuconfig. But code snippets
> may be created manually and added via bbappend to the
> /usr/lib/swupdate/conf.d folder.
> 
> All modes (file, webserver, webclient) of swupdate are supported.
> Different variables might be defined by the code snippets added to the
> named folders:
> - SWUPDATE_ARGS
> - SWUPDATE_WEBSERVER_ARGS
> - SWUPDATE_DOWNLOAD_ARGS
> 
> Finally swupdate gets started by a line similar to:
> 
>    exec /usr/bin/swupdate $SWUPDATE_ARGS \
>                           -w "$SWUPDATE_WEBSERVER_ARGS" \
>                           -u "$SWUPDATE_DOWNLOAD_ARGS"
> 
> The default set of configuraton and service files is now installed by
> the "make install" target of the swupdate Makefile. The service files
> which are not used for the latest git version of swupdate are moved
> to swupdate-2019.04 folder.
> 
> Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
> ---
>   .../swupdate-progress.service                      |  0
>   .../swupdate-usb.rules                             |  0
>   .../swupdate-usb@.service                          |  0
>   .../swupdate.service                               |  0
>   .../systemd-tmpfiles-swupdate.conf                 |  0
>   recipes-support/swupdate/swupdate.inc              | 40 +++++++++-------------
>   recipes-support/swupdate/swupdate_2019.04.bb       |  8 +++++
>   recipes-support/swupdate/swupdate_git.bb           |  4 +++
>   8 files changed, 29 insertions(+), 23 deletions(-)
>   rename recipes-support/swupdate/{swupdate => swupdate-2019.04}/swupdate-progress.service (100%)
>   rename recipes-support/swupdate/{swupdate => swupdate-2019.04}/swupdate-usb.rules (100%)
>   rename recipes-support/swupdate/{swupdate => swupdate-2019.04}/swupdate-usb@.service (100%)
>   rename recipes-support/swupdate/{swupdate => swupdate-2019.04}/swupdate.service (100%)
>   rename recipes-support/swupdate/{swupdate => swupdate-2019.04}/systemd-tmpfiles-swupdate.conf (100%)
> 
> diff --git a/recipes-support/swupdate/swupdate/swupdate-progress.service b/recipes-support/swupdate/swupdate-2019.04/swupdate-progress.service
> similarity index 100%
> rename from recipes-support/swupdate/swupdate/swupdate-progress.service
> rename to recipes-support/swupdate/swupdate-2019.04/swupdate-progress.service
> diff --git a/recipes-support/swupdate/swupdate/swupdate-usb.rules b/recipes-support/swupdate/swupdate-2019.04/swupdate-usb.rules
> similarity index 100%
> rename from recipes-support/swupdate/swupdate/swupdate-usb.rules
> rename to recipes-support/swupdate/swupdate-2019.04/swupdate-usb.rules
> diff --git a/recipes-support/swupdate/swupdate/swupdate-usb@.service b/recipes-support/swupdate/swupdate-2019.04/swupdate-usb@.service
> similarity index 100%
> rename from recipes-support/swupdate/swupdate/swupdate-usb@.service
> rename to recipes-support/swupdate/swupdate-2019.04/swupdate-usb@.service
> diff --git a/recipes-support/swupdate/swupdate/swupdate.service b/recipes-support/swupdate/swupdate-2019.04/swupdate.service
> similarity index 100%
> rename from recipes-support/swupdate/swupdate/swupdate.service
> rename to recipes-support/swupdate/swupdate-2019.04/swupdate.service
> diff --git a/recipes-support/swupdate/swupdate/systemd-tmpfiles-swupdate.conf b/recipes-support/swupdate/swupdate-2019.04/systemd-tmpfiles-swupdate.conf
> similarity index 100%
> rename from recipes-support/swupdate/swupdate/systemd-tmpfiles-swupdate.conf
> rename to recipes-support/swupdate/swupdate-2019.04/systemd-tmpfiles-swupdate.conf
> diff --git a/recipes-support/swupdate/swupdate.inc b/recipes-support/swupdate/swupdate.inc
> index 1c863bb..19ccf4a 100644
> --- a/recipes-support/swupdate/swupdate.inc
> +++ b/recipes-support/swupdate/swupdate.inc
> @@ -10,25 +10,30 @@ inherit cml1 update-rc.d systemd pkgconfig
>   SRC_URI = "git://github.com/sbabic/swupdate.git;protocol=https \
>        file://defconfig \
>        file://swupdate \
> -     file://swupdate.service \
> -     file://swupdate-usb.rules \
> -     file://swupdate-usb@.service \
> -     file://swupdate-progress.service \
> -     file://systemd-tmpfiles-swupdate.conf \
>        "
>   
>   INSANE_SKIP_${PN} = "ldflags"
>   PACKAGES =+ "${PN}-www ${PN}-lua"
>   
>   FILES_${PN}-lua += "${libdir}/lua/"
> -FILES_${PN}-www = "/www/*"
> -FILES_${PN} += "${libdir}/tmpfiles.d"
> +FILES_${PN}-www = " \
> +    ${libdir}/swupdate/conf.d/*mongoose* \
> +    /www/* \
> +"
> +FILES_${PN} += " \
> +    ${libdir}/tmpfiles.d \
> +    ${libdir}/swupdate/* \
> +    ${systemd_system_unitdir}/swupdate.socket \
> +    ${systemd_system_unitdir}/swupdate.service \
> +    ${systemd_system_unitdir}/swupdate-usb@.service \
> +"
>   
>   RDEPENDS_${PN}-www += "${PN}-tools"
>   
>   S = "${WORKDIR}/git/"
>   
> -EXTRA_OEMAKE += " HOSTCC="${BUILD_CC}" HOSTCXX="${BUILD_CXX}" LD="${CC}" DESTDIR="${D}" V=1 ARCH=${TARGET_ARCH} CROSS_COMPILE=${TARGET_PREFIX} SKIP_STRIP=y"
> +EXTRA_OEMAKE += " HOSTCC="${BUILD_CC}" HOSTCXX="${BUILD_CXX}" LD="${CC}" DESTDIR="${D}" V=1 ARCH=${TARGET_ARCH} CROSS_COMPILE=${TARGET_PREFIX} SKIP_STRIP=y \
> +  ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'SYSTEMD_SYSTEM_UNITDIR=${systemd_system_unitdir}', '', d)}"

NACK. This is a configuration and should be setup during configuration.

Regards
   Stefan
Adrian Freihofer Oct. 24, 2019, 10:43 a.m. UTC | #2
Hi Stefan,

There is an option in Kconfig but this option is not useful for a Yocto 
build system. Therefore the default value of Kbuild allows to provide the 
value like done in the line you are referring.
systemd_system_unitdir is a system specific variable provided by Yocto. 
Every other value as the one set by this line, would break almost 
everything here. What's the advantage of a configuration flag where exactly 
one value is valid? Or what is the other value you would like to configure?

Regards,
Adrian

Am Donnerstag, 24. Oktober 2019 10:47:47 UTC+2 schrieb Stefan 
Herbrechtsmeier:
>
> Am 23.10.19 um 23:10 schrieb Adrian Freihofer: 
> > For most projects starting swupdate requires some logic implemented 
> > in shell scripts. Therefore swupdate is now started by a shell script 
> > also in case of systemd is anabled in DISTRO_FEATURES. 
> > 
> > The new swupdate startup script sources code snippets located in 
> > /usr/lib/swupdate/conf.d and in /etc/swupdate/conf.d. The snippets are 
> > executed in alphabetical order. The idea is that files in /usr are added 
> > at build time and files in /etc might be added or modified at run-time. 
> > If two scripts, one in /etc and one in /usr have the same file name, the 
> > script in /usr gets skipped completely. This allows to disable code in 
> > /usr, which is probably mounted ro, at runtime. 
> > 
> > Code snippets are automatically generated at build-time, depending on 
> > the configuration created by swupdate's menuconfig. But code snippets 
> > may be created manually and added via bbappend to the 
> > /usr/lib/swupdate/conf.d folder. 
> > 
> > All modes (file, webserver, webclient) of swupdate are supported. 
> > Different variables might be defined by the code snippets added to the 
> > named folders: 
> > - SWUPDATE_ARGS 
> > - SWUPDATE_WEBSERVER_ARGS 
> > - SWUPDATE_DOWNLOAD_ARGS 
> > 
> > Finally swupdate gets started by a line similar to: 
> > 
> >    exec /usr/bin/swupdate $SWUPDATE_ARGS \ 
> >                           -w "$SWUPDATE_WEBSERVER_ARGS" \ 
> >                           -u "$SWUPDATE_DOWNLOAD_ARGS" 
> > 
> > The default set of configuraton and service files is now installed by 
> > the "make install" target of the swupdate Makefile. The service files 
> > which are not used for the latest git version of swupdate are moved 
> > to swupdate-2019.04 folder. 
> > 
> > Signed-off-by: Adrian Freihofer <adrian....@siemens.com <javascript:>> 
> > --- 
> >   .../swupdate-progress.service                      |  0 
> >   .../swupdate-usb.rules                             |  0 
> >   .../swupdate-usb@.service                          |  0 
> >   .../swupdate.service                               |  0 
> >   .../systemd-tmpfiles-swupdate.conf                 |  0 
> >   recipes-support/swupdate/swupdate.inc              | 40 
> +++++++++------------- 
> >   recipes-support/swupdate/swupdate_2019.04.bb       |  8 +++++ 
> >   recipes-support/swupdate/swupdate_git.bb           |  4 +++ 
> >   8 files changed, 29 insertions(+), 23 deletions(-) 
> >   rename recipes-support/swupdate/{swupdate => 
> swupdate-2019.04}/swupdate-progress.service (100%) 
> >   rename recipes-support/swupdate/{swupdate => 
> swupdate-2019.04}/swupdate-usb.rules (100%) 
> >   rename recipes-support/swupdate/{swupdate => 
> swupdate-2019.04}/swupdate-usb@.service (100%) 
> >   rename recipes-support/swupdate/{swupdate => 
> swupdate-2019.04}/swupdate.service (100%) 
> >   rename recipes-support/swupdate/{swupdate => 
> swupdate-2019.04}/systemd-tmpfiles-swupdate.conf (100%) 
> > 
> > diff --git a/recipes-support/swupdate/swupdate/swupdate-progress.service 
> b/recipes-support/swupdate/swupdate-2019.04/swupdate-progress.service 
> > similarity index 100% 
> > rename from recipes-support/swupdate/swupdate/swupdate-progress.service 
> > rename to 
> recipes-support/swupdate/swupdate-2019.04/swupdate-progress.service 
> > diff --git a/recipes-support/swupdate/swupdate/swupdate-usb.rules 
> b/recipes-support/swupdate/swupdate-2019.04/swupdate-usb.rules 
> > similarity index 100% 
> > rename from recipes-support/swupdate/swupdate/swupdate-usb.rules 
> > rename to recipes-support/swupdate/swupdate-2019.04/swupdate-usb.rules 
> > diff --git a/recipes-support/swupdate/swupdate/swupdate-usb@.service 
> b/recipes-support/swupdate/swupdate-2019.04/swupdate-usb@.service 
> > similarity index 100% 
> > rename from recipes-support/swupdate/swupdate/swupdate-usb@.service 
> > rename to 
> recipes-support/swupdate/swupdate-2019.04/swupdate-usb@.service 
> > diff --git a/recipes-support/swupdate/swupdate/swupdate.service 
> b/recipes-support/swupdate/swupdate-2019.04/swupdate.service 
> > similarity index 100% 
> > rename from recipes-support/swupdate/swupdate/swupdate.service 
> > rename to recipes-support/swupdate/swupdate-2019.04/swupdate.service 
> > diff --git 
> a/recipes-support/swupdate/swupdate/systemd-tmpfiles-swupdate.conf 
> b/recipes-support/swupdate/swupdate-2019.04/systemd-tmpfiles-swupdate.conf 
> > similarity index 100% 
> > rename from 
> recipes-support/swupdate/swupdate/systemd-tmpfiles-swupdate.conf 
> > rename to 
> recipes-support/swupdate/swupdate-2019.04/systemd-tmpfiles-swupdate.conf 
> > diff --git a/recipes-support/swupdate/swupdate.inc 
> b/recipes-support/swupdate/swupdate.inc 
> > index 1c863bb..19ccf4a 100644 
> > --- a/recipes-support/swupdate/swupdate.inc 
> > +++ b/recipes-support/swupdate/swupdate.inc 
> > @@ -10,25 +10,30 @@ inherit cml1 update-rc.d systemd pkgconfig 
> >   SRC_URI = "git://github.com/sbabic/swupdate.git;protocol=https \ 
> >        file://defconfig \ 
> >        file://swupdate \ 
> > -     file://swupdate.service \ 
> > -     file://swupdate-usb.rules \ 
> > -     file://swupdate-usb@.service \ 
> > -     file://swupdate-progress.service \ 
> > -     file://systemd-tmpfiles-swupdate.conf \ 
> >        " 
> >   
> >   INSANE_SKIP_${PN} = "ldflags" 
> >   PACKAGES =+ "${PN}-www ${PN}-lua" 
> >   
> >   FILES_${PN}-lua += "${libdir}/lua/" 
> > -FILES_${PN}-www = "/www/*" 
> > -FILES_${PN} += "${libdir}/tmpfiles.d" 
> > +FILES_${PN}-www = " \ 
> > +    ${libdir}/swupdate/conf.d/*mongoose* \ 
> > +    /www/* \ 
> > +" 
> > +FILES_${PN} += " \ 
> > +    ${libdir}/tmpfiles.d \ 
> > +    ${libdir}/swupdate/* \ 
> > +    ${systemd_system_unitdir}/swupdate.socket \ 
> > +    ${systemd_system_unitdir}/swupdate.service \ 
> > +    ${systemd_system_unitdir}/swupdate-usb@.service \ 
> > +" 
> >   
> >   RDEPENDS_${PN}-www += "${PN}-tools" 
> >   
> >   S = "${WORKDIR}/git/" 
> >   
> > -EXTRA_OEMAKE += " HOSTCC="${BUILD_CC}" HOSTCXX="${BUILD_CXX}" 
> LD="${CC}" DESTDIR="${D}" V=1 ARCH=${TARGET_ARCH} 
> CROSS_COMPILE=${TARGET_PREFIX} SKIP_STRIP=y" 
> > +EXTRA_OEMAKE += " HOSTCC="${BUILD_CC}" HOSTCXX="${BUILD_CXX}" 
> LD="${CC}" DESTDIR="${D}" V=1 ARCH=${TARGET_ARCH} 
> CROSS_COMPILE=${TARGET_PREFIX} SKIP_STRIP=y \ 
> > +  ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 
> 'SYSTEMD_SYSTEM_UNITDIR=${systemd_system_unitdir}', '', d)}" 
>
> NACK. This is a configuration and should be setup during configuration. 
>
> Regards 
>    Stefan 
>
Joris OFFOUGA Oct. 24, 2019, 11:05 a.m. UTC | #3
Hi Adrian,

Le jeu. 24 oct. 2019 à 12:43, <adrian.freihofer@gmail.com> a écrit :

> Hi Stefan,
>
> There is an option in Kconfig but this option is not useful for a Yocto
> build system. Therefore the default value of Kbuild allows to provide the
> value like done in the line you are referring.
> systemd_system_unitdir is a system specific variable provided by Yocto.
> Every other value as the one set by this line, would break almost
> everything here. What's the advantage of a configuration flag where exactly
> one value is valid? Or what is the other value you would like to configure?
>

I totally agree with you.  That's why I also put the default value in my
patch

Best Regards,
Joris

>
> Regards,
> Adrian
>
> Am Donnerstag, 24. Oktober 2019 10:47:47 UTC+2 schrieb Stefan
> Herbrechtsmeier:
>>
>> Am 23.10.19 um 23:10 schrieb Adrian Freihofer:
>> > For most projects starting swupdate requires some logic implemented
>> > in shell scripts. Therefore swupdate is now started by a shell script
>> > also in case of systemd is anabled in DISTRO_FEATURES.
>> >
>> > The new swupdate startup script sources code snippets located in
>> > /usr/lib/swupdate/conf.d and in /etc/swupdate/conf.d. The snippets are
>> > executed in alphabetical order. The idea is that files in /usr are
>> added
>> > at build time and files in /etc might be added or modified at run-time.
>> > If two scripts, one in /etc and one in /usr have the same file name,
>> the
>> > script in /usr gets skipped completely. This allows to disable code in
>> > /usr, which is probably mounted ro, at runtime.
>> >
>> > Code snippets are automatically generated at build-time, depending on
>> > the configuration created by swupdate's menuconfig. But code snippets
>> > may be created manually and added via bbappend to the
>> > /usr/lib/swupdate/conf.d folder.
>> >
>> > All modes (file, webserver, webclient) of swupdate are supported.
>> > Different variables might be defined by the code snippets added to the
>> > named folders:
>> > - SWUPDATE_ARGS
>> > - SWUPDATE_WEBSERVER_ARGS
>> > - SWUPDATE_DOWNLOAD_ARGS
>> >
>> > Finally swupdate gets started by a line similar to:
>> >
>> >    exec /usr/bin/swupdate $SWUPDATE_ARGS \
>> >                           -w "$SWUPDATE_WEBSERVER_ARGS" \
>> >                           -u "$SWUPDATE_DOWNLOAD_ARGS"
>> >
>> > The default set of configuraton and service files is now installed by
>> > the "make install" target of the swupdate Makefile. The service files
>> > which are not used for the latest git version of swupdate are moved
>> > to swupdate-2019.04 folder.
>> >
>> > Signed-off-by: Adrian Freihofer <adrian....@siemens.com>
>> > ---
>> >   .../swupdate-progress.service                      |  0
>> >   .../swupdate-usb.rules                             |  0
>> >   .../swupdate-usb@.service                          |  0
>> >   .../swupdate.service                               |  0
>> >   .../systemd-tmpfiles-swupdate.conf                 |  0
>> >   recipes-support/swupdate/swupdate.inc              | 40
>> +++++++++-------------
>> >   recipes-support/swupdate/swupdate_2019.04.bb       |  8 +++++
>> >   recipes-support/swupdate/swupdate_git.bb           |  4 +++
>> >   8 files changed, 29 insertions(+), 23 deletions(-)
>> >   rename recipes-support/swupdate/{swupdate =>
>> swupdate-2019.04}/swupdate-progress.service (100%)
>> >   rename recipes-support/swupdate/{swupdate =>
>> swupdate-2019.04}/swupdate-usb.rules (100%)
>> >   rename recipes-support/swupdate/{swupdate =>
>> swupdate-2019.04}/swupdate-usb@.service (100%)
>> >   rename recipes-support/swupdate/{swupdate =>
>> swupdate-2019.04}/swupdate.service (100%)
>> >   rename recipes-support/swupdate/{swupdate =>
>> swupdate-2019.04}/systemd-tmpfiles-swupdate.conf (100%)
>> >
>> > diff --git
>> a/recipes-support/swupdate/swupdate/swupdate-progress.service
>> b/recipes-support/swupdate/swupdate-2019.04/swupdate-progress.service
>> > similarity index 100%
>> > rename from recipes-support/swupdate/swupdate/swupdate-progress.service
>> > rename to
>> recipes-support/swupdate/swupdate-2019.04/swupdate-progress.service
>> > diff --git a/recipes-support/swupdate/swupdate/swupdate-usb.rules
>> b/recipes-support/swupdate/swupdate-2019.04/swupdate-usb.rules
>> > similarity index 100%
>> > rename from recipes-support/swupdate/swupdate/swupdate-usb.rules
>> > rename to recipes-support/swupdate/swupdate-2019.04/swupdate-usb.rules
>> > diff --git a/recipes-support/swupdate/swupdate/swupdate-usb@.service
>> b/recipes-support/swupdate/swupdate-2019.04/swupdate-usb@.service
>> > similarity index 100%
>> > rename from recipes-support/swupdate/swupdate/swupdate-usb@.service
>> > rename to recipes-support/swupdate/swupdate-2019.04/swupdate-usb@.service
>>
>> > diff --git a/recipes-support/swupdate/swupdate/swupdate.service
>> b/recipes-support/swupdate/swupdate-2019.04/swupdate.service
>> > similarity index 100%
>> > rename from recipes-support/swupdate/swupdate/swupdate.service
>> > rename to recipes-support/swupdate/swupdate-2019.04/swupdate.service
>> > diff --git
>> a/recipes-support/swupdate/swupdate/systemd-tmpfiles-swupdate.conf
>> b/recipes-support/swupdate/swupdate-2019.04/systemd-tmpfiles-swupdate.conf
>> > similarity index 100%
>> > rename from
>> recipes-support/swupdate/swupdate/systemd-tmpfiles-swupdate.conf
>> > rename to
>> recipes-support/swupdate/swupdate-2019.04/systemd-tmpfiles-swupdate.conf
>> > diff --git a/recipes-support/swupdate/swupdate.inc
>> b/recipes-support/swupdate/swupdate.inc
>> > index 1c863bb..19ccf4a 100644
>> > --- a/recipes-support/swupdate/swupdate.inc
>> > +++ b/recipes-support/swupdate/swupdate.inc
>> > @@ -10,25 +10,30 @@ inherit cml1 update-rc.d systemd pkgconfig
>> >   SRC_URI = "git://github.com/sbabic/swupdate.git;protocol=https \
>> >        file://defconfig \
>> >        file://swupdate \
>> > -     file://swupdate.service \
>> > -     file://swupdate-usb.rules \
>> > -     file://swupdate-usb@.service \
>> > -     file://swupdate-progress.service \
>> > -     file://systemd-tmpfiles-swupdate.conf \
>> >        "
>> >
>> >   INSANE_SKIP_${PN} = "ldflags"
>> >   PACKAGES =+ "${PN}-www ${PN}-lua"
>> >
>> >   FILES_${PN}-lua += "${libdir}/lua/"
>> > -FILES_${PN}-www = "/www/*"
>> > -FILES_${PN} += "${libdir}/tmpfiles.d"
>> > +FILES_${PN}-www = " \
>> > +    ${libdir}/swupdate/conf.d/*mongoose* \
>> > +    /www/* \
>> > +"
>> > +FILES_${PN} += " \
>> > +    ${libdir}/tmpfiles.d \
>> > +    ${libdir}/swupdate/* \
>> > +    ${systemd_system_unitdir}/swupdate.socket \
>> > +    ${systemd_system_unitdir}/swupdate.service \
>> > +    ${systemd_system_unitdir}/swupdate-usb@.service \
>> > +"
>> >
>> >   RDEPENDS_${PN}-www += "${PN}-tools"
>> >
>> >   S = "${WORKDIR}/git/"
>> >
>> > -EXTRA_OEMAKE += " HOSTCC="${BUILD_CC}" HOSTCXX="${BUILD_CXX}"
>> LD="${CC}" DESTDIR="${D}" V=1 ARCH=${TARGET_ARCH}
>> CROSS_COMPILE=${TARGET_PREFIX} SKIP_STRIP=y"
>> > +EXTRA_OEMAKE += " HOSTCC="${BUILD_CC}" HOSTCXX="${BUILD_CXX}"
>> LD="${CC}" DESTDIR="${D}" V=1 ARCH=${TARGET_ARCH}
>> CROSS_COMPILE=${TARGET_PREFIX} SKIP_STRIP=y \
>> > +  ${@bb.utils.contains('DISTRO_FEATURES', 'systemd',
>> 'SYSTEMD_SYSTEM_UNITDIR=${systemd_system_unitdir}', '', d)}"
>>
>> NACK. This is a configuration and should be setup during configuration.
>>
>> Regards
>>    Stefan
>>
> --
> You received this message because you are subscribed to the Google Groups
> "swupdate" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to swupdate+unsubscribe@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/swupdate/962bbe3f-6185-4c7f-b539-51af4546fbeb%40googlegroups.com
> <https://groups.google.com/d/msgid/swupdate/962bbe3f-6185-4c7f-b539-51af4546fbeb%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
Stefan Herbrechtsmeier Oct. 24, 2019, 12:13 p.m. UTC | #4
Hi Adrian,

Am 24.10.19 um 12:43 schrieb adrian.freihofer@gmail.com:
> Hi Stefan,
> 
> There is an option in Kconfig but this option is not useful for a Yocto 
> build system.

Why?

Couldn't you append the value to the .config?

> Therefore the default value of Kbuild allows to provide 
> the value like done in the line you are referring.
> systemd_system_unitdir is a system specific variable provided by Yocto. 
> Every other value as the one set by this line, would break almost 
> everything here. What's the advantage of a configuration flag where 
> exactly one value is valid? Or what is the other value you would like to 
> configure?

The problem is the break of the common design. You have three step: 
configure, build, install. You break this concept because you set a 
configuration option during install. All other build tools (autotools, 
cmake, meson) use the configuration step to configure the installation step.

Regards
   Stefan
Adrian Freihofer Oct. 24, 2019, 2:32 p.m. UTC | #5
Am Donnerstag, 24. Oktober 2019 14:13:13 UTC+2 schrieb Stefan 
Herbrechtsmeier:
>
> Hi Adrian, 
>
> Am 24.10.19 um 12:43 schrieb adrian....@gmail.com <javascript:>: 
> > Hi Stefan, 
> > 
> > There is an option in Kconfig but this option is not useful for a Yocto 
> > build system. 
>
> Why? 
>
> Couldn't you append the value to the .config? 
>
The important thing is that Yocto must be the master of this information. 
Kbuild or the user (via menuconfig) do not have the information. My 
assumption is that the Kbuild system has menuconfig as the only configure 
input. There is nothing comparable to e.g. cmake -Dfoo=bar for the KBuild 
system. If you could explain me how to pass variables to the configure step 
of the Kbuild system, I would of course agree with you.

>
> > Therefore the default value of Kbuild allows to provide 
> > the value like done in the line you are referring. 
> > systemd_system_unitdir is a system specific variable provided by Yocto. 
> > Every other value as the one set by this line, would break almost 
> > everything here. What's the advantage of a configuration flag where 
> > exactly one value is valid? Or what is the other value you would like to 
> > configure? 
>
> The problem is the break of the common design. You have three step: 
> configure, build, install. You break this concept because you set a 
> configuration option during install. All other build tools (autotools, 
> cmake, meson) use the configuration step to configure the installation 
> step. 
>
> For example cmake takes the PREFIX variable as an install parameter. It's 
not exactly the same, but quite similar.

Regards,
Adrian
 

> Regards 
>    Stefan 
>
Stefan Herbrechtsmeier Oct. 24, 2019, 3:51 p.m. UTC | #6
Hi Adrian,

Am 24.10.19 um 16:32 schrieb adrian.freihofer@gmail.com:
> Am Donnerstag, 24. Oktober 2019 14:13:13 UTC+2 schrieb Stefan 
> Herbrechtsmeier:
> 
>     Hi Adrian,
> 
>     Am 24.10.19 um 12:43 schrieb adrian....@gmail.com <javascript:>:
>      > Hi Stefan,
>      >
>      > There is an option in Kconfig but this option is not useful for a
>     Yocto
>      > build system.
> 
>     Why?
> 
>     Couldn't you append the value to the .config?
> 
> The important thing is that Yocto must be the master of this 
> information. Kbuild or the user (via menuconfig) do not have the 
> information. My assumption is that the Kbuild system has menuconfig as 
> the only configure input. There is nothing comparable to e.g. cmake 
> -Dfoo=bar for the KBuild system. If you could explain me how to pass 
> variables to the configure step of the Kbuild system, I would of course 
> agree with you.

Check the kernel-yocto.bbclass as example.

do_configure_append() {
     echo "# Global settings from swupdate recipe" >> ${B}/.config
     echo "CONFIG_SYSTEMD_SYSTEM_UNITDIR=\"${SYSTEMD_SYSTEM_UNITDIR}\"" 
 >> ${B}/.config
}

> 
> 
>      > Therefore the default value of Kbuild allows to provide
>      > the value like done in the line you are referring.
>      > systemd_system_unitdir is a system specific variable provided by
>     Yocto.
>      > Every other value as the one set by this line, would break almost
>      > everything here. What's the advantage of a configuration flag where
>      > exactly one value is valid? Or what is the other value you would
>     like to
>      > configure?
> 
>     The problem is the break of the common design. You have three step:
>     configure, build, install. You break this concept because you set a
>     configuration option during install. All other build tools (autotools,
>     cmake, meson) use the configuration step to configure the
>     installation step.
> 
> For example cmake takes the PREFIX variable as an install parameter. 
> It's not exactly the same, but quite similar.

But isn't the PREFIX set in the configuration step?

Regards
   Stefan
diff mbox series

Patch

diff --git a/recipes-support/swupdate/swupdate/swupdate-progress.service b/recipes-support/swupdate/swupdate-2019.04/swupdate-progress.service
similarity index 100%
rename from recipes-support/swupdate/swupdate/swupdate-progress.service
rename to recipes-support/swupdate/swupdate-2019.04/swupdate-progress.service
diff --git a/recipes-support/swupdate/swupdate/swupdate-usb.rules b/recipes-support/swupdate/swupdate-2019.04/swupdate-usb.rules
similarity index 100%
rename from recipes-support/swupdate/swupdate/swupdate-usb.rules
rename to recipes-support/swupdate/swupdate-2019.04/swupdate-usb.rules
diff --git a/recipes-support/swupdate/swupdate/swupdate-usb@.service b/recipes-support/swupdate/swupdate-2019.04/swupdate-usb@.service
similarity index 100%
rename from recipes-support/swupdate/swupdate/swupdate-usb@.service
rename to recipes-support/swupdate/swupdate-2019.04/swupdate-usb@.service
diff --git a/recipes-support/swupdate/swupdate/swupdate.service b/recipes-support/swupdate/swupdate-2019.04/swupdate.service
similarity index 100%
rename from recipes-support/swupdate/swupdate/swupdate.service
rename to recipes-support/swupdate/swupdate-2019.04/swupdate.service
diff --git a/recipes-support/swupdate/swupdate/systemd-tmpfiles-swupdate.conf b/recipes-support/swupdate/swupdate-2019.04/systemd-tmpfiles-swupdate.conf
similarity index 100%
rename from recipes-support/swupdate/swupdate/systemd-tmpfiles-swupdate.conf
rename to recipes-support/swupdate/swupdate-2019.04/systemd-tmpfiles-swupdate.conf
diff --git a/recipes-support/swupdate/swupdate.inc b/recipes-support/swupdate/swupdate.inc
index 1c863bb..19ccf4a 100644
--- a/recipes-support/swupdate/swupdate.inc
+++ b/recipes-support/swupdate/swupdate.inc
@@ -10,25 +10,30 @@  inherit cml1 update-rc.d systemd pkgconfig
 SRC_URI = "git://github.com/sbabic/swupdate.git;protocol=https \
      file://defconfig \
      file://swupdate \
-     file://swupdate.service \
-     file://swupdate-usb.rules \
-     file://swupdate-usb@.service \
-     file://swupdate-progress.service \
-     file://systemd-tmpfiles-swupdate.conf \
      "
 
 INSANE_SKIP_${PN} = "ldflags"
 PACKAGES =+ "${PN}-www ${PN}-lua"
 
 FILES_${PN}-lua += "${libdir}/lua/"
-FILES_${PN}-www = "/www/*"
-FILES_${PN} += "${libdir}/tmpfiles.d"
+FILES_${PN}-www = " \
+    ${libdir}/swupdate/conf.d/*mongoose* \
+    /www/* \
+"
+FILES_${PN} += " \
+    ${libdir}/tmpfiles.d \
+    ${libdir}/swupdate/* \
+    ${systemd_system_unitdir}/swupdate.socket \
+    ${systemd_system_unitdir}/swupdate.service \
+    ${systemd_system_unitdir}/swupdate-usb@.service \
+"
 
 RDEPENDS_${PN}-www += "${PN}-tools"
 
 S = "${WORKDIR}/git/"
 
-EXTRA_OEMAKE += " HOSTCC="${BUILD_CC}" HOSTCXX="${BUILD_CXX}" LD="${CC}" DESTDIR="${D}" V=1 ARCH=${TARGET_ARCH} CROSS_COMPILE=${TARGET_PREFIX} SKIP_STRIP=y"
+EXTRA_OEMAKE += " HOSTCC="${BUILD_CC}" HOSTCXX="${BUILD_CXX}" LD="${CC}" DESTDIR="${D}" V=1 ARCH=${TARGET_ARCH} CROSS_COMPILE=${TARGET_PREFIX} SKIP_STRIP=y \
+  ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'SYSTEMD_SYSTEM_UNITDIR=${systemd_system_unitdir}', '', d)}"
 
 DEPENDS += "kern-tools-native"
 
@@ -144,23 +149,12 @@  do_install () {
 
   install -d ${D}${sysconfdir}/init.d
   install -m 755 ${WORKDIR}/swupdate ${D}${sysconfdir}/init.d
-
-  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}${libdir}/tmpfiles.d
-    install -m 0644 ${WORKDIR}/systemd-tmpfiles-swupdate.conf ${D}${libdir}/tmpfiles.d/swupdate.conf
-    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"
+SYSTEMD_SERVICE_${PN} = " \
+    swupdate.service \
+    swupdate-usb@.service \
+    "
diff --git a/recipes-support/swupdate/swupdate_2019.04.bb b/recipes-support/swupdate/swupdate_2019.04.bb
index e2eabbb..83785d7 100644
--- a/recipes-support/swupdate/swupdate_2019.04.bb
+++ b/recipes-support/swupdate/swupdate_2019.04.bb
@@ -1,4 +1,12 @@ 
 require swupdate.inc
 require swupdate_tools.inc
 
+SRC_URI += " \
+     file://swupdate.service \
+     file://swupdate-usb.rules \
+     file://swupdate-usb@.service \
+     file://swupdate-progress.service \
+     file://systemd-tmpfiles-swupdate.conf \
+     "
+
 SRCREV = "d39f4b8e00ef1929545b66158e45b82ea922bf81"
diff --git a/recipes-support/swupdate/swupdate_git.bb b/recipes-support/swupdate/swupdate_git.bb
index 9fea83a..a4289f6 100644
--- a/recipes-support/swupdate/swupdate_git.bb
+++ b/recipes-support/swupdate/swupdate_git.bb
@@ -5,3 +5,7 @@  DEFAULT_PREFERENCE = "-1"
 
 SRCREV ?= "045a618a725d0a2fce64161f10101c0004ac5d85"
 PV = "2019.04+git${SRCPV}"
+
+SYSTEMD_SERVICE_${PN} += " \
+    swupdate.socket \
+"