Bug 5546 - Optimise away meta-oe X init mechanism
Summary: Optimise away meta-oe X init mechanism
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: graphics (show other bugs)
Version: 1.6
Hardware: All Multiple
: High enhancement
Target Milestone: 2.3 M1
Assignee: Jussi Kukkonen
QA Contact:
URL:
Whiteboard:
: 9701 (view as bug list)
Depends on:
Blocks: 5599
  Show dependency tree
 
Reported: 2013-11-15 11:36 UTC by Paul Eggleton
Modified: 2017-12-06 16:47 UTC (History)
13 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Eggleton 2013-11-15 11:36:43 UTC
OE-Core and meta-oe both provide xserver-nodm-init, however the two versions are quite different. The most notable difference is that the OE-Core version uses x11-common whereas the meta-oe version uses xserver-common. The split here as roots deep in history but we really need to bring the two together and remove the need for meta-oe to have any overlap; at the moment it is very easy to break your X startup by adding/removing meta-oe in an existing build tree.

This will involve analysing the unique features of the meta-oe X initialisation components and bringing them over to OE-Core. Note that meta-oe's xserver-common concentrates device-specific configuration in the upstream source instead of providing this in each BSP layer; in the OE-Core system we use formfactor for this which is normally extended by each BSP. We need to find a way to make formfactor work for this.

(I did start some of the harmonisation work for this late in the 1.5 development cycle, but the job was a bit too much work for the time available.)
Comment 1 Ross Burton 2014-05-06 15:44:03 UTC
FWIW, if you find yourself overloaded I can take this.
Comment 2 noor_ahsan 2016-04-22 07:24:00 UTC
Hello Paul and Ross,

this is quite old issue and it is still open. Any chance that we get it fixed for Yocto 2.2?
Comment 3 Ross Burton 2016-06-03 09:52:56 UTC
*** Bug 9701 has been marked as a duplicate of this bug. ***
Comment 4 Jussi Kukkonen 2016-06-03 09:58:34 UTC
(In reply to comment #3)
> *** Bug 9701 has been marked as a duplicate of this bug. ***

The duplicate was set to medium+ and targetting M2 just a few days ago: this one should probably do the same
Comment 5 Jussi Kukkonen 2016-07-19 11:37:59 UTC
Copying richards comment from the duplicate so I find it later:
---

Its confusing for users to add meta-oe and then have the system change behaviour. meta-oe has a different (higher) version of xserver-nodm-init and we really need to figure out a way so we have one good version of this rather than two incompatible ones with different features.

Once that is resolved, we could also do with either trying to reconcile x11-common and xserver-common, or putting in PROVIDES += "virtual/xserver-common" into both such that only one can build and an error is triggered if its attempted to mix them.

For nodm-init a diff is shown below. We need to:
a) Drop the unused killproc from the OE-Core version
b) Merge the shell fix for meta-oe (so cat isn't used for s subshell)
c) Add rootless X support to the meta-oe version
d) Add the misisng chvt from meta-oe
e) Add a restart sleep to OE-Core
f) Look at the differences between /etc/X11/xserver-common verses  "xinit /etc/X11/Xsession"


$ diff -u xserver-nodm-init{,-2.0}/xserver-nodm
--- xserver-nodm-init/xserver-nodm	2015-12-14 22:52:39.482429236 +0000
+++ xserver-nodm-init-2.0/xserver-nodm	2016-01-25 21:07:34.000000000 +0000
@@ -8,13 +8,10 @@
 # Default-Stop:      0 1 2 3 6
 ### END INIT INFO
 
-killproc() {            # kill the named process(es)
-        pid=`/bin/pidof $1`
-        [ "$pid" != "" ] && kill $pid
-}
 
-read CMDLINE < /proc/cmdline
-for x in $CMDLINE; do
+. /etc/init.d/functions
+
+for x in $(cat /proc/cmdline); do
         case $x in
         x11=false)
 		echo "X Server disabled" 
@@ -25,35 +22,33 @@
 
 case "$1" in
   start)
+    # We don't want this script to block the rest of the boot process
+    if [ "$2" != "background" ]; then
+      $0 $1 background &
+    else
+       # work around from /etc/X11/Xinit
+       export USER=root
+       export HOME=/home/root
+       if [ ! -d $HOME ] && [ -d /root ]; then
+         HOME=/root
+       fi
+
        . /etc/profile
-       username=root
+
        echo "Starting Xserver"
-       if [ -f /etc/X11/Xusername ]; then
-           username=`cat /etc/X11/Xusername`
-           # setting for rootless X
-           chmod o+w /var/log
-           chmod g+r /dev/tty[0-3]
-           # hidraw device is probably needed
-           if [ -e /dev/hidraw0 ]; then
-               chmod o+rw /dev/hidraw*
-           fi
-       fi
-       # Using su rather than sudo as latest 1.8.1 cause failure [YOCTO #1211]
-       su -l -c '/etc/X11/Xserver&' $username 
-       # Wait for the desktop to say its finished loading
-       # before loading the rest of the system
-       # dbus-wait org.matchbox_project.desktop Loaded
+       . /etc/X11/xserver-common
+       xinit /etc/X11/Xsession -- `which $XSERVER` $ARGS >/var/log/Xsession.log 2>&1
+    fi 
   ;;
 
   stop)
         echo "Stopping XServer"
         killproc xinit
-        sleep 1
-        chvt 1 &
   ;;
 
   restart)
 	$0 stop
+        sleep 1
         $0 start
   ;;
Comment 6 Jussi Kukkonen 2016-08-18 13:23:58 UTC
(In reply to comment #5)
> Copying richards comment from the duplicate so I find it later:
> ---
> 
> Its confusing for users to add meta-oe and then have the system change
> behaviour. meta-oe has a different (higher) version of xserver-nodm-init and
> we really need to figure out a way so we have one good version of this
> rather than two incompatible ones with different features.

I've been going through these and currently I believe we can pretty much just remove meta-oe version without loss of functionality. The only difference is x11-common vs xserver-common. Supporting the latter in oe-core xserver-nodm-init should be pretty easy (when "support" is defined as working like meta-oe version does). Then I guess the already existing "VIRTUAL-RUNTIME_xserver_common" setting can be used to select between x11-common and xserver-common.



I recognise that there's a possibility I'm overlooking something, so here's some details starting with Richards list:

> a) Drop the unused killproc from the OE-Core version

killproc isn't unused, see "stop" (in both versions of the scripts)

> b) Merge the shell fix for meta-oe (so cat isn't used for s subshell)

The oe-core version is the correct one (there's another use of cat that can be replaced though).

> c) Add rootless X support to the meta-oe version

oe-core version seems complete here.

> d) Add the misisng chvt from meta-oe
> e) Add a restart sleep to OE-Core

These are in oe-core version, just moved to "stop" (according to commit message chvt may not work properly unless X has had time to stop?)

> f) Look at the differences between /etc/X11/xserver-common verses  "xinit
> /etc/X11/Xsession"

I'm assuming this means the difference between oe-cores start with
    su -l -c '/etc/X11/Xserver&' $username
and meta-oes similar
    xinit /etc/X11/Xsession

As far as I can see the versions are equal, except:
* oe-core uses su for rootless X, so does not need to set USER and HOME
* oe-core script does not have the recursing "background" option: instead
  /etc/X11/Xserver is started in the background
* oe-core uses "exec" to run xinit -- this seems correct to me
* meta-oe sources /etc/X11/xserver-common to dynamically set 
  $XSERVER and $ARGS.


Next I'll check if the last item actually works with oe-cores nodm-init.
Comment 7 Jussi Kukkonen 2016-08-19 10:48:30 UTC
There is one thing we have to change in nodm-init to support xserver-common: The oe-core nodm-init "start" executes /etc/X11/Xserver. This file is provided by both xserver-common and x11-common but meta-oe nodm-init does _not_ actually use this file at all. 


I plan to deprecate /etc/X11/Xserver in x11-common as well and do those few lines directly in /etc/init.d/xserver-nodm. Then xserver-nodm would support both xserver-common and x11-common.


Obviously there may still be differences between using x11-common and xserver-common (Xsession stuff at the very least). But getting rid of xserver-nodm-2.0 would be the first step in something sensible...
Comment 8 Jussi Kukkonen 2016-09-13 07:37:04 UTC
First patches are in 2.2 M3  and new xserver-nodm-init should have all features from both versions (meta-oe & oe-core) but I can't call this resolved yet:
 * meta-oe version of xserver-nodm-init would need to be removed so it doesn't
   get used when meta-oe is added to layers
 * probably our version would need a PV bump (to make it upgrade cleanly
   from meta-oe)
 * x11-common/xserver-common should be merged

The last point could be a new issue (and a 2.3 feature), but the first two are clearly part of this one as the confusion between meta-oe version and ours continues... I think I can't possibly squeeze this in 2.2 either even if the change itself is tiny.

If we do the two first points:
 * People who relied on getting xserver-common features just because they have
   meta-oe in their layers will be unpleasantly surprised (setting 
   VIRTUAL-RUNTIME_xserver_common is now needed)
 * People who relied on getting xserver-nodm-init from meta-oe just
   because they have meta-oe in layers _should_ not be surprised at all
   but bugs are of course possible.

Ross, any disagreement on moving this to 2.3?
Comment 9 Jussi Kukkonen 2016-09-13 13:37:32 UTC
Agreed with Ross to move to 2.3 M1.
Comment 10 Jussi Kukkonen 2016-11-17 09:25:25 UTC
Patchsets "X initialization refactoring" sent to both oe-core and meta-oe mailing lists.
Comment 11 Jussi Kukkonen 2016-12-08 12:11:34 UTC
I'm thinking of closing this as the patchsets have landed in oe-core and meta-oe. The end result isn't exactly what Paul describes in the original message: I have made sure we don't duplicate code or config files in the layers and ensured that just adding meta-oe to BBLAYERS doesn't modify the X initialization. I have _not_ tried to bring the device specific configuration from xserver-common into the bsp layers formfactor files.


If the formfactor improvements are still wanted, I can file a new bug. They should almost certainly be done piece-by-piece for things we know are relevant. I also wouldn't want to try to modify some custom xserver setup without actually being able to test that. 

As an example, we already have DISPLAY_DPI variable in machconfig but I don't think we use that in xserver startup -- maybe we should if it is set?
Comment 12 Ross Burton 2016-12-08 12:35:52 UTC
Absolutely agree that we can close this now.