Commit Graph

51 Commits

Author SHA1 Message Date
Jörg Thalheim d7aa78c32f meson: add option to skip installing to $sysconfdir
This is useful for development where overwriting files out side
the configured prefix will affect the host as well as stateless
systems such as NixOS that don't let packages install to /etc but handle
configuration on their own.

Alternative to https://github.com/systemd/systemd/pull/17501

tested with:

$ mkdir inst build && cd build
$ meson \
  -Dcreate-log-dirs=false \
  -Dsysvrcnd-path=$(realpath ../inst)/etc/rc.d \
  -Dsysvinit-path=$(realpath ../inst)/etc/init.d \
  -Drootprefix=$(realpath ../inst) \
  -Dinstall-sysconfdir=false \
  --prefix=$(realpath ../inst) ..
$ ninja install
2020-11-12 11:21:46 +01:00
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Norbert Lange 63e2d1714e udev: single binary replacing udevd and udevadm
Since the separate binaries contain mostly the same code,
this almost halves the size of the installation.

before:
398K /bin/udevadm
391K /lib/systemd/systemd-udevd

after:
431K /bin/udevadm
0    /lib/systemd/systemd-udevd -> ../../bin/udevadm

Fixes: #14200
2020-06-01 09:41:21 +02:00
Lennart Poettering b355d0c9af udev: move naming-scheme.[ch] into src/shared/
That way we can use it from non-udev code too, for example nspawn.
2020-01-02 19:34:00 +01:00
Yu Watanabe 9648956d1f test: move {test,fuzz}-fido-id-desc.c into src/udev/fido_id 2019-10-31 10:37:42 +09:00
Fabian Henneke d45ee2f31a udev: Add id program and rule for FIDO security tokens
Add a fido_id program meant to be run for devices in the hidraw
subsystem via an IMPORT directive. The program parses the HID report
descriptor and assigns the ID_SECURITY_TOKEN environment variable if a
declared usage matches the FIDO_CTAPHID_USAGE declared in the FIDO CTAP
specification. This replaces the previous approach of whitelisting all
known security token models manually.

This commit is accompanied by a test suite and a fuzzer target for the
descriptor parsing routine.

Fixes: #11996.
2019-09-07 02:23:58 +09:00
Yu Watanabe 5c2316c605 ethtool-util: move from src/udev/net/ to src/shared/ 2019-06-19 09:03:50 +09:00
Yu Watanabe 25de7aa7b9 udev: modernize udev-rules.c
This does the following:
- rename enum udev_builtin_cmd -> UdevBuiltinCmd
- rename struct udev_builtin -> UdevBuiltin
- move type definitions to udev-rules.h
- move prototypes of functions defined in udev-rules.c to udev-rules.h
- drop to use strbuf
- propagate critical errors in applying rules,
- drop limitation for number of tokens per line.
2019-06-02 14:15:26 +09:00
Zbigniew Jędrzejewski-Szmek 60722ad778 meson: declare version.h as dep for various targets that include build.h
Should fix #11565.
2019-02-25 10:41:41 +01:00
Yu Watanabe a378400b3f fuzz: add fuzzer for parsing .link files
This also renames load_link() to link_load_one()
2019-02-25 12:35:51 +09:00
Zbigniew Jędrzejewski-Szmek 35b351900f udev: move naming-scheme bits into their own file 2019-01-17 13:56:02 +01:00
Zbigniew Jędrzejewski-Szmek 3d3075e309 meson: simplify handling of pkgconfigdatadir=no, pkgconfiglibdir=no
The idea was that those vars could be configured to 'no' to not install the .pc
files, or they could be set to '', and then they would be built but not
installed. This was inherited from the autoconf build system. This couldn't
work because '' is replaced by the default value. Also, having this level of
control doesn't seem necessary, since creating those files is very
quick. Skipping with 'no' was implemented only for systemd.pc and not the other
.pc files. Let's simplify things and skip installation if the target dir
is configured as 'no' for all .pc files.
2018-12-21 13:43:20 +01:00
Zbigniew Jędrzejewski-Szmek 3fa3dc9e44 meson: rename two more variables from _c to _sources
_c is misleading because .h files should be included in those lists too
(this tells meson that the build outputs should be rebuilt if the header
files change).

Follow-up for 1437822638.
2018-12-18 12:19:52 +01:00
Lennart Poettering a55d8bedd2
Merge pull request #10176 from yuwata/udev-cleanup-7
udev: replace udev_device by sd_device
2018-10-12 12:26:33 +02:00
Yu Watanabe be44b572f3 meson: fix '-Dstatic-libsystemd=true' or '-Dstatic-libudev=true'
Follow-up for a5d8835c78.
2018-10-12 17:54:23 +09:00
Yu Watanabe 5eddbba3a1 meson: do not use mempool from libudev.so
Follow-up for a5d8835c78.
2018-10-12 17:54:23 +09:00
Yu Watanabe 07a26e42da udev-builtin: move definitions related to builtin commands to udev-builtin.h 2018-10-11 04:21:14 +09:00
Yu Watanabe 7d68eb1bdf udev-ctrl: move prototypes of udev_ctrl_*() to udev-ctrl.h 2018-10-11 04:21:14 +09:00
Yu Watanabe a2554acec6 udev-node: replace udev_device by sd_device and modernize code a bit 2018-10-11 04:21:14 +09:00
Yu Watanabe 7006860271 udev-watch: replace udev_device by sd_device and modernize code a bit 2018-10-11 04:21:14 +09:00
Yu Watanabe 3d05193e67 udevadm: use dispatch_verb() and drop udevadm_cmd struct 2018-09-10 18:27:36 +09:00
Yu Watanabe a168792c2d udev: drop collect 2018-09-10 18:27:36 +09:00
Zbigniew Jędrzejewski-Szmek 0cd41d4dff Drop my copyright headers
perl -i -0pe 's/\s*Copyright © .... Zbigniew Jędrzejewski.*?\n/\n/gms' man/*xml
git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/(#\n)?# +Copyright © [0-9, -]+ Zbigniew Jędrzejewski.*?\n//gms'
git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s*\/\*\*\*\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*?\s*\*\*\*\/\s*/\n\n/gms'
git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*//gms'
2018-06-14 13:03:20 +02:00
Lennart Poettering 96b2fb93c5 tree-wide: beautify remaining copyright statements
Let's unify an beautify our remaining copyright statements, with a
unicode ©. This means our copyright statements are now always formatted
the same way. Yay.
2018-06-14 10:20:21 +02:00
Zbigniew Jędrzejewski-Szmek 975464e0d4 meson: recompile all sources for install_libudev_static and install_libsystemd_static
This means that when those targets are built, all the sources are built again,
instead of reusing the work done to create libbasic.a and other convenience static
libraries. It would be nice to not do this, but there seems to be no support in
our toolchain for joining multiple static libraries into one. When linking
a static library, any -l arguments are simply ignored by ar/gcc-ar, and .a
libraries given as positional arguments are copied verbatim into the archive
so they objects in them cannot be accessed.

https://stackoverflow.com/questions/2157629/linking-static-libraries-to-other-static-libraries
suggests either unzipping all the archives and putting them back togather,
or using a linker script. Unzipping and zipping back together seems ugly.
The other option is not very nice. The linker script language does not
allow "+" to appear in the filenames, and filenames that meson generates
use that, so files would have to be renamed before a linker script was used.
And we would have to generate the linker script on the fly. Either way, this
doesn't seem attractive. Since those static libraries are a niche use case,
it seems reasonable to just go with the easiest and safest solution and
recompile all the source files. Thanks to ccache, this is probably almost as
cheap as actually reusing the convenience .a libraries.

test-libsystemd-sym.c and test-libudev-sym.c compile fine with the generated
static libs, so it seems that they indeed provide all the symbols they should.
2018-05-08 17:33:04 +02:00
Davide Cavalca 20f3d32d8d meson: only build test-lib{systemd,udev}-static-sym for pic 2018-05-08 17:33:04 +02:00
Davide Cavalca 70848ecfc6 meson: add support for building static libsystemd and libudev 2018-05-08 17:33:04 +02:00
Zbigniew Jędrzejewski-Szmek 11a1589223 tree-wide: drop license boilerplate
Files which are installed as-is (any .service and other unit files, .conf
files, .policy files, etc), are left as is. My assumption is that SPDX
identifiers are not yet that well known, so it's better to retain the
extended header to avoid any doubt.

I also kept any copyright lines. We can probably remove them, but it'd nice to
obtain explicit acks from all involved authors before doing that.
2018-04-06 18:58:55 +02:00
Lennart Poettering 2f5fa62bf7 tree-wide: tabs suck (#8527) 2018-03-23 15:21:35 +01:00
Zbigniew Jędrzejewski-Szmek 7f1ea2cc94 meson: add a single .h file to shared libs with no sources
Otherwise stuff doesn't build on old Ubuntu with meson-0.42.1-1~xenial.
2018-01-03 12:09:46 +01:00
Zbigniew Jędrzejewski-Szmek 0c06b50662 meson: rename libudev_internal to libudev_static and link into libudev
This reduces the meson man=false target count to 1281.

v2:
- link test-engine with libshared instead of libsystemd_static
Previous version built fine on F27, but fails on F26 with the following error:
/usr/bin/ld: /tmp/ccr8HRGw.ltrans6.ltrans.o: undefined reference to symbol '__start_BUS_ERROR_MAP@@SD_SHARED'
/home/zbyszek/fedora/systemd/systemd-9d5aae75c64f5583a110f03b94816aacc03bbf4d/x86_64-redhat-linux-gnu/src/shared/libsystemd-shared-236.so: error adding symbols: DSO missing from command line

v3:
- add libudev_basic
2018-01-03 12:09:46 +01:00
Zbigniew Jędrzejewski-Szmek 37e4d7a855 meson: rename libsystemd_internal to libsystem_static
We already use the "_static" suffix for libshared_static ("shared" is the name
of the library, "static" is the format) and other libs, so let's rename for
consistency.

Also change libsystemd_static_sources to libsystemd_sources, since the same
list is used for both and shorter is better.
2017-12-21 17:01:02 +01:00
Franck Bui 6671e818e9 meson: libudev_core and udevadm should have LOG_REALM=LOG_REALM_UDEV (#7666)
Otherwise, setting udev_log=debug in /etc/udev/udev.conf has no effects since
systemd-udevd is built with LOG_REALM=LOG_REALM_UDEV.

However using LOG_REALM_UDEV (for libudev_core) reveals another similar bug for
udevadm which should also define LOG_REALM_UDEV.
2017-12-16 09:36:36 +01:00
Zbigniew Jędrzejewski-Szmek 3a726fcd08 Add license headers and SPDX identifiers to meson.build files
So far I avoided adding license headers to meson files, but they are pretty
big and important and should carry license headers like everything else.
I added my own copyright, even though other people modified those files too.
But this is mostly symbolic, so I hope that's OK.
2017-11-19 19:08:15 +01:00
Zbigniew Jędrzejewski-Szmek 349cc4a507 build-sys: use #if Y instead of #ifdef Y everywhere
The advantage is that is the name is mispellt, cpp will warn us.

$ git grep -Ee "conf.set\('(HAVE|ENABLE)_" -l|xargs sed -r -i "s/conf.set\('(HAVE|ENABLE)_/conf.set10('\1_/"
$ git grep -Ee '#ifn?def (HAVE|ENABLE)' -l|xargs sed -r -i 's/#ifdef (HAVE|ENABLE)/#if \1/; s/#ifndef (HAVE|ENABLE)/#if ! \1/;'
$ git grep -Ee 'if.*defined\(HAVE' -l|xargs sed -i -r 's/defined\((HAVE_[A-Z0-9_]*)\)/\1/g'
$ git grep -Ee 'if.*defined\(ENABLE' -l|xargs sed -i -r 's/defined\((ENABLE_[A-Z0-9_]*)\)/\1/g'
+ manual changes to meson.build

squash! build-sys: use #if Y instead of #ifdef Y everywhere

v2:
- fix incorrect setting of HAVE_LIBIDN2
2017-10-04 12:09:29 +02:00
Michal Suchanek 1b83323719 Use same script to build key list in Makefile and meson 2017-06-27 13:27:37 +02:00
Yu Watanabe 8ff213fd65 meson: do not use generate_gperfs.py for keyboard-keys-from-name.gperf (#5968)
Fixes #5967.
2017-05-15 20:51:22 -04:00
Lennart Poettering 6e4177315f Merge pull request #5432 from keszybz/udev-logging
udev logging separation
2017-05-12 15:22:46 +02:00
John Paul Adrian Glaubitz eb8124f6d5 meson: Add missing dependency on libkmod for libudev_core 2017-05-09 13:13:49 +02:00
Zbigniew Jędrzejewski-Szmek 5c72049f91 udev: use LOG_REALM_UDEV in all udev code
Any call to set/query/use the log level in the code with LOG_REALM=LOG_REALM_UDEV
refers to log_max_level[1]. In particular this means that systemd code using
the libudev library uses does not set the log level for log calls done in libudev.

Fixes #4525.

v2:
- also update meson's meson.build
2017-05-07 22:49:12 -04:00
Zbigniew Jędrzejewski-Szmek 2c201c2140 meson: use booleans for conf.set and drop unecessary conditionals
Using conf.set() with a boolean argument does the right thing:
either #ifdef or #undef. This means that conf.set can be used unconditionally.

Previously I used '1' as the placeholder value, and that needs to be changed to
'true' for consistency (under meson 1 cannot be used in boolean context). All
checks need to be adjusted.
2017-05-02 16:29:11 -04:00
Zbigniew Jędrzejewski-Szmek 1aec3ed90d meson: add libblkid as libudev-core dep to fix include dir
Follow-up for 6b5cf3ea62.

v2:
- also link udevadm and systemd-udev statically if requested

v3:
- fix install_rpath for udevadm (Michael Biebl)
2017-04-23 21:47:29 -04:00
Zbigniew Jędrzejewski-Szmek 37efbbd821 meson: reindent all files with 8 spaces
The indentation for emacs'es meson-mode is added .dir-locals.

All files are reindented automatically, using the lasest meson-mode from git.
Indentation should now be fairly consistent.
2017-04-23 21:47:29 -04:00
Zbigniew Jędrzejewski-Szmek 3a30f21ff8 meson: allow optional static linking of shared code in udev helpers
This makes the helper binaries significantly bigger (in some cases, the final
size depends on link options and optimization level), and is only useful for
distributions which want to provide the option to install udev without systemd.
As the linking is improved, the difference between the columns might shrink,
but it's unlikely that linking libshared statically could ever be more
efficient.

E.g. with -O0, no -flto:
                   (static) (shared)
src/udev/ata_id     999176    85696
src/udev/cdrom_id  1024344   111656
src/udev/collect    990344    81280
src/udev/scsi_id   1023592   115656
src/udev/v4l_id     811736    17744

When linked dynamically, install_rpath must be specified, so add that.
2017-04-23 21:47:29 -04:00
Zbigniew Jędrzejewski-Szmek aac2605820 meson: eliminate libsystemd_journal_internal and use libsystemd_internal less
This simplifies things and leads to a smaller installation footprint.
libsystemd_internal and libsystemd_journal_internal are linked into
libystemd-shared and available to all programs linked to libsystemd-shared.
libsystemd_journal_internal is not needed anymore, and libsystemd-shared
is used everwhere. The few exceptions are: libsystemd.so, test-engine,
test-bus-error, and various loadable modules.
2017-04-23 21:47:28 -04:00
Michael Biebl e17e5ba9bf meson: use join_paths consistently
With -Dsplit-usr=true, we set rootprefix to /. This leads to //lib/systemd or
//lib/udev for various dir variables. Using join_paths() avoids this.
2017-04-23 21:47:28 -04:00
Zbigniew Jędrzejewski-Szmek 9cc0e6e99c meson: make cpp invocations cross-compilation friendly
This implementation assumes that the arguments in compiler.cmd_array()
don't contain any spaces. Since we are only interested in compilation
on Linux, I think this is a safe assumption.

Solution suggested by Nirbheek Chauhan.
2017-04-23 21:47:27 -04:00
Zbigniew Jędrzejewski-Szmek 826472ce36 meson: update linking for fixed meson linking
With mesonbuid/meson#1545, meson does not propagate deps of a library
when linking with that library. That's of course the right thing to do,
but it exposes a bunch of missing deps.

This compiles with both meson-0.39.1 and meson-git + pr/1545.
2017-04-23 21:47:27 -04:00
Zbigniew Jędrzejewski-Szmek 94e75a5409 meson: create dirs and touch /usr
This is the equivalent of $(INSTALL_DIRS) and install-touch-usr-hook.
I did not bother to create the directories into which we install files,
since they will be created anyway.

v2:
- remove bashism
2017-04-23 21:47:27 -04:00
Zbigniew Jędrzejewski-Szmek 69e96427a2 meson: define tests
Tests can be run with 'ninja-build test' or using 'mesontest'.
'-Dtests=unsafe' can be used to include the "unsafe" tests in the
test suite, same as with autotools.

v2:
- use more conf.get guards are optional components
- declare deps on generated headers for test-{af,arphrd,cap}-list

v3:
- define environment for tests

  Most test don't need this, but to be consistent with autotools-based build, and
  to avoid questions which tests need it and which don't, set the same environment
  for all tests.

v4:
- rework test generation

  Use a list of lists to define each test. This way we can reduce the
  boilerplate somewhat, although the test listings are still pretty verbose. We
  can also move the definitions of the tests to the subdirs. Unfortunately some
  subdirs are included earlier than some of the libraries that test binaries
  are linked to.  So just dump all definitions of all tests that cannot be
  defined earlier into src/test. The `executable` definitions are still at the
  top level, so the binaries are compiled into the build root.

v5:
- tag test-dnssec-complex as manual

v6:
- fix HAVE_LIBZ typo
- add missing libgobject/libgio defs
- mark test-qcow2 as manual
2017-04-23 21:47:26 -04:00