From: Vladimír Čunát Date: Wed, 28 Jun 2023 08:17:41 +0000 (+0200) Subject: deprecate legacy systemd units X-Git-Tag: v6.0.2~38^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dc4f93cb7add6fb1d42002834436697a2c1c0854;p=thirdparty%2Fknot-resolver.git deprecate legacy systemd units - separate meson option, disabled by default - deb,rpm: don't install these legacy units - deb,rpm: use the new knot-resolver.service on all the places --- diff --git a/distro/pkg/deb/knot-resolver-core.install b/distro/pkg/deb/knot-resolver-core.install index c9dd93dfc..74ff1c570 100644 --- a/distro/pkg/deb/knot-resolver-core.install +++ b/distro/pkg/deb/knot-resolver-core.install @@ -1,6 +1,3 @@ -usr/lib/systemd/system/kresd@.service lib/systemd/system/ -usr/lib/systemd/system/kres-cache-gc.service lib/systemd/system/ -usr/lib/systemd/system/kresd.target lib/systemd/system/ usr/lib/*.so.* usr/lib/tmpfiles.d/knot-resolver.conf usr/lib/knot-resolver/*.so diff --git a/distro/pkg/deb/knot-resolver-core.links b/distro/pkg/deb/knot-resolver-core.links deleted file mode 100644 index 8196524dd..000000000 --- a/distro/pkg/deb/knot-resolver-core.links +++ /dev/null @@ -1,2 +0,0 @@ -dev/null lib/systemd/system/kresd.service -lib/systemd/system/kresd.target lib/systemd/system/multi-user.target.wants/kresd.target diff --git a/distro/pkg/deb/knot-resolver-core.manpages b/distro/pkg/deb/knot-resolver-core.manpages index 101a4acf6..f9ca908fd 100644 --- a/distro/pkg/deb/knot-resolver-core.manpages +++ b/distro/pkg/deb/knot-resolver-core.manpages @@ -1,2 +1 @@ debian/tmp/usr/share/man/man8/kresd.8* -debian/tmp/usr/share/man/man7/kresd.systemd.7* diff --git a/distro/pkg/deb/knot-resolver-core.postinst b/distro/pkg/deb/knot-resolver-core.postinst index a1fcadd2f..e98529876 100644 --- a/distro/pkg/deb/knot-resolver-core.postinst +++ b/distro/pkg/deb/knot-resolver-core.postinst @@ -9,7 +9,7 @@ fi if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then systemctl daemon-reload || true systemd-tmpfiles --create /usr/lib/tmpfiles.d/knot-resolver.conf - systemctl try-restart 'kresd@*.service' kres-cache-gc.service || true + systemctl try-restart knot-resolver.service || true fi #DEBHELPER# diff --git a/distro/pkg/deb/knot-resolver-manager.links b/distro/pkg/deb/knot-resolver-manager.links new file mode 100644 index 000000000..c5467e848 --- /dev/null +++ b/distro/pkg/deb/knot-resolver-manager.links @@ -0,0 +1 @@ +lib/systemd/system/knot-resolver.service lib/systemd/system/multi-user.target.wants/knot-resolver.service diff --git a/distro/pkg/rpm/knot-resolver.spec b/distro/pkg/rpm/knot-resolver.spec index e181e5af1..10925a03e 100644 --- a/distro/pkg/rpm/knot-resolver.spec +++ b/distro/pkg/rpm/knot-resolver.spec @@ -101,10 +101,6 @@ written in C and LuaJIT, including both a resolver library and a daemon. Modular architecture of the library keeps the core tiny and efficient, and provides a state-machine like API for extensions. -The package is pre-configured as local caching resolver. -To start using it, start a single kresd instance: -$ systemctl start kresd@1.service - %package devel Summary: Development headers for Knot Resolver Requires: %{name}-core%{?_isa} = %{version}-%{release} @@ -205,9 +201,9 @@ popd %install DESTDIR="${RPM_BUILD_ROOT}" %{NINJA} -v -C build_rpm install -# add kresd.target to multi-user.target.wants to support enabling kresd services +# add knot-resolver.service to multi-user.target.wants to support enabling kresd services install -m 0755 -d %{buildroot}%{_unitdir}/multi-user.target.wants -ln -s ../kresd.target %{buildroot}%{_unitdir}/multi-user.target.wants/kresd.target +ln -s ../knot-resolver.service %{buildroot}%{_unitdir}/multi-user.target.wants/knot-resolver.service # remove modules with missing dependencies rm %{buildroot}%{_libdir}/knot-resolver/kres_modules/etcd.lua @@ -248,11 +244,11 @@ getent passwd knot-resolver >/dev/null || useradd -r -g knot-resolver -d %{_sysc /sbin/ldconfig %endif -%preun core -%systemd_preun kres-cache-gc.service kresd.target +%preun manager +%systemd_preun knot-resolver.service -%postun core -%systemd_postun_with_restart 'kresd@*.service' kres-cache-gc.service +%postun manager +%systemd_postun_with_restart knot-resolver.service %if "x%{?fedora}" == "x" /sbin/ldconfig %endif @@ -269,12 +265,8 @@ getent passwd knot-resolver >/dev/null || useradd -r -g knot-resolver -d %{_sysc %{_sysconfdir}/knot-resolver/icann-ca.pem %attr(750,knot-resolver,knot-resolver) %dir %{_sharedstatedir}/knot-resolver %attr(640,knot-resolver,knot-resolver) %{_sharedstatedir}/knot-resolver/root.keys -%{_unitdir}/kresd@.service -%{_unitdir}/kres-cache-gc.service -%{_unitdir}/kresd.target %dir %{_unitdir}/multi-user.target.wants -%{_unitdir}/multi-user.target.wants/kresd.target -%{_mandir}/man7/kresd.systemd.7.gz +%{_unitdir}/multi-user.target.wants/knot-resolver.service %{_tmpfilesdir}/knot-resolver.conf %ghost /run/%{name} %ghost %{_localstatedir}/cache/%{name} diff --git a/doc/meson.build b/doc/meson.build index 494985ce2..94c93cfa4 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -7,7 +7,7 @@ man_config.set('version', meson.project_version()) man_config.set('date', run_command('../scripts/get-date.sh', check: true).stdout()) man_config.set('man_seealso_systemd', '') -if systemd_files == 'enabled' +if systemd_legacy_units == 'enabled' man_config.set('man_seealso_systemd', '\\fIkresd.systemd(7)\\fR, ') endif diff --git a/manager/tests/packaging/manpage.sh b/manager/tests/packaging/manpage.sh index eeab3e4f1..c48d90480 100755 --- a/manager/tests/packaging/manpage.sh +++ b/manager/tests/packaging/manpage.sh @@ -2,6 +2,4 @@ set -e -man -w kresd -man -w kresd.systemd man -w kresctl diff --git a/meson.build b/meson.build index 4fbef2961..1a941a325 100644 --- a/meson.build +++ b/meson.build @@ -114,6 +114,7 @@ xdp = meson.get_compiler('c').has_header('libknot/xdp/xdp.h') ### Systemd systemd_files = get_option('systemd_files') +systemd_legacy_units = get_option('systemd_legacy_units') libsystemd = dependency('libsystemd', required: systemd_files == 'enabled') ### Allocator @@ -231,9 +232,7 @@ subdir('etc') # Systemd unit files -if systemd_files != 'disabled' - subdir('systemd') -endif +subdir('systemd') # Additional files diff --git a/meson_options.txt b/meson_options.txt index ee8b576aa..8bff17b2a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -101,6 +101,16 @@ option( description: 'installs systemd-related files', ) +option( + 'systemd_legacy_units', + type: 'combo', + choices: [ + 'disabled', + 'enabled', + ], + value: 'disabled', + description: 'installs legacy systemd units for running without manager, like with versions before 6', +) # Component options option( diff --git a/systemd/meson.build b/systemd/meson.build index 0948e69f5..249905081 100644 --- a/systemd/meson.build +++ b/systemd/meson.build @@ -13,7 +13,8 @@ systemd_config.set('etc_dir', etc_dir) systemd_config.set('run_dir', run_dir) systemd_config.set('lib_dir', lib_dir) -if systemd_files == 'enabled' +if systemd_legacy_units == 'enabled' + ## unit files kresd_service = configure_file( input: 'kresd@.service.in', @@ -31,13 +32,6 @@ if systemd_files == 'enabled' sources: 'kresd.target', install_dir: systemd_unit_dir, ) - manager_service = configure_file( - input: 'knot-resolver.service.in', - output: 'knot-resolver.service', - configuration: systemd_config, - install_dir: systemd_unit_dir, - ) - ## man page kresd_systemd_man = configure_file( input: 'kresd.systemd.7.in', @@ -46,6 +40,18 @@ if systemd_files == 'enabled' ) install_man(kresd_systemd_man) +endif + + +if systemd_files == 'enabled' + + manager_service = configure_file( + input: 'knot-resolver.service.in', + output: 'knot-resolver.service', + configuration: systemd_config, + install_dir: systemd_unit_dir, + ) + ## tmpfiles tmpfiles = configure_file( input: 'tmpfiles.d/knot-resolver.conf.in',