From cb436fd93e9966bffab45428126d2205f43a7ce4 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Wed, 12 Feb 2025 16:03:46 +0100 Subject: [PATCH 1/3] rec: add install target to meson And always generate default config in YAML format --- pdns/recursordist/Makefile.am | 2 +- pdns/recursordist/meson.build | 26 ++++++++++++++++++++++++++ pdns/recursordist/rec-main.cc | 5 +++-- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/pdns/recursordist/Makefile.am b/pdns/recursordist/Makefile.am index 32f27c7366d1..90070b3f1e79 100644 --- a/pdns/recursordist/Makefile.am +++ b/pdns/recursordist/Makefile.am @@ -572,7 +572,7 @@ pubsuffix.cc: $(srcdir)/effective_tld_names.dat sysconf_DATA = recursor.yml-dist recursor.yml-dist: pdns_recursor - dir=$$(mktemp -d) && touch "$$dir/recursor.yml" && ./pdns_recursor --config-dir="$$dir" --config=default 2> /dev/null > $@ && rm "$$dir/recursor.yml" && rmdir "$$dir" + ./pdns_recursor --config-dir="$$dir" --config=default 2> /dev/null > $@ ## Manpages MANPAGES=pdns_recursor.1 \ diff --git a/pdns/recursordist/meson.build b/pdns/recursordist/meson.build index c3a877a384ea..bb999c3f2cdf 100644 --- a/pdns/recursordist/meson.build +++ b/pdns/recursordist/meson.build @@ -432,6 +432,8 @@ tools = { librec_signers_sodium, dep_pubsuffix, ], + 'install': true, + 'install_dir': get_option('sbindir'), }, 'rec_control': { 'main': src_dir / 'rec_control.cc', @@ -441,6 +443,7 @@ tools = { dep_recrust, dep_rust_recrust, ], + 'install': true, }, } @@ -541,6 +544,8 @@ foreach tool, info: tools export_dynamic = 'export-dynamic' in info ? info['export-dynamic'] : false files_extra = 'files-extra' in info ? info['files-extra'] : [] deps_extra = 'deps-extra' in info ? info['deps-extra'] : [] + install = 'install' in info ? info['install'] : false + install_dir = 'install_dir' in info ? info['install_dir'] : get_option('bindir') set_variable( var_name, @@ -554,6 +559,8 @@ foreach tool, info: tools librec_common, deps_extra, ], + install: install, + install_dir: install_dir, ) ) @@ -605,6 +612,10 @@ if python.found() endif if dep_systemd.found() + systemd_system_unit_dir = dep_systemd_prog.get_variable( + 'systemdsystemunitdir', + ) + systemd_service_conf = configuration_data() systemd_service_conf.set('BinDir', get_option('prefix') / get_option('bindir')) systemd_service_conf.set('StaticBinDir', get_option('prefix') / get_option('sbindir')) @@ -684,6 +695,8 @@ if dep_systemd.found() input: 'pdns-recursor.service.meson.in', output: 'pdns-recursor.service', configuration: rec_service_conf_general, + install: true, + install_dir: systemd_system_unit_dir, ) rec_service_conf_instance = configuration_data() @@ -699,5 +712,18 @@ if dep_systemd.found() input: 'pdns-recursor.service.meson.in', output: 'pdns-recursor@.service', configuration: rec_service_conf_instance, + install: true, + install_dir: systemd_system_unit_dir, ) endif + + +dep_conf_distfile = custom_target( + 'gen-conf-distfile', + command: [pdns_recursor, '--config=default'], + output: 'recursor.yml-dist', + capture: true, + install: true, + install_dir: get_option('sysconfdir'), +) + diff --git a/pdns/recursordist/rec-main.cc b/pdns/recursordist/rec-main.cc index 3fae0825f6ae..0666317678b3 100644 --- a/pdns/recursordist/rec-main.cc +++ b/pdns/recursordist/rec-main.cc @@ -3014,7 +3014,8 @@ static pair doConfig(Logr::log_t startupLog, const string& configname } } else if (config == "default" || config.empty()) { - cout << ::arg().configstring(false, true); + auto yaml = pdns::settings::rec::defaultsToYaml(); + cout << yaml << endl; } else if (config == "diff") { if (!::arg().laxFile(configname)) { @@ -3249,7 +3250,7 @@ int main(int argc, char** argv) } else { configname += ".conf"; - startupLog->info(Logr::Warning, "Trying to read YAML from .yml or .conf failed, failing back to old-style config read", "configname", Logging::Loggable(configname)); + startupLog->info(Logr::Warning, "Trying to read YAML from .yml or .conf failed, falling back to old-style config read", "configname", Logging::Loggable(configname)); bool mustExit = false; std::tie(ret, mustExit) = doConfig(startupLog, configname, argc, argv); if (ret != 0 || mustExit) { From 2a522240fdf0d45988f26f0ca756cba83f90e117 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Fri, 14 Feb 2025 11:58:12 +0100 Subject: [PATCH 2/3] Fix meson dist issues found after new way of generating man pages was merged. Including a path fix to the cmp command, which wrongly assumes MESON_SOURCE_ROOT was the toplevel dir. --- pdns/recursordist/meson-dist-script.sh | 6 ++-- pdns/recursordist/meson.build | 43 +++++++++++++++----------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/pdns/recursordist/meson-dist-script.sh b/pdns/recursordist/meson-dist-script.sh index b972994dad2b..ebb338d9162c 100755 --- a/pdns/recursordist/meson-dist-script.sh +++ b/pdns/recursordist/meson-dist-script.sh @@ -12,7 +12,7 @@ symlinks=$(find . -type l) # If these two get out-of-sync, fix it! It used to be a symlink but that can no longer be as we are # working with a partial checkout in the dist root dir. -cmp "$MESON_SOURCE_ROOT"/builder-support/gen-version "$MESON_PROJECT_DIST_ROOT"/builder-support/gen-version +cmp "$MESON_SOURCE_ROOT"/../../builder-support/gen-version "$MESON_PROJECT_DIST_ROOT"/builder-support/gen-version # Get the dereffed symbolic links (the actual files being pointed to) from the source dir # Extract them over the existing symbolic links @@ -25,8 +25,8 @@ autoreconf -vi # Generate man pages cd "$MESON_PROJECT_BUILD_ROOT" -ninja man-pages -cp -vp rec-man-pages/*.1 "$MESON_PROJECT_DIST_ROOT" +ninja pdns_recursor.1 +cp -vp *.1 "$MESON_PROJECT_DIST_ROOT" rm -rf "$MESON_PROJECT_DIST_ROOT"/autom4te.cache diff --git a/pdns/recursordist/meson.build b/pdns/recursordist/meson.build index bb999c3f2cdf..7c0ddd215856 100644 --- a/pdns/recursordist/meson.build +++ b/pdns/recursordist/meson.build @@ -588,27 +588,34 @@ if python.found() foreach tool, info: tools if 'manpages' in info foreach man_page: info['manpages'] - generated_man_pages += man_page + if not fs.is_file(man_page) + generated_man_pages += man_page + endif endforeach endif endforeach - custom_target( - 'man-pages', - input: man_pages, - output: generated_man_pages, - install: true, - install_dir: join_paths(get_option('mandir'), 'man1'), - command: [ - python, - product_source_dir / docs_dir / 'generate-man-pages.py', - '--build-root', '@BUILD_ROOT@', - '--source-root', '@SOURCE_ROOT@', - '--venv-name', 'venv-rec-man-pages', - '--requirements-file', docs_dir / 'requirements.txt', - '--source-directory', docs_dir, - '--target-directory', '@BUILD_ROOT@', - ] + man_pages, - ) + if generated_man_pages.length() != 0 + summary('Generating man pages', true, section: 'Manual Pages') + custom_target( + 'man-pages', + input: man_pages, + output: generated_man_pages, + install: true, + install_dir: join_paths(get_option('mandir'), 'man1'), + command: [ + python, + product_source_dir / docs_dir / 'generate-man-pages.py', + '--build-root', '@BUILD_ROOT@', + '--source-root', '@SOURCE_ROOT@', + '--venv-name', 'venv-rec-man-pages', + '--requirements-file', docs_dir / 'requirements.txt', + '--source-directory', docs_dir, + '--target-directory', '@BUILD_ROOT@', + ] + man_pages, + ) + else + summary('Generating man pages', false, section: 'Manual Pages') + endif endif if dep_systemd.found() From f52dbc269251fecf8ea4f7754a84fcb49340790e Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Fri, 14 Feb 2025 12:21:53 +0100 Subject: [PATCH 3/3] Don't set --config-dir when generating dist config, no need to anymore --- pdns/recursordist/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pdns/recursordist/Makefile.am b/pdns/recursordist/Makefile.am index 90070b3f1e79..faaee9c2a9f3 100644 --- a/pdns/recursordist/Makefile.am +++ b/pdns/recursordist/Makefile.am @@ -572,7 +572,7 @@ pubsuffix.cc: $(srcdir)/effective_tld_names.dat sysconf_DATA = recursor.yml-dist recursor.yml-dist: pdns_recursor - ./pdns_recursor --config-dir="$$dir" --config=default 2> /dev/null > $@ + ./pdns_recursor --config=default 2> /dev/null > $@ ## Manpages MANPAGES=pdns_recursor.1 \