Skip to content

Commit

Permalink
Merge pull request #15161 from omoerbeek/rec-meson-install
Browse files Browse the repository at this point in the history
rec: add meson install target and fix meson dist issues after new way of generating man pages was merged
  • Loading branch information
omoerbeek authored Feb 14, 2025
2 parents 132717d + f52dbc2 commit 7b6e4d2
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 24 deletions.
2 changes: 1 addition & 1 deletion pdns/recursordist/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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=default 2> /dev/null > $@

## Manpages
MANPAGES=pdns_recursor.1 \
Expand Down
6 changes: 3 additions & 3 deletions pdns/recursordist/meson-dist-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
69 changes: 51 additions & 18 deletions pdns/recursordist/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -441,6 +443,7 @@ tools = {
dep_recrust,
dep_rust_recrust,
],
'install': true,
},
}

Expand Down Expand Up @@ -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,
Expand All @@ -554,6 +559,8 @@ foreach tool, info: tools
librec_common,
deps_extra,
],
install: install,
install_dir: install_dir,
)
)

Expand Down Expand Up @@ -581,30 +588,41 @@ 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()
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'))
Expand Down Expand Up @@ -684,6 +702,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()
Expand All @@ -699,5 +719,18 @@ if dep_systemd.found()
input: 'pdns-recursor.service.meson.in',
output: '[email protected]',
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'),
)

5 changes: 3 additions & 2 deletions pdns/recursordist/rec-main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3014,7 +3014,8 @@ static pair<int, bool> 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)) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 7b6e4d2

Please sign in to comment.