Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "libglnx"]
path = subprojects/libglnx
url = https://gitlab.gnome.org/GNOME/libglnx.git
[submodule "debugedit"]
path = subprojects/debugedit
url = https://sourceware.org/git/debugedit.git
1 change: 0 additions & 1 deletion subprojects/libglnx
Submodule libglnx deleted from 202b29
21 changes: 21 additions & 0 deletions subprojects/libglnx/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2015 Colin Walters
# SPDX-License-Identifier: LGPL-2.1-or-later

# A path ostree writes to work around automake bug with
# subdir-objects
Makefile-libglnx.am.inc

libglnx-config.h

# Some standard bits
.deps
.libs
.dirstamp
*.typelib
*.la
*.lo
*.o
*.pyc
*.stamp
*~

41 changes: 41 additions & 0 deletions subprojects/libglnx/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2019 Endless OS Foundation LLC
# SPDX-License-Identifier: LGPL-2.0-or-later

image: registry.fedoraproject.org/fedora:30

stages:
- build

before_script:
- dnf install -y gcc git meson ninja-build "pkgconfig(gio-2.0)" "pkgconfig(gio-unix-2.0)" "pkgconfig(glib-2.0)" xz

build:
stage: build
script:
- meson _build .
- ninja -C _build
- meson test -C _build
# Run it again! This previously did not work.
- meson test -C _build
# Ensure that we can build as a subproject
- rm -fr _build/meson-dist
- meson dist -C _build
- mkdir -p tests/use-as-subproject/subprojects/libglnx
- tar --strip-components=1 -C tests/use-as-subproject/subprojects/libglnx -xf _build/meson-dist/*.tar.xz
- meson tests/use-as-subproject/_build tests/use-as-subproject
- ninja -C tests/use-as-subproject/_build
- meson test -C tests/use-as-subproject/_build
artifacts:
when: on_failure
name: "libglnx-${CI_COMMIT_REF_NAME}-${CI_JOB_NAME}"
paths:
- "${CI_PROJECT_DIR}/_build/meson-logs"

reuse:
stage: build
image:
name: fsfe/reuse:latest
entrypoint: [""]
before_script: []
script:
- reuse lint
3 changes: 3 additions & 0 deletions subprojects/libglnx/COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This project's licensing is REUSE-compliant <https://reuse.software/>.
See individual files for full details of copyright and licensing,
and see LICENSES/*.txt for the license text.
174 changes: 174 additions & 0 deletions subprojects/libglnx/LICENSES/LGPL-2.0-or-later.txt

Large diffs are not rendered by default.

502 changes: 502 additions & 0 deletions subprojects/libglnx/LICENSES/LGPL-2.1-or-later.txt

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions subprojects/libglnx/LICENSES/LicenseRef-old-glib-tests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
This work is provided "as is"; redistribution and modification
in whole or in part, in any medium, physical or electronic is
permitted without restriction.

This work is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

In no event shall the authors or contributors be liable for any
direct, indirect, incidental, special, exemplary, or consequential
damages (including, but not limited to, procurement of substitute
goods or services; loss of use, data, or profits; or business
interruption) however caused and on any theory of liability, whether
in contract, strict liability, or tort (including negligence or
otherwise) arising in any way out of the use of this software, even
if advised of the possibility of such damage.
90 changes: 90 additions & 0 deletions subprojects/libglnx/Makefile-libglnx.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Copyright (C) 2015 Colin Walters <[email protected]>
# SPDX-License-Identifier: LGPL-2.0-or-later
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

EXTRA_DIST += \
$(libglnx_srcpath)/README.md \
$(libglnx_srcpath)/COPYING \
$(libglnx_srcpath)/LICENSES/LGPL-2.0-or-later.txt \
$(libglnx_srcpath)/LICENSES/LGPL-2.1-or-later.txt \
$(libglnx_srcpath)/libglnx.m4 \
$(NULL)

BUILT_SOURCES += $(top_builddir)/libglnx-config.h
CLEANFILES += $(top_builddir)/libglnx-config.h
$(top_builddir)/libglnx-config.h: Makefile.am
echo '#include "config.h"' > $@

libglnx_la_SOURCES = \
$(libglnx_srcpath)/glnx-macros.h \
$(libglnx_srcpath)/glnx-backport-autocleanups.h \
$(libglnx_srcpath)/glnx-backport-autoptr.h \
$(libglnx_srcpath)/glnx-backport-testutils.h \
$(libglnx_srcpath)/glnx-backport-testutils.c \
$(libglnx_srcpath)/glnx-backports.h \
$(libglnx_srcpath)/glnx-backports.c \
$(libglnx_srcpath)/glnx-local-alloc.h \
$(libglnx_srcpath)/glnx-local-alloc.c \
$(libglnx_srcpath)/glnx-errors.h \
$(libglnx_srcpath)/glnx-errors.c \
$(libglnx_srcpath)/glnx-console.h \
$(libglnx_srcpath)/glnx-console.c \
$(libglnx_srcpath)/glnx-dirfd.h \
$(libglnx_srcpath)/glnx-dirfd.c \
$(libglnx_srcpath)/glnx-fdio.h \
$(libglnx_srcpath)/glnx-fdio.c \
$(libglnx_srcpath)/glnx-lockfile.h \
$(libglnx_srcpath)/glnx-lockfile.c \
$(libglnx_srcpath)/glnx-missing-syscall.h \
$(libglnx_srcpath)/glnx-missing.h \
$(libglnx_srcpath)/glnx-xattrs.h \
$(libglnx_srcpath)/glnx-xattrs.c \
$(libglnx_srcpath)/glnx-shutil.h \
$(libglnx_srcpath)/glnx-shutil.c \
$(libglnx_srcpath)/libglnx.h \
$(libglnx_srcpath)/tests/libglnx-testlib.h \
$(NULL)

libglnx_la_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags) -I$(builddir)
libglnx_la_LDFLAGS = -avoid-version -Bsymbolic-functions -export-symbols-regex "^glnx_" -no-undefined -export-dynamic
libglnx_la_LIBADD = $(libglnx_libs)

libglnx_tests = test-libglnx-xattrs test-libglnx-fdio test-libglnx-errors test-libglnx-macros test-libglnx-shutil
TESTS += $(libglnx_tests)

libglnx_testlib_sources = $(libglnx_srcpath)/tests/libglnx-testlib.c

check_PROGRAMS += $(libglnx_tests)
test_libglnx_xattrs_SOURCES = $(libglnx_testlib_sources) $(libglnx_srcpath)/tests/test-libglnx-xattrs.c
test_libglnx_xattrs_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
test_libglnx_xattrs_LDADD = $(libglnx_libs) libglnx.la

test_libglnx_fdio_SOURCES = $(libglnx_testlib_sources) $(libglnx_srcpath)/tests/test-libglnx-fdio.c
test_libglnx_fdio_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
test_libglnx_fdio_LDADD = $(libglnx_libs) libglnx.la

test_libglnx_errors_SOURCES = $(libglnx_testlib_sources) $(libglnx_srcpath)/tests/test-libglnx-errors.c
test_libglnx_errors_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
test_libglnx_errors_LDADD = $(libglnx_libs) libglnx.la

test_libglnx_macros_SOURCES = $(libglnx_testlib_sources) $(libglnx_srcpath)/tests/test-libglnx-macros.c
test_libglnx_macros_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
test_libglnx_macros_LDADD = $(libglnx_libs) libglnx.la

test_libglnx_shutil_SOURCES = $(libglnx_testlib_sources) $(libglnx_srcpath)/tests/test-libglnx-shutil.c
test_libglnx_shutil_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
test_libglnx_shutil_LDADD = $(libglnx_libs) libglnx.la
82 changes: 82 additions & 0 deletions subprojects/libglnx/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
libglnx is the successor to [libgsystem](https://gitlab.gnome.org/Archive/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 a `GCancellable`
to support dynamic cancellation
- APIs also have a `GError` parameter
- 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](https://github.com/git/git/blob/master/contrib/subtree/git-subtree.txt):

```
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.)

<!--
Copyright 2015-2018 Colin Walters
Copyright 2019 Endless OS Foundation LLC
SPDX-License-Identifier: LGPL-2.1-or-later
-->
Loading