This makes the flatpak project more self-contained, and would have avoided the problems we encountered with unintended changes in the 1.14.7 release. See <https://diziet.dreamwidth.org/14666.html> for an opinionated description of some of the problems with submodules. If we can eliminate submodules altogether, then it will become possible to build Flatpak from a simple `git clone` or `git archive`, or from the source tarballs auto-generated by Github (which are equivalent to a `git archive`), without needing an extra step to populate the submodules. As well as reducing the support burden from users periodically complaining that our source releases are incomplete, this is a useful "nothing up my sleeve" mechanism to make it easy to verify that our source releases do not contain malicious changes hidden in vendored or generated files, like the one that made CVE-2024-3094 possible. Added with: git remote add --no-tags libglnx https://gitlab.gnome.org/GNOME/libglnx.git git fetch libglnx git subtree add -P subprojects/libglnx202b294e60git commit --amend -s To compare with upstream: git remote add --no-tags libglnx https://gitlab.gnome.org/GNOME/libglnx.git git fetch libglnx git diff HEAD:subprojects/libglnx libglnx/master After checking the diff, updates can be merged into this project with: git subtree merge -P subprojects/libglnx libglnx/master git commit --amend -s The commit merged here is the same one that was previously a submodule. A subsequent commit will update it to the latest version of libglnx, demonstrating how to review such updates. git-subtree-dir: subprojects/libglnx git-subtree-mainline: 7df25d63dfde9b4755479950f5b87bafe85cd277 git-subtree-split:202b294e60Signed-off-by: Simon McVittie <smcv@collabora.com>
libglnx is the successor to libgsystem.
It is for modules which depend on both GLib and Linux, intended to be used as a git submodule.
Features:
- File APIs which use
openat()like APIs, but also take aGCancellableto support dynamic cancellation - APIs also have a
GErrorparameter - High level "shutil", somewhat inspired by Python's
- A "console" API for tty output
- A backport of the GLib cleanup macros for projects which can't yet take a dependency on 2.40.
Why?
There are multiple projects which have a hard dependency on Linux and GLib, such as NetworkManager, ostree, flatpak, etc. It makes sense for them to be able to share Linux-specific APIs.
This module also contains some code taken from systemd, which has very high quality LGPLv2+ shared library code, but most of the internal shared library is private, and not namespaced.
One could also compare this project to gnulib; the salient differences there are that at least some of this module is eventually destined for inclusion in GLib.
Adding this to your project
Meson
First, set up a Git submodule:
git submodule add https://gitlab.gnome.org/GNOME/libglnx subprojects/libglnx
Or a Git subtree:
git remote add libglnx https://gitlab.gnome.org/GNOME/libglnx.git
git fetch libglnx
git subtree add -P subprojects/libglnx libglnx/master
Then, in your top-level meson.build:
libglnx_dep = subproject('libglnx').get_variable('libglnx_dep')
# now use libglnx_dep in your dependencies
Porting from libgsystem
For all of the filesystem access code, libglnx exposes only
fd-relative API, not GFile*. It does use GCancellable where
applicable.
For local allocation macros, you should start using the g_auto
macros from GLib. A backport is included in libglnx. There are a few
APIs not defined in GLib yet, such as glnx_autofd.
gs_transfer_out_value is replaced by g_steal_pointer.
Contributing
Development happens in GNOME Gitlab: https://gitlab.gnome.org/GNOME/libglnx
(If you're seeing this on the Github mirror, we used to do development on Github but that was before GNOME deployed Gitlab.)