blob: fd62ea87ea4f80d2d02101a5a7729e61e0ffbb8c [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 mandoc package."""
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",)
def src_configure(_metadata):
"""Configure the source."""
for var in ("AR", "CC", "CFLAGS", "CPPFLAGS", "LDFLAGS"):
os.environ.pop(var, None)
if not os.path.exists("Makefile.local"):
ssh_client.run(["./configure"])
def src_compile(_metadata):
"""Compile the source."""
ssh_client.emake("mandoc")
def src_install(metadata):
"""Install the package."""
target = metadata["S"] / "mandoc"
path = ssh_client.BUILD_BINDIR / "mandoc"
ssh_client.symlink(target, path)
# Copy style files used by generated man pages.
plugin_docs = ssh_client.OUTPUT / "plugin" / "docs"
plugin_docs.mkdir(parents=True, exist_ok=True)
target_css = plugin_docs / "mandoc.css"
ssh_client.copy("mandoc.css", target_css)
# Insert our darkmode settings.
data = "@import '../../css/mandoc-darkmode.css';\n" + target_css.read_text()
target_css.write_text(data)
ssh_client.build_package(sys.modules[__name__], "build")