Implement basic subcommands.
This commit is contained in:
parent
88213d8500
commit
21ed7c4a7d
7 changed files with 188 additions and 5 deletions
|
@ -17,11 +17,13 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from . import (
|
from . import note
|
||||||
run_build, run_clean, run_install, run_test,
|
|
||||||
note)
|
|
||||||
from .buildsystem import NoBuildToolsFound
|
from .buildsystem import NoBuildToolsFound
|
||||||
|
from .build import run_build
|
||||||
|
from .clean import run_clean
|
||||||
from .dist import run_dist
|
from .dist import run_dist
|
||||||
|
from .install import run_install
|
||||||
|
from .test import run_test
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
@ -67,8 +67,10 @@ class AptManager(object):
|
||||||
status_path = os.path.join(root, 'var/lib/dpkg/status')
|
status_path = os.path.join(root, 'var/lib/dpkg/status')
|
||||||
missing = set(packages)
|
missing = set(packages)
|
||||||
with apt_pkg.TagFile(status_path) as tagf:
|
with apt_pkg.TagFile(status_path) as tagf:
|
||||||
while tagf and missing:
|
while missing:
|
||||||
tagf.step()
|
tagf.step()
|
||||||
|
if not tagf.section:
|
||||||
|
break
|
||||||
if tagf.section['Package'] in missing:
|
if tagf.section['Package'] in missing:
|
||||||
if tagf.section['Status'] == 'install ok installed':
|
if tagf.section['Status'] == 'install ok installed':
|
||||||
missing.remove(tagf.section['Package'])
|
missing.remove(tagf.section['Package'])
|
||||||
|
|
34
ognibuild/build.py
Normal file
34
ognibuild/build.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
# Copyright (C) 2020-2021 Jelmer Vernooij <jelmer@jelmer.uk>
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
|
||||||
|
from .apt import AptManager
|
||||||
|
from .buildsystem import detect_buildsystems, NoBuildToolsFound
|
||||||
|
|
||||||
|
|
||||||
|
def run_build(session):
|
||||||
|
apt = AptManager(session)
|
||||||
|
apt.install(['git'])
|
||||||
|
|
||||||
|
# Some things want to write to the user's home directory,
|
||||||
|
# e.g. pip caches in ~/.cache
|
||||||
|
session.create_home()
|
||||||
|
|
||||||
|
for buildsystem in detect_buildsystems(session):
|
||||||
|
buildsystem.build()
|
||||||
|
return
|
||||||
|
|
||||||
|
raise NoBuildToolsFound()
|
|
@ -18,6 +18,10 @@
|
||||||
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
|
from .apt import AptManager
|
||||||
|
from .fix_build import run_with_build_fixer
|
||||||
|
|
||||||
|
|
||||||
class NoBuildToolsFound(Exception):
|
class NoBuildToolsFound(Exception):
|
||||||
|
@ -33,7 +37,49 @@ class BuildSystem(object):
|
||||||
def dist(self):
|
def dist(self):
|
||||||
raise NotImplementedError(self.dist)
|
raise NotImplementedError(self.dist)
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
raise NotImplementedError(self.test)
|
||||||
|
|
||||||
|
def build(self):
|
||||||
|
raise NotImplementedError(self.build)
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
raise NotImplementedError(self.clean)
|
||||||
|
|
||||||
|
def install(self):
|
||||||
|
raise NotImplementedError(self.install)
|
||||||
|
|
||||||
|
|
||||||
|
class Pear(BuildSystem):
|
||||||
|
|
||||||
|
def dist(self):
|
||||||
|
apt = AptManager(self.session)
|
||||||
|
apt.install(['php-pear'])
|
||||||
|
run_with_build_fixer(self.session, ['pear', 'package'])
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
apt = AptManager(self.session)
|
||||||
|
apt.install(['php-pear'])
|
||||||
|
run_with_build_fixer(self.session, ['pear', 'run-tests'])
|
||||||
|
|
||||||
|
def build(self):
|
||||||
|
apt = AptManager(self.session)
|
||||||
|
apt.install(['php-pear'])
|
||||||
|
run_with_build_fixer(self.session, ['pear', 'build'])
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
apt = AptManager(self.session)
|
||||||
|
apt.install(['php-pear'])
|
||||||
|
# TODO
|
||||||
|
|
||||||
|
def install(self):
|
||||||
|
apt = AptManager(self.session)
|
||||||
|
apt.install(['php-pear'])
|
||||||
|
run_with_build_fixer(self.session, ['pear', 'install'])
|
||||||
|
|
||||||
|
|
||||||
def detect_buildsystems(session):
|
def detect_buildsystems(session):
|
||||||
"""Detect build systems."""
|
"""Detect build systems."""
|
||||||
return []
|
if os.path.exists('package.xml'):
|
||||||
|
logging.info('Found package.xml, assuming pear package.')
|
||||||
|
yield Pear(session)
|
||||||
|
|
34
ognibuild/clean.py
Normal file
34
ognibuild/clean.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
# Copyright (C) 2020-2021 Jelmer Vernooij <jelmer@jelmer.uk>
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
|
||||||
|
from .apt import AptManager
|
||||||
|
from .buildsystem import detect_buildsystems, NoBuildToolsFound
|
||||||
|
|
||||||
|
|
||||||
|
def run_clean(session):
|
||||||
|
apt = AptManager(session)
|
||||||
|
apt.install(['git'])
|
||||||
|
|
||||||
|
# Some things want to write to the user's home directory,
|
||||||
|
# e.g. pip caches in ~/.cache
|
||||||
|
session.create_home()
|
||||||
|
|
||||||
|
for buildsystem in detect_buildsystems(session):
|
||||||
|
buildsystem.clean()
|
||||||
|
return
|
||||||
|
|
||||||
|
raise NoBuildToolsFound()
|
31
ognibuild/install.py
Normal file
31
ognibuild/install.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
# Copyright (C) 2020-2021 Jelmer Vernooij <jelmer@jelmer.uk>
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
|
||||||
|
from .apt import AptManager
|
||||||
|
from .buildsystem import detect_buildsystems, NoBuildToolsFound
|
||||||
|
|
||||||
|
|
||||||
|
def run_install(session):
|
||||||
|
# Some things want to write to the user's home directory,
|
||||||
|
# e.g. pip caches in ~/.cache
|
||||||
|
session.create_home()
|
||||||
|
|
||||||
|
for buildsystem in detect_buildsystems(session):
|
||||||
|
buildsystem.install()
|
||||||
|
return
|
||||||
|
|
||||||
|
raise NoBuildToolsFound()
|
34
ognibuild/test.py
Normal file
34
ognibuild/test.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
# Copyright (C) 2020-2021 Jelmer Vernooij <jelmer@jelmer.uk>
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
|
||||||
|
from .apt import AptManager
|
||||||
|
from .buildsystem import detect_buildsystems, NoBuildToolsFound
|
||||||
|
|
||||||
|
|
||||||
|
def run_test(session):
|
||||||
|
apt = AptManager(session)
|
||||||
|
apt.install(['git'])
|
||||||
|
|
||||||
|
# Some things want to write to the user's home directory,
|
||||||
|
# e.g. pip caches in ~/.cache
|
||||||
|
session.create_home()
|
||||||
|
|
||||||
|
for buildsystem in detect_buildsystems(session):
|
||||||
|
buildsystem.test()
|
||||||
|
return
|
||||||
|
|
||||||
|
raise NoBuildToolsFound()
|
Loading…
Add table
Reference in a new issue