Commit graph

352 commits

Author SHA1 Message Date
Frantisek Sumsal 782051f3cb tools: pylint generate-gperfs.py 2023-08-10 18:13:29 +02:00
Frantisek Sumsal 8b1932cf2d tools: pylint dbus_exporter.py 2023-08-10 11:08:17 +02:00
Frantisek Sumsal f56accb6ef tools: pylint check-includes.py 2023-08-10 11:08:17 +02:00
Frantisek Sumsal b4048aaa1e tools: pylint catalog-report.py 2023-08-10 11:08:17 +02:00
Frantisek Sumsal e7ecc24eda tools: pylint analyze-dump-sort.py 2023-08-10 11:08:17 +02:00
Yu Watanabe 9289e093ae meson: use install_emptydir() and drop meson-make-symlink.sh
The script is mostly equivalent to 'mkdir -p' and 'ln -sfr'.
Let's replace it with install_emptydir() builtin function and
inline meson call.
2023-08-08 22:11:34 +01:00
Luca Boccassi fcd71b62be
Merge pull request #28595 from medhefgo/elf2efi-fixes
elf2efi: Fixes
2023-07-31 00:07:28 +01:00
Jan Janssen ee91e06a58 elf2efi: Fix header size calculation
The PE header size calculation failed to take the PE magic and coff
header size into account, which will lead to header truncation if we are
writing only 5 sections.
2023-07-30 21:31:38 +02:00
Yu Watanabe e95acdfe1d meson: drop short script to generate vcs tag 2023-07-30 04:54:03 +09:00
Daan De Meyer 09444a2e76 elf2efi: Make compatible with python 3.6 again
CentOS 8 ships python 3.6 so let's try and stay compatible with that
since the only feature we're using that requires python 3.9 is the
streamlined type annotations which are trivial to convert back to
the older stuff to stay compatible with python 3.6.
2023-07-14 14:41:19 +02:00
Zbigniew Jędrzejewski-Szmek c18dde32e5 man: generate link mode list dynamically
The entries are sorted by speed. Some fields are left empty when there is no
clear value to use. The table is much longer now, but I think it's better to
document the allowed values, even if some are not terribly useful.

Fixes #26256.
2023-05-30 13:05:33 +02:00
Luca Boccassi e78fc81d30 elf2efi: ensure minimum gap between .text and other sections
When linking an almost empty binary the linker can merged .text with
a later section, creating a RWE segment, that then it rejects.
2023-05-24 11:06:36 +01:00
Luca Boccassi e18e3c4305 elf2efi: add parameter to increase reserved space for headers
When building a minimal empty addon it would not have enough
space to append sections. Add an option that will later be
used to reserve enough space.
2023-05-24 11:06:36 +01:00
Jan Janssen ab7d54b9dd elf2efi: Do not emit an empty relocation section
At least shim will choke on an empty relocation section when loading the
binary. Note that the binary is still considered relocatable (just with
no base relocations to apply) as we do not set the
IMAGE_FILE_RELOCS_STRIPPED DLL characteristic.
2023-05-23 22:47:28 +01:00
Zbigniew Jędrzejewski-Szmek e11c9ba7bf tools/oss-fuzz: s/perl/awk/
The pattern is not exactly the same, but I don't think we need to
be super-precise here.
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek e76ff43236 tools/check-includes: compat with Python 3.7
I thought that 3.8 is enough. But Centos8 CI chokes on the walrus.
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek 495658d43c check-includes: print path relative to project root
Instead of /home/zbyszek/src/systemd-work/build/../src/xdg-autostart-generator/xdg-autostart-service.h:11,
print just src/xdg-autostart-generator/xdg-autostart-service.h:11.

This is a bit annoying that this requires so much verbosity, but the output
with the full names was too annoying.
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek c4a090d60e Rewrite check-includes.pl in python 2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek 85a336f81d tools: add dump-auxv.py
This is a little helper I used when preparing the tests for auxv
parsing. Just looking at hexdump output is pretty hard. We could
enhance it to display some specific data types better.
2023-03-24 18:49:34 +00:00
Jan Janssen 31ffb6b183 boot: Add RISCV32 and LoongArch support
This is completely untested, but should work in theory, as it's just
adding a couple defines according to the specs.
2023-03-10 11:41:08 +01:00
Jan Janssen c4ad9b23ca boot: Fix debug experience 2023-03-10 11:41:08 +01:00
Jan Janssen 2afeaf1675 boot: Bring back bootloader builds
This adds back sd-boot builds by using meson compile targets directly.
We can do this now, because userspace binaries use the special
dependency that allows us to easily separate flags, so that we don't
pass anything to EFI builds that shouldn't be passed.

Additionally, we pass a bunch of flags to hopefully disable/override any
distro provided flags that should not be used for EFI binaries.

Fixes: #12275
2023-03-10 11:41:08 +01:00
Jan Janssen dfca5587cf tree-wide: Drop gnu-efi
This drops all mentions of gnu-efi and its manual build machinery. A
future commit will bring bootloader builds back. A new bootloader meson
option is now used to control whether to build sd-boot and its userspace
tooling.
2023-03-10 11:41:03 +01:00
Yu Watanabe e3b2f7c056 tools: explicitly specify "setup" subcommand
As invoking meson without subcommand is deprecated since 0.64.0.
2023-03-03 20:06:30 +09:00
Yu Watanabe 26ab5ea69d tools: fix the file name that "meson setup" generates 2023-03-03 19:54:38 +09:00
Zbigniew Jędrzejewski-Szmek a324a8958b meson: adjust whitespace handling in jinja2 rendering
In 6abe882bae the renderer was made to
unconditionally append a newline to output. This works, but is ugly. A nicer
solution is to tell jinja2 to not strip the newline in the first place, via
keep_trailing_newline=True. It seems that the result is unchanged because all
our source files have exactly one trailing newline.

Also, enable lstrip_blocks=True. This would cause whitespace on the line before
an {%if block to be automatically stripped. It seems reasonable to enable that
if trim_blocks=True.

Overall, no change is expected, though I didn't test combinations of
configurations, so there might be a change in some cases. But now the rules of
rendering are more logical, e.g. we should be able to indent nested conditional
statements without getting unexpected whitespace in the output.
2023-02-21 06:41:19 +09:00
Zbigniew Jędrzejewski-Szmek 397c27097b tools: replace multi-line echo by <<EOF 2023-02-06 09:19:04 +01:00
Zbigniew Jędrzejewski-Szmek 7a17e41dcf test: drop whitespace after shell redirection operators
(The one case that is left unchanged is '< <(subcommand)'.)

This way, the style with no gap was already dominant. This way, the reader
immediately knows that ' < ' is a comparison operator and ' << ' is a shift.

In a few cases, replace custom EOF replacement by just EOF. There is no point
in using someting like "_EOL" unless "EOF" appears in the text.
2023-02-06 09:19:04 +01:00
Frantisek Sumsal bef8d18b3f oss-fuzz: include generated corpora in the final zip file
Since the files with generated directives are now automatically
generated during build, they're now under the respective build directory
which the current oss-fuzz CI script didn't account for.

Follow-up to: #24958
Resolves: #25859
2023-01-07 17:44:23 +01:00
Zbigniew Jędrzejewski-Szmek db81144428 tree-wide: BLS and DPS are now on uapi-group website 2022-11-21 12:26:35 +01:00
Luca Boccassi 034fe54cd5
Merge pull request #24958 from Werkov/meson-generated-directives
Generate dirrectives for fuzzer tests
2022-10-31 21:04:30 +01:00
Zbigniew Jędrzejewski-Szmek aa314c87c5 Report version string as in the Boot Loader Spec, fix boot loader upgrades
We generate a "version string" that is reported by various tools. This patch
changes this version string to use the characters specified for the version
string in the Boot Loader Specification. We start using the special characters
we have in the spec for this exact purpose and thus fix version comparisons.
We also stop using '+' which is not part of the allowed charset and is used for
boot attempt counting and should not be part of the version string.

The version string is (among other places) used in sd-boot and the comparison
result is used by 'bootctl update' to decide whether to install a new binary.
Before, because 'nn-rc1' compares higher than 'nn', we would refuse to upgrade
pre-release versions.

The boot loader is the primary motivation. I'm not aware of programatic version
comparisons in other places, but it makes sense to use the same versions string
everywhere.

(This patch effectively only matters for non-distro builds, because distro
builds presumably use -Dversion-tag to set something meaningful. Ideally, those
version strings are compatible with our version strings, but this is outside of
our control.)
2022-10-25 13:23:57 +02:00
Michal Koutný 7e343b530e meson: Generate fuzzer inputs with directives
The lists of directives for fuzzer tests are maintained manually in the
repo. There is a tools/check-directives.sh script that runs during test
phase and reports stale directive lists.
Let's rework the script into a generator so that these directive files
are created on-the-flight and needn't be updated whenever a unit file
directives change. The scripts is rewritten in Python to get rid of gawk
dependency and each generated file is a separate meson target so that
incremental builds refresh what is just necessary (and parallelize
(negligible)).

Note: test/fuzz/fuzz-unit-file/directives-all.slice is kept since there
is not automated way to generate it (it is not covered by the check
script neither).
2022-10-20 14:43:50 +02:00
Zbigniew Jędrzejewski-Szmek da7dfd8ef5 docs/DPS: use the SD_GPT_* constants here too 2022-09-21 15:30:31 +02:00
Zbigniew Jędrzejewski-Szmek 974fcc916c tools/list-discoverable-partitions: make the script work again 2022-09-20 16:48:50 +02:00
Frantisek Sumsal 176086a2ec ci: simplify the Coverity script a bit
Also, address https://github.com/systemd/systemd/pull/24252#issuecomment-1208747320
by using a pre-defined e-mail address stored in the GH Action secrets.
2022-08-11 10:57:25 +02:00
Daan De Meyer c9bd01ae90 meson: Switch default-locale default to C.UTF-8
We're already using C.UTF-8 as the default locale for nspawn. Let's
make the same change for the default-locale option instead of deciding
what to use based on the locale used by the host system. Users can
still override the locale using the default-locale option if needed.
2022-06-04 05:08:37 +09:00
Evgeny Vereshchagin b22f5ed5fb oss-fuzz: support i386
Closes https://github.com/systemd/systemd/issues/23532
2022-05-29 09:32:00 +00:00
наб ee0d4cf74a
Fix which(1) in meson-build.sh 2022-05-23 12:52:56 +02:00
Evgeny Vereshchagin 51cef2b56f
Merge pull request #23246 from medhefgo/check-compilation
meson: Improve public header tests
2022-05-05 01:53:28 +03:00
Yu Watanabe 9b260c967b
Merge pull request #23264 from keszybz/shorten-test-names
Shorten test names
2022-05-04 23:25:47 +09:00
Jan Janssen 911c15087c meson: Remove check-compilation.sh
No need to involve a trivial shell script for this.

We could call the compiler directly, but test() expects arguments
to be passed separately and cc.cmd_array() can contain arguments
itself. Using env is easier than manually slicing the array because
meson has no builtins for that.
2022-05-04 15:59:51 +02:00
Zbigniew Jędrzejewski-Szmek d7ff524039 tree-wide: drop manually-crafted message for missing variables
Bash will generate a very nice message for us:
/tmp/ff.sh: line 1: SOMEVAR: parameter null or not set

Let's save some keystrokes by not replacing this with our own inferior
messages.
2022-05-04 20:53:46 +09:00
Zbigniew Jędrzejewski-Szmek 41d992cf51 fuzz-network-parser: drop ".network" and shorten names
All fuzzer inputs as .network files. Some had the suffix, others didn't.
So drop it everywhere, and also shorten some other names.
2022-05-04 12:57:48 +02:00
Evgeny Vereshchagin ebd4541efe oss-fuzz: turn off fuzz-introspector
fuzz-introspector passes -fuse-ld=gold and -flto using CFLAGS/LDFLAGS and due to
https://github.com/mesonbuild/meson/issues/6377#issuecomment-575977919 and
https://github.com/mesonbuild/meson/issues/6377 it doesn't mix well with meson.
It's possible to build systemd with duct tape there using something like
https://github.com/google/oss-fuzz/pull/7583#issuecomment-1104011067 but
apparently even with gold and lto some parts of systemd are missing from
reports (presumably due to https://github.com/google/oss-fuzz/issues/7598).
Let's just fail here for now to make it clear that fuzz-introspector isn't supported.
2022-04-22 09:08:47 +09:00
Zbigniew Jędrzejewski-Szmek 8f04a1ca2b meson: also allow setting GIT_VERSION via templates
GIT_VERSION is not available as a config.h variable, because it's rendered
into version.h during builds. Let's rework jinja2 rendering to also
parse version.h. No functional change, the new variable is so far unused.

I guess this will make partial rebuilds a bit slower, but it's useful
to be able to use the full version string.
2022-04-05 22:18:31 +02:00
Zbigniew Jędrzejewski-Szmek 9f9be6ea28 test/check-help: check that --help and -h are identical 2022-04-05 22:18:31 +02:00
Zbigniew Jędrzejewski-Szmek ffb7406ba9 tests: add a smoke test for --version option in binaries
This is very similar to (and directly based on) the test for --help. I think
it's nice to do this: the test is very quick, but it'll catch cases where we
forgot to hook up the option, or forgot to exit after printing --version, and
it'll also increase our test coverage a bit.
2022-04-05 22:18:31 +02:00
Zbigniew Jędrzejewski-Szmek e0a5fc7267 tools/git-contrib: list contributions not only from Weblate
It seems that --invert-grep used to affect --author, but now it doesn't (with
git-2.35.1-1.fc36.x86_64), so effectively we would only show the one entry that
was supposed to be filtered out.
2022-03-29 19:42:01 +02:00
Zbigniew Jędrzejewski-Szmek 77d45f1f83 meson: replace sh+find with an internal glob in the python helper
As suggested in https://github.com/systemd/systemd/pull/22810#discussion_r831708052

This makes the whole thing simpler. A glob is passed to helper which then resolves
it on its own. This way it's trivial to call the helper with a different
set of files for testing.
2022-03-23 11:37:35 +09:00
Zbigniew Jędrzejewski-Szmek 3b9d38f5c8 tools/dbus_exporter: deblackify and shorten code a bit
When we do mkdir, we should just use 0o777 and let the umask take care of the
rest. Specifying an explicit mode is inappropriate. And when touching the code,
let's replace black madness with normal python style.
2022-03-22 14:07:53 +01:00
Matthias Lisin 7d5beae28c docs: swap Name and Partition Type UUID in header 2022-02-21 02:46:57 +01:00
Matthias Lisin 5fa87e9651 tools: adjust re.match to recent gpt.h additions
with addition of SD_ID128_MAKE_UUID_STR entries to src/shared/gpt.h the tool
failed halfway due to falsly matching the new entries
2022-02-21 02:35:26 +01:00
Evgeny Vereshchagin 69aa4982bc ci: merge seed corpora with public OSS-Fuzz corpora on CFLite
to let it cover as much code as possible. It should help to catch
most regressions in a few minutes.
2022-01-30 10:17:25 +00:00
Evgeny Vereshchagin 81f84a2c0b ci: use CFLite to test forks (including systemd-stable)
It's like CIFuzz but unlike CIFuzz it's compatible with forks and
it should make it possible to run the fuzzers to make sure that
patches backported to them are backported correctly without introducing
new bugs and regressions.
2022-01-29 18:37:17 +00:00
Jan Janssen b6167d9611 meson: Use same name format for efi binary intermediates 2022-01-26 14:40:55 +01:00
Evgeny Vereshchagin e0ec0450e9 tests: fuzz etc_hosts_parse
That's just a follow-up to https://github.com/systemd/systemd/pull/22179
2022-01-20 15:53:48 +09:00
Yu Watanabe 7611946ebc tree-wide: fix typo 2022-01-06 22:20:11 +09:00
Evgeny Vereshchagin 85ed912479 oss-fuzz: drop line-tables-only
It was copy-pasted directly from OSS-Fuzz where it makes sense to
kind of strip binaries to get nice backtraces but when the fuzzers
are built and run locally with gdb it would be nice to have a little
bit more than that.

It was initially discovered in elfutils where I put the same flags
and was surprised when I couldn't run the fuzzer comfortably step
by step, which led to the same change there: https://github.com/google/oss-fuzz/pull/7092
:-)
2022-01-05 12:04:27 +01:00
Jan Janssen 948d085e89 boot: Add gdb support and documentation
This will finally allow debugging issues in systemd without resorting to
Print() calls all over the place.
2022-01-04 17:23:01 +01:00
Evgeny Vereshchagin c84059f16e oss-fuzz: turn on the alignment check 2021-12-29 10:39:06 +00:00
Evgeny Vereshchagin 4b65fc8725 tests: add fuzz-bcd 2021-12-29 10:39:06 +00:00
Zbigniew Jędrzejewski-Szmek 4287c85589 meson: create new libsystemd-core.so private shared library
The scheme is very similar to libsystemd-shared.so: instead of building a
static library, we build a shared library from the same objects and link the
two users to it. Both systemd and systemd-analyze consist mostly of the fairly
big code in libcore, so we save a bit on the installation:

(-0g, no strip)
-rwxr-xr-x 5238864 Dec 14 12:52 /var/tmp/inst1/usr/lib/systemd/systemd
-rwxr-xr-x 5399600 Dec 14 12:52 /var/tmp/inst1/usr/bin/systemd-analyze
-rwxr-xr-x  244912 Dec 14 13:17 /var/tmp/inst2/usr/lib/systemd/systemd
-rwxr-xr-x  461224 Dec 14 13:17 /var/tmp/inst2/usr/bin/systemd-analyze
-rwxr-xr-x 5271568 Dec 14 13:17 /var/tmp/inst2/usr/lib/systemd/libsystemd-core-250.so

(-0g, strip)
-rwxr-xr-x 2522080 Dec 14 13:19 /var/tmp/inst1/usr/lib/systemd/systemd
-rwxr-xr-x 2604160 Dec 14 13:19 /var/tmp/inst1/usr/bin/systemd-analyze
-rwxr-xr-x  113304 Dec 14 13:19 /var/tmp/inst2/usr/lib/systemd/systemd
-rwxr-xr-x  207656 Dec 14 13:19 /var/tmp/inst2/usr/bin/systemd-analyze
-rwxr-xr-x 2648520 Dec 14 13:19 /var/tmp/inst2/usr/lib/systemd/libsystemd-core-250.so

So for systemd itself we grow a bit (2522080 → 2648520+113304=2761824), but
overall we save. The most is saved on all the test files that link to libcore,
if they are installed, because there's 15 of them:

$ du -s /var/tmp/inst?
220096	/var/tmp/inst1
122960	/var/tmp/inst2

I also considered making systemd-analyze a symlink to /usr/lib/systemd/systemd
and turning systemd into a multicall binary. We did something like this with
udevd and udevadm. But that solution doesn't fit well in this case.
systemd-analyze has a bunch of functionality that is not used in systemd,
so the systemd binary would need to grow quite a bit. And we're likely to
add new types of verification or introspection features in analyze, and this
baggage would only grow. In addition, there are the test binaries which also
benefit from this.
2021-12-25 15:18:47 +09:00
Yu Watanabe 34b5684846 man: also add anotations for methods
Fixes #21882.
2021-12-24 10:18:11 +00:00
наб f1e6f93372
Change all fixed-path bash shebangs to /u/b/env bash outside test/ 2021-12-12 21:13:50 +01:00
igo95862 e3c6892455 Export D-Bus interfaces to /usr/share/dbus-1/interfaces
Pass -Ddbus-interfaces-dir=no to meson to disable export

Interfaces from:
org.freedesktop.home1
org.freedesktop.hostname1
org.freedesktop.import1
org.freedesktop.locale1
org.freedesktop.LogControl1
org.freedesktop.login1
org.freedesktop.machine1
org.freedesktop.oom1
org.freedesktop.portable1
org.freedesktop.resolve1
org.freedesktop.systemd1
org.freedesktop.timedate1
2021-12-10 08:51:58 +01:00
Zbigniew Jędrzejewski-Szmek 6abe882bae meson: add missing final newline in jinja2 outputs
I think this might be caused by trim_blocks=True. We were
missing the final newline everywhere.
2021-12-09 12:46:19 +01:00
James Hilliard d40ce01814 bpf: refactor skeleton generation
This should hopefully fix cross compilation for the bpf programs.
2021-12-07 18:37:17 +01:00
Evgeny Vereshchagin 4997d1b965 ci: pin python dependencies and let Dependabot keep track of them 2021-12-07 09:08:26 +00:00
Alyssa Ross f000edf9ea docs: fix descriptions in discoverable partitions
00db9a114e ("docs: generate table from header using a script") got the
descriptions for the partition types mixed up.  After that change, the
spec claimed, for example, that the /usr partition should contain
"dm-verity integrity hash data for the matching root partition", and
that the /usr verity partition should be of type "Any native, optionally
in LUKS".  This made the spec an extremely confusing read before I
figured out what must have happened!

I've gone through the table as it existed prior to 00db9a114e, and moved
the descriptions around in the script that generates the table until
they matched up with what they used to be.  Then I regenerated the
table from the fixed script.
2021-11-27 13:46:35 +00:00
Daan De Meyer 6d4c80ddbb gpt: Rename PPC64LE TO PPC64_LE
For consistency with ARCHITECTURE_PPC64_LE
2021-11-24 12:00:41 +01:00
Zbigniew Jędrzejewski-Szmek 07430e514a docs: remove comment that makes githubs renderer very angry
It is fine on github.com, but not on github.io.
2021-11-23 19:46:27 +01:00
Zbigniew Jędrzejewski-Szmek c0fb66ec30 Add a trivial guard against using the same uuid twice 2021-11-19 18:49:46 +01:00
Zbigniew Jędrzejewski-Szmek 0ccc588c2f docs: document the partition UUID used by homed 2021-11-19 18:49:46 +01:00
Zbigniew Jędrzejewski-Szmek 00db9a114e docs: generate table from header using a script
This adds a helper script:
$ python3 tools/list-discoverable-partitions.py <src/shared/gpt.h
<!-- generated with tools/list-discoverable-partitions.py -->
| Partition Type UUID | Name | Allowed File Systems | Explanation |
|---------------------|------|----------------------|-------------|
| _Root Partition (Alpha)_ | `6523f8ae-3eb1-4e2a-a05a-18b695ae656f` | [Root Partition] | [Root Partition more] |
| _Root Partition (ARC)_ | `d27f46ed-2919-4cb8-bd25-9531f3c16534` | ditto | ditto |
...

The output can be pasted into the markdown file. I think this works better than
trying to match the two lists by hand.
2021-11-19 18:49:46 +01:00
Evgeny Vereshchagin 2fd1beb3e2 oss-fuzz: move apt-gets and pips to the systemd repository
to be able to control our dependencies right here without
sending PRs like https://github.com/google/oss-fuzz/pull/5199 and
https://github.com/google/oss-fuzz/pull/5601.

It should also allow us to pin meson to let Dependabot keep track of
it and jump from one version to another without breaking anything
2021-11-19 08:52:28 +00:00
Christian Brauner a6d1760024 build: preserve correct mode when generating files via jinja2
When using "capture : true" in custom_target()s the mode of the source
file is not preserved when the generated file is not installed and so
needs to be tweaked manually. Switch from output capture to creating the
target file and copy the permissions from the input file.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-11-08 12:06:48 +00:00
Zbigniew Jędrzejewski-Szmek 5f035b13de meson-render-jinja2: use ast.literal_eval()
Imports are sorted in the usual fashion: stdlib first.

literal_eval() parses string/numbers/lists/sets/dicts, and nothing else, while
eval will execute any python code. Using literal_eval() is generally more
correct, because it avoids the risk of side effects from the parsed expression.
In this case, we generate the parsed strings ourselves, so it's very unlikely
to have anything unexpected in the expressions. But let's do the correct thing
anyway.
2021-11-05 14:56:32 +01:00
Luca Boccassi 948def4af6 tree-wide: fix SPDX short identifier for LGPL-2.1-or-later
https://spdx.dev/ids/#:~:text=Allowing%20later%20versions%20of%20a%20license
https://spdx.org/licenses/LGPL-2.1-or-later.html
2021-10-01 17:27:34 +01:00
Zbigniew Jędrzejewski-Szmek 090ade7ee7 licensing: add spdx header to chromiumos helper, move license file
It makes it easier to process the license automatically like other files.
The text of the license in tools/chromiumos/LICENSE matches
https://spdx.org/licenses/BSD-3-Clause.html exactly.
2021-10-01 14:45:00 +02:00
Frantisek Sumsal f7e0d22d76 tools: shellcheck-ify tool scripts 2021-09-30 12:27:06 +02:00
Luca Boccassi 95b63c755b git-contrib: copypaste-friendly output
Format output in a manner that can be copypasted as-is to NEWS.
That is, with 8 spaces indentation and wrapped at 80 columns.

Before:

$ tools/git-contrib.sh
        Ben Stockett,
        Carl Lei,
        Frantisek Sumsal,
        Gibeom Gwon,
        Hugo Osvaldo Barrera,
        James Hilliard,
        Jan Palus,
        Lennart Poettering,
        Luca Boccassi,
        Luca BRUNO,
        Mike Gilbert,
        nassir90,
        nl6720,
        Raul Tambre,
        Yegor Alexeyev,
        Yu Watanabe,
        Zbigniew Jędrzejewski-Szmek,

After:

        Contributions from: Ben Stockett, Carl Lei, Frantisek Sumsal,
        Gibeom Gwon, Hugo Osvaldo Barrera, James Hilliard, Jan Palus,
        Lennart Poettering, Luca Boccassi, Luca BRUNO, Mike Gilbert,
        nassir90, nl6720, Raul Tambre, Yegor Alexeyev, Yu Watanabe,
        Zbigniew Jędrzejewski-Szmek
2021-07-19 15:39:26 +09:00
Zbigniew Jędrzejewski-Szmek d080734dcb man: add "DNS resource record types" section 2021-06-29 10:44:18 +02:00
Zbigniew Jędrzejewski-Szmek 19c79550b4 tools/analyze-dump-sort: a helper to compare two 'systemd-analyze dump' outputs
Lines in the dumps are ordered by some pseudo-random hashmap entry order, which
makes it hard to diff two outputs. This sort the entries alphabetically, and
also sorts items within the entries, and supresses timestamps and other fields
which always vary.

We could sort the output inside of systemd itself, but it'd make things more
complex, and we probably don't need output to be sorted in most cases. It also
wouldn't be enough, because timestamps and such would still need to be ignored
to do a nice diff. So I think doing the sorting and suppression in a python
helper is a better approach.
2021-06-04 12:09:58 +02:00
Luca Boccassi c5fd89adcd core: make libbpf a dlopen() dependency 2021-05-25 12:59:26 +01:00
Zbigniew Jędrzejewski-Szmek 44ff8df777 Drop dependency on m4
m4 was hugely popular in the past, because autotools, automake, flex, bison and
many other things used it. But nowadays it much less popular, and might not even
be installed in the buildroot. (m4 is small, so it doesn't make a big difference.)

(FWIW, Fedora dropped make from the buildroot now,
https://fedoraproject.org/wiki/Changes/Remove_make_from_BuildRoot. I think it's
reasonable to assume that m4 will be dropped at some point too.)

The main reason to drop m4 is that the syntax is not very nice, and we should
minimize the number of different syntaxes that we use. We still have two
(configure_file() with @FOO@ and jinja2 templates with {{foo}} and the
pythonesque conditional expressions), but at least we don't need m4 (with
m4_dnl and `quotes').
2021-05-19 10:24:43 +09:00
Zbigniew Jędrzejewski-Szmek 6b1aac3ccf meson: replace some m4 templates with jinja2
m4 was nice in '85, but the syntax feels a bit dated. Since we use python for
meson, let's use a popular python templating engine to replace some m4 usage.

A little nicety is that typos are caught:

FAILED: sysusers.d/systemd-remote.conf
/usr/bin/meson --internal exe --capture sysusers.d/systemd-remote.conf -- /home/zbyszek/src/systemd/tools/meson-render-jinja2.py config.h ../sysusers.d/systemd-remote.conf.j2
Traceback (most recent call last):
  File "/home/zbyszek/src/systemd/tools/meson-render-jinja2.py", line 28, in <module>
    print(render(sys.argv[2], defines))
  File "/home/zbyszek/src/systemd/tools/meson-render-jinja2.py", line 24, in render
    return template.render(defines)
  File "/usr/lib/python3.9/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/lib/python3.9/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/lib/python3.9/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 8, in top-level template code
jinja2.exceptions.UndefinedError: 'HAVE_MICROHTTP' is undefined

This checking mirrors what 349cc4a507 did for C defines.
2021-05-19 10:24:43 +09:00
Jörg Thalheim f96bc66901 fix bash shebangs 2021-05-17 22:27:41 +01:00
Zbigniew Jędrzejewski-Szmek b8f1045fe7 Revert "tools/make-directive-index: parallelize"
This reverts commit a2031de849.

The patch itself seems OK, but it exposes a bug in lxml or libxml2-2.9.12 which
was just released. This is being resolved in
https://gitlab.gnome.org/GNOME/libxml2/-/issues/255, but it might be while. So
let's revert this for now to unbreak our CI.

Fixes #19601.
2021-05-14 23:16:24 +01:00
Zbigniew Jędrzejewski-Szmek a2031de849 tools/make-directive-index: parallelize
I occasionally do 'build/man/man systemd.directives' when working on man pages,
and it's annoying slow. By paralellizing the parsing of xml, we can make it a
bit faster.

This is still rather innefficient. Only the parsing part is serialized, xml is
still produced serially at the end, which is hard to avoid.

$ ninja -C build man/systemd.directives.xml
before:
8.20s user 0.21s system 99% cpu 8.460 total
8.33s user 0.18s system 98% cpu 8.619 total
8.72s user 0.19s system 98% cpu 9.019 total

after:
13.99s user 0.73s system 345% cpu 4.262 total
14.15s user 0.35s system 348% cpu 4.161 total
14.33s user 0.35s system 339% cpu 4.321 total

I.e. it uses almost twice as much cpu, but cuts the wallclock time down (on a
2-core/4-thread cpu) to about half too, which is an overall win if you're just
trying to render the man page.

The change from list and .append() to set and .add() is something that could
have been done before too, but it's noticable now. It cuts down on the
serialization/deserialization time (about .2s).
2021-05-13 11:53:01 +02:00
Julia Kartseva cf4f9a57f2 bpf: add build script for bpf programs
Add a build script to compile bpf source code. A program in restricted
C is compiled into an object file. Object file is converted to BPF
skeleton [0] header file.
If build with custom meson build rule, the target header will reside in
build/ directory (not in source tree), e.g the path for socket_bind:
`build/src/core/bpf/socket_bind/socket-bind.skel.h`

Script runs the phases:
* clang to generate *.o from restricted C
* llvm-strip to remove useless DWARF info
* bpf skeleton generation with bpftool
These phases are logged to stderr for debug purposes.

To include BTF debug information, -g option is passed to clang.

[0] https://lwn.net/Articles/806911/
2021-04-26 16:07:41 -07:00
Frantisek Sumsal 3b6fd3c1de tools: shellcheck-ify most of the tool scripts 2021-04-20 20:11:13 +02:00
Frantisek Sumsal 34fde9f898 test: check if the unit file fuzzer corpora is up to date
This follows a similar pattern we already have in place for
networkd-related directives.
2021-04-05 14:41:05 +01:00
Zbigniew Jędrzejewski-Szmek b242d2dec9 git-contrib: use non-breaking spaces in names
Some people have initials or abbreviated parts in the name and looks strange
when a line break occurs in the middle. Let's keep each name in one line.
2021-03-30 13:17:59 +02:00
Lennart Poettering 1ab4edae12 tools: exclude Weblate bot from "ninja git-contrib"
Bots are not people, no reason to say thanks to them and list them as
authors or contributors.
2021-03-17 16:53:14 +01:00
Zbigniew Jędrzejewski-Szmek a3fbf67180 hwdb: update for v248
Seems to be additions and corrections as usual.
Includes an update of the chromiumos autosuspend rules.
2021-03-08 14:27:48 +01:00
Zbigniew Jędrzejewski-Szmek 64eb60b8c5 update-dbus-docs: use color in summary 2021-02-06 11:41:42 +01:00
Zbigniew Jędrzejewski-Szmek 7bd5b8614d update-dbus-docs: say "MODIFIED" not "OUTDATED"
When executed in test mode, "OUTDATED" is appropriate. But when executed
to actually update the text, after the tool executes, those pages are the
opposite, not outdated.
2021-02-06 11:41:42 +01:00
Evgeny Vereshchagin 77591e9732 oss-fuzz: show meson logs
It should help to make it more clear what causes issues like
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=30140
and https://github.com/google/oss-fuzz/pull/5084
2021-02-01 22:51:43 +09:00
Anita Zhang 934d0d023e tools: make update-dbus-docs compatible with Python 3.6
668b3a42fe allowed update-dbus-docs.py to start
running on Cent OS 8 (instead of skipping). But subprocess.check_output()'s
text argument didn't exist until Python 3.7 and C8 is still running
Python 3.6. Use universal_newlines instead for backwards compatibility.
2021-02-01 11:21:10 +00:00