<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">2016-09-07 11:22 GMT+02:00 Chen Qi <span dir="ltr"><<a target="_blank" href="mailto:Qi.Chen@windriver.com">Qi.Chen@windriver.com</a>></span>:<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">Add new variable SYSTEMD_USER_SERVICE and SYSTEM_USER_AUTO_ENABLE<br>
to manage user services. Their usage is like SYSTEMD_SERVICE and<br>
SYSTEMD_AUTO_ENABLE.<br>
<br>
[YOCTO #7800]<br>
<br>
Signed-off-by: Chen Qi <<a href="mailto:Qi.Chen@windriver.com">Qi.Chen@windriver.com</a>><br>
---<br>
meta/classes/systemd.bbclass | 17 +++++++++++++----<br>
1 file changed, 13 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/meta/classes/systemd.bbclass b/meta/classes/systemd.bbclass<br>
index db7873f..78cec97 100644<br>
--- a/meta/classes/systemd.bbclass<br>
+++ b/meta/classes/systemd.bbclass<br>
@@ -7,6 +7,7 @@ SYSTEMD_PACKAGES_class-<wbr>nativesdk ?= ""<br>
<br>
# Whether to enable or disable the services on installation.<br>
SYSTEMD_AUTO_ENABLE ??= "enable"<br>
+SYSTEMD_USER_AUTO_ENABLE ??= "enable"<br>
<br>
# This class will be included in any recipe that supports systemd init scripts,<br>
# even if systemd is not in DISTRO_FEATURES. As such don't make any changes<br>
@@ -30,10 +31,14 @@ fi<br>
<br>
if type systemctl >/dev/null 2>/dev/null; then<br>
systemctl $OPTS ${SYSTEMD_AUTO_ENABLE} ${SYSTEMD_SERVICE}<br>
+ systemctl $OPTS --global ${SYSTEMD_USER_AUTO_ENABLE} ${SYSTEMD_USER_SERVICE} <br></blockquote><div><br></div><div>I'm not sure having these 2 systemctl being executed together everytime is a good idea. What if a recipe has a user service and no system service? We are calling the first one with an empty system service? Or we are may be enabling a systemd system service which should not be enabled according to the recipe? I have the feeling this kind of cases are not being catch in here and other pkg scripts in this commit.<br><br></div><div>It is far from perfect, but in case you didn't, you may want to have a look at my initial/previous commit to try to fix the issue: <a href="https://www.mail-archive.com/openembedded-devel@lists.openembedded.org/msg42187.html">https://www.mail-archive.com/openembedded-devel@lists.openembedded.org/msg42187.html</a><br></div><div> </div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
<br>
if [ -z "$D" -a "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then<br>
systemctl restart ${SYSTEMD_SERVICE}<br>
fi<br>
+ if [ -z "$D" -a "${SYSTEMD_USER_AUTO_ENABLE}" = "enable" ]; then<br>
+ systemctl --global restart ${SYSTEMD_USER_SERVICE}<br>
+ fi<br>
fi<br>
}<br>
<br>
@@ -47,9 +52,11 @@ fi<br>
if type systemctl >/dev/null 2>/dev/null; then<br>
if [ -z "$D" ]; then<br>
systemctl stop ${SYSTEMD_SERVICE}<br>
+ systemctl --global stop ${SYSTEMD_USER_SERVICE}<br></blockquote><div><br></div><div>I think this is not gonna work, you cannot call --global with stop afair. I'm not sure which is the good solution for this though, but you should ideally go through all systemd user sessions and call "systemctl --user stop". No idea if that's actually easily feasible.<br></div><div> </div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
fi<br>
<br>
systemctl $OPTS disable ${SYSTEMD_SERVICE}<br>
+ systemctl $OPTS --global disable ${SYSTEMD_USER_SERVICE}<br>
fi<br>
}<br>
<br>
@@ -139,12 +146,14 @@ python systemd_populate_packages() {<br>
def systemd_check_services():<br>
searchpaths = [oe.path.join(d.getVar("<wbr>sysconfdir", True), "systemd", "system"),]<br>
searchpaths.append(d.getVar("<wbr>systemd_system_unitdir", True))<br>
+ searchpaths.append(oe.path.<wbr>join(d.getVar("sysconfdir", True), "systemd", "user"))<br>
+ searchpaths.append(d.getVar("<wbr>systemd_user_unitdir", True))<br>
systemd_packages = d.getVar('SYSTEMD_PACKAGES', True)<br>
<br>
keys = 'Also'<br>
# scan for all in SYSTEMD_SERVICE[]<br>
for pkg_systemd in systemd_packages.split():<br>
- for service in get_package_var(d, 'SYSTEMD_SERVICE', pkg_systemd).split():<br>
+ for service in (get_package_var(d, 'SYSTEMD_SERVICE', pkg_systemd) + get_package_var(d, 'SYSTEMD_USER_SERVICE', pkg_systemd)).split():<br>
path_found = ''<br>
<br>
# Deal with adding, for example, 'ifplugd@eth0.service' from<br>
@@ -165,14 +174,14 @@ python systemd_populate_packages() {<br>
if path_found != '':<br>
systemd_add_files_and_parse(<wbr>pkg_systemd, path_found, service, keys)<br>
else:<br>
- raise bb.build.FuncFailed("SYSTEMD_<wbr>SERVICE_%s value %s does not exist" % \<br>
- (pkg_systemd, service))<br>
+ raise bb.build.FuncFailed("SYSTEMD_<wbr>SERVICE_%s or SYSTEMD_USER_SERVICE_%s value %s does not exist" % \<br>
+ (pkg_systemd, pkg_systemd, service))<br>
<br>
# Run all modifications once when creating package<br>
if os.path.exists(d.getVar("D", True)):<br>
for pkg in d.getVar('SYSTEMD_PACKAGES', True).split():<br>
systemd_check_package(pkg)<br>
- if d.getVar('SYSTEMD_SERVICE_' + pkg, True):<br>
+ if d.getVar('SYSTEMD_SERVICE_' + pkg, True) or d.getVar('SYSTEMD_USER_<wbr>SERVICE_' + pkg, True):<br>
systemd_generate_package_<wbr>scripts(pkg)<br>
systemd_check_services()<br>
}<br>
<span class="gmail-HOEnZb"><font color="#888888">--<br>
1.9.1<br>
<br>
--<br>
______________________________<wbr>_________________<br>
Openembedded-core mailing list<br>
<a href="mailto:Openembedded-core@lists.openembedded.org">Openembedded-core@lists.<wbr>openembedded.org</a><br>
<a target="_blank" rel="noreferrer" href="http://lists.openembedded.org/mailman/listinfo/openembedded-core">http://lists.openembedded.org/<wbr>mailman/listinfo/openembedded-<wbr>core</a><br>
</font></span></blockquote></div><br></div></div>