blob: 38923dcd6bd8576821e720195d6c73fd5737c49e [file]
#!/usr/bin/env python3
# Copyright 2018 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Build ldns package."""
import logging
import os
from pathlib import Path
import sys
FILESDIR = Path(__file__).resolve().parent
sys.path.insert(0, str(FILESDIR.parent.parent / "bin"))
import ssh_client # pylint: disable=wrong-import-position
ARCHIVES = ("%(p)s.tar.gz",)
PATCHES = (
"%(pn)s-no-getproto.patch",
"%(pn)s-CVE-2017-1000231.patch",
"%(pn)s-CVE-2017-1000232.patch",
"%(pn)s-ssl-engine.patch",
"%(pn)s-ssl-headers.patch",
)
def src_configure(metadata):
"""Configure the source."""
if os.path.exists("Makefile"):
logging.info("Makefile exists; skipping ./configure step")
return
tc = metadata["toolchain"]
EXTRA_CFLAGS = [
# The configure script tests these structs (and finds them), but then
# forgets to create the right defines for them. Force the logic when
# we build to avoid failures.
"-DHAVE_STRUCT_SOCKADDR_STORAGE",
"-DHAVE_STRUCT_IN6_ADDR",
"-DHAVE_STRUCT_SOCKADDR_IN6",
]
cmd = [
"./configure",
f"--build={tc.cbuild}",
f"--host={tc.chost}",
# The prefix path matches what is used at runtime.
"--prefix=/",
"--cache-file=../config.cache",
f"CFLAGS={' '.join(EXTRA_CFLAGS)}",
"--with-drill",
"--disable-dane-verify",
"--disable-gost",
# The ldns configure logic is quite poor and searches the filesystem
# instead of querying the compiler. Force it to our sysroot.
f"--with-ssl={tc.sysroot}",
]
ssh_client.run(cmd)
def src_compile(_metadata):
"""Compile the source."""
ssh_client.emake("setup-builddir")
ssh_client.emake("lib")
ssh_client.emake("drill")
def src_install(metadata):
"""Install the package."""
tc = metadata["toolchain"]
# List install targets ourselves to avoid installing man pages.
# This package has a lot (~500) and can be a little slow.
ssh_client.emake(
"install-h", "install-lib", "install-config", f"DESTDIR={tc.sysroot}"
)
ssh_client.build_package(sys.modules[__name__], "pnacl")