Porting X11Libre to FreeBSD.

Same applies btw for the Nvidia driver package. At least there is the workaround to grab from Nvidia download page and compile manually.
So I'm suggesting to use DEFAULT_VERSIONS framework (would be the compination of Mk/bsd.default-versions.mk and Mk/Uses/xorg.mk here).
I imagine that DEFAULT_VERSIONS+= xorg to choose xorg (default) and DEFAULT_VERSIONS+= xlibre to switch to xlibre, switching actual *_DEPENDS in Mk/Uses/xorg.mk.

Mk/Uses/xorg.mk has a list named XORG_MODULES. Not tried, but splitting it into 2 parts, one (in current name) for anything XLibre does NOT provides alternatives, and another (i.e., XORG_MODULES_DEFAULT) containing anything replaced when xlibre is chosen. And add a new list (i.e., XORG_MODULES_XLIBRE) to contain alternatives provided by XLibre.

*.pc files would be need something alike, too.
 
So I'm suggesting to use DEFAULT_VERSIONS framework (would be the compination of Mk/bsd.default-versions.mk and Mk/Uses/xorg.mk here).
I imagine that DEFAULT_VERSIONS+= xorg to choose xorg (default) and DEFAULT_VERSIONS+= xlibre to switch to xlibre, switching actual *_DEPENDS in Mk/Uses/xorg.mk.

Mk/Uses/xorg.mk has a list named XORG_MODULES. Not tried, but splitting it into 2 parts, one (in current name) for anything XLibre does NOT provides alternatives, and another (i.e., XORG_MODULES_DEFAULT) containing anything replaced when xlibre is chosen. And add a new list (i.e., XORG_MODULES_XLIBRE) to contain alternatives provided by XLibre.

*.pc files would be need something alike, too.
Sounds reasonable to me. Although I doubt if I personally would get it done even though I am thinking about helping somehow since I appreciate the project.
 
Although I doubt if I personally would get it done even though I am thinking about helping somehow since I appreciate the project.
Unfortunately, me, too, have chicken and egg problem here to help it.
I'm currently one of the de-facto maintainer of nvidia driver ports, thus, switching to another, exclusive-with-xorg components makes it much harder to work on.
Even if I can take time to look into deeper and create proof-of-concept patch, I myself cannot test it, maybe.
 
Unfortunately, me, too, have chicken and egg problem here to help it.
I'm currently one of the de-facto maintainer of nvidia driver ports, thus, switching to another, exclusive-with-xorg components makes it much harder to work on.
Even if I can take time to look into deeper and create proof-of-concept patch, I myself cannot test it, maybe.
I probably would be willing to test if you have something, currently it looks good here concerning spare time.
 
I probably would be willing to test if you have something, currently it looks good here concerning spare time.
Not tested, and not intended to be enough, but the minimal PoC would be something like below.

Code:
--- a/Mk/bsd.default-versions.mk
+++ b/Mk/bsd.default-versions.mk
@@ -20,7 +20,7 @@
 .  for lang in APACHE BDB COROSYNC EBUR128 EMACS FIREBIRD FORTRAN FPC GCC \
     GHOSTSCRIPT GL GO GUILE IMAGEMAGICK JAVA LAZARUS LIBRSVG2 LINUX LLVM \
     LUA LUAJIT MONO MYSQL NINJA NODEJS OPENLDAP PERL5 PGSQL PHP \
-    PYCRYPTOGRAPHY PYTHON PYTHON2 RUBY RUST SAMBA SSL TCLTK VARNISH
+    PYCRYPTOGRAPHY PYTHON PYTHON2 RUBY RUST SAMBA SSL TCLTK VARNISH XORG
 .    if defined(${lang}_DEFAULT)
 ERROR+=    "The variable ${lang}_DEFAULT is set and it should only be defined through DEFAULT_VERSIONS+=${lang:tl}=${${lang}_DEFAULT} in /etc/make.conf"
 .    endif
@@ -188,6 +188,8 @@
 TCLTK_DEFAULT?=        8.6
 # Possible values: 6, 7
 VARNISH_DEFAULT?=    6
+# Possible values: xorg, xlibre
+XORG_DEFAULT?=    xorg
 
 .endif
 
--- a/Mk/Uses/xorg.mk
+++ b/Mk/Uses/xorg.mk
@@ -110,7 +110,13 @@
 xmu_LIB_PC_DEPENDS=        ${LOCALBASE}/libdata/pkgconfig/xmu.pc:x11-toolkits/libXmu
 xmuu_LIB_PC_DEPENDS=        ${LOCALBASE}/libdata/pkgconfig/xmuu.pc:x11-toolkits/libXmu
 xorg-macros_BUILD_DEPENDS=    ${LOCALBASE}/libdata/pkgconfig/xorg-macros.pc:devel/xorg-macros
+.if ${XORG_DEFAULT} == xlibre
+xorg-server_LIB_PC_DEPENDS=    ${LOCALBASE}/libdata/pkgconfig/xlibre-server.pc:x11-servers/xlibre-server
+.elif ${XORG_DEFAULT} == xorg
 xorg-server_LIB_PC_DEPENDS=    ${LOCALBASE}/libdata/pkgconfig/xorg-server.pc:x11-servers/xorg-server
+.else
+IGNORE= invalid DEFAULT_VERSIONS+=xorg=${XORG_DEFAULT}
+.endif
 xorgproto_BUILD_DEPENDS=    xorgproto>=0:x11/xorgproto
 xp_LIB_PC_DEPENDS=        ${LOCALBASE}/libdata/pkgconfig/xp.pc:x11/libXp
 xpm_LIB_PC_DEPENDS=        ${LOCALBASE}/libdata/pkgconfig/xpm.pc:x11/libXpm
Maybe some spaces needed to be converted to tab to apply. And would be many more to do to be usable.
 
Not tested, and not intended to be enough, but the minimal PoC would be something like below.

Code:
--- a/Mk/bsd.default-versions.mk
+++ b/Mk/bsd.default-versions.mk
@@ -20,7 +20,7 @@
 .  for lang in APACHE BDB COROSYNC EBUR128 EMACS FIREBIRD FORTRAN FPC GCC \
     GHOSTSCRIPT GL GO GUILE IMAGEMAGICK JAVA LAZARUS LIBRSVG2 LINUX LLVM \
     LUA LUAJIT MONO MYSQL NINJA NODEJS OPENLDAP PERL5 PGSQL PHP \
-    PYCRYPTOGRAPHY PYTHON PYTHON2 RUBY RUST SAMBA SSL TCLTK VARNISH
+    PYCRYPTOGRAPHY PYTHON PYTHON2 RUBY RUST SAMBA SSL TCLTK VARNISH XORG
 .    if defined(${lang}_DEFAULT)
 ERROR+=    "The variable ${lang}_DEFAULT is set and it should only be defined through DEFAULT_VERSIONS+=${lang:tl}=${${lang}_DEFAULT} in /etc/make.conf"
 .    endif
@@ -188,6 +188,8 @@
 TCLTK_DEFAULT?=        8.6
 # Possible values: 6, 7
 VARNISH_DEFAULT?=    6
+# Possible values: xorg, xlibre
+XORG_DEFAULT?=    xorg
 
 .endif
 
--- a/Mk/Uses/xorg.mk
+++ b/Mk/Uses/xorg.mk
@@ -110,7 +110,13 @@
 xmu_LIB_PC_DEPENDS=        ${LOCALBASE}/libdata/pkgconfig/xmu.pc:x11-toolkits/libXmu
 xmuu_LIB_PC_DEPENDS=        ${LOCALBASE}/libdata/pkgconfig/xmuu.pc:x11-toolkits/libXmu
 xorg-macros_BUILD_DEPENDS=    ${LOCALBASE}/libdata/pkgconfig/xorg-macros.pc:devel/xorg-macros
+.if ${XORG_DEFAULT} == xlibre
+xorg-server_LIB_PC_DEPENDS=    ${LOCALBASE}/libdata/pkgconfig/xlibre-server.pc:x11-servers/xlibre-server
+.elif ${XORG_DEFAULT} == xorg
 xorg-server_LIB_PC_DEPENDS=    ${LOCALBASE}/libdata/pkgconfig/xorg-server.pc:x11-servers/xorg-server
+.else
+IGNORE= invalid DEFAULT_VERSIONS+=xorg=${XORG_DEFAULT}
+.endif
 xorgproto_BUILD_DEPENDS=    xorgproto>=0:x11/xorgproto
 xp_LIB_PC_DEPENDS=        ${LOCALBASE}/libdata/pkgconfig/xp.pc:x11/libXp
 xpm_LIB_PC_DEPENDS=        ${LOCALBASE}/libdata/pkgconfig/xpm.pc:x11/libXpm
Maybe some spaces needed to be converted to tab to apply. And would be many more to do to be usable.
I prolly gonna check this out later in the evening and will report back.
 
baaz - I suggest you speak with the KDE maintainers because pkg install kde brings in xorg-server and thus it's impossible to use your packages with KDE.
Huh,
The chain goes like this:
kde (metaport)
plasma6-plasma
plasma6-plasma-desktop
xf86-input-libinput xf86-input-evdev
xorg-server ---> clashes with xlibre-server.
 
T-Aoki
I have implemented your changes and tested with x11/nvidia-driver-devel.
It works and pulls xlibre instead of xorg.

Here some details:
Code:
root@elfreebsdo1:/usr/ports # ls -l x11-servers/xlibre-server
lrwxr-xr-x  1 root wheel 51 Aug  2 18:01 x11-servers/xlibre-server -> /root/xlibre/xlibre-ports/x11-servers/xlibre-server
root@elfreebsdo1:/usr/ports # git status
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   Mk/Uses/xorg.mk
    modified:   Mk/bsd.default-versions.mk

Untracked files:
  (use "git add <file>..." to include in what will be committed)
    x11-servers/xlibre-server

no changes added to commit (use "git add" and/or "git commit -a")
root@elfreebsdo1:/usr/ports # git diff
diff --git a/Mk/Uses/xorg.mk b/Mk/Uses/xorg.mk
index bf4e78b9a5de..dddde6e379e9 100644
--- a/Mk/Uses/xorg.mk
+++ b/Mk/Uses/xorg.mk
@@ -110,7 +110,13 @@ xkbfile_LIB_PC_DEPENDS=            ${LOCALBASE}/libdata/pkgconfig/xkbfile.pc:x11/libxkbfil
 xmu_LIB_PC_DEPENDS=            ${LOCALBASE}/libdata/pkgconfig/xmu.pc:x11-toolkits/libXmu
 xmuu_LIB_PC_DEPENDS=           ${LOCALBASE}/libdata/pkgconfig/xmuu.pc:x11-toolkits/libXmu
 xorg-macros_BUILD_DEPENDS=     ${LOCALBASE}/libdata/pkgconfig/xorg-macros.pc:devel/xorg-macros
+.if ${XORG_DEFAULT} == xlibre
+xorg-server_LIB_PC_DEPENDS=    ${LOCALBASE}/libdata/pkgconfig/xlibre-server.pc:x11-servers/xlibre-server
+.elif ${XORG_DEFAULT} == xorg
 xorg-server_LIB_PC_DEPENDS=    ${LOCALBASE}/libdata/pkgconfig/xorg-server.pc:x11-servers/xorg-server
+.else
+IGNORE= invalid DEFAULT_VERSIONS+=xorg=${XORG_DEFAULT}
+.endif
 xorgproto_BUILD_DEPENDS=       xorgproto>=0:x11/xorgproto
 xp_LIB_PC_DEPENDS=             ${LOCALBASE}/libdata/pkgconfig/xp.pc:x11/libXp
 xpm_LIB_PC_DEPENDS=            ${LOCALBASE}/libdata/pkgconfig/xpm.pc:x11/libXpm
diff --git a/Mk/bsd.default-versions.mk b/Mk/bsd.default-versions.mk
index 3192f9cf5ce5..9144ff8d830f 100644
--- a/Mk/bsd.default-versions.mk
+++ b/Mk/bsd.default-versions.mk
@@ -20,7 +20,7 @@ LOCALBASE?=   /usr/local
 .  for lang in APACHE BDB COROSYNC EBUR128 EMACS FIREBIRD FORTRAN FPC GCC \
        GHOSTSCRIPT GL GO GUILE IMAGEMAGICK JAVA LAZARUS LIBRSVG2 LINUX LLVM \
        LUA LUAJIT MONO MYSQL NINJA NODEJS OPENLDAP PERL5 PGSQL PHP \
-       PYCRYPTOGRAPHY PYTHON PYTHON2 RUBY RUST SAMBA SSL TCLTK VARNISH
+       PYCRYPTOGRAPHY PYTHON PYTHON2 RUBY RUST SAMBA SSL TCLTK VARNISH XORG
 .    if defined(${lang}_DEFAULT)
 ERROR+=        "The variable ${lang}_DEFAULT is set and it should only be defined through DEFAULT_VERSIONS+=${lang:tl}=${${lang}_DEFAULT} in /etc/make.conf"
 .    endif
@@ -188,5 +188,6 @@ SSL_DEFAULT?=       base
 TCLTK_DEFAULT?=                8.6
 # Possible values: 6, 7
 VARNISH_DEFAULT?=      6
-
+# Possible values: xorg, xlibre
+XORG_DEFAULT?=         xorg
 .endif
root@elfreebsdo1:/usr/ports # grep xlibre /etc/make.conf 
OVERLAYS=/root/xlibre/xlibre-ports/
DEFAULT_VERSIONS+=xorg=xlibre
root@elfreebsdo1:/usr/ports # 
cd x11/nvidia-driver-devel/
root@elfreebsdo1:/usr/ports/x11/nvidia-driver-devel # make missing
/root/xlibre/xlibre-ports//x11-servers/xlibre-server
root@elfreebsdo1:/usr/ports/x11/nvidia-driver-devel #

I have attached the git diff, too.
 

Attachments

I have addressed some of this Issues in the GhostBSD main-xlibre branch, notably the driver server mismatches for NVIDIA, XRDP, SCFB and Egalx ones.
All you need to do is to clone the GhostBSD tree and make the ports with FLAVOR=xlibre set.

After discussion and brainstorming we came to the conclusion that using flavors is the best way forward to fix this issue in a way that there would be no headaches for both X.Org users and XLibre users.

The basic idea is that for all ports that depend on xorg-server and do not have a xlibre replacement we would create a non default xlibre flavor for them that would depend on XLibre instead.

TBH I did not check for other packages that directly depend on xorg-dirvers, I did not consider that they might exist outside of xorg-drivers.
 
I have addressed some of this Issues in the GhostBSD main-xlibre branch, notably the driver server mismatches for NVIDIA, XRDP, SCFB and Egalx ones.
All you need to do is to clone the GhostBSD tree and make the ports with FLAVOR=xlibre set.

After discussion and brainstorming we came to the conclusion that using flavors is the best way forward to fix this issue in a way that there would be no headaches for both X.Org users and XLibre users.

The basic idea is that for all ports that depend on xorg-server and do not have a xlibre replacement we would create a non default xlibre flavor for them that would depend on XLibre instead.

TBH I did not check for other packages that directly depend on xorg-dirvers, I did not consider that they might exist outside of xorg-drivers.
That means you vote for a different solution than the one I PoC'ed with/for T-Aoki?
 
Yes, you can read the issue's discussion for why we made this choice.
Record for the future readers:
There's Pros and Cons in both approach.

My PoC using DEFAULT_VERSIONS:
  • Pros: No need to modify consumers like x11/nvidia-driver at all, if both XLibre and Xorg are compatible enough.
  • Cons: Both need to be compatible enough and also needs simple rebuilds to works fine . Only default ones are built on official pkg builder.

FLAVORS:
  • Pros: Easier to handle incompatibilities, if any. All flavors are always built if the pkg builder is configured to do so.
  • Cons: Always needs supports for each consumer ports even for already complexed ones like x11/nvidia-driver, introducing additional difficulties for maintaining especially for whom want to newly pop in to maintain.
 
Testing XLibre on real hardware is the best help, and you are already doing that :) .
I sadly still have not found the cause of the issue you raised, I got rid of my NVIDIA cards long ago.
Since I am somewhat good at programming/debugging, maybe you can give me some ideas how to track down the issue?
 
Since I am somewhat good at programming/debugging, maybe you can give me some ideas how to track down the issue?

Well it would be nice to see what commit caused this, so you can build and test the server with the commits between 25.0.0.5-25.0.0.7 in a binary search fashion.
To do this you would need to
  1. Set GH_TAGNAME=commithash in the xlibre-server Makefile
  2. Clean and rebuild it.
  3. Remove the package with pkg remove xlibre-server and reinstall it with make install.
  4. And try running it again.
Also you can try building the server without the patch I made that enabled epoll-shim, to do this you would need to revert my ports tree to commit hash 01a6686 and then try building the server with the newer commit hashes as I mentioned above.
 
Well it would be nice to see what commit caused this, so you can build and test the server with the commits between 25.0.0.5-25.0.0.7 in a binary search fashion.
To do this you would need to
  1. Set GH_TAGNAME=commithash in the xlibre-server Makefile
  2. Clean and rebuild it.
  3. Remove the package with pkg remove xlibre-server and reinstall it with make install.
  4. And try running it again.
Also you can try building the server without the patch I made that enabled epoll-shim, to do this you would need to revert my ports tree to commit hash 01a6686 and then try building the server with the newer commit hashes as I mentioned above.
What I did so far:
I have checked out commit 01a6686 and rebuild/reinstalled.
=> now everything is working perfectly and the problems are gone.
Now I try to build head and then git bisect to find the problem commit.
 
What I did so far:
I have checked out commit 01a6686 and rebuild/reinstalled.
=> now everything is working perfectly and the problems are gone.
Now I try to build head and then git bisect to find the problem commit.
That commit is still building the 25.0.0.5 version that you previously confirmed was working.
You'd need to bump the version up in the Makefile to a higher version or use a higher commit hash after resetting the tree to 01a6686.
 
That commit is still building the 25.0.0.5 version that you previously confirmed was working.
You'd need to bump the version up in the Makefile to a higher version or use a higher commit hash after resetting the tree to 01a6686.
Yeah I know, I just wanted to double check the previous version is still working to make sure not something else is causing the issue.

Now I have a question:
When building xlibre-server from xlibre git, I get an error during startx. I have attached the corresponding console output. What can I do? (that probably is an easy one).
 

Attachments

Yeah I know, I just wanted to double check the previous version is still working to make sure not something else is causing the issue.

Now I have a question:
When building xlibre-server from xlibre git, I get an error during startx. I have attached the corresponding console output. What can I do? (that probably is an easy one).
It looks like you have disabled the SUID wrapper option in the make configs and are trying to run X as a non root user.
 
It looks like you have disabled the SUID wrapper option in the make configs and are trying to run X as a non root user.
I have changed the following but it did not help:
Code:
root@elfreebsdo1:~/xlibre/xlibre-git/xserver # git diff
diff --git a/meson_options.txt b/meson_options.txt
index 6077dca96..dc6d28433 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -60,7 +60,7 @@ option('listen_local', type: 'boolean', value: true,
 option('int10', type: 'combo', choices: ['stub', 'x86emu', 'vm86', 'auto', 'false'],
        value: 'auto',
        description: 'Xorg int10 backend (default: usually x86emu)')
-option('suid_wrapper', type: 'boolean', value: false,
+option('suid_wrapper', type: 'boolean', value: true,
        description: 'SUID wrapper for legacy driver support')
 option('pciaccess', type: 'boolean', value: true,
        description: 'Xorg pciaccess support')
root@elfreebsdo1:~/xlibre/xlibre-git/xserver #
 
I have changed the following but it did not help:
Code:
root@elfreebsdo1:~/xlibre/xlibre-git/xserver # git diff
diff --git a/meson_options.txt b/meson_options.txt
index 6077dca96..dc6d28433 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -60,7 +60,7 @@ option('listen_local', type: 'boolean', value: true,
 option('int10', type: 'combo', choices: ['stub', 'x86emu', 'vm86', 'auto', 'false'],
        value: 'auto',
        description: 'Xorg int10 backend (default: usually x86emu)')
-option('suid_wrapper', type: 'boolean', value: false,
+option('suid_wrapper', type: 'boolean', value: true,
        description: 'SUID wrapper for legacy driver support')
 option('pciaccess', type: 'boolean', value: true,
        description: 'Xorg pciaccess support')
root@elfreebsdo1:~/xlibre/xlibre-git/xserver #
I think you misunderstood me, I was talking about the port option SUID you can set it in the menu that opens up when running make configure.
 
I think you misunderstood me, I was talking about the port option SUID you can set it in the menu that opens up when running make configure.
Ok, I was trying to find the upstream commit causing my problems by directly compiling from xlibre upstream repo.
Anyhow now I get what you meant and will try debugging in the port, unless you can help me to find the upstream commit (which might be more helpful).

Nevermind, now I understood what you mean.
 
Well it would be nice to see what commit caused this, so you can build and test the server with the commits between 25.0.0.5-25.0.0.7 in a binary search fashion.
To do this you would need to
  1. Set GH_TAGNAME=commithash in the xlibre-server Makefile
I have the impression that GH_TAGNAME handles tags not commit.
To start & test bisect with the working commit, I added
Code:
USE_GITHUB=    yes
GH_TAGNAME=    01a66863
to the Makefile and now receive
Code:
root@elfreebsdo1:~/xlibre/xlibre-ports/x11-servers/xlibre-server # make
===>  License MIT accepted by the user
===>   xlibre-server- depends on file: /usr/local/sbin/pkg - found
=> xlibre/server/X11Libre-xserver--01a66863_GH0.tar.gz is not in /root/xlibre/xlibre-ports/x11-servers/xlibre-server/distinfo.
=> Either /root/xlibre/xlibre-ports/x11-servers/xlibre-server/distinfo is out of date, or
=> xlibre/server/X11Libre-xserver--01a66863_GH0.tar.gz is spelled incorrectly.
*** Error code 1

Stop.
make[1]: stopped in /root/xlibre/xlibre-ports/x11-servers/xlibre-server
*** Error code 1

Stop.
make: stopped in /root/xlibre/xlibre-ports/x11-servers/xlibre-server
root@elfreebsdo1:~/xlibre/xlibre-ports/x11-servers/xlibre-server #

Any idea?
 
Back
Top