systemd.bbclass: Introduce do_install_append and use systemd unitdir
PATCH 1/1 systemd.bbclass: Introduce do_install_append and use systemd unitdir
systemd always uses /lib and /usr/lib to store unit files so using libdir and base_libdir is incorrect. It will work where libdir is usr/lib and base_libdir is /lib but wont work when say its /lib64
Additionally introduce the install append from meta-oe lot of recipe appends in meta-systemd depend on that
--- meta/classes/systemd.bbclass | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
meta/classes/systemd.bbclass +15 -6
@@ -115,11 +115,9 @@ def systemd_populate_packages(d): # Check service-files and call systemd_add_files_and_parse for each entry def systemd_check_services(): - base_libdir = d.getVar('base_libdir', True) - searchpaths = [oe.path.join(d.getVar("sysconfdir", True), "systemd", "system"),] - searchpaths.append(oe.path.join(d.getVar("base_libdir", True), "systemd", "system")) - searchpaths.append(oe.path.join(d.getVar("libdir", True), "systemd", "system")) - searchpaths.append(oe.path.join(d.getVar("libdir", True), "systemd", "user")) + searchpaths = '/etc/systemd/system/' + ' ' + searchpaths += '/lib/systemd/system/' + ' ' + searchpaths += '/usr/lib/systemd/system/' + ' ' systemd_packages = d.getVar('SYSTEMD_PACKAGES', True) has_exactly_one_service = len(systemd_packages.split()) == 1 if has_exactly_one_service:
@@ -133,7 +131,7 @@ def systemd_populate_packages(d): for pkg_systemd in systemd_packages.split(): for service in get_package_var(d, 'SYSTEMD_SERVICE', pkg_systemd).split(): path_found = '' - for path in searchpaths: + for path in searchpaths.split(): if os.path.exists(oe.path.join(d.getVar("D", True), path, service)): path_found = path break
@@ -156,3 +154,14 @@ python populate_packages_prepend () { if oe.utils.contains ('DISTRO_FEATURES', 'systemd', True, False, d): systemd_populate_packages (d) } +# automatically install all *.service and *.socket supplied in recipe's SRC_URI +do_install_append() { + for service in `find ${WORKDIR} -maxdepth 1 -name '*.service' -o -name '*.socket'` ; do + # ensure installing systemd-files only (e.g not avahi *.service) + if grep -q '\[Unit\]' $service ; then + install -d ${D}${systemd_unitdir}/system + install -m 644 $service ${D}${systemd_unitdir}/system + fi + done +} +
Signature · 1 line
1.7.9.5
Quoted 4 lines · Khem Raj
systemd always uses /lib and
/usr/libto store unit files so using libdir andbase_libdiris incorrect. It will work where libdir is usr/lib andbase_libdiris /lib but wont work when say its /lib64
That's interesting, wasn't aware of that. Why doesn't systemd respect the configure options?
Quoted 2 lines
Additionally introduce the install append from meta-oe lot of recipe appends in meta-systemd depend on that
This was removed on purpose because it should never be used. It was used in meta-systemd because the service files in SRC_URI had hard-coded /usr/bin, /usr/sbin, etc. Hard-coding these paths is wrong, you'll need e.g. run a service.in through a s/@sbindir@/${sbindir} and if you're doing this you can just do that in do_install_append() and drop it directly into ${D}.
Radu's work at merging the rest of the changes in meta-systemd to oe-core does this, for example:
Ross
Quoted 18 lines · Khem Raj
systemd always uses /lib and
/usr/libto store unit files so using libdir andbase_libdiris incorrect. It will work where libdir is usr/lib andbase_libdiris /lib but wont work when say its /lib64Additionally introduce the install append from meta-oe lot of recipe appends in meta-systemd depend on that
Signed-off-by Khem Raj <[email protected]>--- meta/classes/systemd.bbclass | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)meta/classes/systemd.bbclass +0
-0
meta/classes/systemd.bbclass def systemd_populate_packages(d): · line 118
Quoted 9 lines
meta/classes/systemd.bbclass +1
-5@@ -115,11 +115,9 @@ def systemd_populate_packages(d): # Check service-files and call systemd_add_files_and_parse for each entry def systemd_check_services(): - base_libdir = d.getVar('base_libdir', True) - searchpaths = [oe.path.join(d.getVar("sysconfdir", True), "systemd", "system"),] - searchpaths.append(oe.path.join(d.getVar("base_libdir", True), "systemd", "system")) - searchpaths.append(oe.path.join(d.getVar("libdir", True), "systemd", "system")) - searchpaths.append(oe.path.join(d.getVar("libdir", True), "systemd", "user")) + searchpaths = '/etc/systemd/system/' + ' '
Why remove sysconfdir?
Also, lets standardise on one variable please. We have ${nonarch_base_libdir} and ${systemd_unitdir} so do we need to hardcode /lib and /usr/lib?
I'd suggest we add ${nonarch_libdir}, standardise on those and drop systemd_unitdir. We use the nonarch for other non-systemd multilib work.
Quoted 19 lines
meta/classes/systemd.bbclass +4
-1+ searchpaths += '/lib/systemd/system/' + ' ' + searchpaths += '/usr/lib/systemd/system/' + ' ' systemd_packages = d.getVar('SYSTEMD_PACKAGES', True) has_exactly_one_service = len(systemd_packages.split()) == 1 if has_exactly_one_service:@@ -133,7 +131,7 @@ def systemd_populate_packages(d): for pkg_systemd in systemd_packages.split(): for service in get_package_var(d, 'SYSTEMD_SERVICE', pkg_systemd).split(): path_found = '' - for path in searchpaths: + for path in searchpaths.split(): if os.path.exists(oe.path.join(d.getVar("D", True), path, service)): path_found = path break@@ -156,3 +154,14 @@ python populate_packages_prepend () { if oe.utils.contains ('DISTRO_FEATURES', 'systemd', True, False, d): systemd_populate_packages (d) } +# automatically install all *.service and *.socket supplied in recipe's SRC_URI
meta/classes/systemd.bbclass python populate_packages_prepend () { · line 167
Quoted 10 lines
meta/classes/systemd.bbclass +10
-0+do_install_append() { + for service in `find ${WORKDIR} -maxdepth 1 -name '*.service' -o -name '*.socket'` ; do + # ensure installing systemd-files only (e.g not avahi *.service) + if grep -q '\[Unit\]' $service ; then + install -d ${D}${systemd_unitdir}/system + install -m 644 $service ${D}${systemd_unitdir}/system + fi + done +} +
Please no. We have this kind of mess from the binconfig class and its horrible to maintain. I'm looking forward to ripping that class out someday.
Lets just write proper do_install functions in the recipes and make them conditional on systemd being enabled.
Cheers,
Richard
Quoted 72 lines · Richard Purdie
Quoted 18 lines · Khem Raj
systemd always uses /lib and
/usr/libto store unit files so using libdir andbase_libdiris incorrect. It will work where libdir is usr/lib andbase_libdiris /lib but wont work when say its /lib64Additionally introduce the install append from meta-oe lot of recipe appends in meta-systemd depend on that
Signed-off-by Khem Raj <[email protected]>--- meta/classes/systemd.bbclass | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)meta/classes/systemd.bbclass +0
-0meta/classes/systemd.bbclass def systemd_populate_packages(d): · line 118
Quoted 9 lines
meta/classes/systemd.bbclass +1
-5@@ -115,11 +115,9 @@ def systemd_populate_packages(d): # Check service-files and call systemd_add_files_and_parse for each entry def systemd_check_services(): - base_libdir = d.getVar('base_libdir', True) - searchpaths = [oe.path.join(d.getVar("sysconfdir", True), "systemd", "system"),] - searchpaths.append(oe.path.join(d.getVar("base_libdir", True), "systemd", "system")) - searchpaths.append(oe.path.join(d.getVar("libdir", True), "systemd", "system")) - searchpaths.append(oe.path.join(d.getVar("libdir", True), "systemd", "user")) + searchpaths = '/etc/systemd/system/' + ' 'Why remove sysconfdir?
Also, lets standardise on one variable please. We have ${nonarch_base_libdir} and ${systemd_unitdir} so do we need to hardcode /lib and
/usr/lib?I'd suggest we add ${nonarch_libdir}, standardise on those and drop
systemd_unitdir. We use the nonarch for other non-systemd multilib work.Quoted 19 lines
meta/classes/systemd.bbclass +4
-1+ searchpaths += '/lib/systemd/system/' + ' ' + searchpaths += '/usr/lib/systemd/system/' + ' ' systemd_packages = d.getVar('SYSTEMD_PACKAGES', True) has_exactly_one_service = len(systemd_packages.split()) == 1 if has_exactly_one_service:@@ -133,7 +131,7 @@ def systemd_populate_packages(d): for pkg_systemd in systemd_packages.split(): for service in get_package_var(d, 'SYSTEMD_SERVICE', pkg_systemd).split(): path_found = '' - for path in searchpaths: + for path in searchpaths.split(): if os.path.exists(oe.path.join(d.getVar("D", True), path, service)): path_found = path break@@ -156,3 +154,14 @@ python populate_packages_prepend () { if oe.utils.contains ('DISTRO_FEATURES', 'systemd', True, False, d): systemd_populate_packages (d) } +# automatically install all *.service and *.socket supplied in recipe's SRC_URImeta/classes/systemd.bbclass python populate_packages_prepend () { · line 167
Quoted 10 lines
meta/classes/systemd.bbclass +10
-0+do_install_append() { + for service in `find ${WORKDIR} -maxdepth 1 -name '*.service' -o -name '*.socket'` ; do + # ensure installing systemd-files only (e.g not avahi *.service) + if grep -q '\[Unit\]' $service ; then + install -d ${D}${systemd_unitdir}/system + install -m 644 $service ${D}${systemd_unitdir}/system + fi + done +} +Please no. We have this kind of mess from the binconfig class and its horrible to maintain. I'm looking forward to ripping that class out someday.
Quoted 3 lines
Lets just write proper
do_installfunctions in the recipes and make them conditional on systemd being enabled.
Copying similar code in in tons of recipes is easier to maintain? We had this before meta-systemd started and it was a mess. How about a variable SYSTEMD_AUTO_INSTALL?="enable" for this - since it fits in many cases.
Andreas
Quoted 74 lines · Andreas Müller
Quoted 72 lines · Richard Purdie
Quoted 18 lines · Khem Raj
systemd always uses /lib and
/usr/libto store unit files so using libdir andbase_libdiris incorrect. It will work where libdir is usr/lib andbase_libdiris /lib but wont work when say its /lib64Additionally introduce the install append from meta-oe lot of recipe appends in meta-systemd depend on that
Signed-off-by Khem Raj <[email protected]>--- meta/classes/systemd.bbclass | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)meta/classes/systemd.bbclass +0
-0meta/classes/systemd.bbclass def systemd_populate_packages(d): · line 118
Quoted 9 lines
meta/classes/systemd.bbclass +1
-5@@ -115,11 +115,9 @@ def systemd_populate_packages(d): # Check service-files and call systemd_add_files_and_parse for each entry def systemd_check_services(): - base_libdir = d.getVar('base_libdir', True) - searchpaths = [oe.path.join(d.getVar("sysconfdir", True), "systemd", "system"),] - searchpaths.append(oe.path.join(d.getVar("base_libdir", True), "systemd", "system")) - searchpaths.append(oe.path.join(d.getVar("libdir", True), "systemd", "system")) - searchpaths.append(oe.path.join(d.getVar("libdir", True), "systemd", "user")) + searchpaths = '/etc/systemd/system/' + ' 'Why remove sysconfdir?
Also, lets standardise on one variable please. We have ${nonarch_base_libdir} and ${systemd_unitdir} so do we need to hardcode /lib and
/usr/lib?I'd suggest we add ${nonarch_libdir}, standardise on those and drop
systemd_unitdir. We use the nonarch for other non-systemd multilib work.Quoted 19 lines
meta/classes/systemd.bbclass +4
-1+ searchpaths += '/lib/systemd/system/' + ' ' + searchpaths += '/usr/lib/systemd/system/' + ' ' systemd_packages = d.getVar('SYSTEMD_PACKAGES', True) has_exactly_one_service = len(systemd_packages.split()) == 1 if has_exactly_one_service:@@ -133,7 +131,7 @@ def systemd_populate_packages(d): for pkg_systemd in systemd_packages.split(): for service in get_package_var(d, 'SYSTEMD_SERVICE', pkg_systemd).split(): path_found = '' - for path in searchpaths: + for path in searchpaths.split(): if os.path.exists(oe.path.join(d.getVar("D", True), path, service)): path_found = path break@@ -156,3 +154,14 @@ python populate_packages_prepend () { if oe.utils.contains ('DISTRO_FEATURES', 'systemd', True, False, d): systemd_populate_packages (d) } +# automatically install all *.service and *.socket supplied in recipe's SRC_URImeta/classes/systemd.bbclass python populate_packages_prepend () { · line 167
Quoted 10 lines
meta/classes/systemd.bbclass +10
-0+do_install_append() { + for service in `find ${WORKDIR} -maxdepth 1 -name '*.service' -o -name '*.socket'` ; do + # ensure installing systemd-files only (e.g not avahi *.service) + if grep -q '\[Unit\]' $service ; then + install -d ${D}${systemd_unitdir}/system + install -m 644 $service ${D}${systemd_unitdir}/system + fi + done +} +Please no. We have this kind of mess from the binconfig class and its horrible to maintain. I'm looking forward to ripping that class out someday.
Quoted 4 lines
Quoted 3 lines
Lets just write proper
do_installfunctions in the recipes and make them conditional on systemd being enabled.Copying similar code in in tons of recipes is easier to maintain?
Its dangerous and risky. This code sits silently in the class file and copies files. Imagine some project starts installing its own service files yet someone doesn't notice when they upgrade the recipe. All of a sudden we start overwriting files and nobody notices. This does happen as things get adopted by upstreams.
This is the big problem with the binconfig class, it overwrites anything do_install does. We have so much history there we don't dare touch it either. How did we get there? Originally packages didn't provide -config files. Personally, I can't wait to delete the thing.
Quoted 3 lines
We had this before meta-systemd started and it was a mess. How about a variable SYSTEMD_AUTO_INSTALL?="enable" for this - since it fits in many cases.
At least spell out which files to install:
SYSTEMD_EXTRAINSTALL = "${WORKDIR}/xxxx.service"
then the user stands a better change of spotting a conflict. Yes, I know the files are listed in SRC_URI but I don't think its enough. We can also throw an error if the files already exist.
There is a time and a place for magic things behind the scenes but IME find calls in functions like this don't end well. The "ignore avahi service files" issue in the code already should serve as a suitable warning too.
Cheers,
Richard
Quoted 1 line · Andreas Müller
Copying similar code in in tons of recipes is easier to maintain?
If the code that needs to go in the "tons" of recipes is just:
do_install_append() {
install -m 644 ${WORKDIR}/my.service ${D}${systemd_unitdir}/system
}then yes, this is easier to maintain than a mechanism that magically fishes out files from the workdir and installs them for itself. As Richard mentioned, we have previous experience with this in the form of binconfig (and there have been others in the past) and this sort of thing has universally turned out to be a maintenance headache after a while.
There's even a comment in the code you quoted:
Quoted 1 line
Quoted 1 line
+ # ensure installing systemd-files only (e.g not avahi *.service)
which suggests that some poor soul has previously found that it was installing things it oughtn't to have done.
p.
Quoted 16 lines · Phil Blundell
Quoted 1 line · Andreas Müller
Copying similar code in in tons of recipes is easier to maintain?
If the code that needs to go in the "tons" of recipes is just:
do_install_append() { install -m 644 ${WORKDIR}/my.service ${D}${systemd_unitdir}/system }then yes, this is easier to maintain than a mechanism that magically fishes out files from the workdir and installs them for itself. As Richard mentioned, we have previous experience with this in the form of binconfig (and there have been others in the past) and this sort of thing has universally turned out to be a maintenance headache after a while.
Quoted 7 lines
There's even a comment in the code you quoted:
Quoted 1 line
Quoted 1 line
+ # ensure installing systemd-files only (e.g not avahi *.service)
which suggests that some poor soul has previously found that it was installing things it oughtn't to have done.
I have dropped the idea of having append and taken the pain to add the append to bbappends I think as systemd gets adopted widely I think the packages themselves will start providing systemd support and then we have to start dropping them one by one
so if they are per recipe then its easier.
Quoted 8 lines
p.
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core