]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Meson: Reproducible builds
authorFred Morcos <fred.morcos@open-xchange.com>
Thu, 6 Jul 2023 08:23:23 +0000 (10:23 +0200)
committerFred Morcos <fred.morcos@open-xchange.com>
Wed, 20 Mar 2024 12:28:27 +0000 (13:28 +0100)
meson.build
meson/reproducible/meson.build [new file with mode: 0644]
meson_options.txt

index 5ade7ea8665d6e5432316ea4d2c0fecb5c387af4..69628fe04ef94a89bab012ea108775fb7cee855d 100644 (file)
@@ -45,6 +45,7 @@ subdir('meson/ragel')           # Find Ragel
 subdir('meson/clock-gettime')   # Clock_gettime
 subdir('meson/boost')           # Boost
 subdir('meson/unit-tests')      # Unit Tests
+subdir('meson/reproducible')    # Reproducible Builds
 
 # Boost Program Options library
 dep_boost_program_options = dependency('boost', modules: ['program_options'], required: true)
diff --git a/meson/reproducible/meson.build b/meson/reproducible/meson.build
new file mode 100644 (file)
index 0000000..8263d0a
--- /dev/null
@@ -0,0 +1,50 @@
+# Reproducible Builds
+# Inputs: conf
+
+opt_repro = get_option('reproducible')
+conf.set10('REPRODUCIBLE', opt_repro, description: 'Whether we enable reproducible builds')
+
+if opt_repro
+  id_prog = find_program('id', required: opt_repro)
+  id_prog_res = run_command(id_prog, '-u', '-n', check: true)
+  build_user = id_prog_res.stdout().strip()
+
+  build_host = ''
+  hostname_prog = find_program('hostname', required: opt_repro)
+  build_system = build_machine.system()
+  if build_system == 'sunos' or build_system == 'openbsd'
+    domainname_prog = find_program('domainname', required: opt_repro)
+
+    hostname_prog_res = run_command(hostname_prog, check: true)
+    domainname_prog_res = run_command(domainname_prog, check: true)
+
+    build_host_hostname = hostname_prog_res.stdout().strip()
+    build_host_domainname = domainname_prog_res.stdout().strip()
+
+    build_host = build_host_hostname + '.' + build_host_domainname
+  else
+    cmds = [
+      [hostname_prog, '-f'],
+      [hostname_prog],
+      ['echo', '\'localhost\''],
+    ]
+
+    found = false
+    foreach cmd: cmds
+      res = run_command(cmd, check: false)
+      if res.returncode() == 0
+        build_host = res.stdout().strip()
+        found = true
+        break
+      endif
+    endforeach
+
+    if not found
+      error('Reproducible builds requested but could not figure out a build host string on ' + build_system)
+    endif
+  endif
+
+  build_host = build_user + '@' + build_host
+  conf.set_quoted('BUILD_HOST', build_host, description: 'The user and host to built PowerDNS')
+  summary('Build Host', build_host, section: 'Reproducible Builds')
+endif
index 66065b813cc8c6ae91bdacdd983daa57ba501968..7f32c767e0853cb3a33ca40c9caf8749f2d571a3 100644 (file)
@@ -11,3 +11,4 @@ option('dns-over-tls', type: 'boolean', value: false, description: 'Enable DNS o
 option('ipcipher', type: 'feature', value: 'auto', description: 'Enable ipcipher support (requires libcrypto)')
 option('unit-tests', type: 'boolean', value: false, description: 'Enable building unit tests')
 option('backend-unit-tests', type: 'boolean', value: false, description: 'Enable building backend unit tests')
+option('reproducible', type: 'boolean', value: false, description: 'Create reproducible builds. Use this only if you are a distribution maintainer and need reproducible builds. If you compile PowerDNS yourself, leave this disabled, as it might make debugging harder')