blob: 5108a6e7fc8b61a0d656108bcc752f2470fc4231 [file] [log] [blame]
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2018 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Build ldns package."""
from __future__ import print_function
import logging
import os
import sys
FILESDIR = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.join(FILESDIR, '..', '..', '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',
'--build=%s' % (tc.cbuild,),
'--host=%s' % (tc.chost,),
# The prefix path matches what is used at runtime.
'--prefix=/',
'--cache-file=../config.cache',
'CFLAGS=%s' % (' '.join(EXTRA_CFLAGS),),
'--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.
'--with-ssl=%s' % (tc.sysroot,),
]
ssh_client.run(cmd)
def src_compile(_metadata):
"""Compile the source."""
ssh_client.emake('setup-builddir')
ssh_client.emake('lib')
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',
'DESTDIR=%s' % (tc.sysroot,))
ssh_client.build_package(sys.modules[__name__], 'pnacl')