Commit graph

726 commits

Author SHA1 Message Date
Thomas Haller 36ad5cbb3b
contrib/rpm: fix condition in "NetworkManager.spec" (3)
Fixes: 096b9955d6 ('contrib/fedora: make "lto" in the spec file configurable')
Fixes: 7a62845424 ('contrib/rpm: fix condition in "NetworkManager.spec"')
2023-01-24 12:29:04 +01:00
Thomas Haller 13dfdaf3a0
contrib/rpm: fix condition in "NetworkManager.spec" (2)
Fixes: 096b9955d6 ('contrib/fedora: make "lto" in the spec file configurable')
Fixes: 7a62845424 ('contrib/rpm: fix condition in "NetworkManager.spec"')
2023-01-24 11:46:44 +01:00
Thomas Haller 7a62845424
contrib/rpm: fix condition in "NetworkManager.spec"
Fixes: 096b9955d6 ('contrib/fedora: make "lto" in the spec file configurable')
2023-01-24 11:31:54 +01:00
Thomas Haller 096b9955d6
contrib/fedora: make "lto" in the spec file configurable
When we build a copr image, we run the "nm-copr-build.sh" script.
That script, should honor "LTO=0|1|" to explicitly enable/disable
LTO. Since the copr script only builds a SRPM, which then gets build
we need that the default LTO flag in the SRPM is templated.

Fixes: 0566e9dc63 ('contrib: support disabling "LTO" in "nm-copr-build.sh"')
2023-01-24 10:36:34 +01:00
Thomas Haller 0566e9dc63
contrib: support disabling "LTO" in "nm-copr-build.sh"
The "nm-copr-build.sh" script is run by our copr to generate the SRPM of
NetworkManager (via `curl ... | bash`).

Building with LTO takes a long time, for testing it can be nice to disable
that. Add an environment variable for that. It can be used when manually
building an RPM in copr.
2023-01-24 08:46:14 +01:00
Thomas Haller 128c000f0c
contrib/fedora: install "python36-gobject" when building with meson on centos7
With the meson build configuration, there is obviously python3 installed
and in the path. The build script will pick that up as preferred python.

However, we will also need working pygobject to build the documentation.
But we only have that for python2 installed. Fix that, by installing
"python36-gobject".
2023-01-23 21:39:00 +01:00
Thomas Haller ea16997c4a
contrib/fedora: disable "qt" build of examples for spec file
Otherwise, we require a C++ compiler, but our build requirements
don't install g++. So build will fail.
2023-01-23 18:24:56 +01:00
Thomas Haller a9cb294b73
contrib/fedora: explicitly set "pppd" path in configure script
We have "BuildRequires: ppp-devel". While in Fedora 37 that has a
dependency on "ppp" package, that is not the case on Centos7. I didn't
test others, but the point is it's not always there.

"/usr/sbin/pppd" is provided by "ppp" package, and we might not have it
installed via the build requirements. But we only need it to detect the
path, which is not necessary on RHEL/Fedora. Just set the path
explicitly with the respective configure option.
2023-01-23 18:24:56 +01:00
Lubomir Rintel ff472d8e59 rpm: don't BR dhcp-client
We don't need the builder to install dhcp-client to build with support for
it. Requiring it to be installed it not great because it has runtime
implications -- it installs a dispatcher script.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1503
2023-01-17 13:56:57 +01:00
Thomas Haller ae7e7bf3d3
contrib: add "reexec" step to "nm-in-container.sh"
Just a shortcut for reset and exec.
2023-01-05 08:59:10 +01:00
Thomas Haller 897a96da7b
contrib: default to run same fedora version in nm-in-container.sh as host
If the out host runs Fedora, it's most useful that the container is the
same Fedora version. Detect it.
2023-01-05 08:17:24 +01:00
Thomas Haller 81527052d7
contrib: install more package in "nm-in-container.sh"
NM-ci wants to install a lot of packages when running the first test.
In particular, NM-ci has no nice script that lists all the dependencies,
so it's not immediately clear which packages are required.

Still, install some of those packages so that they are already present
when running the first NM-ci test.
2023-01-04 21:40:00 +01:00
Thomas Haller ea80a4a813
contrib/scripts: update "nm-copr-build.sh" script to use new nm-git-bundle 2022-12-20 11:38:32 +01:00
Thomas Haller 8febb15bfe
contrib: fix duplicate package in "contrib/scripts/nm-in-container.sh" script 2022-12-14 10:07:23 +01:00
Thomas Haller c33a95e6f6
gitlab-ci: ignore failure to install "python-setuptools" on debian
python-setuptools is now gone from debian:testing ([1], [2]):

    Package python-setuptools is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source

    E: Package 'python-setuptools' has no installation candidate

This package is entirely optional. Fix the failure by ignoring any failure to
install the package.

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=938168
[2] https://tracker.debian.org/news/1391360/python-setuptools-removed-from-testing/
2022-11-29 19:54:19 +01:00
Thomas Haller 3fb8c0f614
clang-format: reformat code with clang-format 15.0.4-1.fc37
This is the version shipped in Fedora 37. As Fedora 37 is now out, the
core developers switch to it. Our gitlab-ci will also use that as base
image for the check-{patch.tree} tests and to generate the pages. There
is a need that everybody agrees on which clang-format version to use,
and that version should be the one of the currently used Fedora release.

Also update the used Fedora image in "contrib/scripts/nm-code-format-container.sh"
script.

The gitlab-ci still needs update in the following commit. The change
in isolation will break the "check-tree" test.
2022-11-23 09:17:21 +01:00
Thomas Haller ad7d5887cd
all: cleanup close() handling and clarify nm_close()/nm_close_with_error()
Cleanup the handling of close().

First of all, closing an invalid (non-negative) file descriptor (EBADF) is
always a serious bug. We want to catch that. Hence, we should use nm_close()
(or nm_close_with_error()) which asserts against such bugs. Don't ever use
close() directly, to get that additional assertion.

Also, our nm_close() handles EINTR internally and correctly. Recent
POSIX defines that on EINTR the close should be retried. On Linux,
that is never correct. After close() returns, the file descriptor is
always closed (or invalid). nm_close() gets this right, and pretends
that EINTR is a success (without retrying).

The majority of our file descriptors are sockets, etc. That means,
often an error from close isn't something that we want to handle. Adjust
nm_close() to return no error and preserve the caller's errno. That is
the appropriate reaction to error (ignoring it) in most of our cases.

And error from close may mean that there was an IO error (except EINTR
and EBADF). In a few cases, we may want to handle that. For those
cases we have nm_close_with_error().

TL;DR: use almost always nm_close(). Unless you want to handle the error
code, then use nm_close_with_error(). Never use close() directly.

There is much reading on the internet about handling errors of close and
in particular EINTR. See the following links:

https://lwn.net/Articles/576478/
https://askcodes.net/coding/what-to-do-if-a-posix-close-call-fails-
https://www.austingroupbugs.net/view.php?id=529
https://sourceware.org/bugzilla/show_bug.cgi?id=14627
https://news.ycombinator.com/item?id=3363819
https://peps.python.org/pep-0475/
2022-10-25 13:12:48 +02:00
Thomas Haller c7bc4e0c67
checkpatch: suggest nm_memdup() instead of g_memdup() 2022-10-18 20:31:21 +02:00
Thomas Haller 6cbad14721
contrib: discourage g_type_class_add_private() via "checkpatch.pl"
Our GObject structs should be internal API. In which case, we should
embed the private data in the struct themselves (`_priv`) and use the
_NM_GET_PRIVATE() macro. The advantage is better debugability because
following G_TYPE_INSTANCE_GET_PRIVATE() in the debugger is very
cumbersome. Another (less relevant) advantage is better performance.

Thus, warn about uses of g_type_class_add_private() and
G_TYPE_INSTANCE_GET_PRIVATE().

Note that if the struct and is in a header file (which is usually only
necessary when subclassing the type), then the private data should be
an opaque pointer `_priv` instead, and we should use the _NM_GET_PRIVATE_PTR()
macro. In that case, the use of g_type_class_add_private() and
G_TYPE_INSTANCE_GET_PRIVATE() is correct and the warning is false. But
this is only a warning, for the unusual case where we have deep object
hierarchies.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1396
2022-10-03 17:23:29 +02:00
Thomas Haller a80bb943b1
contrib: add entries to bash_history for nm-in-container.sh script 2022-09-28 18:35:48 +02:00
Thomas Haller 1fa9db0705
contrib: add entries to bash_history for nm-in-container.sh script 2022-09-28 17:51:15 +02:00
Thomas Haller 2f8bb7c86a
contrib: handle non-existing files with nm-code-format.sh -u
"-u" calls `git diff -name-only $UPSTREAM` to get a list of files.
However, if $UPSTREAM contains a file that doesn't exist in the current
checkout, we get a non-existing file name and clang-format will fail.

Avoid that, by filtering only files that exist.

Also, pass "--no-renames" option to git-diff.
2022-09-23 15:32:28 +02:00
Thomas Haller 6e0ede9d65
contrib: add "nm-code-format.sh -u" parameter
Reformatting the entire source tree takes quite long. For fast
development it's useful to only check the files that changes on the
current checkout.

For that there was already the "-F|--fast" option, but that only
compared the files that changed compared to HEAD^.

What actually would be useful is to check the files that changed on the
current branch, compared to some upstream commit. Add "-u|--upstream"
option to specify the upstream commit (usually "main").

As a special twist,

  ./contrib/scripts/nm-code-format.sh -u

is the same as

  ./contrib/scripts/nm-code-format.sh -u main
2022-09-21 10:22:32 +02:00
Thomas Haller e6b9f6ecd0
contrib: discourage g_array_index() in "checkpatch.pl" 2022-09-15 12:39:08 +02:00
Thomas Haller 5cfb9d9f78
contrib: setup "nm-in-container.sh" on start via rc.local script
We need to mount sysfs, so that `ip netns exec` works.
Do that automatically when starting the system container, via rc.local.

While at it, use `podman build --squash-all` to speedup the building of
the container image.
2022-09-09 17:46:00 +02:00
Thomas Haller 8686eb5927
contrib: fix syntax error in "configure-for-system.sh" 2022-09-08 15:29:10 +02:00
Thomas Haller a8b9aef08f
contrib: update bash history for "nm-in-container.sh" and motd 2022-09-07 09:09:32 +02:00
Thomas Haller 8ae132cc49
contrib: add "reset" command to "nm-in-container.sh"
It's between "stop" and "clean". It removes the container,
but keeps the container images. This is to fast restart without
rebuilding the container (image).
2022-09-01 16:33:39 +02:00
Thomas Haller 98c3ac1480
checkpatch.pl: discourage g_str_hash()/g_direct_hash() and g_direct_equal()
- instead of g_str_hash()/g_direct_hash(), use our own functions
  nm_str_hash()/nm_direct_hash(). Those use siphash24 with a random
  seed.

- don't pass g_direct_equal() to GHashTable. When omitting the equal
  function, it falls back to direct pointer comparison, which is likely
  faster. In any case, it's consistent to not use g_direct_hash()
  when using pointer equality.

- instead of g_int_hash()/g_int64_hash()/g_double_hash(), use
  our nm_pint_hash()/nm_pint64_hash()/nm_pdouble_hash(). The latter
  two don't exist yet.
  The reason is that we want to use siphash24.
  Yes, our name differs from glib's. Our naming seems to make sense
  to me however, because we also have nm_pstr_hash(), nm_pdirect_hash()
  and even nm_ppdirect_hash() for following the pointers. Naming is hard.

- instead of g_int_equal()/g_int64_equal()/g_double_equal() use
  our nm_pint_equal()/nm_pint64_equal()/nm_pdouble_equal(). The latter
  two don't exist yet. The reason is purely naming consistency since
  our hash variants follow the other name.
2022-08-31 10:59:22 +02:00
Thomas Haller 90b267afa7
contrib: add "--fast" flag to nm-core-format.sh to only check changed files
It's not the default, because a caller might not be aware that this flag
exists, and when calling the script without arguments, it should do
correct (albeit slow) thing.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1341
2022-08-24 12:06:34 +02:00
Thomas Haller f27b11dd3f
contrib: install Polish translation in "nm-in-container.sh"
It's needed for the unit tests to test translations too.
2022-08-23 15:42:42 +02:00
Thomas Haller 305f02a912
contrib: set short DHCP lifetime in "nm-env-prepare.sh" script 2022-08-10 15:34:43 +02:00
Thomas Haller 540112e36f
contrib: install tcpdump with "nm-in-container.sh"
It's useful for testing, which is what "nm-in-container.sh" is supposed
to provide. It's also only half a megabyte, so reasonably small to
install.
2022-08-10 15:26:41 +02:00
Thomas Haller f14bb2d7b6
contrib: set fixed MAC address in "nm-env-prepare.sh" script 2022-08-10 15:22:11 +02:00
Thomas Haller 0a26320c09
contrib: update bash history in nm-in-container.sh 2022-08-08 20:45:18 +02:00
Thomas Haller 341c46de84
contrib: improve motd for nm-in-container.sh script
Leave a hint about core-dumps.

Also, now we have `contrib/fedora/rpm/configure-for-system.sh` script,
which can configure the build in a way similar to what we get
when doing an RPM build.

That means, inside "contrib/scripts/nm-in-container.sh" we
can just type `make install`, and it will replace the pre-installed
NetworkManager.

The main advantage is that it becomes convenient to run NetworkManager
as a systemd service. Previously, the suggested was to to install
NetworkManager inside another prefix, and run it in the terminal.

Running NetworkManager as systemd service is also necessary for NM-ci,
which restarts the NetworkManager service, and you couldn't run a test,
if you just started NetworkManager in a terminal.

Previously, you had to build a complete RPM, which takes a lot of time.
2022-08-08 11:54:27 +02:00
Thomas Haller d966c2ac4c
contrib: install "qt-devel" in nm-in-container.sh script
Yes, it's a large dependency. But on your outer host you
probably configured NetworkManager with QT enabled (for the
example scripts). We want to compile the same work tree inside
the container. So install qt-devel.
2022-08-08 11:54:27 +02:00
Thomas Haller f2bd67b386
contrib/rpm: add "configure-for-system.sh" script to configure build
This will use the same option as when we do an RPM build.
The purpose is that you could type `make install` with such
a build, and it would replace the files that you'd get by installing
the NetworkManager RPMs.

Of course, you would not want to do that on your work station, but it
will be useful in a container, where we don't mind messing up the
installation.
2022-08-08 11:54:27 +02:00
Thomas Haller 4e4135842e
contrib/rpm: cleanup spec file to unify version comparisons
- always check fedora||rhel and not rhel||fedora.
- consistently use >= instead of >.
2022-08-08 11:54:27 +02:00
Thomas Haller 1e6e15cd80
contrib/rpm: prefer --with-$OPTION=yes|no over --with/--without and --enable/--disable
autotools accepts both --with-$OPTION/--without-$OPTION and
--with-$OPTION=yes|no. Consistently use the latter.

The advantage is that whether it's enabled becomes an argument, so in a
script you could do

  "--with-$OPTION=$VALUE"

Same for enable/disable option.
2022-08-08 11:54:27 +02:00
Lubomir Rintel 3ce3451040 Revert "contrib/rpm: enable -Werror on --with debug instead of --with test"
This reverts commit cac11c736d.
It went in accidentally.
2022-08-02 18:03:45 +02:00
Lubomir Rintel cac11c736d contrib/rpm: enable -Werror on --with debug instead of --with test
The test bcond is used to make test suite failure terminate the %check
phase. That should generally be done for distro builds.

What the distro builds shouldn't do is terminate the build on compiler
warnings, because they're fairly likely to appear on toolchain updates
without indicating actual bugs.

However, currently that's precisely what do we do now.

Let's use -Werror on debug builds instead. They are intentionally made
more prone to fail (e.g. trip more runtime assertions) because failures
can be more rapidly addressed and don't affect distro builds.
2022-08-02 15:06:13 +02:00
Thomas Haller 05825b0348
contrib: make nm-env-prepare.sh script executable 2022-07-29 17:26:58 +02:00
Thomas Haller 1c389445da
contrib: install /usr/bin/python for "nm-in-container.sh" 2022-07-29 17:23:20 +02:00
Thomas Haller 0f1cc3e954
contrib: show diff of git subtrees in "git-subtree-reimport.sh" script 2022-07-25 10:27:33 +02:00
Thomas Haller 8b20d2a856
contrib: add "git-subtree-reimport.sh" script 2022-07-19 08:53:47 +02:00
Lubomir Rintel 8d12cc8152 contrib/rpm: untangle setting of bcond_{test,debug} defaults
Resolve the defaults in build.sh instead of RPM macros. This looks less
terrible maintaining the same defaults as well as options to override it
upstream.

Moving it to the block that downstreams (Fedora, Red Hat) keep
customized makes it possible for them to also maintain customized
defaults here.

In particular, the downstreams should be able to enable bcond_test
at least for their production release (otherwise there's little point in
actually running tests at package build time).

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1286
2022-07-10 20:49:05 +02:00
Thomas Haller b12281089c
gitlab-ci: fix unit tests on centos7 for python-pexpect dependency
Fixes: 9570224e86 ('tests/client: add a pexpect-based test runner')
2022-07-06 18:36:52 +02:00
Thomas Haller d8a4b3bec2
all: reformat with clang-format (clang-tools-extra-14.0.0-1.fc36) and update gitlab-ci to f36 2022-07-06 11:06:53 +02:00
Thomas Haller 30d89a121d
contrib: fix "nm-python-black-format.sh" script to ignore systemd,c-util,nettools files
Otherwise, the path "src/c-stdaux/src/docs/conf.py" matches for
formatting. But this file is imported via git-subtree, we don't
want to format it.

Filter out such paths.
2022-07-06 10:44:18 +02:00