Split out build system.

This commit is contained in:
Jelmer Vernooij 2021-02-06 14:59:49 +00:00
parent 7919d42f05
commit 69ae73b960
No known key found for this signature in database
GPG key ID: 579C160D4C9E23E8
3 changed files with 44 additions and 8 deletions

View file

@ -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):

39
ognibuild/buildsystem.py Normal file
View file

@ -0,0 +1,39 @@
#!/usr/bin/python
# Copyright (C) 2019-2020 Jelmer Vernooij <jelmer@jelmer.uk>
# 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 []

View file

@ -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.')