From: Michael Tremer Date: Tue, 17 May 2022 16:24:52 +0000 (+0000) Subject: builder: Drop legacy Python build stuff X-Git-Tag: 0.9.28~782 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5eaa0ffa865d4429c240f51ed00490948e74dd2e;p=pakfire.git builder: Drop legacy Python build stuff This has now all moved into the C library Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 980795746..acd520b11 100644 --- a/Makefile.am +++ b/Makefile.am @@ -124,7 +124,6 @@ CLEANFILES += \ pakfire_PYTHON = \ src/pakfire/__init__.py \ src/pakfire/__version__.py \ - src/pakfire/builder.py \ src/pakfire/client.py \ src/pakfire/config.py \ src/pakfire/constants.py \ diff --git a/src/pakfire/builder.py b/src/pakfire/builder.py deleted file mode 100644 index 66469015e..000000000 --- a/src/pakfire/builder.py +++ /dev/null @@ -1,164 +0,0 @@ -#!/usr/bin/python3 -############################################################################### -# # -# Pakfire - The IPFire package management system # -# Copyright (C) 2011 Pakfire development team # -# # -# 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 3 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, see . # -# # -############################################################################### - -import glob -import os -import uuid - -from . import _pakfire -from . import logger -from . import util - -import logging -log = logging.getLogger("pakfire.builder") - -from .constants import * -from .i18n import _ -from .errors import * - -BUILD_LOG_HEADER = """ - ____ _ __ _ _ _ _ _ -| _ \ __ _| | __/ _(_)_ __ ___ | |__ _ _(_) | __| | ___ _ __ -| |_) / _` | |/ / |_| | '__/ _ \ | '_ \| | | | | |/ _` |/ _ \ '__| -| __/ (_| | <| _| | | | __/ | |_) | |_| | | | (_| | __/ | -|_| \__,_|_|\_\_| |_|_| \___| |_.__/ \__,_|_|_|\__,_|\___|_| - - Version : %(version)s - Host : %(hostname)s (%(host_arch)s) - Time : %(time)s - -""" - -class Builder(object): - def __init__(self, conf, arch=None, build_id=None, logfile=None, **kwargs): - self.conf = conf - - # Settings array. - self.settings = { - "enable_ccache" : True, - "enable_snapshot" : True, - } - - # Add settings from keyword arguments - self.settings.update(kwargs) - - # Generate a build ID - self.build_id = build_id or "%s" % uuid.uuid4() - - # Setup logging - self.log = self.setup_logging(logfile) - - # Architecture to build for - self.arch = arch or _pakfire.native_arch() - - def __enter__(self): - self.log.debug("Entering %s" % self) - - # Initialise Pakfire instance - pakfire = _pakfire.Pakfire( - arch=self.arch, - conf=self.conf, - - # Enable build mode - build=True, - **self.settings, - ) - - # Setup domain name resolution in chroot - for i in ("/etc/resolv.conf", "/etc/hosts"): - pakfire.copy_in(i, i) - - return BuilderContext(pakfire, self) - - def __exit__(self, type, value, traceback): - self.log.debug("Leaving %s" % self) - - def setup_logging(self, logfile): - l = log.getChild(self.build_id) - l.setLevel(logging.DEBUG) - - # Print everything to the console - console = logger.ConsoleHandler() - l.addHandler(console) - - # If we have a log file, we write INFO and higher level messages to it - # using the build formatter which adds a timestamp - if logfile: - h = logging.FileHandler(logfile) - h.setLevel(logging.INFO) - l.addHandler(h) - - # Set formatter - f = logger.BuildFormatter() - h.setFormatter(f) - - return l - - -class BuilderContext(object): - def __init__(self, pakfire, builder): - self.pakfire = pakfire - self.builder = builder - - # Get a reference to the logger - self.log = self.builder.log - - def _install(self, packages): - self.log.debug(_("Installing packages in build environment:")) - for package in packages: - self.log.debug(" %s" % package) - - # Initialise Pakfire - with self.pakfire as p: - # Install all required packages - transaction = p.install(packages) - - # Return how many packages were installed/changed - ret = len(transaction) - - # Dump transaction to log - t = transaction.dump() - self.log.info(t) - - # Download transaction - transaction.download() - - # Run the transaction - transaction.run() - - return ret - - def build(self, path, shell=True): - # Install the package - self._install([path]) - - for makefile in glob.glob("%s/usr/src/packages/*/*.nm" % self.pakfire.path): - self.pakfire.build(makefile, logging_callback=self.log.log, interactive=shell) - - def shell(self, packages=[], install=None): - if install: - packages += install - - self._install(packages) - - # Enter the shell - self.pakfire.shell() - diff --git a/src/pakfire/daemon.py b/src/pakfire/daemon.py index 73a0aeb36..ea46094cf 100644 --- a/src/pakfire/daemon.py +++ b/src/pakfire/daemon.py @@ -9,7 +9,6 @@ import sys import tempfile import time -import pakfire.builder import pakfire.util from .system import system