ssh_client: mandoc: convert to new Python framework
Change-Id: Id8b88688b7446276f372fb6c358cf541beac4f1d
Reviewed-on: https://chromium-review.googlesource.com/c/1289815
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Vitaliy Shipitsyn <vsh@google.com>
diff --git a/ssh_client/build.sh b/ssh_client/build.sh
index 7481701..a6c2329 100755
--- a/ssh_client/build.sh
+++ b/ssh_client/build.sh
@@ -35,7 +35,7 @@
./third_party/webports/build
export WEB_PORTS="${PWD}/output/webports"
-./third_party/mandoc/build.sh
+./third_party/mandoc/build
./third_party/openssh-7.9/build.sh
BUILD_ARGS=()
diff --git a/ssh_client/third_party/mandoc/build b/ssh_client/third_party/mandoc/build
new file mode 100755
index 0000000..666e27a
--- /dev/null
+++ b/ssh_client/third_party/mandoc/build
@@ -0,0 +1,43 @@
+#!/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 mandoc package."""
+
+from __future__ import print_function
+
+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',)
+
+
+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 = os.path.join(os.getcwd(), 'mandoc')
+ path = os.path.join(ssh_client.OUTPUT, 'mandoc')
+ ssh_client.symlink(target, path)
+
+
+ssh_client.build_package(sys.modules[__name__])
diff --git a/ssh_client/third_party/mandoc/build.sh b/ssh_client/third_party/mandoc/build.sh
deleted file mode 100755
index 26ec90b..0000000
--- a/ssh_client/third_party/mandoc/build.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/bash
-# 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.
-
-ncpus=$(getconf _NPROCESSORS_ONLN || echo 2)
-readonly OPENSSH_MIRROR="https://commondatastorage.googleapis.com/chromeos-localmirror/secureshell"
-
-pushd output >/dev/null
-
-MANDOC_P="mandoc-1.14.3"
-if [[ ! -x ${MANDOC_P}/mandoc ]]; then
- rm -f mandoc
- if [[ ! -f ${MANDOC_P}.tar.gz ]]; then
- wget "${OPENSSH_MIRROR}/${MANDOC_P}.tar.gz"
- fi
- rm -rf "${MANDOC_P}"
- tar xf ${MANDOC_P}.tar.gz
- pushd "${MANDOC_P}" >/dev/null
- (
- unset AR CC CFLAGS CPPFLAGS LDFLAGS
- ./configure
- )
- make -j${ncpus} mandoc
- popd >/dev/null
-fi
-
-if [[ ! -x mandoc ]]; then
- ln -sf "${MANDOC_P}/mandoc" ./mandoc
-fi
-
-popd >/dev/null