Porting X11Libre to FreeBSD.

As per T-Aoki's suggestions to move the FLAVORs discussions to the forms, I will be posting this here.

I have tried few times to describe this situation solely with text but I figured out a little visual aid would help make things much clearer and easier to communicate.

So here are few slides and diagrams that I made on regarding this topic:


(The forum file size limit was not sufficient so I had to resort to GitHub pages)
At least "Updates" part is inaccurate.
One of the person in current de-facto maintaining team accepted changes to x11/nvidia-driver, but I (mainly maintaining it and related driver ports) and former maintainer (danfe@) are objecting.

Commit was done while I was writing objectiong comment (caused mid-air collision when I attempt to save my comment) after I've finished my daytime $work and noticed PR 291598. Further discussions are going to be made on PR 291594 as per comment 8.
 
T-Aoki
(from PR 291594)
I don't object for FLAVORization if both Xorg implementation and XLibre implementation of X11 server can sanely coexist in single installation, selectable, i.e., via libmap or alike on startup. But currently XLibre conflicts with Xorg implementation.
Could a coexistence be possible?
 
T-Aoki
(from PR 291594)

Could a coexistence be possible?
I think "technically" possible.
Rename conflicting files to something different (i.e., /usr/local/bin/X for XLibre to /usr/local/bin/X.XLibre, for Xorg to /usr/local/bin/X.Xorg and create wrapper port to choose proper one and symlink from /usr/local/bin/X).
Limited with libraries, libmap would work. But others would need something like above. Anyway, large rework. So I said "technically". Maybe objections would arise, like current FLAVORized implementation.
 
T-Aoki
(from PR 291594)

Could a coexistence be possible?

No, XLibre uses the same binary name, wrapper name, .pc file and ... .

This is to keep backwards compatibility with many tools, scripts and ..., that depend on these being named as such, and changing it would break a huge number of use cases.

I do not understand why this has anything to do with FLAVORS.
 
I do not understand why this has anything to do with FLAVORS.
Because I don't think FLAVOR is good thing for conflicting things.
Default alone should be packaged and non-default conflicting things would be better built locally as per admin's choice.
This was what happened on transition from XFree86 to Xorg. Conflicting each other (except for things carried over from Xfree86, named xf86-*).

As there were no USES nor DEFAULT_VERSIONS implemented at the moment, so make variable WITH_NEW_XORG was introduced (now obsolete and deleted as the transition finished). Packages were built for XFree86 only and anyone want to try Xorg before official transition happened built Xorg locally. Why not for this time? Now we have DEFAULT_VERSIONS and USES framework.
 
Packages were built for XFree86 only and anyone want to try Xorg before official transition happened built Xorg locally. Why not for this time? Now we have DEFAULT_VERSIONS and USES framework.
XFree86 and Xorg were both monolithic back then; so things were a little easier for people to handle locally admittedly.
Because Xorg and Xlibre are split up into random fragments and not all of them are forked, I can assume it needs to be handled a little differently.
 
I think "technically" possible.
Rename conflicting files to something different (i.e., /usr/local/bin/X for XLibre to /usr/local/bin/X.XLibre, for Xorg to /usr/local/bin/X.Xorg and create wrapper port to choose proper one and symlink from /usr/local/bin/X).
Limited with libraries, libmap would work. But others would need something like above. Anyway, large rework. So I said "technically". Maybe objections would arise, like current FLAVORized implementation.
So then anything you want to run under Xlibre has to be aware of these mangled names? How's that simpler than FLAVORS?
 
So then anything you want to run under Xlibre has to be aware of these mangled names? How's that simpler than FLAVORS?
Have you read the whole post?
I've written "and create wrapper port to choose proper one", means, everything currently provided by both needs kinda wrapper keeping each filenames should be created by the wrapper port as symlink to whichever chozen (via OPTIONS preferrably, but in this case, FLAVOR is acceptable).
But this causes massive renames of existing Xorg ones.
 
Have you read the whole post?
I've written "and create wrapper port to choose proper one", means, everything currently provided by both needs kinda wrapper keeping each filenames should be created by the wrapper port as symlink to whichever chozen (via OPTIONS preferrably, but in this case, FLAVOR is acceptable).
But this causes massive renames of existing Xorg ones.
Yeah, my bad. Still a whole lot more work than the simple flavorized approach baaz implemented, and still way more friction to someone that just wants to try out Xlibre without spending a bunch of time on it.
 
Last edited:
Yeah, so let's behave like adults and try not to have this one locked too. There will be people trying their best to derail the thread, we must report them to the moderators and NEVER answer the trolls directly.

The old internet rule of 20+ years ago is still valid: "Don't feed the trolls".
 
I might speak for most of the readers when I say: flavors or default options, both is fine with me, as long as reasonable ports/packages are available. :)
 
OK, some more technical stuff.
I have found a better, more elegant solution to the KDE problem.

The entire reason that the KDE x11/plasma6-plasma-desktop port can't be installed alongside xlibre-server is due to its RUNTIME dependency on X.Org drivers:

x11-drivers/xf86-input-libinput

and

x11-drivers/xf86-input-evdev


Now why is there a dependency on these two drivers in the first place?

It is because of the diabolical scheme that was put into place for communicating default values of properties associated with xf86-input-* drivers to the input configuration utilities present in desktop environments.

Instead of a simple, humble text file, the xf86 input drivers generate a C header and a pkgconf file that is then depended on and included by a DE's input configuration tool, and it in turn sets its default values based on the list of "#define"s in these header files.


The things to note:

  • This is done for just setting the default values of these configuration utilities.
  • All of this is happening during compile time.

The libinput driver is basically the only ** driver whose exported properties are depended on by other ports. Moreover, those properties are based on the defaults of libinput itself.

So, by letting these ports just depend on xf86-input-libinput during build time instead of xlibre-xf86-input-libinput, we are not breaking anything for XLibre users because the exported properties by these drivers are based on the shared libinput library's defaults and are the same between XLibre and X.Org. (Even if we were to break anything, it would just make the default values of the GUI configuration utilities for XLibre users have different values).


The problem that we are currently facing is that the KDE Plasma 6 Desktop port not only depends on these ports in build time but also in run time, and I have found this runtime dependency to be unnecessary. I have not found anything in x11/plasma6-plasma-desktop that requires a hard dependency on these drives in runtime. I have even searched some of the Linux package repos, and they all listed these 2 drivers as build-time dependencies of plasma-desktop:

https://github.com/void-linux/void-packages/blob/master/srcpkgs/plasma-desktop/template

https://archlinux.org/packages/extra/x86_64/plasma-desktop/

By just removing the runtime dependency of x11/plasma6-plasma-desktop on these two drivers and keeping their build-time dependencies, we can solve this issue without needing to use any FLAVORs.

So just a ~2 line diff:


Diff:
diff --git a/x11/plasma6-plasma-desktop/Makefile b/x11/plasma6-plasma-desktop/Makefile
--- a/x11/plasma6-plasma-desktop/Makefile
+++ b/x11/plasma6-plasma-desktop/Makefile
@@ -19,9 +19,7 @@
 LIB_DEPENDS=  libcanberra.so:audio/libcanberra \
                 libxkbcommon.so:x11/libxkbcommon \
                 libxkbfile.so:x11/libxkbfile \

 RUN_DEPENDS=   noto-emoji>0:x11-fonts/noto-emoji \
-               xdg-user-dir:devel/xdg-user-dirs \
-               xf86-input-evdev>0:x11-drivers/xf86-input-evdev \
-               xf86-input-libinput>0:x11-drivers/xf86-input-libinput
+               xdg-user-dir:devel/xdg-user-dirs
 USES=          cmake gettext gl gnome kde:6 pkgconfig python qt:6 tar:xz xorg
 USE_GL=                gl opengl




** The evdev input driver is also depended by plasma-desktop but it has been removed:
 
Was this cleanup the result of trying to integrate with Xlibre?
Nope, that commit is from the April of 2024; it is older than XLibre :) .
It was done because everyone moved form the previous Linux input device abstraction™️(evdev) to the new one (libinput) and there was no reason to left to support the former.

The X11 parts of KDE have been mostly forked and are maintained by a new project called Sonic-DE. It was started by some of the developers in the XLibre community.
I have heard from the project developers that KDE has been very positive towards them, and that they aim to have a symbiotic relationship with them.
 
OK, some more technical stuff.
I have found a better, more elegant solution to the KDE problem.

The entire reason that the KDE x11/plasma6-plasma-desktop port can't be installed alongside xlibre-server is due to its RUNTIME dependency on X.Org drivers:

x11-drivers/xf86-input-libinput

and

x11-drivers/xf86-input-evdev


Now why is there a dependency on these two drivers in the first place?

It is because of the diabolical scheme that was put into place for communicating default values of properties associated with xf86-input-* drivers to the input configuration utilities present in desktop environments.

Instead of a simple, humble text file, the xf86 input drivers generate a C header and a pkgconf file that is then depended on and included by a DE's input configuration tool, and it in turn sets its default values based on the list of "#define"s in these header files.


The things to note:

  • This is done for just setting the default values of these configuration utilities.
  • All of this is happening during compile time.

The libinput driver is basically the only ** driver whose exported properties are depended on by other ports. Moreover, those properties are based on the defaults of libinput itself.

So, by letting these ports just depend on xf86-input-libinput during build time instead of xlibre-xf86-input-libinput, we are not breaking anything for XLibre users because the exported properties by these drivers are based on the shared libinput library's defaults and are the same between XLibre and X.Org. (Even if we were to break anything, it would just make the default values of the GUI configuration utilities for XLibre users have different values).


The problem that we are currently facing is that the KDE Plasma 6 Desktop port not only depends on these ports in build time but also in run time, and I have found this runtime dependency to be unnecessary. I have not found anything in x11/plasma6-plasma-desktop that requires a hard dependency on these drives in runtime. I have even searched some of the Linux package repos, and they all listed these 2 drivers as build-time dependencies of plasma-desktop:

https://github.com/void-linux/void-packages/blob/master/srcpkgs/plasma-desktop/template

https://archlinux.org/packages/extra/x86_64/plasma-desktop/

By just removing the runtime dependency of x11/plasma6-plasma-desktop on these two drivers and keeping their build-time dependencies, we can solve this issue without needing to use any FLAVORs.

So just a ~2 line diff:


Diff:
diff --git a/x11/plasma6-plasma-desktop/Makefile b/x11/plasma6-plasma-desktop/Makefile
--- a/x11/plasma6-plasma-desktop/Makefile
+++ b/x11/plasma6-plasma-desktop/Makefile
@@ -19,9 +19,7 @@
 LIB_DEPENDS=  libcanberra.so:audio/libcanberra \
                 libxkbcommon.so:x11/libxkbcommon \
                 libxkbfile.so:x11/libxkbfile \

 RUN_DEPENDS=   noto-emoji>0:x11-fonts/noto-emoji \
-               xdg-user-dir:devel/xdg-user-dirs \
-               xf86-input-evdev>0:x11-drivers/xf86-input-evdev \
-               xf86-input-libinput>0:x11-drivers/xf86-input-libinput
+               xdg-user-dir:devel/xdg-user-dirs
 USES=          cmake gettext gl gnome kde:6 pkgconfig python qt:6 tar:xz xorg
 USE_GL=                gl opengl




** The evdev input driver is also depended by plasma-desktop but it has been removed:

The SLiM login manager does not need need to have dependency on xorg-server too ...

I've looked into it, and there is nothing in SLiM requiring a dependency on xorg-server neither in run-time nor build-time.
You can compile and run it without xorg-server even being present on the system.

I also looked at Arch Linux's repos and his dependency is non existent in there. *

And I suspect that is has been added becuse of the fact that SLiM starts the X server by default, but that is a run-time cofigurable option and you can set the X server path to anything! **
So for example you can configure SLiM to start a nested X server like Xephyr or Xnest instead of Xorg.

It looks like the dependency dates back to the XFree86 ages and it has been kept ever since for 20~ years. ***

This one is a 1 line diff (Maybe 2 if you wanted to fix the line wrap):

Diff:
diff --git a/x11/slim/Makefile b/x11/slim/Makefile
--- a/x11/slim/Makefile
+++ b/x11/slim/Makefile
@@ -18,7 +18,7 @@ RUN_DEPENDS=  dbus-daemon:devel/dbus

 USES=          cmake compiler:c++11-lang cpe jpeg pkgconfig xorg
 CPE_VENDOR=    berlios
-USE_XORG=      ice sm x11 xau xcb xdmcp xext xft xmu xorg-server xrandr \
+USE_XORG=      ice sm x11 xau xcb xdmcp xext xft xmu xrandr \
              xrender xt
 USE_RC_SUBR=   slim
 USE_LDCONFIG=  yes

* https://archlinux.org/packages/extra/x86_64/slim/
** https://github.com/iwamatsu/slim/blob/4a40caff34b52c9b9bcf8cbb83775ade9398d179/slim.conf#L4
*** https://github.com/freebsd/freebsd-...3d4164af15401d658f1b8ab/x11/slim/Makefile#L20
 
Page 5 has the flavor patch for xf86-video-scfb as (trimmed to show only changing lines)
Diff:
+FLAVORS= xorg xlibre
+FLAVOR?= ${FLAVORS:[1]}
+
+.if ${FLAVOR} == xlibre
+PKGNAMEPREFIX= xlibre-
+USES= xlibre-cat:driver
+.else
USES= xorg-cat:driver
+.endif
Any reason to not simplify to
Diff:
+FLAVORS= xorg xlibre
+FLAVOR?= ${FLAVORS:[1]}
+
+.if ${FLAVOR} == xlibre
+PKGNAMEPREFIX= xlibre-
+.endif
+USES= ${FLAVOR}-cat:driver
or go further and always make the flavor clear and eliminate the variable testing entirely
Diff:
+FLAVORS= xorg xlibre
+FLAVOR?= ${FLAVORS:[1]}
+
+PKGNAMEPREFIX= ${FLAVOR}-
+USES= ${FLAVOR}-cat:driver
 
I have just pushed out the new release of XLibre, 2.1.0, to xlibre-ports.
The release 25.1.0 wiki page:

A very short summary of what is new:
We had over 1,500 commits since the last release.
Did a whole ton of bugfixes. (Fixed cursor problems and ...)
Added Cygwin, MinGW32, Net, Free and DragonFlyBSD to our CI.
Added sysutils/seatd support for running X without root privileges, and in multi-seat setups.
Brought back Xfbdev. (An X server for the Linux frame-buffer device).
Problems with older NVIDIA driver versions have been fixed.
Forked the SCFB and eGalax drivers!
And many, many more...

Be sure to update your xlibre-xf86-* drivers simultaneously with the server!

DFBSD builds are fixed.

Oh, and on an unrelated note: Merry Christmas every one!

 
Last edited:
I have just pushed out the new release of XLibre, 2.1.0, to xlibre-ports.
Wait, did I miss something? I was under the impression that xlibre was now distributed as an official port and thus xlibre-ports was not necessary anymore.

So, as now I'm running xlibre from the ports repo, what should I do to get the new release? Just re-create your repo and run pkg update followed by pkg upgrade? Will it bring in seatd? Is it now a dependency or is it optional?

Thanks in advance.

Edit: I managed to perform the upgrade re-adding the repo and forcing pkg to fetch the relevant packages from it. I can confirm that seatd is now a dependency but starting X via CDE ( dtlogin ) I get in the logs:

Code:
[2025-12-25 05:22:09] (WW) seat-libseat: libseat integration requires -keeptty which was not provided, disabling

therefore Xorg is still running as root on my system. What should I do?

Edit2: I found how to configure dtlogin to add -keeptty but Xorg still runs as root (whilst the previous error is not present in the logs anymore):

Code:
[6:37][fmc000@dabrafenib ]$ ps -auxww| grep Xorg|grep -v grep                                                                                                                                                   ~
root   3888   0,3  0,4   278452 116872  -  S    06:24     0:04,80 /usr/local/libexec/Xorg :0 -keeptty -auth /var/dt/authdir/authfiles/A:0-ie1o3k
[6:37][fmc000@dabrafenib ]$

Edit3: I finally managed to have Xorg run as user nobody:

Code:
[9:44][fmc000@dabrafenib ]$ ps -auxww| grep Xorg|grep -v grep                                                                                                                                                   ~
nobody 7523   1,0  0,3   275964 113284 v1  S    09:44      0:01,51 /usr/local/libexec/Xorg :0 -keeptty -auth /var/dt/authdir/authfiles/A:0-gelPnb
[9:45][fmc000@dabrafenib ]$

Steps needed:
  • change the last line of /usr/local/dt/config/Xservers to :0 Local local@console /usr/local/bin/X :0 -keeptty (this is only for CDE / dtlogin - other DEs may or may not need something similar);
  • set the primary group to video for the user nobody, otherwise the user can not attach itself to /var/run/seatd.socket;
  • optional: add nobody as secondary group for the user nobody;
  • add needs_root_rights = no to /usr/local/etc/X11/Xwrapper.config;
  • change /var/log permissions to 777 so that Xorg running as user nobody can write its own logs.
Please let me know if I missed something, I'm still testing this solution (and I don't like the last point of the list at all).
 
Wait, did I miss something? I was under the impression that xlibre was now distributed as an official port and thus xlibre-ports was not necessary anymore.
It is still necessary because:
  1. The changes to some 3rd party ports have not yet been accepted, so they can't be installed alongside XLibre.
  2. It can be used as a "beta testing" stage before anything is merged to the main tree.
  3. DragonFlyBSD has not yet merged the FreeBSD's master, so they do not have access to these ports.
Will it bring in seatd? Is it now a dependency or is it optional?
seatd support is enabled by default, but I have added it as a port OPTION (SEATD) and you can disable it during builds if you want to. So yes it will take in sysutils/seatd by default.

For the "root problem":

By default, in both X.Org and XLibre, the /usr/local/bin/Xorg executable is actually just a tiny shell script that tries to execute /usr/local/libexec/Xorg.wrap and if that was not present it then will try to execute
/usr/local/libexec/Xorg.

(The X executable (/usr/local/bin/X) is just a symlink to /usr/local/bin/Xorg)

/usr/local/libexec/Xorg.wrap is a "wraper" binary, with it's setuid bit set, it allows normal users to start an X server which needs access to files usually owned by root (DRI/DRM devices and ...). It can check for the permissions of these devices and then drop its root privileges, if they are not necessary, before executing the actual X server. Read more about it in Xorg.wrap(1)()

(This wrapper can be disabled during a build of xlibre-server by unchecking the SUID OPTION.)

The actual X server is located at /usr/local/libexec/Xorg it is a normal executable that you launch and pass the same X server CML arguments to. It will run as the user that launced it, and it will have the same permissions. Most importantly, when ran as a normal user, it will use the ~/.local/share/xorg/Xorg.log folder for its logs.

So with all that out of the way, you can try lanching your X session like this:
sh:
[sudo | doas | su] service seatd start

/usr/local/libexec/Xorg -seat seat0 -keeptty


Also the group which seatd's socket belongs to is video but it can be changed in its rc script, so make sure your user is a member of that group.
 
Updates:

The DFBSD builds are fixed.
plasma6-plasma-desktop without the runtime dependencies on X.Org drivers is available in the FreeBSD builds.
 
  • Like
Reactions: mer
Back
Top