From d691ffcffdb9b29fc018216bae65c3360df3b1d6 Mon Sep 17 00:00:00 2001 From: Piotr Kubaj Date: Sun, 25 Oct 2026 17:33:49 +0100 Subject: [PATCH 1/2] Add a meson option for a local public suffix list gen-public-suffix.py downloads public_suffix_list.dat at build time and only falls back to a few hardcoded Linux paths when that fails. Package builds usually run without network access, and on FreeBSD the list is installed under /usr/local/share/public_suffix_list, so the build dies with "unable to load public suffix list". Add a public-suffix-list option that takes the path of a local copy. When it is set the generator reads just that file and never goes online, which also keeps the generated table reproducible. --- meson_options.txt | 5 +++++ src/common/gen-public-suffix.py | 18 +++++++++--------- src/common/meson.build | 8 +++++++- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/meson_options.txt b/meson_options.txt index 03d525ea..2499093e 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -72,3 +72,8 @@ option('with-upd', type: 'boolean', option('with-perl-legacy-api', type: 'boolean', value: false, description: 'Enables the legacy IRC perl module for compatibility with old scripts' ) + +# Build inputs +option('public-suffix-list', type: 'string', value: '', + description: 'Path to a local public_suffix_list.dat to generate the URL detection rules from instead of downloading it' +) diff --git a/src/common/gen-public-suffix.py b/src/common/gen-public-suffix.py index cd3a96e6..1a392fc8 100644 --- a/src/common/gen-public-suffix.py +++ b/src/common/gen-public-suffix.py @@ -38,16 +38,16 @@ def main(): if len(sys.argv) not in (2, 3): raise SystemExit("usage: gen-public-suffix.py [source]") output = Path(sys.argv[1]) - sources = [] if len(sys.argv) == 3: - sources.append(Path(sys.argv[2])) - sources.extend( - [ - Path(__file__).with_name("public_suffix_list.dat"), - Path("/usr/share/publicsuffix/public_suffix_list.dat"), - Path("/app/share/publicsuffix/public_suffix_list.dat"), - ] - ) + # An explicit source is authoritative, don't go online behind its back. + rules = parse_rules(Path(sys.argv[2]).read_text(encoding="utf-8")) + emit_header(str(output), rules) + return + sources = [ + Path(__file__).with_name("public_suffix_list.dat"), + Path("/usr/share/publicsuffix/public_suffix_list.dat"), + Path("/app/share/publicsuffix/public_suffix_list.dat"), + ] data = None for url in URLS: try: diff --git a/src/common/meson.build b/src/common/meson.build index b7ca6afe..13c269b7 100644 --- a/src/common/meson.build +++ b/src/common/meson.build @@ -110,9 +110,15 @@ make_te = find_program('make-te.py') python3 = find_program('python3', required: true) +public_suffix_cmd = [python3, files('gen-public-suffix.py'), '@OUTPUT@'] +public_suffix_list = get_option('public-suffix-list') +if public_suffix_list != '' + public_suffix_cmd += public_suffix_list +endif + public_suffix_data = custom_target('public_suffix_data_h', output: 'public_suffix_data.h', - command: [python3, files('gen-public-suffix.py'), '@OUTPUT@'] + command: public_suffix_cmd ) emoji_data_table = custom_target('emoji_data_table_h', From 5bb6b77e988056debfbdf68e053a6227ded9b8f9 Mon Sep 17 00:00:00 2001 From: Piotr Kubaj Date: Sun, 25 Oct 2026 19:58:04 +0100 Subject: [PATCH 2/2] Use AF_UNSPEC for the getaddrinfo() hints network.c defines _POSIX_C_SOURCE before pulling in the socket headers. On FreeBSD that hides the non-standard PF_* aliases from , so PF_UNSPEC is undeclared and the build fails: src/common/network.c:169:20: error: use of undeclared identifier 'PF_UNSPEC' getaddrinfo() is specified in terms of the AF_* constants anyway, and the rest of the file already uses AF_INET, so use AF_UNSPEC here too. --- src/common/network.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/network.c b/src/common/network.c index 8892b3e5..54ef749d 100644 --- a/src/common/network.c +++ b/src/common/network.c @@ -166,7 +166,7 @@ net_resolve (netstore * ns, char *hostname, int port, char **real_host) sprintf (portstring, "%d", port); memset (&hints, 0, sizeof (struct addrinfo)); - hints.ai_family = PF_UNSPEC; /* support ipv6 and ipv4 */ + hints.ai_family = AF_UNSPEC; /* support ipv6 and ipv4 */ hints.ai_flags = AI_CANONNAME | AI_ADDRCONFIG; hints.ai_socktype = SOCK_STREAM;