summaryrefslogtreecommitdiff
path: root/contrib/scripts
Commit message (Collapse)AuthorAgeFilesLines
* contrib: show clang-format version in failure messageThomas Haller2023-04-181-1/+1
| | | | | | The actual formatting depends on the version of clang-format. Print the used version, which is in particular interesting when we get an error in our gitlab-ci check (which uses the correct version).
* find-backports: improve git_ref_exists() to cache also the hashes themselvesThomas Haller2023-04-071-17/+33
| | | | | git_ref_exists() memoizes the result. But while it looks up the SHA sum for "ref", it also can cache the result for the SHA sum itself.
* find-backports: warn if any commits are not from the first referenceThomas Haller2023-04-061-0/+26
| | | | | | | | | | | | | | | | | Every branch (for example "nm-1-40") has exactly one next branch, from which patches should be backported (in that example that branch is "nm-1-42"). While "find-backports" searches all newer branches for patches, it does not make it clear form where the patch should come from. That means, if you run the script `contrib/scripts/find-backports origin/nm-1-40` it will check nm-1-42 and main branch, and might suggest to backport patches that are only on main, but not "nm-1-42". That would be wrong, because patches need to first go into nm-1-42, and then backported (from there) further to nm-1-40. Print a warning to highlight that.
* find-backports: various cleanups in scriptThomas Haller2023-04-061-11/+11
| | | | | - avoid list([...]). - use some f-strings.
* find-backports: enable debug logging in scriptThomas Haller2023-04-061-10/+22
|
* checkpatch: discourage deprecated "(allow-none)" annotationThomas Haller2023-03-291-0/+1
|
* contrib,tools: move "nm-in-container.sh" script to "tools"Thomas Haller2023-03-206-870/+0
| | | | | This script seems very useful to me. Give it a more prominent place and move it out from "contrib/scripts". Also do some further renaming.
* nm-in-container: disable handling of "/etc/resolv.conf" in container and use ↵Thomas Haller2023-03-163-0/+10
| | | | | | | | | | | | | | 8.8.8.8. By default, podman bind mounts a "/etc/resolv.conf" file. That prevents NetworkManager (inside the container) to update the file, which leads to warnings in the log and certain NM-ci tests won't pass due to that. Disable handling of "/etc/resolv.conf" in podman. But also pre-deploy a default resolv.conf, with the google name server 8.8.8.8. I don't understand why, but even with "--dns=none", writing "/etc/resolv.conf" while building the container doesn't take effect. Instead, write a usable "/etc/resolv.conf" from "/etc/rc.d/rc.local".
* nm-in-container: add nm-deploy.sh script for reinstalling NetworkManagerThomas Haller2023-03-152-0/+16
|
* nm-in-container: symlink NM/NM-ci directories in nm-in-containerThomas Haller2023-03-151-3/+20
|
* contrib: escape shell arguments in "nm-setup-git.sh" outputThomas Haller2023-03-091-2/+12
|
* contrib: update history and hints in "nm-in-container.sh" scriptThomas Haller2023-03-081-3/+3
| | | | | Calling `nm-env-prepare.sh --prefix eth -i 1 && nmcli device connect eth1` has a race, where NetworkManager didn't see the interface yet. Add a sleep.
* contrib: install more packages in "nm-in-container.sh"Thomas Haller2023-03-031-0/+3
|
* contrib: add usage comment to "git-subtree-reimport.sh"Thomas Haller2023-03-031-0/+9
|
* systemd: merge branch systemd into mainThomas Haller2023-02-131-0/+1
|\ | | | | | | https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1529
* | contrib: accept ssh:// git url for origin in "nm-setup-git.sh"Thomas Haller2023-02-091-1/+2
| |
* | contrib: add "git-backport-merge" script for backporting merge commits in ↵Thomas Haller2023-02-032-0/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NetworkManager On the main branch, we commonly rebase our WIP branches to latest HEAD, before merging them with "--no-ff". The effect is to have a merge commit that acts as a parentheses around the set of patches. When backporting such a branch, we should preserve that structure and take the merge commit too. We should must use `git cherry-pick -x` to record the commit IDs of the original patch. This script helps with that. Also hook it up in "contrib/scripts/nm-setup-git.sh" to create an alias for it. This alias has the advantage, of fetching the latest version of the script from "main" or "origin/main", so it also works on older branches.
* | gitlab-ci: use "meson test" for running unit testsThomas Haller2023-01-301-4/+5
| | | | | | | | | | | | | | | | It seems that `meson test` is preferred over `ninja test`. Also, pass "--print-errorlogs" to meson, and pass "-v" to the build steps. Note that `ninja test` already ends up calling `meson test --print-errorlogs`, but it doesn't use "-v", so the logs are truncated.
* | gitlab-ci: rerun meson test on failure with debuggingThomas Haller2023-01-301-7/+10
| | | | | | | | | | | | Like done for autotools. First we run the test without debugging option. If it fails, we run it again to possibly trigger the failure again and get better logs.
* | gitlab-ci: explicitly set "NMTST_DEBUG=debug,..." for second debug runThomas Haller2023-01-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "debug" is implied when setting NMTST_DEBUG, but not specifying "no-debug". This change has thus no effect, but it seems clearer to be explicit. The "debug" flag affects nmtst_is_debug(). Note that tests *must* not result in different code paths based on debug, they may only 1) print more debug logging 2) do more assertion checks. Having more assertion checks can result in different outcome of the test, that is, that the additional assertion fails first. That is acceptable, because failing earlier is possibly closer to the issue and helps debugging. Also, when the additional failure is fixed and passes, we still will fail at the assertion we are trying to debug. In particular, an access to nmtst_get_rand*()/nmtst_rand*() must not depend on nmtst_is_debug(), because then different randomized paths are taken based on whether debugging is enabled.
* | gitlab-ci: fix randomizing tests in "nm-ci-run.sh"Thomas Haller2023-01-301-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code was just wrong. Usually in gitlab-ci, NMTST_SEED_RANDOM is unset, so the previous code would not have set it. Which means that our tests run with NMTST_SEED_RANDOM="0". Fuzzing (or randomizing tests) is very useful, we should do that for the unit tests that run in gitlab-ci. Fix this. But don't let the test choose a random number. Instead, let the calling script choose it. That is, because we might run the tests more than once (without debugging and no valgrind; in case of failure return with debugging; with valgrind). Those runs should use the same seed. This fixes commit 70487d9ff8a0 ('ci: randomize tests during our CI'), but as fixing randomization can break previously running tests, we may only want to backport this commit after careful evaluation.
* | contrib/copr: better detect git-ref in "nm-copr-build.sh"Thomas Haller2023-01-241-0/+1
| |
* | contrib/fedora: make "lto" in the spec file configurableThomas Haller2023-01-241-2/+2
| | | | | | | | | | | | | | | | | | 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: 0566e9dc63fb ('contrib: support disabling "LTO" in "nm-copr-build.sh"')
* | contrib: support disabling "LTO" in "nm-copr-build.sh"Thomas Haller2023-01-241-2/+13
| | | | | | | | | | | | | | | | | | 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.
* | contrib: add "reexec" step to "nm-in-container.sh"Thomas Haller2023-01-051-4/+9
| | | | | | | | Just a shortcut for reset and exec.
* | contrib: default to run same fedora version in nm-in-container.sh as hostThomas Haller2023-01-051-1/+8
| | | | | | | | | | If the out host runs Fedora, it's most useful that the container is the same Fedora version. Detect it.
* | contrib: install more package in "nm-in-container.sh"Thomas Haller2023-01-041-1/+61
| | | | | | | | | | | | | | | | | | 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.
* | contrib/scripts: update "nm-copr-build.sh" script to use new nm-git-bundleThomas Haller2022-12-201-1/+1
| |
* | contrib: fix duplicate package in "contrib/scripts/nm-in-container.sh" scriptThomas Haller2022-12-141-1/+0
| |
* | clang-format: reformat code with clang-format 15.0.4-1.fc37Thomas Haller2022-11-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | all: cleanup close() handling and clarify nm_close()/nm_close_with_error()Thomas Haller2022-10-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/
* | checkpatch: suggest nm_memdup() instead of g_memdup()Thomas Haller2022-10-181-0/+1
| |
* | contrib: discourage g_type_class_add_private() via "checkpatch.pl"Thomas Haller2022-10-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | contrib: add entries to bash_history for nm-in-container.sh scriptThomas Haller2022-09-281-0/+1
| |
* | contrib: add entries to bash_history for nm-in-container.sh scriptThomas Haller2022-09-281-3/+10
| |
* | contrib: handle non-existing files with `nm-code-format.sh -u`Thomas Haller2022-09-231-1/+14
| | | | | | | | | | | | | | | | | | | | "-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.
* | contrib: add "nm-code-format.sh -u" parameterThomas Haller2022-09-211-9/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | contrib: discourage g_array_index() in "checkpatch.pl"Thomas Haller2022-09-151-0/+1
| |
* | contrib: setup "nm-in-container.sh" on start via rc.local scriptThomas Haller2022-09-094-23/+25
| | | | | | | | | | | | | | | | 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.
* | contrib: update bash history for "nm-in-container.sh" and motdThomas Haller2022-09-071-3/+14
| |
* | contrib: add "reset" command to "nm-in-container.sh"Thomas Haller2022-09-011-9/+14
| | | | | | | | | | | | 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).
* | checkpatch.pl: discourage g_str_hash()/g_direct_hash() and g_direct_equal()Thomas Haller2022-08-311-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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.
* | contrib: add "--fast" flag to nm-core-format.sh to only check changed filesThomas Haller2022-08-241-11/+39
| | | | | | | | | | | | | | | | 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
* | contrib: install Polish translation in "nm-in-container.sh"Thomas Haller2022-08-231-0/+3
| | | | | | | | It's needed for the unit tests to test translations too.
* | contrib: set short DHCP lifetime in "nm-env-prepare.sh" scriptThomas Haller2022-08-101-1/+1
| |
* | contrib: install tcpdump with "nm-in-container.sh"Thomas Haller2022-08-101-0/+1
| | | | | | | | | | | | 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.
* | contrib: set fixed MAC address in "nm-env-prepare.sh" scriptThomas Haller2022-08-101-3/+5
| |
* | contrib: update bash history in nm-in-container.shThomas Haller2022-08-081-4/+9
| |
* | contrib: improve motd for nm-in-container.sh scriptThomas Haller2022-08-081-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | contrib: install "qt-devel" in nm-in-container.sh scriptThomas Haller2022-08-081-0/+1
| | | | | | | | | | | | | | 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.