From 69ae73b960ef5a50b7100ffa3ee7c833b3084b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelmer=20Vernoo=C4=B3?= Date: Sat, 6 Feb 2021 14:59:49 +0000 Subject: [PATCH] Split out build system. --- ognibuild/__init__.py | 4 ---- ognibuild/buildsystem.py | 39 +++++++++++++++++++++++++++++++++++++++ ognibuild/dist.py | 9 +++++---- 3 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 ognibuild/buildsystem.py diff --git a/ognibuild/__init__.py b/ognibuild/__init__.py index d769c5e..c0a0b30 100644 --- a/ognibuild/__init__.py +++ b/ognibuild/__init__.py @@ -24,10 +24,6 @@ import sys DEFAULT_PYTHON = 'python3' -class NoBuildToolsFound(Exception): - """No supported build tools were found.""" - - class DetailedFailure(Exception): def __init__(self, retcode, argv, error): diff --git a/ognibuild/buildsystem.py b/ognibuild/buildsystem.py new file mode 100644 index 0000000..a68a9a4 --- /dev/null +++ b/ognibuild/buildsystem.py @@ -0,0 +1,39 @@ +#!/usr/bin/python +# Copyright (C) 2019-2020 Jelmer Vernooij +# encoding: utf-8 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + +import logging + + +class NoBuildToolsFound(Exception): + """No supported build tools were found.""" + + +class BuildSystem(object): + """A particular buildsystem.""" + + def __init__(self, session): + self.session = session + + def dist(self): + raise NotImplementedError(self.dist) + + +def detect_buildsystems(session): + """Detect build systems.""" + return [] diff --git a/ognibuild/dist.py b/ognibuild/dist.py index ee61f77..75294c9 100644 --- a/ognibuild/dist.py +++ b/ognibuild/dist.py @@ -33,6 +33,7 @@ from breezy.workingtree import WorkingTree from breezy.plugins.debian.repack_tarball import get_filetype from . import apt, DetailedFailure, shebang_binary +from .buildsystem import detect_buildsystems from .session import run_with_tee, Session from .session.schroot import SchrootSession from .debian.fix_build import ( @@ -141,10 +142,6 @@ def run_with_build_fixer(session: Session, args: List[str]): fixed_errors.append(error) -class NoBuildToolsFound(Exception): - """No supported build tools were found.""" - - def run_dist(session): apt.install(session, ['git']) @@ -152,6 +149,10 @@ def run_dist(session): # e.g. pip caches in ~/.cache session.create_home() + for buildsystem in detect_buildsystems(session): + buildsystem.dist() + return + if os.path.exists('package.xml'): apt.install(session, ['php-pear', 'php-horde-core']) logging.info('Found package.xml, assuming pear package.')