Commit Graph

171 Commits

Author SHA1 Message Date
Thomas Haller
866e3a2b51 contrib/scripts: update "nm-copr-build.sh" script to use new nm-git-bundle 2022-01-06 10:03:57 +01:00
Thomas Haller
34c59c96c5 contrib/scripts: better explain the purpose of nm-git-bundle 2022-01-06 10:01:51 +01:00
Thomas Haller
99f82b4b84 contrib: fix "find-backports" script to properly handle "Ignore-Backport" tag
The "Ignore-Backport" tag can be used to mark a commit that should not
be backported. Similar to the "cherry picked from" line, which indicates
that the patch was backported.

Anyway, this didn't work correctly, because we first pre-filter the
commits we search (as a performance optimization) by using `git-log` to
get a subset of the commits we want to investigate.

So if you had a commit with an "Ignore-Backport" tag, but without "cherry
picked from" line, then it wasn't found.

Fix that.
2022-01-05 09:30:16 +01:00
Thomas Haller
a6ff5ee448 contrib/scripts: add Fedora version to podmain container name for "nm-code-format-container.sh"
Older branches, like "nm-1-32" will always be formatted with a
different, older clang-format version. Luckily we also have on "nm-1-32"
branch the "nm-code-format-container.sh" script, so we can still
reformat the sources using the container.

However, as the name of the container was always "nm-code-format",
we would have to re-generate the container when we switch between
branches. As the container really only depends on the Fedora version
(as the clang-format version is tied to the corresponding Fedora
version), let's include the Fedora version in the name of the container.
2022-01-04 21:17:19 +01:00
Thomas Haller
081510ed94 gitlab-ci: use Fedora 35 as default build target 2021-11-29 09:31:09 +00:00
Thomas Haller
3e6c18e9af checkpatch: suggest to use _nm_setting_property_define_direct_*() for setting properties
We have multiple ways to define properties (like, GVariant based
nm_setting_option_*() or GObject based properties). For the latter,
they nowadays should all be implemented via _nm_setting_property_define_direct_*()
API.
2021-11-04 20:25:19 +01:00
Lubomir Rintel
ae4412b2fc contrib/checkpatch: recognize git subtree merges
Make checkpatch.pl identify subtree merges in "git am"-formatted
patches and reconstruct the full path names based in the subtree root.

This fixes some spurious warnings for parts of the tree that use
different coding style from what we usually do.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/989
2021-10-12 15:13:44 +02:00
Thomas Haller
34410c9c3e contrib: fix motd comment in "nm-in-container.sh" 2021-10-08 12:35:15 +02:00
Thomas Haller
82260cc5c2 contrib: add "contrib/scripts/test-ppp.sh" test script 2021-10-04 15:40:15 +02:00
Thomas Haller
1b488fe34c contrib: make it easy to test PPPoE in container script
It doesn't actually work inside the root-less container...
Well, it works as far as starting to activate, before it
fails. That is still somewhat useful. So have it there...
2021-10-04 15:40:15 +02:00
Thomas Haller
b9ff90c87d checkpatch: discourage use of g_clear_pointer()
We have nm_clear_pointer() instead, which does not cast the function
argument, and thus the compiler is better at checking the arguments.
2021-09-22 17:26:02 +02:00
Thomas Haller
48691a2101 contrib: improve nm-in-container.sh script (7) 2021-09-21 13:56:37 +02:00
Thomas Haller
bf6d5f355e contrib: improve nm-in-container.sh script (6) 2021-09-21 09:13:44 +02:00
Thomas Haller
6f2c69f484 contrib: improve nm-in-container.sh script (5) 2021-09-16 20:54:49 +02:00
Thomas Haller
3e80b4fa63 contrib: reformat by default from "nm-code-format.sh" script
The majority of times when I call this script, I want it to do the reformatting,
not the check-only mode. This is also because we use git, so I start with a
clean working directory and run the reformatting code. In the best case, there
is nothing to reformat, and all is good. I seldom want to only check.

Change the default of the script.
2021-09-16 09:01:50 +02:00
Thomas Haller
1a56dcd4da contrib: explicitly pass "-n" to "nm-code-format.sh" in "code-style-git-post-commit-hook"
"nm-code-format.sh" is going to change the default behavior from "-n" to
"-i", that is, from check-only to reformat. Explicitly pass "-n" where
we want it.
2021-09-16 08:47:38 +02:00
Thomas Haller
ef7258eafe contrib: improve nm-in-container.sh script (4) 2021-09-15 22:08:42 +02:00
Thomas Haller
a9f6f49c8a gitignore: fix ignore file for nm-in-container.d 2021-09-15 22:08:41 +02:00
Thomas Haller
4c007c4c27 contrib: fix "nm-code-format.sh" to select files to format
There was always the idea that you could pass paths and filenames
to "nm-code-format.sh" to format only a subset. However, the script
also needs to honor files that should be excluded and don't need
formatting.

Previously, what was implemented via `git ls-files -- ':(exclude)...'`
command, but git-ls-files has a bug ([1]) and might not list all files.

Refactor and do the filtering ourselves.

[1] https://www.spinics.net/lists/git/msg397982.html
2021-09-15 22:08:13 +02:00
Thomas Haller
756757102f contrib: improve nm-in-container.sh script 2021-09-15 12:31:23 +02:00
Thomas Haller
dbcbb45224 contrib: improve nm-in-container.sh script 2021-09-14 22:26:12 +02:00
Thomas Haller
7fea431061 contrib: improve nm-in-container.sh script 2021-09-14 20:23:15 +02:00
Thomas Haller
d7c0dcc7b4 contrib: improve nm-in-container.sh script 2021-09-13 22:18:51 +02:00
Thomas Haller
549424273a contrib: add nm-in-container.sh script to build a (podman) container for testing
Only a first attempt. It needs more improvements.
2021-09-13 16:57:31 +02:00
Thomas Haller
023c8ad88b code-format: exclude "src/linux-headers" from "nm-code-format.sh" script 2021-09-06 10:00:35 +02:00
Thomas Haller
3a39ce6a99 checkpatch: encourage g_snprintf() over snprintf()
The only reason is consistency. The majority of times we
do use g_snprintf(). As there are no strong reasons to
prefer one over the other, prefer the one that use use
most of the time.
2021-08-26 14:59:53 +02:00
Thomas Haller
a99ac7ccd8 glib-aux: add nm_g_idle_add()
g_idle_add() is discouraged, and the checkpatch.pl script warns
about it.

Sometimes there is a legitimate use of it, when you want to always
schedule an idle action (without intent to cancel or track it). That
makes more sense for g_idle_add() than it does for g_timeout_add(),
because a timeout really should be tracked and cancelled if necessary.

Add a wrapper to rename the legitimate uses. This way, we can avoid the
checkpatch.pl warnings, and can grep for the remaining illegitimate uses.
2021-07-26 15:30:04 +02:00
Beniamino Galvani
1e3bbdfbbb contrib: add script to test IPv6 prefix delegation
Add a script to test IPv6 prefix delegation with NM, in different
modes.
2021-07-13 09:43:04 +02:00
Thomas Haller
5388542fc0 checkpatch: discourage use of API that uses numeric source IDs
The numeric source IDs exist from a time before 2000, when there
was only one "GMainContext" singleton instance. Nowadays, the source
ID is only relative to one GMainContext, and you'd have to track
that association yourself. Als, g_source_remove() requires an additional
hash lookup, when you could simply track the GSource instance from the
start.

This API should not be used anymore. Operate on GSouce instances
direclty and use API like

  nm_clear_g_source_inst()
  nm_g_idle_add_source()
  nm_g_idle_souce_new()
  nm_g_source_attach()
  g_source_attach
  g_source_destroy
  g_source_unref
  etc.

Note that if you don't care about to ever remove a source again, like
scheduling an idle action that should not be cancelled, then

  g_idle_add(callback, user_data);

is fine. It is only problematic to do something with those numeric IDs.
checkpatch.pl would also flag those uses, but these are just warnings
and in the few cases where such a warning is emitted wrongly, it's find
to ignore them.
2021-06-28 13:31:33 +02:00
Thomas Haller
26090bafc9 contrib: extend "test-create-many-device-setup.sh" script 2021-06-22 09:47:44 +02:00
Thomas Haller
be4b997e4f examples: add "examples/python/gi/nm-up-many.py"
It's an example for how to use libnm and asynchronous API.
But it's also a script I will use to test activating many
profiles in parallel.

Also add a test script that creates many veth interfaces and connection
profiles. So now you can do:

   sudo NUM_DEVS=100 contrib/scripts/test-create-many-device-setup.sh setup
   ./examples/python/gi/nm-up-many.py c-a{1..100}

and cleanup with

   nmcli connection down c-a{1..100}
   sudo contrib/scripts/test-create-many-device-setup.sh cleanup

Of course, be careful to do this on your production machine.
2021-06-11 22:48:41 +02:00
Thomas Haller
39d71ee356 contrib: update NM-log script to highlight "enslaving to master" messages 2021-06-11 10:54:15 +02:00
Thomas Haller
6439c243e7 systemd: move "src/core/systemd" to "src/libnm-systemd-core"
This follows the recently introduced naming scheme and directory layout.
"libnm-systemd-core" is an independent component, and as such should no
be inside "src/core/".

Move it.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/875
2021-05-30 09:45:05 +02:00
Thomas Haller
6365d8c67a contrib/scripts: drop unnecessary line in "find-backports" script 2021-05-26 23:38:58 +02:00
Thomas Haller
fb2ea999ea clang-format: update "nm-code-format-container.sh" script to use Fedora 34 container 2021-05-04 13:56:27 +02:00
Thomas Haller
23a200d19e checkpatch: warn about uses of strcmp()/g_strcmp0()
Using strcmp()/g_strcmp0() for checking for string equality is hard
to read. We should prefer our streq variants -- unless, you really
mean cmp.
2021-04-26 09:53:11 +02:00
Thomas Haller
74fc279341 contrib: fix URL to nm-git-bundle in "nm-copr-build.sh" 2021-04-01 22:34:06 +02:00
Thomas Haller
172dace30d contrib/scripts: use "main" branch name in "checkpatch-feature-branch.sh" 2021-04-01 22:28:59 +02:00
Thomas Haller
f938ec6977 contrib: update nm-git-bundle to use "main" branch 2021-04-01 22:24:49 +02:00
Thomas Haller
f0612bd67b contrib/scripts: update find-backports script to use "main" branch name 2021-04-01 21:40:25 +02:00
Thomas Haller
e643703418 tests/client: run "test-client.py" also for meson 2021-03-15 17:10:56 +01:00
Thomas Haller
afd55358a4 contrib/scripts: fix "nm-copr-build.sh" script to use new nm-git-bundle 2021-03-03 11:00:06 +01:00
Thomas Haller
3906cc9cf4 build: move c-util/nettools library from "shared/" to "src/" 2021-02-24 12:48:28 +01:00
Thomas Haller
a8c34b9dcf build: move "shared/nm-std-aux" to "src/libnm-std-aux" 2021-02-24 12:48:24 +01:00
Thomas Haller
39225258d6 build: move "shared/systemd" to "src/libnm-systemd-shared" 2021-02-24 12:48:16 +01:00
Thomas Haller
ac1a9e03e4 all: move "src/" directory to "src/core/"
Currently "src/" mostly contains the source code of the daemon.
I say mostly, because that is not true, there are also the device,
settings, wwan, ppp plugins, the initrd generator, the pppd and dhcp
helper, and probably more.

Also we have source code under libnm-core/, libnm/, clients/, and
shared/ directories. That is all confusing.

We should have one "src" directory, that contains subdirectories. Those
subdirectories should contain individual parts (libraries or
applications), that possibly have dependencies on other subdirectories.
There should be a flat hierarchy of directories under src/, which
contains individual modules.

As the name "src/" is already taken, that prevents any sensible
restructuring of the code.

As a first step, move "src/" to "src/core/". This gives space to
reorganize the code better by moving individual components into "src/".

For inspiration, look at systemd's "src/" directory.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/743
2021-02-04 09:45:55 +01:00
Thomas Haller
7869aacf61 gitlab-ci: skip valgrind on Debian/sid with glib2.0 (2.66.4-2)
See-also: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1902#note_1018573
2021-01-28 14:50:32 +01:00
Thomas Haller
8e735a51b8 contrib: handle no files in "nm-code-format.sh"
Calling `clang-format` with no files means to read
stdin, it thus hangs:

   $ ./contrib/scripts/nm-code-format.sh .git

Also, the following does not work:

   $ ./contrib/scripts/nm-code-format.sh src/platform/

hangs. Seems there is a bug in `git ls-files` to not list all files:

   podman run -ti alpine:latest \
      sh -c '
         apk add git &&
         git clone https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git &&
         cd NetworkManager &&
         git checkout -B tmp cd754680a6 &&
         echo ">>>>>>BAD1: $PWD" &&
         git ls-files -- src/platform/ ":(exclude)shared/n-acd"
         echo ">>>>>>GOOD1: $PWD" &&
         git ls-files -- src/platform/ ":(exclude)shared/c-list"
         echo ">>>>>>GOOD2: $PWD" &&
         git ls-files -- src/platform ":(exclude)shared/n-acd"
         echo ">>>>>>GOOD3: $PWD" &&
         git ls-files -- src/vpn/ ":(exclude)shared/n-acd"
      '

Fixes: 9bef4ece92 ('contrib: improve nm-code-format.sh script')
2021-01-13 16:49:09 +01:00
Thomas Haller
9bef4ece92 contrib: improve nm-code-format.sh script
- accept directory names in the command line. In that case,
  still honor the excluded files. That is a major improvement
  for me, because I usually only want to reformat a directory
  that I know has changed and it is fast to only process some
  directories.

- pass all files at once to clang-format. For me that gives
  a significant speed improvement (about 3 times faster), although
  clang-format is only single threaded. Possibly clang-format could
  even be faster by checking files in parallel.
  In case of a style error, the script still falls back to
  iterate over all files to find the first bad file and print
  the full diff. But that is considered an unusual case.

- make it correctly work from calling it from a subdirectory.
  In that case, we only check files inside that directory --
  but still correctly honor the excluded files.
2021-01-13 12:57:48 +01:00
Thomas Haller
d26fa1cd52 contrib: fix "contrib/scripts/nm-copr-build.sh" script 2021-01-12 14:53:00 +01:00