<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">&lt;<a target="_blank" href="mailto:Qi.Chen@windriver.com">Qi.Chen@windriver.com</a>&gt;</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 &lt;<a href="mailto:Qi.Chen@windriver.com">Qi.Chen@windriver.com</a>&gt;<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 ?= &quot;&quot;<br>
<br>
 # Whether to enable or disable the services on installation.<br>
 SYSTEMD_AUTO_ENABLE ??= &quot;enable&quot;<br>
+SYSTEMD_USER_AUTO_ENABLE ??= &quot;enable&quot;<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&#39;t make any changes<br>
@@ -30,10 +31,14 @@ fi<br>
<br>
 if type systemctl &gt;/dev/null 2&gt;/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&#39;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&#39;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 &quot;$D&quot; -a &quot;${SYSTEMD_AUTO_ENABLE}&quot; = &quot;enable&quot; ]; then<br>
                systemctl restart ${SYSTEMD_SERVICE}<br>
        fi<br>
+       if [ -z &quot;$D&quot; -a &quot;${SYSTEMD_USER_AUTO_ENABLE}&quot; = &quot;enable&quot; ]; then<br>
+               systemctl --global restart ${SYSTEMD_USER_SERVICE}<br>
+       fi<br>
 fi<br>
 }<br>
<br>
@@ -47,9 +52,11 @@ fi<br>
 if type systemctl &gt;/dev/null 2&gt;/dev/null; then<br>
        if [ -z &quot;$D&quot; ]; 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&#39;m not sure which is the good solution for this though, but you should ideally go through all systemd user sessions and call &quot;systemctl --user stop&quot;. No idea if that&#39;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(&quot;<wbr>sysconfdir&quot;, True), &quot;systemd&quot;, &quot;system&quot;),]<br>
         searchpaths.append(d.getVar(&quot;<wbr>systemd_system_unitdir&quot;, True))<br>
+        searchpaths.append(oe.path.<wbr>join(d.getVar(&quot;sysconfdir&quot;, True), &quot;systemd&quot;, &quot;user&quot;))<br>
+        searchpaths.append(d.getVar(&quot;<wbr>systemd_user_unitdir&quot;, True))<br>
         systemd_packages = d.getVar(&#39;SYSTEMD_PACKAGES&#39;, True)<br>
<br>
         keys = &#39;Also&#39;<br>
         # scan for all in SYSTEMD_SERVICE[]<br>
         for pkg_systemd in systemd_packages.split():<br>
-            for service in get_package_var(d, &#39;SYSTEMD_SERVICE&#39;, pkg_systemd).split():<br>
+            for service in (get_package_var(d, &#39;SYSTEMD_SERVICE&#39;, pkg_systemd) + get_package_var(d, &#39;SYSTEMD_USER_SERVICE&#39;, pkg_systemd)).split():<br>
                 path_found = &#39;&#39;<br>
<br>
                 # Deal with adding, for example, &#39;ifplugd@eth0.service&#39; from<br>
@@ -165,14 +174,14 @@ python systemd_populate_packages() {<br>
                 if path_found != &#39;&#39;:<br>
                     systemd_add_files_and_parse(<wbr>pkg_systemd, path_found, service, keys)<br>
                 else:<br>
-                    raise bb.build.FuncFailed(&quot;SYSTEMD_<wbr>SERVICE_%s value %s does not exist&quot; % \<br>
-                        (pkg_systemd, service))<br>
+                    raise bb.build.FuncFailed(&quot;SYSTEMD_<wbr>SERVICE_%s or SYSTEMD_USER_SERVICE_%s value %s does not exist&quot; % \<br>
+                        (pkg_systemd, pkg_systemd, service))<br>
<br>
     # Run all modifications once when creating package<br>
     if os.path.exists(d.getVar(&quot;D&quot;, True)):<br>
         for pkg in d.getVar(&#39;SYSTEMD_PACKAGES&#39;, True).split():<br>
             systemd_check_package(pkg)<br>
-            if d.getVar(&#39;SYSTEMD_SERVICE_&#39; + pkg, True):<br>
+            if d.getVar(&#39;SYSTEMD_SERVICE_&#39; + pkg, True) or d.getVar(&#39;SYSTEMD_USER_<wbr>SERVICE_&#39; + 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>