<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 09/07/2016 08:14 PM, Pau Espin
Pedrol wrote:<br>
</div>
<blockquote
cite="mid:CAEGpDuav43RX6WbQS5OVtDO6oRry-ybyMNt5iG8t1qMDriQ2gA@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<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 moz-do-not-send="true" 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 moz-do-not-send="true"
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?</div>
</div>
</div>
</div>
</blockquote>
<br>
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.<br>
<br>
<blockquote
cite="mid:CAEGpDuav43RX6WbQS5OVtDO6oRry-ybyMNt5iG8t1qMDriQ2gA@mail.gmail.com"
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 moz-do-not-send="true"
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>
</div>
</blockquote>
<br>
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>
Best Regards,<br>
Chen Qi<br>
<br>
<blockquote
cite="mid:CAEGpDuav43RX6WbQS5OVtDO6oRry-ybyMNt5iG8t1qMDriQ2gA@mail.gmail.com"
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("<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,
'<a class="moz-txt-link-abbreviated" href="mailto:ifplugd@eth0.service">ifplugd@eth0.service</a>' 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 moz-do-not-send="true"
href="mailto:Openembedded-core@lists.openembedded.org">Openembedded-core@lists.<wbr>openembedded.org</a><br>
<a moz-do-not-send="true" 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>
</blockquote>
<br>
</body>
</html>