Re: [OE-core] [OE-Core][PATCH] systemd: Default to non-stateless images

2019-05-06 Thread Jonas Bonn

Hi Alex,

On 06/05/2019 11:36, Alex Kiernan wrote:

On Mon, May 6, 2019 at 5:54 AM Jonas Bonn  wrote:


Hi Alex,

The below is fine and looks good.  The one thing that bothers me about
this is that "stateless" isn't really a property of the "distro", rather
it's a property of the image/machine.


I agree it should be part of image, I'll respin it.


  I suspect, in the same sense that
we have readonly-rootfs, that we should probably have image features
"stateless-rootfs" (no /etc, no /var) and "volatile-rootfs" (no /var).



That makes sense to me


Furthermore, if you want to boot with 'ro' on the command-line, I really
think you need to build your image with the "readonly-rootfs" feature
set.  The default should be writable+persistent /etc as that's the
configuration used 99% of the time (currently).  "readonly-rootfs" does
a bit more than just creating machine-id but it's all relevant to the
'ro' case where /etc isn't writable.



I think there's (at least) two use cases for ro boot:

- systems which boot ro and stay that way
- systems which transition to rw during systemd-remount-fs

I'm in the second case as I have no initramfs and need the filesystem
readonly until it's fscked/remounted rw.


I'd argue that you are abusing systemd for this because systemd 
explicity requires /etc to be writable.  The fact that it works on a 
read-only /etc is both incidental and fragile.


That said, I understand why you want to do this.  Have you considered 
putting the fsck in a "systemd generator" that doesn't return until fsck 
finishes?  Generators are kind of like units that run before systemd 
starts... or, at least, they can be (ab)used in this way.  Systemd won't 
start until all the generators are finished (the idea being that the 
generators may be responsible for creating units dynamically).





Just for clarification:

i)  volatile-rootfs:  means there's no point in prepopulating /var
because it's on a tmpfs and needs to be populated at boot time

ii)  stateless-rootfs:  means there's no point in prepopulating neither
/etc nor /var because they are on a tmpfs and need to be populated at
boot time

iii)  readonly-rootfs:  means that /etc is really not writable so it's
important that: the systemd first-boot stuff needs to be done at build
time:  machine-id, unit files set up, all tmpfiles.d snippets that touch
/etc and /var need to be done in advance.



I'm assuming definitions from here?

http://0pointer.net/blog/projects/stateless.html

Either way, those work for me...


Correct.  Thanks for digging that up... I should have posted it myself.

/Jonas






--
Alex Kiernan


--
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [OE-Core][PATCH] systemd: Default to non-stateless images

2019-05-06 Thread Jonas Bonn

Hi Peter,

On 06/05/2019 12:28, Peter Kjellerstedt wrote:

-Original Message-
From: openembedded-core-boun...@lists.openembedded.org  On Behalf Of Jonas Bonn
Sent: den 6 maj 2019 06:54
To: Alex Kiernan ; openembedded-
c...@lists.openembedded.org
Subject: Re: [OE-core] [OE-Core][PATCH] systemd: Default to non-
stateless images

Hi Alex,

The below is fine and looks good.  The one thing that bothers me about
this is that "stateless" isn't really a property of the "distro",
rather
it's a property of the image/machine.  I suspect, in the same sense
that
we have readonly-rootfs, that we should probably have image features
"stateless-rootfs" (no /etc, no /var) and "volatile-rootfs" (no /var).

Furthermore, if you want to boot with 'ro' on the command-line, I
really
think you need to build your image with the "readonly-rootfs" feature
set.  The default should be writable+persistent /etc as that's the
configuration used 99% of the time (currently).  "readonly-rootfs" does
a bit more than just creating machine-id but it's all relevant to the
'ro' case where /etc isn't writable.

Just for clarification:

i)  volatile-rootfs:  means there's no point in prepopulating /var
because it's on a tmpfs and needs to be populated at boot time


This doesn't really say anything about the state of the rootfs outside
of /var, i.e., is it writable or read-only?


ii)  stateless-rootfs:  means there's no point in prepopulating neither
/etc nor /var because they are on a tmpfs and need to be populated at
boot time


Same here.


iii)  readonly-rootfs:  means that /etc is really not writable so it's
important that: the systemd first-boot stuff needs to be done at build
time:  machine-id, unit files set up, all tmpfiles.d snippets that
touch /etc and /var need to be done in advance.

/Jonas


Maybe we need some more generic way of describing the intended
structure of the image? E.g., what are the expected behavior of
/etc, /var and the rest of the rootfs? For each they can typically
be "read-only", "persistent" (writable and survives reboots) or
"volatile" (writable, but doesn't survive a reboot).


Alex already put this link into an earlier response but I'll repeat it 
here and defer to it for the terminology and justification.


http://0pointer.net/blog/projects/stateless.html

That said, the paradigm here is that:

i)  /etc MUST be writable
ii)  /var MUST be writable
iii)  For everything, it doesn't matter... writable or not.  Most 
importantly, though, read-only is OK and no program should assume that 
they can write outside of /etc and /var (and /tmp and /run).


/Jonas



//Peter


--
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [OE-Core][PATCH] systemd: Default to non-stateless images

2019-05-05 Thread Jonas Bonn

Hi Alex,

The below is fine and looks good.  The one thing that bothers me about 
this is that "stateless" isn't really a property of the "distro", rather 
it's a property of the image/machine.  I suspect, in the same sense that 
we have readonly-rootfs, that we should probably have image features 
"stateless-rootfs" (no /etc, no /var) and "volatile-rootfs" (no /var).


Furthermore, if you want to boot with 'ro' on the command-line, I really 
think you need to build your image with the "readonly-rootfs" feature 
set.  The default should be writable+persistent /etc as that's the 
configuration used 99% of the time (currently).  "readonly-rootfs" does 
a bit more than just creating machine-id but it's all relevant to the 
'ro' case where /etc isn't writable.


Just for clarification:

i)  volatile-rootfs:  means there's no point in prepopulating /var 
because it's on a tmpfs and needs to be populated at boot time


ii)  stateless-rootfs:  means there's no point in prepopulating neither 
/etc nor /var because they are on a tmpfs and need to be populated at 
boot time


iii)  readonly-rootfs:  means that /etc is really not writable so it's 
important that: the systemd first-boot stuff needs to be done at build 
time:  machine-id, unit files set up, all tmpfiles.d snippets that touch 
/etc and /var need to be done in advance.


/Jonas


On 03/05/2019 18:48, Alex Kiernan wrote:

When creating images, for anything other than the explicitly stateless
case, touch /etc/machine-id so that the images can be booted without an
initramfs and with `ro` set on the kernel command line, otherwise system
refuses to start:

   [7.222134] systemd[1]: No hostname configured.
   [7.227266] systemd[1]: Set hostname to .
   [7.232622] systemd[1]: System cannot boot: Missing /etc/machine-id and 
/etc is mounted read-only.
   [7.241750] systemd[1]: Booting up is supported only when:
   [7.247362] systemd[1]: 1) /etc/machine-id exists and is populated.
   [7.253752] systemd[1]: 2) /etc/machine-id exists and is empty.
   [7.259757] systemd[1]: 3) /etc/machine-id is missing and /etc is 
writable.

If DISTRO_FEATURES includes `stateless` then systemctl-native is not run
on the image leaving the image for population at runtime by systemd.

Signed-off-by: Alex Kiernan 
---

  meta/classes/image.bbclass| 7 +++
  meta/recipes-core/systemd/systemd-systemctl/systemctl | 8 
  2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index a23403c0827a..3cb185dd2045 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -665,12 +665,11 @@ reproducible_final_image_task () {
  fi
  }
  
-IMAGE_EXTRADEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd-systemctl-native', '', d)}"

-
  systemd_preset_all () {
-   systemctl --root="${IMAGE_ROOTFS}" --preset-mode=enable-only preset-all
+systemctl --root="${IMAGE_ROOTFS}" --preset-mode=enable-only preset-all
  }
  
-IMAGE_PREPROCESS_COMMAND_append = " ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd_preset_all;', '', d)} reproducible_final_image_task; "

+IMAGE_EXTRADEPENDS += "${@ 'systemd-systemctl-native' if 
bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d) and not 
bb.utils.contains('DISTRO_FEATURES', 'stateless', True, False, d) else ''}"
+IMAGE_PREPROCESS_COMMAND_append = " ${@ 'systemd_preset_all;' if 
bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d) and not 
bb.utils.contains('DISTRO_FEATURES', 'stateless', True, False, d) else ''} 
reproducible_final_image_task; "
  
  CVE_PRODUCT = ""

diff --git a/meta/recipes-core/systemd/systemd-systemctl/systemctl 
b/meta/recipes-core/systemd/systemd-systemctl/systemctl
index d7d4e0d29a09..7da8f23ab893 100755
--- a/meta/recipes-core/systemd/systemd-systemctl/systemctl
+++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl
@@ -241,6 +241,14 @@ def preset_all(root):
  if state == "enable" or state is None:
  enable(root, service, location, services)
  
+# If we populate the systemd links we also create /etc/machine-id, which

+# allows systemd to boot with the filesystem read-only before generating
+# a real value and then committing it back.
+#
+# For the stateless configuration, where /etc is generated at runtime
+# (for example on a tmpfs), this script shouldn't run at all and we
+# allow systemd to completely populate /etc.
+(root / SYSCONFDIR / "machine-id").touch()
  
  def mask(root, *services):

  systemdir = root / SYSCONFDIR / "systemd" / "system"


--
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [OE-Core][PATCH v6 6/6] image: call systemctl preset-all for images

2019-05-03 Thread Jonas Bonn

Hi Alex,

On 02/05/2019 23:09, Alex Kiernan wrote:

From: Alex Kiernan 

Rather than rely on systemd's default invocation of preset-all at
runtime, we pre-populate the symlink tree as part of of the image. This
is done late so any overrides of presets during rootfs construction
should already have happened.

Whilst we don't strictly need this for the read-write root case, it
avoids boot time churn; for read-only root we have to do it here.

Signed-off-by: Alex Kiernan 
---

Changes in v6:
- moved systemctl preset-all to IMAGE_PREPROCESS so it runs after ROOTFS,
   run for all images, not just read-only

Changes in v5: None

  meta/classes/image.bbclass | 9 -
  1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 276d0d31f4a5..a23403c0827a 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -664,6 +664,13 @@ reproducible_final_image_task () {
  find  ${IMAGE_ROOTFS} -exec touch -h  
--date=@$REPRODUCIBLE_TIMESTAMP_ROOTFS {} \;
  fi
  }
-IMAGE_PREPROCESS_COMMAND_append = " reproducible_final_image_task; "
+
+IMAGE_EXTRADEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 
'systemd-systemctl-native', '', d)}"
+
+systemd_preset_all () {
+   systemctl --root="${IMAGE_ROOTFS}" --preset-mode=enable-only preset-all
+}
+
+IMAGE_PREPROCESS_COMMAND_append = " ${@bb.utils.contains('DISTRO_FEATURES', 
'systemd', 'systemd_preset_all;', '', d)} reproducible_final_image_task; "
  
  CVE_PRODUCT = ""




In the interest of being able to produce a "stateless" system, I'd 
prefer to see us trying to empty out /etc at buildtime.  That will 
allows us to error out when things are being installed directly to /etc 
such that they won't be set up properly at runtime when the system is 
"stateless".  Allow things that _can_ be set up at runtime to be so; the 
runtime cost is small and paid only at first boot for stateful systems.


Calling preset-all at buildtime should only be necessary for read-only 
rootfs; even there, long term, /etc should be writable as that's what 
systemd (and others) expect.


/Jonas
--
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [OE-Core][PATCH v6 0/6] systemd stateless configuration

2019-05-03 Thread Jonas Bonn

Hi Alex,

On 03/05/2019 10:37, Alex Kiernan wrote:

On Thu, May 2, 2019 at 10:10 PM Alex Kiernan  wrote:



This patch set is largely Jonas Bonn's to move towards a "stateless"
configuration:

   These patches make some modifications to systemd with the long-term goal
   of being able to run OE in systemd's "stateless" configuration.
   "Stateless" boils down to building an image with empty /etc and /var
   directories so that volatile (tmpfs) filesystems can be mounted there;
   this requires that the system subsequently be able to populate these
   directories dynamically, which systemd mostly takes care of if things are
   done right.

   In these patches:
   i)   Don't include machine-id in writable images so that systemd can run
its first-boot machinery
   ii)  Move systemd configuration files out of /etc
   iii) Allow systemd to dynamically enable services and populate
/etc/systemd/system via the presets mechanism

   There's a long way to go to get to a working "stateless" configuration.
   Getting to a "volatile" system (just empty /var) should be easier and I'll
   post patches moving things in that direction shortly.

However as a result of the systemd 242 upgrade, which includes 01d2041e41f4
("meson: stop creating enablement symlinks in /etc during installation"),
services such as systemd-networkd are no longer enabled in images.

This patch set fixes this problem in addition to satisfying the goal of
moving towards "stateless" configurations.

The issue with respect to image testing during CI was caused by
systemd-time-wait-sync.service being enabled due to the lack of a default
preset policy:

https://www.freedesktop.org/wiki/Software/systemd/Preset/#howto

Changes in v6:
- switch configuration to simple overrides in /usr/lib/systemd/*.conf.d
- make systemd RRECOMMENDS rather than RDEPENDS on systemd-conf
- don't exit in postinst as when that executes we're actually a
   concatenation of all fragments
- validate SYSTEMD_AUTO_ENABLE is `enable` or `disable`
- rewrite systemctl-native in Python
- moved systemctl preset-all to IMAGE_PREPROCESS so it runs after ROOTFS,
   run for all images, not just read-only

Changes in v5:
- rebased for systemd 242
- install default preset distribution policy of "enable nothing"

Alex Kiernan (3):
   systemd-conf: simplify creation of machine-specific configuration
   systemctl-native: Rewrite in Python supporting preset-all and mask
   image: call systemctl preset-all for images

Jonas Bonn (3):
   systemd: don't build firstboot by default
   systemd: do not create machine-id
   systemd: create preset files instead of installing in image

  meta/classes/image.bbclass|   9 +-
  meta/classes/rootfs-postcommands.bbclass  |   6 +
  meta/classes/systemd.bbclass  |  41 +-
  .../systemd/systemd-conf/journald.conf|   3 +
  .../systemd/systemd-conf/logind.conf  |   2 +
  .../systemd/systemd-conf/system.conf  |   2 +
  .../systemd/systemd-conf/system.conf-qemuall  |   3 +
  meta/recipes-core/systemd/systemd-conf_242.bb |  61 +--
  .../systemd/systemd-systemctl/systemctl   | 476 ++
  .../systemd/systemd/99-default.preset |   1 +
  meta/recipes-core/systemd/systemd_242.bb  |  26 +-
  11 files changed, 360 insertions(+), 270 deletions(-)
  create mode 100644 meta/recipes-core/systemd/systemd-conf/journald.conf
  create mode 100644 meta/recipes-core/systemd/systemd-conf/logind.conf
  create mode 100644 meta/recipes-core/systemd/systemd-conf/system.conf
  create mode 100644 meta/recipes-core/systemd/systemd-conf/system.conf-qemuall
  create mode 100644 meta/recipes-core/systemd/systemd/99-default.preset



Sigh...

this still has issues - if you boot with `ro` on the kernel command
line and without an initramfs, then / is read-only when systemd starts
and it basically refuses to do anything:

[7.222134] systemd[1]: No hostname configured.
[7.227266] systemd[1]: Set hostname to .
[7.232622] systemd[1]: System cannot boot: Missing /etc/machine-id
and /etc is mounted read-only.
[7.241750] systemd[1]: Booting up is supported only when:
[7.247362] systemd[1]: 1) /etc/machine-id exists and is populated.
[7.253752] systemd[1]: 2) /etc/machine-id exists and is empty.
[7.259757] systemd[1]: 3) /etc/machine-id is missing and /etc is writable.

Note this has nothing to do with read-only-rootfs, this is just a
regular boot... that said a bunch of things that were broken now work,
so it's progress!

I'm leaning towards having systemctl-native touch /etc/machine-id when
it runs, unless you explicitly ask for stateless in DISTRO_FEATURES...
patches to follow.


The paradigm that systemd follows is that /etc is _always_ writable. 
The read-only rootfs that OE produces with a read-only /etc is 
pathological from systemd's point of view (as is your 'ro' kernel 
paramete

Re: [OE-core] [PATCH] systemd: upgrade to 242

2019-04-26 Thread Jonas Bonn

Hi Alex,

On 26/04/2019 16:14, Alex Kiernan wrote:

On Thu, Apr 18, 2019 at 11:22 AM Andrej Valek  wrote:


PATCH REBASED:
==
0001-do-not-disable-buffer-in-writing-files.patch
0002-don-t-use-glibc-specific-qsort_r.patch
0003-missing_type.h-add-__compare_fn_t-and-comparison_fn_.patch
0004-add-fallback-parse_printf_format-implementation.patch
0005-rules-watch-metadata-changes-in-ide-devices.patch
0005-src-basic-missing.h-check-for-missing-strndupa.patch
0007-don-t-fail-if-GLOB_BRACE-and-GLOB_ALTDIRFUNC-is-not.patch
0009-socket-util-don-t-fail-if-libc-doesn-t-support-IDN.patch
0017-Do-not-disable-buffering-when-writing-to-oom_score_a.patch
0021-avoid-redefinition-of-prctl_mm_map-structure.patch
0024-test-json.c-define-M_PIl.patch

PATCH DROPPED:
==
0001-meson-declare-version.h-as-dep-for-various-targets-t.patch
0001-meson-declare-version.h-as-dependency-for-systemd.patch
0013-test-hexdecoct.c-Include-missing.h-for-strndupa.patch

PATCH ADDED:
0025-fs-utilh-add-missing-sys-stat-include.patch

Signed-off-by: Andrej Valek 
---


This change in 242 means I'm no longer getting network up after
flashing a new image (I'm flashing the entire eMMC from an image):

* During package installation (with `ninja install`), we would create
symlinks for systemd-networkd.service, systemd-networkd.socket,
systemd-resolved.service, remote-cryptsetup.target, remote-fs.target,
systemd-networkd-wait-online.service, and systemd-timesyncd.service
in /etc, as if `systemctl enable` was called for those units, to make
the system usable immediately after installation. Now this is not
done anymore, and instead calling `systemctl preset-all` is
recommended after the first installation of systemd.

I don't know if Jonas is still working on this series:

https://patchwork.openembedded.org/series/15497/


I haven't given up on it, but I had to put it aside for a bit due to 
more pressing matters.




as that looks like it has the kind of machinery we need (though I
don't think this problem is specific to read only rootfs now) - I'm
looking at the series in case he's not.


If you have a writable root, systemd will automatically do the 
preset-all for you; the catch is, systemd only does this if 
/etc/machine-id does not exist.  OE forces an empty /etc/machine-id onto 
all root images so this doesn't work; as such, you'll need to do the 
preset-all magic manually for ALL filesystems irregardless of whether 
they are read-only or not.


A better solution is drop the /etc/machine-id and let systemd create 
that automatically; then it will also do the automatic preset-all at 
first-boot.  The problem here is that the OE build farm detects images 
that stall at boot when /etc/machine-id isn't present; I wasn't able to 
find the cause of this but that's where you should be looking if you 
want to pursue this patch series.  Aside from that little glitch, I 
think the rest of it is fine.


And getting this working is also a big step towards making "stateless" 
systems (using the systemd terminology) work where /etc may be a tmpfs 
and gets populated at boot.


/Jonas



The quick-hack fix is to revert 01d2041e41f4 ("meson: stop creating
enablement symlinks in /etc during installation"), but clearly that's
not sustainable.

--
Alex Kiernan


--
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH] systemd: RDEPENDS on util-linux-umount

2019-02-14 Thread Jonas Bonn



On 13/02/2019 21:45, Randy MacLeod wrote:

On 2/13/19 5:00 AM, Jonas Bonn wrote:



On 11/02/2019 13:15, mikko.rap...@bmw.de wrote:

On Mon, Feb 11, 2019 at 12:08:46PM +, André Draszik wrote:
Please ignore this patch. Looks like a red-herring. Sorry for the 
noise.


FWIW, I would like to see this patch merged. Had some issues in the past
with busybox umount and added same change as a bbappend.


I'm also carrying a patch locally for this with the following 
explanation:


systemd passes the "-c" parameter (do not canonicalize) to the umount 
command and busybox's umount does not understand this parameter.


With the current busybox do you really still see a problem since
busybox umount has been told to ignore "-c" now:


OK, my patch predates the fix in busybox and I haven't tested without it 
recently.  Previously umount would error out due to the unknown option 
and systemd-mount would fail rather inelegantly; the busybox fix should 
be sufficient to rectify this.


/Jonas
--
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH] systemd: RDEPENDS on util-linux-umount

2019-02-13 Thread Jonas Bonn



On 11/02/2019 13:15, mikko.rap...@bmw.de wrote:

On Mon, Feb 11, 2019 at 12:08:46PM +, André Draszik wrote:

Please ignore this patch. Looks like a red-herring. Sorry for the noise.


FWIW, I would like to see this patch merged. Had some issues in the past
with busybox umount and added same change as a bbappend.


I'm also carrying a patch locally for this with the following explanation:

systemd passes the "-c" parameter (do not canonicalize) to the umount 
command and busybox's umount does not understand this parameter.


/Jonas
--
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH v4 0/6] systemd patches

2019-01-31 Thread Jonas Bonn

Hi Richard,

On 30/01/2019 22:54, Richard Purdie wrote:

On Mon, 2019-01-28 at 21:58 +0100, Jonas Bonn wrote:

Changed in v4:
- add patch to make systemd-firstboot a non-default option to systemd
to
   prevent unexpected prompts at runtime


There were still some failures:

https://autobuilder.yoctoproject.org/typhoon/#/builders/72/builds/237

(steps 5c, 6c and 7c)


OK, thanks.

I looked into these failures and have a couple of comments:

i)  There are seemingly two failures here:  unable to sync time and 
unable to connect to network (by looks of things).  These are related 
because the network failure leads to the timesync failure, AFAICT.


ii)  I have seen these failures locally; however, I even get these 
failures on origin/master, i.e. without any of my systemd patches.


iii)  The failure behaviour on this end is strange:  sometimes I get 
warnings from the ethernet driver about "incomplete frames" being 
detected.  Same kernel on the same hardware with Thud doesn't produce 
these warnings (with or without the systemd patches in this series).


iv)  connman-1.36 crashes (something about Wispr despite 'wispr' being 
disabled in my connman build... it seems bits of wispr are built despite 
this) immediately after getting a DHCP address and is unable to get an 
address when it's restarted.


v)  Disabling connman altogether and things work much better. 
systemd-network can bring up the network without ethernet driver frame 
errors, strangely enough.


So with that:

a)  Does buildbot use connman, systemd-networkd, both, or something 
else?  How do I find this out?


b)  I'll poke at the patch series again once I get a working 
origin/master build so that I have sane state to work from.  The systemd 
patches work fine on Thud... I suspect the problem lies elsewhere.


c)  Are others seeing similar errors with connman?

Thanks,
/Jonas



Cheers,

Richard


--
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 4/4] keymaps: tighten package write dependency

2019-01-28 Thread Jonas Bonn
The dependency on systemd-systemctl-native is only needed if _both_
systemd and sysvinit are in play.

Signed-off-by: Jonas Bonn 
---
 meta/recipes-bsp/keymaps/keymaps_1.0.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/recipes-bsp/keymaps/keymaps_1.0.bb 
b/meta/recipes-bsp/keymaps/keymaps_1.0.bb
index 34b208c5b3..24b13f920f 100644
--- a/meta/recipes-bsp/keymaps/keymaps_1.0.bb
+++ b/meta/recipes-bsp/keymaps/keymaps_1.0.bb
@@ -37,7 +37,7 @@ do_install () {
 fi
 }
 
-PACKAGE_WRITE_DEPS_append = " 
${@bb.utils.contains('DISTRO_FEATURES','systemd','systemd-systemctl-native','',d)}"
+PACKAGE_WRITE_DEPS_append = " ${@bb.utils.contains('DISTRO_FEATURES','systemd 
sysvinit','systemd-systemctl-native','',d)}"
 pkg_postinst_${PN} () {
if ${@bb.utils.contains('DISTRO_FEATURES','systemd 
sysvinit','true','false',d)}; then
if [ -n "$D" ]; then
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 1/4] glibc: systemd and sysvinit are not mutually exclusive

2019-01-28 Thread Jonas Bonn
Signed-off-by: Jonas Bonn 
---
 meta/recipes-core/glibc/glibc-package.inc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/meta/recipes-core/glibc/glibc-package.inc 
b/meta/recipes-core/glibc/glibc-package.inc
index a98ae1a29c..329732f48c 100644
--- a/meta/recipes-core/glibc/glibc-package.inc
+++ b/meta/recipes-core/glibc/glibc-package.inc
@@ -107,7 +107,9 @@ do_install_append () {
install -d ${D}${sysconfdir}/tmpfiles.d
echo "d /run/nscd 755 root root -" \
> ${D}${sysconfdir}/tmpfiles.d/nscd.conf
-   else
+   fi
+
+   if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', 
d)}; then
install -d ${D}${sysconfdir}/default/volatiles
echo "d root root 0755 /var/run/nscd none" \
> ${D}${sysconfdir}/default/volatiles/98_nscd
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 2/4] dbus: volatiles are only needed by sysvinit configuration

2019-01-28 Thread Jonas Bonn
Signed-off-by: Jonas Bonn 
---
 meta/recipes-core/dbus/dbus_1.12.10.bb | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/meta/recipes-core/dbus/dbus_1.12.10.bb 
b/meta/recipes-core/dbus/dbus_1.12.10.bb
index d71f7f7042..d3301278b0 100644
--- a/meta/recipes-core/dbus/dbus_1.12.10.bb
+++ b/meta/recipes-core/dbus/dbus_1.12.10.bb
@@ -120,6 +120,9 @@ do_install() {
install -d ${D}${sysconfdir}/init.d
sed 's:@bindir@:${bindir}:' < ${WORKDIR}/dbus-1.init 
>${WORKDIR}/dbus-1.init.sh
install -m 0755 ${WORKDIR}/dbus-1.init.sh 
${D}${sysconfdir}/init.d/dbus-1
+   install -d ${D}${sysconfdir}/default/volatiles
+   echo "d messagebus messagebus 0755 ${localstatedir}/run/dbus 
none" \
+> ${D}${sysconfdir}/default/volatiles/99_dbus
fi
 
if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', 
d)}; then
@@ -131,10 +134,6 @@ do_install() {
ln -fs ../dbus.service 
${D}${systemd_system_unitdir}/multi-user.target.wants/dbus.service
fi
 
-   install -d ${D}${sysconfdir}/default/volatiles
-   echo "d messagebus messagebus 0755 ${localstatedir}/run/dbus none" \
-> ${D}${sysconfdir}/default/volatiles/99_dbus
-
 
mkdir -p ${D}${localstatedir}/lib/dbus
 
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 3/4] base-files: filesystems serves no real purpose

2019-01-28 Thread Jonas Bonn
mount can generally figure out the filesystem type from the superblock;
otherwise, /proc/filesystems is a more correct fallback than
/etc/filesystems and presumably always available.

Signed-off-by: Jonas Bonn 
---
 meta/recipes-core/base-files/base-files/filesystems | 8 
 meta/recipes-core/base-files/base-files_3.0.14.bb   | 2 --
 2 files changed, 10 deletions(-)
 delete mode 100644 meta/recipes-core/base-files/base-files/filesystems

diff --git a/meta/recipes-core/base-files/base-files/filesystems 
b/meta/recipes-core/base-files/base-files/filesystems
deleted file mode 100644
index 7e6c41c38f..00
--- a/meta/recipes-core/base-files/base-files/filesystems
+++ /dev/null
@@ -1,8 +0,0 @@
-ext4
-ext3
-ext2
-vfat
-fat
-btrfs
-minix
-*
diff --git a/meta/recipes-core/base-files/base-files_3.0.14.bb 
b/meta/recipes-core/base-files/base-files_3.0.14.bb
index f42a4ef7c4..a1639db830 100644
--- a/meta/recipes-core/base-files/base-files_3.0.14.bb
+++ b/meta/recipes-core/base-files/base-files_3.0.14.bb
@@ -18,7 +18,6 @@ SRC_URI = "file://rotation \
file://profile \
file://shells \
file://fstab \
-   file://filesystems \
file://issue.net \
file://issue \
file://usbd \
@@ -123,7 +122,6 @@ do_install () {
fi
 
install -m 0644 ${WORKDIR}/fstab ${D}${sysconfdir}/fstab
-   install -m 0644 ${WORKDIR}/filesystems ${D}${sysconfdir}/filesystems
install -m 0644 ${WORKDIR}/usbd ${D}${sysconfdir}/default/usbd
install -m 0644 ${WORKDIR}/profile ${D}${sysconfdir}/profile
sed -i 's#ROOTHOME#${ROOT_HOME}#' ${D}${sysconfdir}/profile
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v4 6/6] rootfs-postcommands: call preset-all for read-only-rootfs

2019-01-28 Thread Jonas Bonn
When the rootfs is read-only, we cannot rely on systemd's default
invocation of preset-all at runtime in order to enable services.  As
such, we need to do it at image creation time.

Signed-off-by: Jonas Bonn 
---
 meta/classes/rootfs-postcommands.bbclass | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/meta/classes/rootfs-postcommands.bbclass 
b/meta/classes/rootfs-postcommands.bbclass
index 89f8efd323..5fcd53c4ca 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -16,6 +16,7 @@ ROOTFS_POSTPROCESS_COMMAND += "rootfs_update_timestamp ; "
 
 # Tweak the mount options for rootfs in /etc/fstab if read-only-rootfs is 
enabled
 ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("IMAGE_FEATURES", 
"read-only-rootfs", "read_only_rootfs_hook; ", "",d)}'
+IMAGE_EXTRADEPENDS += '${@bb.utils.contains("IMAGE_FEATURES", 
"read-only-rootfs", "systemd-systemctl-native", "", d)}'
 
 # We also need to do the same for the kernel boot parameters,
 # otherwise kernel or initramfs end up mounting the rootfs read/write
@@ -131,6 +132,7 @@ read_only_rootfs_hook () {
# Create machine-id
# 20:12 < mezcalero> koen: you have three options: a) run 
systemd-machine-id-setup at install time, b) have / read-only and an empty file 
there (for stateless) and c) boot with / writable
touch ${IMAGE_ROOTFS}${sysconfdir}/machine-id
+   systemctl --root=${IMAGE_ROOTFS} preset-all
fi
 }
 
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v4 2/6] systemd: do not create machine-id

2019-01-28 Thread Jonas Bonn
There is no reason to have an emtpy machine-id as part of the systemd
package.  Either:

i)  the filesystem is writable and the file will be created
automatically; or
ii) the filesystem is read-only, in which case the empty machine-id file
should be created as part of the read-only-rootfs tweaks.

Signed-off-by: Jonas Bonn 
---
 meta/classes/rootfs-postcommands.bbclass  | 6 ++
 meta/recipes-core/systemd/systemd-conf.bb | 9 ++---
 meta/recipes-core/systemd/systemd_239.bb  | 1 -
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/meta/classes/rootfs-postcommands.bbclass 
b/meta/classes/rootfs-postcommands.bbclass
index bde58ad6cd..89f8efd323 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -126,6 +126,12 @@ read_only_rootfs_hook () {
${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh
fi
fi
+
+   if ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "true", "false", 
d)}; then
+   # Create machine-id
+   # 20:12 < mezcalero> koen: you have three options: a) run 
systemd-machine-id-setup at install time, b) have / read-only and an empty file 
there (for stateless) and c) boot with / writable
+   touch ${IMAGE_ROOTFS}${sysconfdir}/machine-id
+   fi
 }
 
 #
diff --git a/meta/recipes-core/systemd/systemd-conf.bb 
b/meta/recipes-core/systemd/systemd-conf.bb
index 9bb27fd96d..7fe2e1105b 100644
--- a/meta/recipes-core/systemd/systemd-conf.bb
+++ b/meta/recipes-core/systemd/systemd-conf.bb
@@ -7,14 +7,13 @@ DefaultTimeoutStartSec setting."
 
 PACKAGE_ARCH = "${MACHINE_ARCH}"
 
-CONFFILES_${PN} = "${sysconfdir}/machine-id \
-${sysconfdir}/systemd/coredump.conf \
+CONFFILES_${PN} = "${sysconfdir}/systemd/coredump.conf \
 ${sysconfdir}/systemd/journald.conf \
 ${sysconfdir}/systemd/logind.conf \
 ${sysconfdir}/systemd/system.conf \
 ${sysconfdir}/systemd/user.conf"
 
-FILES_${PN} = "${sysconfdir}/machine-id ${sysconfdir}/systemd"
+FILES_${PN} = "${sysconfdir}/systemd"
 
 do_configure[noexec] = '1'
 do_compile[noexec] = '1'
@@ -23,10 +22,6 @@ do_install() {
rm -rf ${D}/${sysconfdir}/systemd
install -d ${D}/${sysconfdir}/systemd
 
-   # Create machine-id
-   # 20:12 < mezcalero> koen: you have three options: a) run 
systemd-machine-id-setup at install time, b) have / read-only and an empty file 
there (for stateless) and c) boot with / writable
-   touch ${D}${sysconfdir}/machine-id
-
install -m 0644 ${S}/src/coredump/coredump.conf 
${D}${sysconfdir}/systemd/coredump.conf
 
install -m 0644 ${S}/src/journal/journald.conf 
${D}${sysconfdir}/systemd/journald.conf
diff --git a/meta/recipes-core/systemd/systemd_239.bb 
b/meta/recipes-core/systemd/systemd_239.bb
index 5a8d6ec2b5..0de21a5c3a 100644
--- a/meta/recipes-core/systemd/systemd_239.bb
+++ b/meta/recipes-core/systemd/systemd_239.bb
@@ -291,7 +291,6 @@ do_install() {
fi
 
# conf files are handled by systemd-conf
-   rm -f ${D}${sysconfdir}/machine-id
rm -f ${D}${sysconfdir}/systemd/coredump.conf
rm -f ${D}${sysconfdir}/systemd/journald.conf
rm -f ${D}${sysconfdir}/systemd/logind.conf
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v4 5/6] systemd-systemctl-native: simplify and support preset-all

2019-01-28 Thread Jonas Bonn
Now that the systemd class sets up service presets instead of actively
enabling services, the 'enable' and 'disable' subcommands for systemctl
are not actually used anywhere.  As such, we can remove these to make
sure that nobody inadvertently introduces new uses of them.

We do, however, one case where the enable/disable machinery is still
required; that is for the read-only-rootfs case where the 'preset-all'
command can not be called at runtime but needs to be called when creatng
the image.  For this case, we implement 'preset-all' here.

There was also a previous implement of 'preset'... not sure that this
ever worked as the implementation looks bogus and there aren't any users
anyway.  This patch removes the 'preset' subcommand, as well.

Signed-off-by: Jonas Bonn 
---
 .../systemd/systemd-systemctl/systemctl   | 36 ---
 1 file changed, 7 insertions(+), 29 deletions(-)

diff --git a/meta/recipes-core/systemd/systemd-systemctl/systemctl 
b/meta/recipes-core/systemd/systemd-systemctl/systemctl
index 2bc6489617..ce50352018 100755
--- a/meta/recipes-core/systemd/systemd-systemctl/systemctl
+++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl
@@ -9,22 +9,6 @@ while [ $# != 0 ]; do
opt="$1"
 
case "$opt" in
-   enable)
-   shift
-
-   action="$opt"
-   services="$1"
-   cmd_args="1"
-   shift
-   ;;
-   disable)
-   shift
-
-   action="$opt"
-   services="$1"
-   cmd_args="1"
-   shift
-   ;;
mask)
shift
 
@@ -33,13 +17,11 @@ while [ $# != 0 ]; do
cmd_args="1"
shift
;;
-   preset)
+   preset-all)
shift
 
action="$opt"
-   services="$1"
-   cmd_args="1"
-   shift
+   cmd_args="0"
;;
--root=*)
ROOT=${opt##--root=}
@@ -57,16 +39,12 @@ while [ $# != 0 ]; do
;;
esac
 done
-if [ "$action" = "preset" -a "$service_file" = "" ]; then
+
+if [ "$action" = "preset-all" ]; then
services=$(for f in `find $ROOT/etc/systemd/system 
$ROOT/lib/systemd/system $ROOT/usr/lib/systemd/system -type f 2>1`; do basename 
$f; done)
-   services="$services $opt"
-   presetall=1
 fi
 
 for service in $services; do
-   if [ "$presetall" = "1" ]; then
-   action="preset"
-   fi
if [ "$action" = "mask" ]; then
if [ ! -d $ROOT/etc/systemd/system/ ]; then
mkdir -p $ROOT/etc/systemd/system/
@@ -105,10 +83,10 @@ for service in $services; do
# If any new unit types are added to systemd they should be added
# to this regular expression.

unit_types_re='\.\(service\|socket\|device\|mount\|automount\|swap\|target\|target\.wants\|path\|timer\|snapshot\)\s*$'
-   if [ "$action" = "preset" ]; then
-   action=`egrep -sh  $service 
$ROOT/etc/systemd/user-preset/*.preset | cut -f1 -d' '`
+   if [ "$action" = "preset-all" ]; then
+   action=`egrep -sh  $service 
$ROOT/usr/lib/systemd/system-preset/*.preset | cut -f1 -d' '`
if [ -z "$action" ]; then
-   globalpreset=`egrep -sh  '\*'  
$ROOT/etc/systemd/user-preset/*.preset | cut -f1 -d' '`
+   globalpreset=`egrep -sh  '\*'  
$ROOT/usr/lib/systemd/system-preset/*.preset | cut -f1 -d' '`
if [ -n "$globalpreset" ]; then
action="$globalpreset"
else
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v4 3/6] systemd-conf: simplify creation of machine-specific configuration

2019-01-28 Thread Jonas Bonn
The configuration files that systemd installs are just skeletons
detailing the available options and their default values.  The
recommended means of changing the configuration is to provide snippets
in configuration directories.  For example, journald.conf settings are
best set in /usr/lib/journald.conf.d/ and can be overridden by the user
by providing overriding snippets in /etc/systemd/journald.conf.d/.

The systemd-conf package is just providing machine-specific overrides
for some systemd defaults.

This patch restores the installation of config files by systemd and
reduces systemd-conf to just providing the config snippets in
/usr/lib/*.conf.d.  This simplfies the systemd-conf recipe considerably
since it now just sets up a couple of text files and doesn't even need
access to the systemd source anymore.

Given, however, that the base configuration files in /etc/systemd have
the lowest priority, they will always be overridden by any snippets.  As
it may confuse a user who is used to modifying these base files
directly, this patch puts symlinks in the overriding
/etc/systemd/*.conf.d/ directories back to the top-level files, thereby
restoring them to their top-level glory.  The default config files
installed by systemd are just lists of (commented out) defaults so this
should be safe.  The symlinks also provide an indication to the user
that there is more to systemd configuration than just the top-level file
and that checking the man page may be in order...

With this patch, systemd gets the right configuration irregardless of
whether /etc is populated at boot or not (i.e. in a "stateless"
system).

License-Update: configuration snippets licensing is independent of
systemd licensing

Signed-off-by: Jonas Bonn 
---
 meta/recipes-core/systemd/systemd-conf.bb | 48 +++
 meta/recipes-core/systemd/systemd_239.bb  | 16 
 2 files changed, 31 insertions(+), 33 deletions(-)

diff --git a/meta/recipes-core/systemd/systemd-conf.bb 
b/meta/recipes-core/systemd/systemd-conf.bb
index 7fe2e1105b..8a9f01c48a 100644
--- a/meta/recipes-core/systemd/systemd-conf.bb
+++ b/meta/recipes-core/systemd/systemd-conf.bb
@@ -1,48 +1,44 @@
-require systemd.inc
-
 SUMMARY = "Systemd system configuration"
 DESCRIPTION = "Systemd may require slightly different configuration for \
 different machines.  For example, qemu machines require a longer \
 DefaultTimeoutStartSec setting."
+LICENSE = "MIT"
 
 PACKAGE_ARCH = "${MACHINE_ARCH}"
 
-CONFFILES_${PN} = "${sysconfdir}/systemd/coredump.conf \
-${sysconfdir}/systemd/journald.conf \
-${sysconfdir}/systemd/logind.conf \
-${sysconfdir}/systemd/system.conf \
-${sysconfdir}/systemd/user.conf"
-
-FILES_${PN} = "${sysconfdir}/systemd"
-
-do_configure[noexec] = '1'
-do_compile[noexec] = '1'
+FILES_${PN} = "/usr/lib/journald.conf.d/* \
+   /usr/lib/logind.conf.d/* \
+   /usr/lib/system.conf.d/* \
+   /etc/systemd/* \
+"
 
 do_install() {
-   rm -rf ${D}/${sysconfdir}/systemd
-   install -d ${D}/${sysconfdir}/systemd
-
-   install -m 0644 ${S}/src/coredump/coredump.conf 
${D}${sysconfdir}/systemd/coredump.conf
-
-   install -m 0644 ${S}/src/journal/journald.conf 
${D}${sysconfdir}/systemd/journald.conf
+   install -d ${D}/usr/lib/journald.conf.d
# Enable journal to forward message to syslog daemon
-   sed -i -e 's/.*ForwardToSyslog.*/ForwardToSyslog=yes/' 
${D}${sysconfdir}/systemd/journald.conf
+   echo "ForwardToSyslog=yes" >> ${D}/usr/lib/journald.conf.d/00-${PN}.conf
# Set the maximium size of runtime journal to 64M as default
-   sed -i -e 's/.*RuntimeMaxUse.*/RuntimeMaxUse=64M/' 
${D}${sysconfdir}/systemd/journald.conf
+   echo "RuntimeMaxUse=64M" >> ${D}/usr/lib/journald.conf.d/00-${PN}.conf
+
+   install -d ${D}${sysconfdir}/systemd/journald.conf.d
+   ln -s ../journald.conf 
${D}${sysconfdir}/systemd/journald.conf.d/00-${PN}.conf
 
-   install -m 0644 ${S}/src/login/logind.conf.in 
${D}${sysconfdir}/systemd/logind.conf
+   install -d ${D}/usr/lib/logind.conf.d
# Set KILL_USER_PROCESSES to yes
-   sed -i -e 's/@KILL_USER_PROCESSES@/yes/' 
${D}${sysconfdir}/systemd/logind.conf
+   echo "KillUserProcesses=yes" >> ${D}/usr/lib/logind.conf.d/00-${PN}.conf
+
+   install -d ${D}${sysconfdir}/systemd/logind.conf.d
+   ln -s ../logind.conf 
${D}${sysconfdir}/systemd/logind.conf.d/00-${PN}.conf
 
-   install -m 0644 ${S}/src/core/system.conf.in 
${D}${sysconfdir}/systemd/system.conf
+   install -d ${D}/usr/lib/system.conf.d
# Set MEMORY_ACCOUNTING_DEFAULT to yes
-   sed -i -e 's/@MEMORY_ACCOUNTING_DEFAULT@/yes/' 
${D}${sysconfdir}/systemd/system.conf
+   echo "DefaultMemoryAccounting=yes" >> 
${D}/usr/lib/system.conf.d/00-${PN}.conf
 
-   install -m 0644 ${S}/src/core/user.conf 
${D}${sysconfdir}/sy

[OE-core] [PATCH v4 4/6] systemd: create preset files instead of installing in image

2019-01-28 Thread Jonas Bonn
At first boot, systemd will create the /etc/systemd/system directory
from service preset files.  As such, for a normal, writable /etc
(writable rootfs), there is no need to set up this directory at image
creation time.

This patch changes the systemd machinery to create preset files and to
rely on systemd to do the service enablement.

This breaks the read-only-rootfs case; there's a fix for this in a
follow-up patch.

Signed-off-by: Jonas Bonn 
---
 meta/classes/systemd.bbclass | 33 -
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/meta/classes/systemd.bbclass b/meta/classes/systemd.bbclass
index c8f4fdec88..403d2108df 100644
--- a/meta/classes/systemd.bbclass
+++ b/meta/classes/systemd.bbclass
@@ -16,43 +16,32 @@ python __anonymous() {
 # from doing any work so that pure-systemd images don't have redundant init
 # files.
 if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d):
-d.appendVar("DEPENDS", " systemd-systemctl-native")
-d.appendVar("PACKAGE_WRITE_DEPS", " systemd-systemctl-native")
 if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, 
d):
 d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1")
 }
 
 systemd_postinst() {
-OPTS=""
-
 if [ -n "$D" ]; then
-OPTS="--root=$D"
+   exit 0
 fi
 
 if type systemctl >/dev/null 2>/dev/null; then
-   if [ -z "$D" ]; then
-   systemctl daemon-reload
-   fi
-
-   systemctl $OPTS ${SYSTEMD_AUTO_ENABLE} ${SYSTEMD_SERVICE_ESCAPED}
+   systemctl daemon-reload
+   systemctl preset ${SYSTEMD_SERVICE_ESCAPED}
 
-   if [ -z "$D" -a "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
+   if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
systemctl --no-block restart ${SYSTEMD_SERVICE_ESCAPED}
fi
 fi
 }
 
 systemd_prerm() {
-OPTS=""
-
 if [ -n "$D" ]; then
-OPTS="--root=$D"
+   exit 0
 fi
 
 if type systemctl >/dev/null 2>/dev/null; then
-   if [ -z "$D" ]; then
-   systemctl stop ${SYSTEMD_SERVICE_ESCAPED}
-   fi
+   systemctl stop ${SYSTEMD_SERVICE_ESCAPED}
 
systemctl $OPTS disable ${SYSTEMD_SERVICE_ESCAPED}
 fi
@@ -177,12 +166,22 @@ python systemd_populate_packages() {
 else:
 bb.fatal("SYSTEMD_SERVICE_%s value %s does not exist" % 
(pkg_systemd, service))
 
+def systemd_create_presets(pkg):
+action = get_package_var(d, 'SYSTEMD_AUTO_ENABLE', pkg)
+presetf = oe.path.join(d.getVar("PKGD"), d.getVar("systemd_unitdir"), 
"system-preset/98-%s.preset" % pkg)
+bb.utils.mkdirhier(os.path.dirname(presetf))
+with open(presetf, 'a') as fd:
+for service in d.getVar('SYSTEMD_SERVICE_%s' % pkg).split():
+fd.write("%s %s\n" % (action,service))
+d.appendVar("FILES_%s" % pkg, ' ' + 
oe.path.join(d.getVar("systemd_unitdir"), "system-preset/98-%s.preset" % pkg))
+
 # Run all modifications once when creating package
 if os.path.exists(d.getVar("D")):
 for pkg in d.getVar('SYSTEMD_PACKAGES').split():
 systemd_check_package(pkg)
 if d.getVar('SYSTEMD_SERVICE_' + pkg):
 systemd_generate_package_scripts(pkg)
+systemd_create_presets(pkg)
 systemd_check_services()
 }
 
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v4 1/6] systemd: don't build firstboot by default

2019-01-28 Thread Jonas Bonn
The firstboot service prompts the user for information about the host at
first boot.  Systemd determines whether or not a boot is a "first boot"
by the existence of the file /etc/machine-id.  Since oe-core always
includes this file (it is part of the systemd package), the firstboot
service never runs so this service is being built but never run.

A follow-up patch to this one will remove the machine-id from the
systemd build and allow it to be created automatically by systemd at
"first boot".  With that patch, we don't want the firstboot service to
suddenly start being invoked and presenting a prompt to the user.

With this patch, the firstboot service becomes a PACKAGECONFIG option
that the user must actively select.

Signed-off-by: Jonas Bonn 
---
 meta/recipes-core/systemd/systemd_239.bb | 1 -
 1 file changed, 1 deletion(-)

diff --git a/meta/recipes-core/systemd/systemd_239.bb 
b/meta/recipes-core/systemd/systemd_239.bb
index 7efc1e5828..5a8d6ec2b5 100644
--- a/meta/recipes-core/systemd/systemd_239.bb
+++ b/meta/recipes-core/systemd/systemd_239.bb
@@ -87,7 +87,6 @@ PACKAGECONFIG ??= " \
 acl \
 backlight \
 binfmt \
-firstboot \
 gshadow \
 hibernate \
 hostnamed \
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v4 0/6] systemd patches

2019-01-28 Thread Jonas Bonn
Changed in v4:
- add patch to make systemd-firstboot a non-default option to systemd to
  prevent unexpected prompts at runtime

Changed in v3:
- parameterize preset-file installation location (as suggested in patch
  review)

Changed in v2:
- address patchtest warnings:
  - include sign-offs on patches
  - include License-Update tag on patch that makes licensing change
- dropped patch implementing brute-force removal of unit files installed
  by systemd into /etc
- reworked the systemd-conf patch to restore the installation of the
  base systemd configuration files


**

These patches make some modifications to systemd with the long-term goal
of being able to run OE in systemd's "stateless" configuration.
"Stateless" boils down to building an image with empty /etc and /var
directories so that volatile (tmpfs) filesystems can be mounted there;
this requires that the system subsequently be able to populate these
directories dynamically, which systemd mostly takes care of if things
are done right.

In these patches:
i)Don't include machine-id in writable images so that systemd can run
its first-boot machinery
ii)   Move systemd configuration files out of /etc
iii)  Allow systemd to dynamically enable services and populate
/etc/systemd/system via the presets mechanism

There's a long way to go to get to a working "stateless" configuration.
Getting to a "volatile" system (just empty /var) should be easier and
I'll post patches moving things in that direction shortly.

/Jonas

Jonas Bonn (6):
  systemd: don't build firstboot by default
  systemd: do not create machine-id
  systemd-conf: simplify creation of machine-specific configuration
  systemd: create preset files instead of installing in image
  systemd-systemctl-native: simplify and support preset-all
  rootfs-postcommands: call preset-all for read-only-rootfs

 meta/classes/rootfs-postcommands.bbclass  |  8 +++
 meta/classes/systemd.bbclass  | 33 ++--
 meta/recipes-core/systemd/systemd-conf.bb | 53 ---
 .../systemd/systemd-systemctl/systemctl   | 36 +++--
 meta/recipes-core/systemd/systemd_239.bb  | 18 +++
 5 files changed, 62 insertions(+), 86 deletions(-)

-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH v3 0/5] systemd patches

2019-01-28 Thread Jonas Bonn




On 28/01/2019 18:26, Richard Purdie wrote:

On Mon, 2019-01-28 at 14:31 +, Richard Purdie wrote:

On Mon, 2019-01-28 at 15:26 +0100, Jonas Bonn wrote:

Hi,

On 28/01/2019 14:55, Richard Purdie wrote:

Unfortunately this series failed in testing:

https://autobuilder.yoctoproject.org/typhoon/#/builders/72/builds/226

https://autobuilder.yoctoproject.org/typhoon/#/builders/56/builds/167

so it looks like it may need some tweaks before we can merge it.


OK.  You'll have to bear with me here as I'm not familiar with
looking at the buildbot output.  From what I can see, the failure
is
when it attempts to boot the image... is that correct?  In what way
does it fail... where do I find that?


Yes, these tests are trying to boot images under qemu. You can see
the
output from boot process and it looks like it starts an interactive
dialog with the user (or attempts to) for setup. The key piece in the
various logs would appear to be:

  DEBUG: Last 25 lines of text:

  Starting First Boot Wizard...
  Starting Rebuild Hardware Database...
  Starting Apply Kernel Variables...
  Mounting NFSD configuration filesystem...

Welcome to your new installation of Poky (Yocto Project Reference

Distro) 2.6+snapshot-20190126 (master)!

Please configure a few basic system settings:

-- Press any key to proceed --[[0;32m  OK  [0m] Started Journal

Service.

(from
https://autobuilder.yoctoproject.org/typhoon/api/v2/logs/257192/raw)



When I build locally this all runs fine.  So what should I be
building locally in order to see a failure like buildbot sees?


Add INHERIT += "testimage" to local.conf and then

"bitbake core-image-sato -c testimage"

You'll need a tun/tap device setup so that "runqemu 
"works.


FWIW testing narrowed it down to the machine id patch causing this.


Thanks.  The reason for the prompt is that systemd-firstboot runs; 
systemd detects whether it's a "first boot" based on the existence of 
the machine-id file.  Since the machine-id file is absent now (by 
design), this service runs.  The question is why systemd-firstboot is 
being included in the build at all given that it should have been 
configured out.  I'll poke at it when I get a moment.


/Jonas



Cheers,

Richard


--
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH v3 0/5] systemd patches

2019-01-28 Thread Jonas Bonn

Hi,

On 28/01/2019 14:55, Richard Purdie wrote:

Unfortunately this series failed in testing:

https://autobuilder.yoctoproject.org/typhoon/#/builders/72/builds/226

https://autobuilder.yoctoproject.org/typhoon/#/builders/56/builds/167

so it looks like it may need some tweaks before we can merge it.


OK.  You'll have to bear with me here as I'm not familiar with looking 
at the buildbot output.  From what I can see, the failure is when it 
attempts to boot the image... is that correct?  In what way does it 
fail... where do I find that?


When I build locally this all runs fine.  So what should I be building 
locally in order to see a failure like buildbot sees?


Thanks,
Jonas
--
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v3 3/5] systemd: create preset files instead of installing in image

2019-01-27 Thread Jonas Bonn
At first boot, systemd will create the /etc/systemd/system directory
from service preset files.  As such, for a normal, writable /etc
(writable rootfs), there is no need to set up this directory at image
creation time.

This patch changes the systemd machinery to create preset files and to
rely on systemd to do the service enablement.

This breaks the read-only-rootfs case; there's a fix for this in a
follow-up patch.

Signed-off-by: Jonas Bonn 
---
 meta/classes/systemd.bbclass | 33 -
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/meta/classes/systemd.bbclass b/meta/classes/systemd.bbclass
index c8f4fdec88..403d2108df 100644
--- a/meta/classes/systemd.bbclass
+++ b/meta/classes/systemd.bbclass
@@ -16,43 +16,32 @@ python __anonymous() {
 # from doing any work so that pure-systemd images don't have redundant init
 # files.
 if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d):
-d.appendVar("DEPENDS", " systemd-systemctl-native")
-d.appendVar("PACKAGE_WRITE_DEPS", " systemd-systemctl-native")
 if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, 
d):
 d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1")
 }
 
 systemd_postinst() {
-OPTS=""
-
 if [ -n "$D" ]; then
-OPTS="--root=$D"
+   exit 0
 fi
 
 if type systemctl >/dev/null 2>/dev/null; then
-   if [ -z "$D" ]; then
-   systemctl daemon-reload
-   fi
-
-   systemctl $OPTS ${SYSTEMD_AUTO_ENABLE} ${SYSTEMD_SERVICE_ESCAPED}
+   systemctl daemon-reload
+   systemctl preset ${SYSTEMD_SERVICE_ESCAPED}
 
-   if [ -z "$D" -a "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
+   if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
systemctl --no-block restart ${SYSTEMD_SERVICE_ESCAPED}
fi
 fi
 }
 
 systemd_prerm() {
-OPTS=""
-
 if [ -n "$D" ]; then
-OPTS="--root=$D"
+   exit 0
 fi
 
 if type systemctl >/dev/null 2>/dev/null; then
-   if [ -z "$D" ]; then
-   systemctl stop ${SYSTEMD_SERVICE_ESCAPED}
-   fi
+   systemctl stop ${SYSTEMD_SERVICE_ESCAPED}
 
systemctl $OPTS disable ${SYSTEMD_SERVICE_ESCAPED}
 fi
@@ -177,12 +166,22 @@ python systemd_populate_packages() {
 else:
 bb.fatal("SYSTEMD_SERVICE_%s value %s does not exist" % 
(pkg_systemd, service))
 
+def systemd_create_presets(pkg):
+action = get_package_var(d, 'SYSTEMD_AUTO_ENABLE', pkg)
+presetf = oe.path.join(d.getVar("PKGD"), d.getVar("systemd_unitdir"), 
"system-preset/98-%s.preset" % pkg)
+bb.utils.mkdirhier(os.path.dirname(presetf))
+with open(presetf, 'a') as fd:
+for service in d.getVar('SYSTEMD_SERVICE_%s' % pkg).split():
+fd.write("%s %s\n" % (action,service))
+d.appendVar("FILES_%s" % pkg, ' ' + 
oe.path.join(d.getVar("systemd_unitdir"), "system-preset/98-%s.preset" % pkg))
+
 # Run all modifications once when creating package
 if os.path.exists(d.getVar("D")):
 for pkg in d.getVar('SYSTEMD_PACKAGES').split():
 systemd_check_package(pkg)
 if d.getVar('SYSTEMD_SERVICE_' + pkg):
 systemd_generate_package_scripts(pkg)
+systemd_create_presets(pkg)
 systemd_check_services()
 }
 
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v3 0/5] systemd patches

2019-01-27 Thread Jonas Bonn
Changed in v3:
- parameterize preset-file installation location (as suggested in patch
  review)

Changed in v2:
- address patchtest warnings:
  - include sign-offs on patches
  - include License-Update tag on patch that makes licensing change
- dropped patch implementing brute-force removal of unit files installed
  by systemd into /etc
- reworked the systemd-conf patch to restore the installation of the
  base systemd configuration files


**

These patches make some modifications to systemd with the long-term goal
of being able to run OE in systemd's "stateless" configuration.
"Stateless" boils down to building an image with empty /etc and /var
directories so that volatile (tmpfs) filesystems can be mounted there;
this requires that the system subsequently be able to populate these
directories dynamically, which systemd mostly takes care of if things
are done right.

In these patches:
i)Don't include machine-id in writable images so that systemd can run
its first-boot machinery
ii)  Allow systemd to dynamically enable services and populate
/etc/systemd/system via the presets mechanism

There's a long way to go to get to a working "stateless" configuration.
Getting to a "volatile" system (just empty /var) should be easier and
I'll post patches moving things in that direction shortly.

/Jonas

Jonas Bonn (5):
  systemd: do not create machine-id
  systemd-conf: simplify creation of machine-specific configuration
  systemd: create preset files instead of installing in image
  systemd-systemctl-native: simplify and support preset-all
  rootfs-postcommands: call preset-all for read-only-rootfs

 meta/classes/rootfs-postcommands.bbclass  |  8 +++
 meta/classes/systemd.bbclass  | 33 ++--
 meta/recipes-core/systemd/systemd-conf.bb | 53 ---
 .../systemd/systemd-systemctl/systemctl   | 36 +++--
 meta/recipes-core/systemd/systemd_239.bb  | 17 +++---
 5 files changed, 62 insertions(+), 85 deletions(-)

-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v3 5/5] rootfs-postcommands: call preset-all for read-only-rootfs

2019-01-27 Thread Jonas Bonn
When the rootfs is read-only, we cannot rely on systemd's default
invocation of preset-all at runtime in order to enable services.  As
such, we need to do it at image creation time.

Signed-off-by: Jonas Bonn 
---
 meta/classes/rootfs-postcommands.bbclass | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/meta/classes/rootfs-postcommands.bbclass 
b/meta/classes/rootfs-postcommands.bbclass
index 89f8efd323..5fcd53c4ca 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -16,6 +16,7 @@ ROOTFS_POSTPROCESS_COMMAND += "rootfs_update_timestamp ; "
 
 # Tweak the mount options for rootfs in /etc/fstab if read-only-rootfs is 
enabled
 ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("IMAGE_FEATURES", 
"read-only-rootfs", "read_only_rootfs_hook; ", "",d)}'
+IMAGE_EXTRADEPENDS += '${@bb.utils.contains("IMAGE_FEATURES", 
"read-only-rootfs", "systemd-systemctl-native", "", d)}'
 
 # We also need to do the same for the kernel boot parameters,
 # otherwise kernel or initramfs end up mounting the rootfs read/write
@@ -131,6 +132,7 @@ read_only_rootfs_hook () {
# Create machine-id
# 20:12 < mezcalero> koen: you have three options: a) run 
systemd-machine-id-setup at install time, b) have / read-only and an empty file 
there (for stateless) and c) boot with / writable
touch ${IMAGE_ROOTFS}${sysconfdir}/machine-id
+   systemctl --root=${IMAGE_ROOTFS} preset-all
fi
 }
 
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v3 1/5] systemd: do not create machine-id

2019-01-27 Thread Jonas Bonn
There is no reason to have an emtpy machine-id as part of the systemd
package.  Either:

i)  the filesystem is writable and the file will be created
automatically; or
ii) the filesystem is read-only, in which case the empty machine-id file
should be created as part of the read-only-rootfs tweaks.

Signed-off-by: Jonas Bonn 
---
 meta/classes/rootfs-postcommands.bbclass  | 6 ++
 meta/recipes-core/systemd/systemd-conf.bb | 9 ++---
 meta/recipes-core/systemd/systemd_239.bb  | 1 -
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/meta/classes/rootfs-postcommands.bbclass 
b/meta/classes/rootfs-postcommands.bbclass
index bde58ad6cd..89f8efd323 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -126,6 +126,12 @@ read_only_rootfs_hook () {
${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh
fi
fi
+
+   if ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "true", "false", 
d)}; then
+   # Create machine-id
+   # 20:12 < mezcalero> koen: you have three options: a) run 
systemd-machine-id-setup at install time, b) have / read-only and an empty file 
there (for stateless) and c) boot with / writable
+   touch ${IMAGE_ROOTFS}${sysconfdir}/machine-id
+   fi
 }
 
 #
diff --git a/meta/recipes-core/systemd/systemd-conf.bb 
b/meta/recipes-core/systemd/systemd-conf.bb
index 9bb27fd96d..7fe2e1105b 100644
--- a/meta/recipes-core/systemd/systemd-conf.bb
+++ b/meta/recipes-core/systemd/systemd-conf.bb
@@ -7,14 +7,13 @@ DefaultTimeoutStartSec setting."
 
 PACKAGE_ARCH = "${MACHINE_ARCH}"
 
-CONFFILES_${PN} = "${sysconfdir}/machine-id \
-${sysconfdir}/systemd/coredump.conf \
+CONFFILES_${PN} = "${sysconfdir}/systemd/coredump.conf \
 ${sysconfdir}/systemd/journald.conf \
 ${sysconfdir}/systemd/logind.conf \
 ${sysconfdir}/systemd/system.conf \
 ${sysconfdir}/systemd/user.conf"
 
-FILES_${PN} = "${sysconfdir}/machine-id ${sysconfdir}/systemd"
+FILES_${PN} = "${sysconfdir}/systemd"
 
 do_configure[noexec] = '1'
 do_compile[noexec] = '1'
@@ -23,10 +22,6 @@ do_install() {
rm -rf ${D}/${sysconfdir}/systemd
install -d ${D}/${sysconfdir}/systemd
 
-   # Create machine-id
-   # 20:12 < mezcalero> koen: you have three options: a) run 
systemd-machine-id-setup at install time, b) have / read-only and an empty file 
there (for stateless) and c) boot with / writable
-   touch ${D}${sysconfdir}/machine-id
-
install -m 0644 ${S}/src/coredump/coredump.conf 
${D}${sysconfdir}/systemd/coredump.conf
 
install -m 0644 ${S}/src/journal/journald.conf 
${D}${sysconfdir}/systemd/journald.conf
diff --git a/meta/recipes-core/systemd/systemd_239.bb 
b/meta/recipes-core/systemd/systemd_239.bb
index 7efc1e5828..54217d3042 100644
--- a/meta/recipes-core/systemd/systemd_239.bb
+++ b/meta/recipes-core/systemd/systemd_239.bb
@@ -292,7 +292,6 @@ do_install() {
fi
 
# conf files are handled by systemd-conf
-   rm -f ${D}${sysconfdir}/machine-id
rm -f ${D}${sysconfdir}/systemd/coredump.conf
rm -f ${D}${sysconfdir}/systemd/journald.conf
rm -f ${D}${sysconfdir}/systemd/logind.conf
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v3 4/5] systemd-systemctl-native: simplify and support preset-all

2019-01-27 Thread Jonas Bonn
Now that the systemd class sets up service presets instead of actively
enabling services, the 'enable' and 'disable' subcommands for systemctl
are not actually used anywhere.  As such, we can remove these to make
sure that nobody inadvertently introduces new uses of them.

We do, however, one case where the enable/disable machinery is still
required; that is for the read-only-rootfs case where the 'preset-all'
command can not be called at runtime but needs to be called when creatng
the image.  For this case, we implement 'preset-all' here.

There was also a previous implement of 'preset'... not sure that this
ever worked as the implementation looks bogus and there aren't any users
anyway.  This patch removes the 'preset' subcommand, as well.

Signed-off-by: Jonas Bonn 
---
 .../systemd/systemd-systemctl/systemctl   | 36 ---
 1 file changed, 7 insertions(+), 29 deletions(-)

diff --git a/meta/recipes-core/systemd/systemd-systemctl/systemctl 
b/meta/recipes-core/systemd/systemd-systemctl/systemctl
index 2bc6489617..ce50352018 100755
--- a/meta/recipes-core/systemd/systemd-systemctl/systemctl
+++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl
@@ -9,22 +9,6 @@ while [ $# != 0 ]; do
opt="$1"
 
case "$opt" in
-   enable)
-   shift
-
-   action="$opt"
-   services="$1"
-   cmd_args="1"
-   shift
-   ;;
-   disable)
-   shift
-
-   action="$opt"
-   services="$1"
-   cmd_args="1"
-   shift
-   ;;
mask)
shift
 
@@ -33,13 +17,11 @@ while [ $# != 0 ]; do
cmd_args="1"
shift
;;
-   preset)
+   preset-all)
shift
 
action="$opt"
-   services="$1"
-   cmd_args="1"
-   shift
+   cmd_args="0"
;;
--root=*)
ROOT=${opt##--root=}
@@ -57,16 +39,12 @@ while [ $# != 0 ]; do
;;
esac
 done
-if [ "$action" = "preset" -a "$service_file" = "" ]; then
+
+if [ "$action" = "preset-all" ]; then
services=$(for f in `find $ROOT/etc/systemd/system 
$ROOT/lib/systemd/system $ROOT/usr/lib/systemd/system -type f 2>1`; do basename 
$f; done)
-   services="$services $opt"
-   presetall=1
 fi
 
 for service in $services; do
-   if [ "$presetall" = "1" ]; then
-   action="preset"
-   fi
if [ "$action" = "mask" ]; then
if [ ! -d $ROOT/etc/systemd/system/ ]; then
mkdir -p $ROOT/etc/systemd/system/
@@ -105,10 +83,10 @@ for service in $services; do
# If any new unit types are added to systemd they should be added
# to this regular expression.

unit_types_re='\.\(service\|socket\|device\|mount\|automount\|swap\|target\|target\.wants\|path\|timer\|snapshot\)\s*$'
-   if [ "$action" = "preset" ]; then
-   action=`egrep -sh  $service 
$ROOT/etc/systemd/user-preset/*.preset | cut -f1 -d' '`
+   if [ "$action" = "preset-all" ]; then
+   action=`egrep -sh  $service 
$ROOT/usr/lib/systemd/system-preset/*.preset | cut -f1 -d' '`
if [ -z "$action" ]; then
-   globalpreset=`egrep -sh  '\*'  
$ROOT/etc/systemd/user-preset/*.preset | cut -f1 -d' '`
+   globalpreset=`egrep -sh  '\*'  
$ROOT/usr/lib/systemd/system-preset/*.preset | cut -f1 -d' '`
if [ -n "$globalpreset" ]; then
action="$globalpreset"
else
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v3 2/5] systemd-conf: simplify creation of machine-specific configuration

2019-01-27 Thread Jonas Bonn
The configuration files that systemd installs are just skeletons
detailing the available options and their default values.  The
recommended means of changing the configuration is to provide snippets
in configuration directories.  For example, journald.conf settings are
best set in /usr/lib/journald.conf.d/ and can be overridden by the user
by providing overriding snippets in /etc/systemd/journald.conf.d/.

The systemd-conf package is just providing machine-specific overrides
for some systemd defaults.

This patch restores the installation of config files by systemd and
reduces systemd-conf to just providing the config snippets in
/usr/lib/*.conf.d.  This simplfies the systemd-conf recipe considerably
since it now just sets up a couple of text files and doesn't even need
access to the systemd source anymore.

Given, however, that the base configuration files in /etc/systemd have
the lowest priority, they will always be overridden by any snippets.  As
it may confuse a user who is used to modifying these base files
directly, this patch puts symlinks in the overriding
/etc/systemd/*.conf.d/ directories back to the top-level files, thereby
restoring them to their top-level glory.  The default config files
installed by systemd are just lists of (commented out) defaults so this
should be safe.  The symlinks also provide an indication to the user
that there is more to systemd configuration than just the top-level file
and that checking the man page may be in order...

With this patch, systemd gets the right configuration irregardless of
whether /etc is populated at boot or not (i.e. in a "stateless"
system).

License-Update: configuration snippets licensing is independent of
systemd licensing

Signed-off-by: Jonas Bonn 
---
 meta/recipes-core/systemd/systemd-conf.bb | 48 +++
 meta/recipes-core/systemd/systemd_239.bb  | 16 
 2 files changed, 31 insertions(+), 33 deletions(-)

diff --git a/meta/recipes-core/systemd/systemd-conf.bb 
b/meta/recipes-core/systemd/systemd-conf.bb
index 7fe2e1105b..8a9f01c48a 100644
--- a/meta/recipes-core/systemd/systemd-conf.bb
+++ b/meta/recipes-core/systemd/systemd-conf.bb
@@ -1,48 +1,44 @@
-require systemd.inc
-
 SUMMARY = "Systemd system configuration"
 DESCRIPTION = "Systemd may require slightly different configuration for \
 different machines.  For example, qemu machines require a longer \
 DefaultTimeoutStartSec setting."
+LICENSE = "MIT"
 
 PACKAGE_ARCH = "${MACHINE_ARCH}"
 
-CONFFILES_${PN} = "${sysconfdir}/systemd/coredump.conf \
-${sysconfdir}/systemd/journald.conf \
-${sysconfdir}/systemd/logind.conf \
-${sysconfdir}/systemd/system.conf \
-${sysconfdir}/systemd/user.conf"
-
-FILES_${PN} = "${sysconfdir}/systemd"
-
-do_configure[noexec] = '1'
-do_compile[noexec] = '1'
+FILES_${PN} = "/usr/lib/journald.conf.d/* \
+   /usr/lib/logind.conf.d/* \
+   /usr/lib/system.conf.d/* \
+   /etc/systemd/* \
+"
 
 do_install() {
-   rm -rf ${D}/${sysconfdir}/systemd
-   install -d ${D}/${sysconfdir}/systemd
-
-   install -m 0644 ${S}/src/coredump/coredump.conf 
${D}${sysconfdir}/systemd/coredump.conf
-
-   install -m 0644 ${S}/src/journal/journald.conf 
${D}${sysconfdir}/systemd/journald.conf
+   install -d ${D}/usr/lib/journald.conf.d
# Enable journal to forward message to syslog daemon
-   sed -i -e 's/.*ForwardToSyslog.*/ForwardToSyslog=yes/' 
${D}${sysconfdir}/systemd/journald.conf
+   echo "ForwardToSyslog=yes" >> ${D}/usr/lib/journald.conf.d/00-${PN}.conf
# Set the maximium size of runtime journal to 64M as default
-   sed -i -e 's/.*RuntimeMaxUse.*/RuntimeMaxUse=64M/' 
${D}${sysconfdir}/systemd/journald.conf
+   echo "RuntimeMaxUse=64M" >> ${D}/usr/lib/journald.conf.d/00-${PN}.conf
+
+   install -d ${D}${sysconfdir}/systemd/journald.conf.d
+   ln -s ../journald.conf 
${D}${sysconfdir}/systemd/journald.conf.d/00-${PN}.conf
 
-   install -m 0644 ${S}/src/login/logind.conf.in 
${D}${sysconfdir}/systemd/logind.conf
+   install -d ${D}/usr/lib/logind.conf.d
# Set KILL_USER_PROCESSES to yes
-   sed -i -e 's/@KILL_USER_PROCESSES@/yes/' 
${D}${sysconfdir}/systemd/logind.conf
+   echo "KillUserProcesses=yes" >> ${D}/usr/lib/logind.conf.d/00-${PN}.conf
+
+   install -d ${D}${sysconfdir}/systemd/logind.conf.d
+   ln -s ../logind.conf 
${D}${sysconfdir}/systemd/logind.conf.d/00-${PN}.conf
 
-   install -m 0644 ${S}/src/core/system.conf.in 
${D}${sysconfdir}/systemd/system.conf
+   install -d ${D}/usr/lib/system.conf.d
# Set MEMORY_ACCOUNTING_DEFAULT to yes
-   sed -i -e 's/@MEMORY_ACCOUNTING_DEFAULT@/yes/' 
${D}${sysconfdir}/systemd/system.conf
+   echo "DefaultMemoryAccounting=yes" >> 
${D}/usr/lib/system.conf.d/00-${PN}.conf
 
-   install -m 0644 ${S}/src/core/user.conf 
${D}${sysconfdir}/sy

Re: [OE-core] [PATCH v2 3/5] systemd: create preset files instead of installing in image

2019-01-08 Thread Jonas Bonn

Hi Peter,


On 07/01/2019 17:43, Peter Kjellerstedt wrote:

-Original Message-
From: openembedded-core-boun...@lists.openembedded.org  On Behalf Of Jonas Bonn

+def systemd_create_presets(pkg):
+action = get_package_var(d, 'SYSTEMD_AUTO_ENABLE', pkg)
+presetf = oe.path.join(d.getVar("PKGD"), 
"/lib/systemd/system-preset/98-%s.preset" % pkg)


Using "/lib" above does not take into account the usrmerge distro
feature. My suggestion is to use ${nonarch_base_libdir} instead of
/lib, or maybe even better is to use ${systemd_unitdir} instead of
/lib/systemd, i.e.:


Yes.  I already had this fixed up locally but using ${systemd_unitdir} 
is smarter than what I've got so I'll do it that way before resubmitting.


Thanks for the review!
/Jonas
--
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v2 5/5] rootfs-postcommands: call preset-all for read-only-rootfs

2019-01-02 Thread Jonas Bonn
When the rootfs is read-only, we cannot rely on systemd's default
invocation of preset-all at runtime in order to enable services.  As
such, we need to do it at image creation time.

Signed-off-by: Jonas Bonn 
---
 meta/classes/rootfs-postcommands.bbclass | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/meta/classes/rootfs-postcommands.bbclass 
b/meta/classes/rootfs-postcommands.bbclass
index 89f8efd323..5fcd53c4ca 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -16,6 +16,7 @@ ROOTFS_POSTPROCESS_COMMAND += "rootfs_update_timestamp ; "
 
 # Tweak the mount options for rootfs in /etc/fstab if read-only-rootfs is 
enabled
 ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("IMAGE_FEATURES", 
"read-only-rootfs", "read_only_rootfs_hook; ", "",d)}'
+IMAGE_EXTRADEPENDS += '${@bb.utils.contains("IMAGE_FEATURES", 
"read-only-rootfs", "systemd-systemctl-native", "", d)}'
 
 # We also need to do the same for the kernel boot parameters,
 # otherwise kernel or initramfs end up mounting the rootfs read/write
@@ -131,6 +132,7 @@ read_only_rootfs_hook () {
# Create machine-id
# 20:12 < mezcalero> koen: you have three options: a) run 
systemd-machine-id-setup at install time, b) have / read-only and an empty file 
there (for stateless) and c) boot with / writable
touch ${IMAGE_ROOTFS}${sysconfdir}/machine-id
+   systemctl --root=${IMAGE_ROOTFS} preset-all
fi
 }
 
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v2 4/5] systemd-systemctl-native: simplify and support preset-all

2019-01-02 Thread Jonas Bonn
Now that the systemd class sets up service presets instead of actively
enabling services, the 'enable' and 'disable' subcommands for systemctl
are not actually used anywhere.  As such, we can remove these to make
sure that nobody inadvertently introduces new uses of them.

We do, however, one case where the enable/disable machinery is still
required; that is for the read-only-rootfs case where the 'preset-all'
command can not be called at runtime but needs to be called when creatng
the image.  For this case, we implement 'preset-all' here.

There was also a previous implement of 'preset'... not sure that this
ever worked as the implementation looks bogus and there aren't any users
anyway.  This patch removes the 'preset' subcommand, as well.

Signed-off-by: Jonas Bonn 
---
 .../systemd/systemd-systemctl/systemctl   | 36 ---
 1 file changed, 7 insertions(+), 29 deletions(-)

diff --git a/meta/recipes-core/systemd/systemd-systemctl/systemctl 
b/meta/recipes-core/systemd/systemd-systemctl/systemctl
index 2bc6489617..ce50352018 100755
--- a/meta/recipes-core/systemd/systemd-systemctl/systemctl
+++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl
@@ -9,22 +9,6 @@ while [ $# != 0 ]; do
opt="$1"
 
case "$opt" in
-   enable)
-   shift
-
-   action="$opt"
-   services="$1"
-   cmd_args="1"
-   shift
-   ;;
-   disable)
-   shift
-
-   action="$opt"
-   services="$1"
-   cmd_args="1"
-   shift
-   ;;
mask)
shift
 
@@ -33,13 +17,11 @@ while [ $# != 0 ]; do
cmd_args="1"
shift
;;
-   preset)
+   preset-all)
shift
 
action="$opt"
-   services="$1"
-   cmd_args="1"
-   shift
+   cmd_args="0"
;;
--root=*)
ROOT=${opt##--root=}
@@ -57,16 +39,12 @@ while [ $# != 0 ]; do
;;
esac
 done
-if [ "$action" = "preset" -a "$service_file" = "" ]; then
+
+if [ "$action" = "preset-all" ]; then
services=$(for f in `find $ROOT/etc/systemd/system 
$ROOT/lib/systemd/system $ROOT/usr/lib/systemd/system -type f 2>1`; do basename 
$f; done)
-   services="$services $opt"
-   presetall=1
 fi
 
 for service in $services; do
-   if [ "$presetall" = "1" ]; then
-   action="preset"
-   fi
if [ "$action" = "mask" ]; then
if [ ! -d $ROOT/etc/systemd/system/ ]; then
mkdir -p $ROOT/etc/systemd/system/
@@ -105,10 +83,10 @@ for service in $services; do
# If any new unit types are added to systemd they should be added
# to this regular expression.

unit_types_re='\.\(service\|socket\|device\|mount\|automount\|swap\|target\|target\.wants\|path\|timer\|snapshot\)\s*$'
-   if [ "$action" = "preset" ]; then
-   action=`egrep -sh  $service 
$ROOT/etc/systemd/user-preset/*.preset | cut -f1 -d' '`
+   if [ "$action" = "preset-all" ]; then
+   action=`egrep -sh  $service 
$ROOT/usr/lib/systemd/system-preset/*.preset | cut -f1 -d' '`
if [ -z "$action" ]; then
-   globalpreset=`egrep -sh  '\*'  
$ROOT/etc/systemd/user-preset/*.preset | cut -f1 -d' '`
+   globalpreset=`egrep -sh  '\*'  
$ROOT/usr/lib/systemd/system-preset/*.preset | cut -f1 -d' '`
if [ -n "$globalpreset" ]; then
action="$globalpreset"
else
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v2 2/5] systemd-conf: simplify creation of machine-specific configuration

2019-01-02 Thread Jonas Bonn
The configuration files that systemd installs are just skeletons
detailing the available options and their default values.  The
recommended means of changing the configuration is to provide snippets
in configuration directories.  For example, journald.conf settings are
best set in /usr/lib/journald.conf.d/ and can be overridden by the user
by providing overriding snippets in /etc/systemd/journald.conf.d/.

The systemd-conf package is just providing machine-specific overrides
for some systemd defaults.

This patch restores the installation of config files by systemd and
reduces systemd-conf to just providing the config snippets in
/usr/lib/*.conf.d.  This simplfies the systemd-conf recipe considerably
since it now just sets up a couple of text files and doesn't even need
access to the systemd source anymore.

Given, however, that the base configuration files in /etc/systemd have
the lowest priority, they will always be overridden by any snippets.  As
it may confuse a user who is used to modifying these base files
directly, this patch puts symlinks in the overriding
/etc/systemd/*.conf.d/ directories back to the top-level files, thereby
restoring them to their top-level glory.  The default config files
installed by systemd are just lists of (commented out) defaults so this
should be safe.  The symlinks also provide an indication to the user
that there is more to systemd configuration than just the top-level file
and that checking the man page may be in order...

With this patch, systemd gets the right configuration irregardless of
whether /etc is populated at boot or not (i.e. in a "stateless"
system).

License-Update: configuration snippets licensing is independent of
systemd licensing

Signed-off-by: Jonas Bonn 
---
 meta/recipes-core/systemd/systemd-conf.bb | 48 +++
 meta/recipes-core/systemd/systemd_239.bb  | 16 
 2 files changed, 31 insertions(+), 33 deletions(-)

diff --git a/meta/recipes-core/systemd/systemd-conf.bb 
b/meta/recipes-core/systemd/systemd-conf.bb
index 7fe2e1105b..8a9f01c48a 100644
--- a/meta/recipes-core/systemd/systemd-conf.bb
+++ b/meta/recipes-core/systemd/systemd-conf.bb
@@ -1,48 +1,44 @@
-require systemd.inc
-
 SUMMARY = "Systemd system configuration"
 DESCRIPTION = "Systemd may require slightly different configuration for \
 different machines.  For example, qemu machines require a longer \
 DefaultTimeoutStartSec setting."
+LICENSE = "MIT"
 
 PACKAGE_ARCH = "${MACHINE_ARCH}"
 
-CONFFILES_${PN} = "${sysconfdir}/systemd/coredump.conf \
-${sysconfdir}/systemd/journald.conf \
-${sysconfdir}/systemd/logind.conf \
-${sysconfdir}/systemd/system.conf \
-${sysconfdir}/systemd/user.conf"
-
-FILES_${PN} = "${sysconfdir}/systemd"
-
-do_configure[noexec] = '1'
-do_compile[noexec] = '1'
+FILES_${PN} = "/usr/lib/journald.conf.d/* \
+   /usr/lib/logind.conf.d/* \
+   /usr/lib/system.conf.d/* \
+   /etc/systemd/* \
+"
 
 do_install() {
-   rm -rf ${D}/${sysconfdir}/systemd
-   install -d ${D}/${sysconfdir}/systemd
-
-   install -m 0644 ${S}/src/coredump/coredump.conf 
${D}${sysconfdir}/systemd/coredump.conf
-
-   install -m 0644 ${S}/src/journal/journald.conf 
${D}${sysconfdir}/systemd/journald.conf
+   install -d ${D}/usr/lib/journald.conf.d
# Enable journal to forward message to syslog daemon
-   sed -i -e 's/.*ForwardToSyslog.*/ForwardToSyslog=yes/' 
${D}${sysconfdir}/systemd/journald.conf
+   echo "ForwardToSyslog=yes" >> ${D}/usr/lib/journald.conf.d/00-${PN}.conf
# Set the maximium size of runtime journal to 64M as default
-   sed -i -e 's/.*RuntimeMaxUse.*/RuntimeMaxUse=64M/' 
${D}${sysconfdir}/systemd/journald.conf
+   echo "RuntimeMaxUse=64M" >> ${D}/usr/lib/journald.conf.d/00-${PN}.conf
+
+   install -d ${D}${sysconfdir}/systemd/journald.conf.d
+   ln -s ../journald.conf 
${D}${sysconfdir}/systemd/journald.conf.d/00-${PN}.conf
 
-   install -m 0644 ${S}/src/login/logind.conf.in 
${D}${sysconfdir}/systemd/logind.conf
+   install -d ${D}/usr/lib/logind.conf.d
# Set KILL_USER_PROCESSES to yes
-   sed -i -e 's/@KILL_USER_PROCESSES@/yes/' 
${D}${sysconfdir}/systemd/logind.conf
+   echo "KillUserProcesses=yes" >> ${D}/usr/lib/logind.conf.d/00-${PN}.conf
+
+   install -d ${D}${sysconfdir}/systemd/logind.conf.d
+   ln -s ../logind.conf 
${D}${sysconfdir}/systemd/logind.conf.d/00-${PN}.conf
 
-   install -m 0644 ${S}/src/core/system.conf.in 
${D}${sysconfdir}/systemd/system.conf
+   install -d ${D}/usr/lib/system.conf.d
# Set MEMORY_ACCOUNTING_DEFAULT to yes
-   sed -i -e 's/@MEMORY_ACCOUNTING_DEFAULT@/yes/' 
${D}${sysconfdir}/systemd/system.conf
+   echo "DefaultMemoryAccounting=yes" >> 
${D}/usr/lib/system.conf.d/00-${PN}.conf
 
-   install -m 0644 ${S}/src/core/user.conf 
${D}${sysconfdir}/sy

[OE-core] [PATCH v2 1/5] systemd: do not create machine-id

2019-01-02 Thread Jonas Bonn
There is no reason to have an emtpy machine-id as part of the systemd
package.  Either:

i)  the filesystem is writable and the file will be created
automatically; or
ii) the filesystem is read-only, in which case the empty machine-id file
should be created as part of the read-only-rootfs tweaks.

Signed-off-by: Jonas Bonn 
---
 meta/classes/rootfs-postcommands.bbclass  | 6 ++
 meta/recipes-core/systemd/systemd-conf.bb | 9 ++---
 meta/recipes-core/systemd/systemd_239.bb  | 1 -
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/meta/classes/rootfs-postcommands.bbclass 
b/meta/classes/rootfs-postcommands.bbclass
index bde58ad6cd..89f8efd323 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -126,6 +126,12 @@ read_only_rootfs_hook () {
${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh
fi
fi
+
+   if ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "true", "false", 
d)}; then
+   # Create machine-id
+   # 20:12 < mezcalero> koen: you have three options: a) run 
systemd-machine-id-setup at install time, b) have / read-only and an empty file 
there (for stateless) and c) boot with / writable
+   touch ${IMAGE_ROOTFS}${sysconfdir}/machine-id
+   fi
 }
 
 #
diff --git a/meta/recipes-core/systemd/systemd-conf.bb 
b/meta/recipes-core/systemd/systemd-conf.bb
index 9bb27fd96d..7fe2e1105b 100644
--- a/meta/recipes-core/systemd/systemd-conf.bb
+++ b/meta/recipes-core/systemd/systemd-conf.bb
@@ -7,14 +7,13 @@ DefaultTimeoutStartSec setting."
 
 PACKAGE_ARCH = "${MACHINE_ARCH}"
 
-CONFFILES_${PN} = "${sysconfdir}/machine-id \
-${sysconfdir}/systemd/coredump.conf \
+CONFFILES_${PN} = "${sysconfdir}/systemd/coredump.conf \
 ${sysconfdir}/systemd/journald.conf \
 ${sysconfdir}/systemd/logind.conf \
 ${sysconfdir}/systemd/system.conf \
 ${sysconfdir}/systemd/user.conf"
 
-FILES_${PN} = "${sysconfdir}/machine-id ${sysconfdir}/systemd"
+FILES_${PN} = "${sysconfdir}/systemd"
 
 do_configure[noexec] = '1'
 do_compile[noexec] = '1'
@@ -23,10 +22,6 @@ do_install() {
rm -rf ${D}/${sysconfdir}/systemd
install -d ${D}/${sysconfdir}/systemd
 
-   # Create machine-id
-   # 20:12 < mezcalero> koen: you have three options: a) run 
systemd-machine-id-setup at install time, b) have / read-only and an empty file 
there (for stateless) and c) boot with / writable
-   touch ${D}${sysconfdir}/machine-id
-
install -m 0644 ${S}/src/coredump/coredump.conf 
${D}${sysconfdir}/systemd/coredump.conf
 
install -m 0644 ${S}/src/journal/journald.conf 
${D}${sysconfdir}/systemd/journald.conf
diff --git a/meta/recipes-core/systemd/systemd_239.bb 
b/meta/recipes-core/systemd/systemd_239.bb
index 03acce25b7..0bb3276bf1 100644
--- a/meta/recipes-core/systemd/systemd_239.bb
+++ b/meta/recipes-core/systemd/systemd_239.bb
@@ -286,7 +286,6 @@ do_install() {
fi
 
# conf files are handled by systemd-conf
-   rm -f ${D}${sysconfdir}/machine-id
rm -f ${D}${sysconfdir}/systemd/coredump.conf
rm -f ${D}${sysconfdir}/systemd/journald.conf
rm -f ${D}${sysconfdir}/systemd/logind.conf
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v2 0/5] systemd patches

2019-01-02 Thread Jonas Bonn
Changed in v2:
- address patchtest warnings:
  - include sign-offs on patches
  - include License-Update tag on patch that makes licensing change
- dropped patch implementing brute-force removal of unit files installed
  by systemd into /etc
- reworked the systemd-conf patch to restore the installation of the
  base systemd configuration files


**

These patches make some modifications to systemd with the long-term goal
of being able to run OE in systemd's "stateless" configuration.
"Stateless" boils down to building an image with empty /etc and /var
directories so that volatile (tmpfs) filesystems can be mounted there;
this requires that the system subsequently be able to populate these
directories dynamically, which systemd mostly takes care of if things
are done right.

In these patches:
i)Don't include machine-id in writable images so that systemd can run
its first-boot machinery
ii)   Move systemd configuration files out of /etc
iii)  Allow systemd to dynamically enable services and populate
/etc/systemd/system via the presets mechanism

There's a long way to go to get to a working "stateless" configuration.
Getting to a "volatile" system (just empty /var) should be easier and
I'll post patches moving things in that direction shortly.

/Jonas

Jonas Bonn (5):
  systemd: do not create machine-id
  systemd-conf: simplify creation of machine-specific configuration
  systemd: create preset files instead of installing in image
  systemd-systemctl-native: simplify and support preset-all
  rootfs-postcommands: call preset-all for read-only-rootfs

 meta/classes/rootfs-postcommands.bbclass  |  8 +++
 meta/classes/systemd.bbclass  | 33 ++--
 meta/recipes-core/systemd/systemd-conf.bb | 53 ---
 .../systemd/systemd-systemctl/systemctl   | 36 +++--
 meta/recipes-core/systemd/systemd_239.bb  | 17 +++---
 5 files changed, 62 insertions(+), 85 deletions(-)

-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v2 3/5] systemd: create preset files instead of installing in image

2019-01-02 Thread Jonas Bonn
At first boot, systemd will create the /etc/systemd/system directory
from service preset files.  As such, for a normal, writable /etc
(writable rootfs), there is no need to set up this directory at image
creation time.

This patch changes the systemd machinery to create preset files and to
rely on systemd to do the service enablement.

This breaks the read-only-rootfs case; there's a fix for this in a
follow-up patch.

Signed-off-by: Jonas Bonn 
---
 meta/classes/systemd.bbclass | 33 -
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/meta/classes/systemd.bbclass b/meta/classes/systemd.bbclass
index c7b784dea8..cf3b5de4a1 100644
--- a/meta/classes/systemd.bbclass
+++ b/meta/classes/systemd.bbclass
@@ -16,43 +16,32 @@ python __anonymous() {
 # from doing any work so that pure-systemd images don't have redundant init
 # files.
 if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d):
-d.appendVar("DEPENDS", " systemd-systemctl-native")
-d.appendVar("PACKAGE_WRITE_DEPS", " systemd-systemctl-native")
 if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, 
d):
 d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1")
 }
 
 systemd_postinst() {
-OPTS=""
-
 if [ -n "$D" ]; then
-OPTS="--root=$D"
+   exit 0
 fi
 
 if type systemctl >/dev/null 2>/dev/null; then
-   if [ -z "$D" ]; then
-   systemctl daemon-reload
-   fi
-
-   systemctl $OPTS ${SYSTEMD_AUTO_ENABLE} ${SYSTEMD_SERVICE_ESCAPED}
+   systemctl daemon-reload
+   systemctl preset ${SYSTEMD_SERVICE_ESCAPED}
 
-   if [ -z "$D" -a "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
+   if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
systemctl --no-block restart ${SYSTEMD_SERVICE_ESCAPED}
fi
 fi
 }
 
 systemd_prerm() {
-OPTS=""
-
 if [ -n "$D" ]; then
-OPTS="--root=$D"
+   exit 0
 fi
 
 if type systemctl >/dev/null 2>/dev/null; then
-   if [ -z "$D" ]; then
-   systemctl stop ${SYSTEMD_SERVICE_ESCAPED}
-   fi
+   systemctl stop ${SYSTEMD_SERVICE_ESCAPED}
 
systemctl $OPTS disable ${SYSTEMD_SERVICE_ESCAPED}
 fi
@@ -177,12 +166,22 @@ python systemd_populate_packages() {
 else:
 bb.fatal("SYSTEMD_SERVICE_%s value %s does not exist" % 
(pkg_systemd, service))
 
+def systemd_create_presets(pkg):
+action = get_package_var(d, 'SYSTEMD_AUTO_ENABLE', pkg)
+presetf = oe.path.join(d.getVar("PKGD"), 
"/lib/systemd/system-preset/98-%s.preset" % pkg)
+bb.utils.mkdirhier(os.path.dirname(presetf))
+with open(presetf, 'a') as fd:
+for service in d.getVar('SYSTEMD_SERVICE_%s' % pkg).split():
+fd.write("%s %s\n" % (action,service))
+d.appendVar("FILES_%s" % pkg, " 
/lib/systemd/system-preset/98-%s.preset" % pkg)
+
 # Run all modifications once when creating package
 if os.path.exists(d.getVar("D")):
 for pkg in d.getVar('SYSTEMD_PACKAGES').split():
 systemd_check_package(pkg)
 if d.getVar('SYSTEMD_SERVICE_' + pkg):
 systemd_generate_package_scripts(pkg)
+systemd_create_presets(pkg)
 systemd_check_services()
 }
 
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH 0/7] systemd patches

2019-01-02 Thread Jonas Bonn




On 02/01/2019 08:58, ChenQi wrote:

Hi Jonas,


Cleaning up systemd's /etc files while leaving other softwares requiring 
/etc files is not that pleasant. At a minimum, systemd users who are not 
aware of this 'stateless' concept would be confused. "Where's my 
/etc/systemd/system.conf file?!" They would ask.


How about this:

In order to support both the "stateless" variant where /etc/systemd does 
not exist and the current situation where we have only the 
(low-priority) top-level configuration files, we could do this:


i)  Let systemd install its unmodified config files into /etc/systemd
ii)  Provide configuration snippets in /usr/lib/*.conf.d
iii)  Provide the overriding configuration snippet directories in /etc 
with symlinks back up to the toplevel file, making the toplevel file 
relevant again in case somebody is modifying it directly.  i.e.:


/etc/systemd/journald.conf
/etc/systemd/journald.conf.d/00-systemd-conf.conf -> ../journald.conf

The important thing to get right here is to give the user an indication 
that he should actually be putting stuff into the conf.d/ directory... 
if they see that the directory exists they may go read the man page and 
understand how these files are stacked.


Thoughts?

/Jonas


So I'd suggest using something like 'stateless' DISTRO_FEATURE (just 
like 'usrmerge') to control each recipe's behavior.


Best Regards,
Chen Qi

--
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH 7/7] systemd: do not pre-enable services, rely on presets

2019-01-02 Thread Jonas Bonn

Hi Alex,

On 02/01/2019 13:06, Alexander Kanavin wrote:

On Mon, 31 Dec 2018 at 13:07, Jonas Bonn  wrote:

diff --git a/meta/recipes-core/systemd/systemd_239.bb 
b/meta/recipes-core/systemd/systemd_239.bb
index 70e687c92e..7b4c5c56aa 100644
--- a/meta/recipes-core/systemd/systemd_239.bb
+++ b/meta/recipes-core/systemd/systemd_239.bb
@@ -298,6 +298,8 @@ do_install() {
 # duplicate udevadm for postinst script
 install -d ${D}${libexecdir}
 ln ${D}${base_bindir}/udevadm ${D}${libexecdir}/${MLPREFIX}udevadm
+
+   rm -rf ${D}${sysconfdir}/systemd/system
  }


Apologies, but this is a hack. You need to tell systemd to not install
the files in the first place, if they are unneeded, instead of
removing them after the fact, which is a maintainability issue
(specifically, anyone looking at the recipe would be totally puzzled
by this removal).

If systemd always installs the files, you should add a configure
option, and send the patch upstream *first*.


Leaving these installed is not a big deal, either.  It's just inelegant 
to leave them there if one is over-mounting /etc with a tmpfs at runtime.


I think this patch is wrong for other reasons, however.  Since there are 
no SYSTEMD_SERVICE_ entries for these .service files in the recipe, they 
probably won't be handled correctly if the systemd package is 
upgraded... the implications are a bit fuzzy, whether or not it matters.


Thanks for looking at this.

/Jonas




Alex


--
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH 0/7] systemd patches

2019-01-02 Thread Jonas Bonn

Hi Chen,

Thanks for looking at this.

On 02/01/2019 08:58, ChenQi wrote:

Hi Jonas,

I'd like to talk about this patchset from a non-technical view.
And to be brief, my conclusion is suggesting using some switch, e.g. 
DISTRO_FEATURE, to control this 'stateless' behavior.

Please see details below.


OK, I agree, and this is part of the plan.  The patches in this set, 
however, are independent of whether or not the user wants a "stateless" 
system or not.  (My primary requirement is actually a "volatile" system, 
with just an empty /var, but the two go hand in hand so working towards 
"stateless" at the same time as "volatile" seems reasonable).




This patchset is based on two assumptions:
1) Users would generally want 'stateless' system. Or in other words, 
they would prefer 'stateless' more than 'stateful'.
2) Other softwares/upstreams are also working against this 'stateless' 
goal.


 From the current situation, both are not that true. As your [PATCH 7/7] 
points out, even systemd defaults to install things under /etc.


Cleaning up systemd's /etc files while leaving other softwares requiring 
/etc files is not that pleasant. At a minimum, systemd users who are not 
aware of this 'stateless' concept would be confused. "Where's my 
/etc/systemd/system.conf file?!" They would ask.


If providing the "example" configuration file that systemd installs is 
necessary, then I think it would be better to provide it at:


/etc/systemd/system.conf.d/00-systemd-conf.conf

If the user edits that file, it at least overrides the "system" version 
at /usr/lib/system.conf.d/.  The toplevel file at 
/etc/systemd/system.conf has the lowest priority so editing it does not 
actually override the systemd settings under /usr.


But this is all unrelated to "stateless".  This is mostly a matter of 
getting "distro" configuration out of /etc which _allows for_ stateless 
down the road, if we want.



So I'd suggest using something like 'stateless' DISTRO_FEATURE (just 
like 'usrmerge') to control each recipe's behavior.


So, just to outline how "volatile" and "stateless" should work:

i)  The user selects "volatile"
ii)  There may then not be any directories, links, or files under /var
iii)  For directories and links, we need to create entries in 
tmpfiles.d/ so that they get created at boot
iv)  For files under /var, we need to move them to 
/usr/share/factory/var and create entries under tmpfiles.d/


v)  The same applies, roughly, to "stateless", replacing /var by /etc

I've got all this working with some fixups to the packaging and image 
classes and "volatile" works fine if one does the above.  The proper 
cleanup that OE needs to do, however, is to actually minimize the 
content installed in the /var and /etc by the packages in favour of 
tmpfiles and volatiles where possible.


"stateless" is trickier due to needing to handle users, etc., but we'll 
get there.


But please don't get hung up on the "stateless" aspect of things when 
looking at this patch series.  These systemd patches are independent of 
whether or not that is the goal.


/Jonas




Best Regards,
Chen Qi

On 12/31/2018 08:05 PM, Jonas Bonn wrote:

These patches make some modifications to systemd with the long-term goal
of being able to run OE in systemd's "stateless" configuration.
"Stateless" boils down to building an image with empty /etc and /var
directories so that volatile (tmpfs) filesystems can be mounted there;
this requires that the system subsequently be able to populate these
directories dynamically, which systemd mostly takes care of if things
are done right.

In these patches:
i)    Don't include machine-id in writable images so that systemd can run
its first-boot machinery
ii)   Move systemd configuration files out of /etc
iii)  Allow systemd to dynamically enable services and populate
/etc/systemd/system via the presets mechanism

There's a long way to go to get to a working "stateless" configuration.
Getting to a "volatile" system (just empty /var) should be easier and
I'll post patches moving things in that direction shortly.

/Jonas

Jonas Bonn (7):
   systemd: do not create machine-id
   systemd-conf: simplify creation of configuration
   systemd: move additional conffiles to systemd-conf
   systemd: create preset files instead of installing in image
   systemd-systemctl-native: simplify and support preset-all
   rootfs-postcommands: call preset-all for read-only-rootfs
   systemd: do not pre-enable services, rely on presets

  meta/classes/rootfs-postcommands.bbclass  |  8 
  meta/classes/systemd.bbclass  | 33 +++---
  meta/recipes-core/systemd/systemd-conf.bb | 45 +++
  .../systemd/systemd-systemctl/systemctl   | 36 +++
  meta/recipes-core/systemd/systemd_239.

Re: [OE-core] [PATCH 2/7] systemd-conf: simplify creation of configuration

2019-01-01 Thread Jonas Bonn

Hi Randy,

Thanks for looking at this.

On 01/01/2019 16:29, Randy MacLeod wrote:

On 12/31/18 7:05 AM, Jonas Bonn wrote:

The configuration files that systemd installs are just skeletons
detailing the available options and their default values.  The
recommended means of changing the configuration is to provide snippets
in configuration directories.  For example, journald.conf settings are
best set in /usr/lib/journald.conf.d/ and can be overridden by the user
by providing overriding snippets in /etc/systemd/journald.conf.d/.

The base configuration files have the lowest priority; they will always
be overridden by any snippets.  As such, it's probably best to not
provide them at all.  This also moves us a step closer to an empty /etc
which is should be a long term goal in order to allow running OE as a
"stateless system".

This patch moves the systemd configuration to snippets in
/usr/lib/*.conf.d.  This simplifies the recipe considerably since it now
just sets up a couple of text files and doesn't even need access to the
systemd source anymore.
---
  meta/recipes-core/systemd/systemd-conf.bb | 34 +--
  1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/meta/recipes-core/systemd/systemd-conf.bb 
b/meta/recipes-core/systemd/systemd-conf.bb

index 7fe2e1105b..a504afe3e7 100644
--- a/meta/recipes-core/systemd/systemd-conf.bb
+++ b/meta/recipes-core/systemd/systemd-conf.bb
@@ -1,9 +1,8 @@
-require systemd.inc
-
  SUMMARY = "Systemd system configuration"
  DESCRIPTION = "Systemd may require slightly different configuration 
for \

  different machines.  For example, qemu machines require a longer \
  DefaultTimeoutStartSec setting."
+LICENSE = "GPLv2"


Systemd claims that these conf files are: LGPLv2.1+ licensed.


The configuration files from systemd may be LGPLv2 licensed, but this 
package now only creates some configuration snippets which are 
independent of systemd (it's just data, now).  As such, one could 
certainly put whatever license one wanted on this.  Honestly, GPLv2 is 
probably a stretch... I can hardly see that any license applies to this, 
to be honest.  Consider that:


/usr/lib/journald.conf.d/systemd-conf.conf

contains

ForwardToSyslog=yes
RuntimeMaxUse=64M

Just configuration data that the package creates dynamically.



https://github.com/systemd/systemd/blob/master/sysusers.d/systemd.conf.m4

https://github.com/systemd/systemd/blob/master/modprobe.d/systemd.conf


  PACKAGE_ARCH = "${MACHINE_ARCH}"
@@ -13,36 +12,29 @@ ${sysconfdir}/systemd/logind.conf \
  ${sysconfdir}/systemd/system.conf \
  ${sysconfdir}/systemd/user.conf"
-FILES_${PN} = "${sysconfdir}/systemd"
-
-do_configure[noexec] = '1'
-do_compile[noexec] = '1'
+FILES_${PN} = "/usr/lib/journald.conf.d/* \
+/usr/lib/logind.conf.d/* \
+/usr/lib/system.conf.d/* \
+"
  do_install() {
-    rm -rf ${D}/${sysconfdir}/systemd
-    install -d ${D}/${sysconfdir}/systemd
-
-    install -m 0644 ${S}/src/coredump/coredump.conf 
${D}${sysconfdir}/systemd/coredump.conf

-
-    install -m 0644 ${S}/src/journal/journald.conf 
${D}${sysconfdir}/systemd/journald.conf

+    install -d ${D}/usr/lib/journald.conf.d


Should the recipe use /usr/lib or is / should there be a
'systemdconfdir' var?


So, I looked into the systemd source and, as far as I can see, it seems 
that systemd hardcodes the paths to configuration files, tmpfiles, 
presets, etc.  It's all really /usr/lib/... with no method of specifying 
any other location.  For this reason, I've used these explicit paths 
above, strange though it may appear...


/Jonas
--
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 5/7] systemd-systemctl-native: simplify and support preset-all

2018-12-31 Thread Jonas Bonn
Now that the systemd class sets up service presets instead of actively
enabling services, the 'enable' and 'disable' subcommands for systemctl
are not actually used anywhere.  As such, we can remove these to make
sure that nobody inadvertently introduces new uses of them.

We do, however, one case where the enable/disable machinery is still
required; that is for the read-only-rootfs case where the 'preset-all'
command can not be called at runtime but needs to be called when creatng
the image.  For this case, we implement 'preset-all' here.

There was also a previous implement of 'preset'... not sure that this
ever worked as the implementation looks bogus and there aren't any users
anyway.  This patch removes the 'preset' subcommand, as well.
---
 .../systemd/systemd-systemctl/systemctl   | 36 ---
 1 file changed, 7 insertions(+), 29 deletions(-)

diff --git a/meta/recipes-core/systemd/systemd-systemctl/systemctl 
b/meta/recipes-core/systemd/systemd-systemctl/systemctl
index 2bc6489617..ce50352018 100755
--- a/meta/recipes-core/systemd/systemd-systemctl/systemctl
+++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl
@@ -9,22 +9,6 @@ while [ $# != 0 ]; do
opt="$1"
 
case "$opt" in
-   enable)
-   shift
-
-   action="$opt"
-   services="$1"
-   cmd_args="1"
-   shift
-   ;;
-   disable)
-   shift
-
-   action="$opt"
-   services="$1"
-   cmd_args="1"
-   shift
-   ;;
mask)
shift
 
@@ -33,13 +17,11 @@ while [ $# != 0 ]; do
cmd_args="1"
shift
;;
-   preset)
+   preset-all)
shift
 
action="$opt"
-   services="$1"
-   cmd_args="1"
-   shift
+   cmd_args="0"
;;
--root=*)
ROOT=${opt##--root=}
@@ -57,16 +39,12 @@ while [ $# != 0 ]; do
;;
esac
 done
-if [ "$action" = "preset" -a "$service_file" = "" ]; then
+
+if [ "$action" = "preset-all" ]; then
services=$(for f in `find $ROOT/etc/systemd/system 
$ROOT/lib/systemd/system $ROOT/usr/lib/systemd/system -type f 2>1`; do basename 
$f; done)
-   services="$services $opt"
-   presetall=1
 fi
 
 for service in $services; do
-   if [ "$presetall" = "1" ]; then
-   action="preset"
-   fi
if [ "$action" = "mask" ]; then
if [ ! -d $ROOT/etc/systemd/system/ ]; then
mkdir -p $ROOT/etc/systemd/system/
@@ -105,10 +83,10 @@ for service in $services; do
# If any new unit types are added to systemd they should be added
# to this regular expression.

unit_types_re='\.\(service\|socket\|device\|mount\|automount\|swap\|target\|target\.wants\|path\|timer\|snapshot\)\s*$'
-   if [ "$action" = "preset" ]; then
-   action=`egrep -sh  $service 
$ROOT/etc/systemd/user-preset/*.preset | cut -f1 -d' '`
+   if [ "$action" = "preset-all" ]; then
+   action=`egrep -sh  $service 
$ROOT/usr/lib/systemd/system-preset/*.preset | cut -f1 -d' '`
if [ -z "$action" ]; then
-   globalpreset=`egrep -sh  '\*'  
$ROOT/etc/systemd/user-preset/*.preset | cut -f1 -d' '`
+   globalpreset=`egrep -sh  '\*'  
$ROOT/usr/lib/systemd/system-preset/*.preset | cut -f1 -d' '`
if [ -n "$globalpreset" ]; then
action="$globalpreset"
else
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 4/7] systemd: create preset files instead of installing in image

2018-12-31 Thread Jonas Bonn
At first boot, systemd will create the /etc/systemd/system directory
from service preset files.  As such, for a normal, writable /etc
(writable rootfs), there is no need to set up this directory at image
creation time.

This patch changes the systemd machinery to create preset files and to
rely on systemd to do the service enablement.

This breaks the read-only-rootfs case; there's a fix for this in a
follow-up patch.
---
 meta/classes/systemd.bbclass | 33 -
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/meta/classes/systemd.bbclass b/meta/classes/systemd.bbclass
index c7b784dea8..cf3b5de4a1 100644
--- a/meta/classes/systemd.bbclass
+++ b/meta/classes/systemd.bbclass
@@ -16,43 +16,32 @@ python __anonymous() {
 # from doing any work so that pure-systemd images don't have redundant init
 # files.
 if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d):
-d.appendVar("DEPENDS", " systemd-systemctl-native")
-d.appendVar("PACKAGE_WRITE_DEPS", " systemd-systemctl-native")
 if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, 
d):
 d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1")
 }
 
 systemd_postinst() {
-OPTS=""
-
 if [ -n "$D" ]; then
-OPTS="--root=$D"
+   exit 0
 fi
 
 if type systemctl >/dev/null 2>/dev/null; then
-   if [ -z "$D" ]; then
-   systemctl daemon-reload
-   fi
-
-   systemctl $OPTS ${SYSTEMD_AUTO_ENABLE} ${SYSTEMD_SERVICE_ESCAPED}
+   systemctl daemon-reload
+   systemctl preset ${SYSTEMD_SERVICE_ESCAPED}
 
-   if [ -z "$D" -a "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
+   if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
systemctl --no-block restart ${SYSTEMD_SERVICE_ESCAPED}
fi
 fi
 }
 
 systemd_prerm() {
-OPTS=""
-
 if [ -n "$D" ]; then
-OPTS="--root=$D"
+   exit 0
 fi
 
 if type systemctl >/dev/null 2>/dev/null; then
-   if [ -z "$D" ]; then
-   systemctl stop ${SYSTEMD_SERVICE_ESCAPED}
-   fi
+   systemctl stop ${SYSTEMD_SERVICE_ESCAPED}
 
systemctl $OPTS disable ${SYSTEMD_SERVICE_ESCAPED}
 fi
@@ -177,12 +166,22 @@ python systemd_populate_packages() {
 else:
 bb.fatal("SYSTEMD_SERVICE_%s value %s does not exist" % 
(pkg_systemd, service))
 
+def systemd_create_presets(pkg):
+action = get_package_var(d, 'SYSTEMD_AUTO_ENABLE', pkg)
+presetf = oe.path.join(d.getVar("PKGD"), 
"/lib/systemd/system-preset/98-%s.preset" % pkg)
+bb.utils.mkdirhier(os.path.dirname(presetf))
+with open(presetf, 'a') as fd:
+for service in d.getVar('SYSTEMD_SERVICE_%s' % pkg).split():
+fd.write("%s %s\n" % (action,service))
+d.appendVar("FILES_%s" % pkg, " 
/lib/systemd/system-preset/98-%s.preset" % pkg)
+
 # Run all modifications once when creating package
 if os.path.exists(d.getVar("D")):
 for pkg in d.getVar('SYSTEMD_PACKAGES').split():
 systemd_check_package(pkg)
 if d.getVar('SYSTEMD_SERVICE_' + pkg):
 systemd_generate_package_scripts(pkg)
+systemd_create_presets(pkg)
 systemd_check_services()
 }
 
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 6/7] rootfs-postcommands: call preset-all for read-only-rootfs

2018-12-31 Thread Jonas Bonn
When the rootfs is read-only, we cannot rely on systemd's default
invocation of preset-all at runtime in order to enable services.  As
such, we need to do it at image creation time.
---
 meta/classes/rootfs-postcommands.bbclass | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/meta/classes/rootfs-postcommands.bbclass 
b/meta/classes/rootfs-postcommands.bbclass
index 89f8efd323..5fcd53c4ca 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -16,6 +16,7 @@ ROOTFS_POSTPROCESS_COMMAND += "rootfs_update_timestamp ; "
 
 # Tweak the mount options for rootfs in /etc/fstab if read-only-rootfs is 
enabled
 ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("IMAGE_FEATURES", 
"read-only-rootfs", "read_only_rootfs_hook; ", "",d)}'
+IMAGE_EXTRADEPENDS += '${@bb.utils.contains("IMAGE_FEATURES", 
"read-only-rootfs", "systemd-systemctl-native", "", d)}'
 
 # We also need to do the same for the kernel boot parameters,
 # otherwise kernel or initramfs end up mounting the rootfs read/write
@@ -131,6 +132,7 @@ read_only_rootfs_hook () {
# Create machine-id
# 20:12 < mezcalero> koen: you have three options: a) run 
systemd-machine-id-setup at install time, b) have / read-only and an empty file 
there (for stateless) and c) boot with / writable
touch ${IMAGE_ROOTFS}${sysconfdir}/machine-id
+   systemctl --root=${IMAGE_ROOTFS} preset-all
fi
 }
 
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 7/7] systemd: do not pre-enable services, rely on presets

2018-12-31 Thread Jonas Bonn
At installation, systemd _both_ installs preset files for its services
and enables the services accordingly (effectively, calling 'systemctl
preset-all' on its own services).  As we now rely on systemd calling
preset-all at first boot, there's no need to carry the pre-populated
/etc/systemd/system directory in the package.

This gets us a step closer to en empty /etc which is a requirement for
running a "stateless system".
---
 meta/recipes-core/systemd/systemd_239.bb | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/meta/recipes-core/systemd/systemd_239.bb 
b/meta/recipes-core/systemd/systemd_239.bb
index 70e687c92e..7b4c5c56aa 100644
--- a/meta/recipes-core/systemd/systemd_239.bb
+++ b/meta/recipes-core/systemd/systemd_239.bb
@@ -298,6 +298,8 @@ do_install() {
# duplicate udevadm for postinst script
install -d ${D}${libexecdir}
ln ${D}${base_bindir}/udevadm ${D}${libexecdir}/${MLPREFIX}udevadm
+
+   rm -rf ${D}${sysconfdir}/systemd/system
 }
 
 
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 0/7] systemd patches

2018-12-31 Thread Jonas Bonn
These patches make some modifications to systemd with the long-term goal
of being able to run OE in systemd's "stateless" configuration.
"Stateless" boils down to building an image with empty /etc and /var
directories so that volatile (tmpfs) filesystems can be mounted there;
this requires that the system subsequently be able to populate these
directories dynamically, which systemd mostly takes care of if things
are done right.

In these patches:
i)Don't include machine-id in writable images so that systemd can run
its first-boot machinery
ii)   Move systemd configuration files out of /etc
iii)  Allow systemd to dynamically enable services and populate
/etc/systemd/system via the presets mechanism

There's a long way to go to get to a working "stateless" configuration.
Getting to a "volatile" system (just empty /var) should be easier and
I'll post patches moving things in that direction shortly.

/Jonas

Jonas Bonn (7):
  systemd: do not create machine-id
  systemd-conf: simplify creation of configuration
  systemd: move additional conffiles to systemd-conf
  systemd: create preset files instead of installing in image
  systemd-systemctl-native: simplify and support preset-all
  rootfs-postcommands: call preset-all for read-only-rootfs
  systemd: do not pre-enable services, rely on presets

 meta/classes/rootfs-postcommands.bbclass  |  8 
 meta/classes/systemd.bbclass  | 33 +++---
 meta/recipes-core/systemd/systemd-conf.bb | 45 +++
 .../systemd/systemd-systemctl/systemctl   | 36 +++
 meta/recipes-core/systemd/systemd_239.bb  |  4 ++
 5 files changed, 52 insertions(+), 74 deletions(-)

-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 1/7] systemd: do not create machine-id

2018-12-31 Thread Jonas Bonn
There is no reason to have an emtpy machine-id as part of the systemd
package.  Either:

i)  the filesystem is writable and the file will be created
automatically; or
ii) the filesystem is read-only, in which case the empty machine-id file
should be created as part of the read-only-rootfs tweaks.
---
 meta/classes/rootfs-postcommands.bbclass  | 6 ++
 meta/recipes-core/systemd/systemd-conf.bb | 9 ++---
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/meta/classes/rootfs-postcommands.bbclass 
b/meta/classes/rootfs-postcommands.bbclass
index bde58ad6cd..89f8efd323 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -126,6 +126,12 @@ read_only_rootfs_hook () {
${IMAGE_ROOTFS}/etc/init.d/populate-volatile.sh
fi
fi
+
+   if ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "true", "false", 
d)}; then
+   # Create machine-id
+   # 20:12 < mezcalero> koen: you have three options: a) run 
systemd-machine-id-setup at install time, b) have / read-only and an empty file 
there (for stateless) and c) boot with / writable
+   touch ${IMAGE_ROOTFS}${sysconfdir}/machine-id
+   fi
 }
 
 #
diff --git a/meta/recipes-core/systemd/systemd-conf.bb 
b/meta/recipes-core/systemd/systemd-conf.bb
index 9bb27fd96d..7fe2e1105b 100644
--- a/meta/recipes-core/systemd/systemd-conf.bb
+++ b/meta/recipes-core/systemd/systemd-conf.bb
@@ -7,14 +7,13 @@ DefaultTimeoutStartSec setting."
 
 PACKAGE_ARCH = "${MACHINE_ARCH}"
 
-CONFFILES_${PN} = "${sysconfdir}/machine-id \
-${sysconfdir}/systemd/coredump.conf \
+CONFFILES_${PN} = "${sysconfdir}/systemd/coredump.conf \
 ${sysconfdir}/systemd/journald.conf \
 ${sysconfdir}/systemd/logind.conf \
 ${sysconfdir}/systemd/system.conf \
 ${sysconfdir}/systemd/user.conf"
 
-FILES_${PN} = "${sysconfdir}/machine-id ${sysconfdir}/systemd"
+FILES_${PN} = "${sysconfdir}/systemd"
 
 do_configure[noexec] = '1'
 do_compile[noexec] = '1'
@@ -23,10 +22,6 @@ do_install() {
rm -rf ${D}/${sysconfdir}/systemd
install -d ${D}/${sysconfdir}/systemd
 
-   # Create machine-id
-   # 20:12 < mezcalero> koen: you have three options: a) run 
systemd-machine-id-setup at install time, b) have / read-only and an empty file 
there (for stateless) and c) boot with / writable
-   touch ${D}${sysconfdir}/machine-id
-
install -m 0644 ${S}/src/coredump/coredump.conf 
${D}${sysconfdir}/systemd/coredump.conf
 
install -m 0644 ${S}/src/journal/journald.conf 
${D}${sysconfdir}/systemd/journald.conf
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 2/7] systemd-conf: simplify creation of configuration

2018-12-31 Thread Jonas Bonn
The configuration files that systemd installs are just skeletons
detailing the available options and their default values.  The
recommended means of changing the configuration is to provide snippets
in configuration directories.  For example, journald.conf settings are
best set in /usr/lib/journald.conf.d/ and can be overridden by the user
by providing overriding snippets in /etc/systemd/journald.conf.d/.

The base configuration files have the lowest priority; they will always
be overridden by any snippets.  As such, it's probably best to not
provide them at all.  This also moves us a step closer to an empty /etc
which is should be a long term goal in order to allow running OE as a
"stateless system".

This patch moves the systemd configuration to snippets in
/usr/lib/*.conf.d.  This simplifies the recipe considerably since it now
just sets up a couple of text files and doesn't even need access to the
systemd source anymore.
---
 meta/recipes-core/systemd/systemd-conf.bb | 34 +--
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/meta/recipes-core/systemd/systemd-conf.bb 
b/meta/recipes-core/systemd/systemd-conf.bb
index 7fe2e1105b..a504afe3e7 100644
--- a/meta/recipes-core/systemd/systemd-conf.bb
+++ b/meta/recipes-core/systemd/systemd-conf.bb
@@ -1,9 +1,8 @@
-require systemd.inc
-
 SUMMARY = "Systemd system configuration"
 DESCRIPTION = "Systemd may require slightly different configuration for \
 different machines.  For example, qemu machines require a longer \
 DefaultTimeoutStartSec setting."
+LICENSE = "GPLv2"
 
 PACKAGE_ARCH = "${MACHINE_ARCH}"
 
@@ -13,36 +12,29 @@ ${sysconfdir}/systemd/logind.conf \
 ${sysconfdir}/systemd/system.conf \
 ${sysconfdir}/systemd/user.conf"
 
-FILES_${PN} = "${sysconfdir}/systemd"
-
-do_configure[noexec] = '1'
-do_compile[noexec] = '1'
+FILES_${PN} = "/usr/lib/journald.conf.d/* \
+/usr/lib/logind.conf.d/* \
+/usr/lib/system.conf.d/* \
+"
 
 do_install() {
-   rm -rf ${D}/${sysconfdir}/systemd
-   install -d ${D}/${sysconfdir}/systemd
-
-   install -m 0644 ${S}/src/coredump/coredump.conf 
${D}${sysconfdir}/systemd/coredump.conf
-
-   install -m 0644 ${S}/src/journal/journald.conf 
${D}${sysconfdir}/systemd/journald.conf
+   install -d ${D}/usr/lib/journald.conf.d
# Enable journal to forward message to syslog daemon
-   sed -i -e 's/.*ForwardToSyslog.*/ForwardToSyslog=yes/' 
${D}${sysconfdir}/systemd/journald.conf
+   echo "ForwardToSyslog=yes" >> ${D}/usr/lib/journald.conf.d/${PN}.conf
# Set the maximium size of runtime journal to 64M as default
-   sed -i -e 's/.*RuntimeMaxUse.*/RuntimeMaxUse=64M/' 
${D}${sysconfdir}/systemd/journald.conf
+   echo "RuntimeMaxUse=64M" >> ${D}/usr/lib/journald.conf.d/${PN}.conf
 
-   install -m 0644 ${S}/src/login/logind.conf.in 
${D}${sysconfdir}/systemd/logind.conf
+   install -d ${D}/usr/lib/logind.conf.d
# Set KILL_USER_PROCESSES to yes
-   sed -i -e 's/@KILL_USER_PROCESSES@/yes/' 
${D}${sysconfdir}/systemd/logind.conf
+   echo "KillUserProcesses=yes" >> ${D}/usr/lib/logind.conf.d/${PN}.conf
 
-   install -m 0644 ${S}/src/core/system.conf.in 
${D}${sysconfdir}/systemd/system.conf
+   install -d ${D}/usr/lib/system.conf.d
# Set MEMORY_ACCOUNTING_DEFAULT to yes
-   sed -i -e 's/@MEMORY_ACCOUNTING_DEFAULT@/yes/' 
${D}${sysconfdir}/systemd/system.conf
-
-   install -m 0644 ${S}/src/core/user.conf 
${D}${sysconfdir}/systemd/user.conf
+   echo "DefaultMemoryAccounting=yes" >> 
${D}/usr/lib/system.conf.d/${PN}.conf
 }
 
 # Based on change from YP bug 8141, OE commit 
5196d7bacaef1076c361adaa2867be31759c1b52
 do_install_append_qemuall() {
# Change DefaultTimeoutStartSec from 90s to 240s
-   echo "DefaultTimeoutStartSec = 240s" >> 
${D}${sysconfdir}/systemd/system.conf
+   echo "DefaultTimeoutStartSec = 240s" >> 
${D}/usr/lib/system.conf.d/${PN}.conf
 }
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 3/7] systemd: move additional conffiles to systemd-conf

2018-12-31 Thread Jonas Bonn
---
 meta/recipes-core/systemd/systemd-conf.bb | 4 +++-
 meta/recipes-core/systemd/systemd_239.bb  | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/meta/recipes-core/systemd/systemd-conf.bb 
b/meta/recipes-core/systemd/systemd-conf.bb
index a504afe3e7..ea99166a2e 100644
--- a/meta/recipes-core/systemd/systemd-conf.bb
+++ b/meta/recipes-core/systemd/systemd-conf.bb
@@ -10,7 +10,9 @@ CONFFILES_${PN} = "${sysconfdir}/systemd/coredump.conf \
 ${sysconfdir}/systemd/journald.conf \
 ${sysconfdir}/systemd/logind.conf \
 ${sysconfdir}/systemd/system.conf \
-${sysconfdir}/systemd/user.conf"
+${sysconfdir}/systemd/user.conf \
+${sysconfdir}/systemd/resolved.conf \
+${sysconfdir}/systemd/timesyncd.conf"
 
 FILES_${PN} = "/usr/lib/journald.conf.d/* \
 /usr/lib/logind.conf.d/* \
diff --git a/meta/recipes-core/systemd/systemd_239.bb 
b/meta/recipes-core/systemd/systemd_239.bb
index 03acce25b7..70e687c92e 100644
--- a/meta/recipes-core/systemd/systemd_239.bb
+++ b/meta/recipes-core/systemd/systemd_239.bb
@@ -292,6 +292,8 @@ do_install() {
rm -f ${D}${sysconfdir}/systemd/logind.conf
rm -f ${D}${sysconfdir}/systemd/system.conf
rm -f ${D}${sysconfdir}/systemd/user.conf
+   rm -f ${D}${sysconfdir}/systemd/resolved.conf
+   rm -f ${D}${sysconfdir}/systemd/timesyncd.conf
 
# duplicate udevadm for postinst script
install -d ${D}${libexecdir}
-- 
2.19.1

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core