<div dir="ltr">Hi,<br><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Pau Espin Pedrol<br></div></div></div></div>
<br><div class="gmail_quote">2016-09-08 4:33 GMT+02:00 ChenQi <span dir="ltr"><<a href="mailto:Qi.Chen@windriver.com" target="_blank">Qi.Chen@windriver.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"><div><div class="h5">
<div>On 09/07/2016 08:14 PM, Pau Espin
Pedrol wrote:<br>
</div>
<blockquote type="cite">
<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 href="mailto:Qi.Chen@windriver.com" target="_blank">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" target="_blank">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-natives<wbr>dk ?=
""<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?</div>
</div>
</div>
</div>
</blockquote>
<br></div></div>
Hi Pau Espin Pedrol,<br>
<br>
Thanks for your review.<br>
<br>
The postinstall script runs successfully with expected result at
rootfs time. But your question reminds me of the situation of the
on-target install/remove situation. I think I'll need to make a new
patch to make sure things work in both situations.<br>
<br>
The key point here is that 'systemctl' at rootfs time is a shell
script written by ourselves and 'systemctl' on target is that
provided by systemd.<span class=""><br></span></div></blockquote><div><br></div><div>Yes, I was unaware of the existance of that OE script when I worked on this. Why are we using that script at build time instead of using systemd's systemctl? Any good reason for that? git log only shows it was imported from another repo a while ago.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><span class="">
<br>
<blockquote type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div> 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" target="_blank">https://www.mail-archive.com/<wbr>openembedded-devel@lists.<wbr>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>
</div>
</blockquote>
<br></span>
The service is enabled and started with '--global' option, and
stopping it with '--global' option seems reasonable to me. If
there's some special case, let's look into it then.<br>
<br></div></blockquote><div><br><br></div><div>Did you try running it in a running image? As in taking the ipkg, and reinstalling it live in the image with systemd's systemctl. I bet you will get an error from systemctl for both "--gobal restart" and "--global stop". At least it used to be like that afair.<br></div><div><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">
Best Regards,<br>
Chen Qi<div><div class="h5"><br>
<br>
<blockquote type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<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("syscon<wbr>fdir",
True), "systemd", "system"),]<br>
searchpaths.append(d.getVar("<wbr>systemd_system_unitdir",
True))<br>
+ searchpaths.append(oe.path.joi<wbr>n(d.getVar("sysconfdir",
True), "systemd", "user"))<br>
+ searchpaths.append(d.getVar("s<wbr>ystemd_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,
'<a href="mailto:ifplugd@eth0.service" target="_blank">ifplugd@eth0.service</a>' from<br>
@@ -165,14 +174,14 @@ python systemd_populate_packages() {<br>
if path_found != '':<br>
systemd_add_files_and_parse(p<wbr>kg_systemd,
path_found, service, keys)<br>
else:<br>
- raise bb.build.FuncFailed("SYSTEMD_S<wbr>ERVICE_%s
value %s does not exist" % \<br>
- (pkg_systemd, service))<br>
+ raise bb.build.FuncFailed("SYSTEMD_S<wbr>ERVICE_%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_SERVICE<wbr>_' + pkg, True):<br>
systemd_generate_package_scri<wbr>pts(pkg)<br>
systemd_check_services()<br>
}<br>
<span><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" target="_blank">Openembedded-core@lists.openem<wbr>bedded.org</a><br>
<a rel="noreferrer" href="http://lists.openembedded.org/mailman/listinfo/openembedded-core" target="_blank">http://lists.openembedded.org/<wbr>mailman/listinfo/openembedded-<wbr>core</a><br>
</font></span></blockquote>
</div>
<br>
</div>
</div>
</blockquote>
<br>
</div></div></div>
</blockquote></div><br></div></div>