[elbe-devel] [PATCH 13/17] elbepack: projectmanager: drop unused function checkout_project_version

Thomas Weißschuh thomas.weissschuh at linutronix.de
Fri Jul 19 13:31:04 CEST 2024


This function is never used, so delete it.
Also propagate the deletion to other components which are now unused.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 debian/python3-elbe-daemon.install |   1 -
 elbepack/asyncworker.py            |  55 -----------------
 elbepack/pkgarchive.py             | 118 -------------------------------------
 elbepack/projectmanager.py         |   7 ---
 4 files changed, 181 deletions(-)

diff --git a/debian/python3-elbe-daemon.install b/debian/python3-elbe-daemon.install
index d4beb4aa1786..13464d0f697a 100644
--- a/debian/python3-elbe-daemon.install
+++ b/debian/python3-elbe-daemon.install
@@ -2,5 +2,4 @@ usr/lib/python3.*/*-packages/elbepack/daemons/__init__.py
 usr/lib/python3.*/*-packages/elbepack/daemons/repo.py
 usr/lib/python3.*/*-packages/elbepack/commands/daemon.py
 usr/lib/python3.*/*-packages/elbepack/asyncworker.py
-usr/lib/python3.*/*-packages/elbepack/pkgarchive.py
 usr/lib/python3.*/*-packages/elbepack/projectmanager.py
diff --git a/elbepack/asyncworker.py b/elbepack/asyncworker.py
index 6376614c84e8..2edefdbe70e8 100644
--- a/elbepack/asyncworker.py
+++ b/elbepack/asyncworker.py
@@ -9,11 +9,9 @@ from queue import Queue
 from threading import Thread
 from urllib.parse import quote
 
-from elbepack.db import get_versioned_filename
 from elbepack.dump import dump_fullpkgs
 from elbepack.elbeproject import AptCacheCommitError, AptCacheUpdateError
 from elbepack.log import elbe_logging, read_maxlevel, reset_level
-from elbepack.pkgarchive import checkout_binpkg_archive
 from elbepack.rfs import DebootstrapException
 from elbepack.updatepkg import gen_update_pkg
 
@@ -422,59 +420,6 @@ class GenUpdateJob(AsyncWorkerJob):
         return filename
 
 
-class CheckoutVersionJob(AsyncWorkerJob):
-    def __init__(self, project, version):
-        AsyncWorkerJob.__init__(self, project)
-        self.version = version
-        self.name = self.project.xml.text('project/name')
-
-    def enqueue(self, queue, db):
-        old_status = db.set_busy(self.project.builddir,
-                                 ['build_done', 'has_changes', 'build_failed'])
-
-        # If old status was build_failed, just restore the source.xml of the
-        # given version and restore the status, indicating that we need a
-        # complete rebuild
-        if old_status == 'build_failed':
-            logging.warning('Previous project status indicated a failed build\n'
-                            'Just checking out the XML file.')
-
-            try:
-                db.checkout_version_xml(self.project.builddir, self.version)
-                self.project.set_xml(None)
-            finally:
-                db.reset_busy(self.project.builddir, old_status)
-            return
-
-        # Otherwise, restore the source.xml of the given version and enqueue
-        # the project for package archive checkout
-        try:
-            db.checkout_version_xml(self.project.builddir, self.version)
-            self.project.set_xml(None)
-        except BaseException:
-            db.reset_busy(self.project.builddir, old_status)
-            self.project.set_xml(None)
-            raise
-
-        logging.info('Enqueueing project for package archive checkout')
-        AsyncWorkerJob.enqueue(self, queue, db)
-
-    def execute(self, db):
-        logging.info('Checking out package archive')
-        repodir = get_versioned_filename(self.name, self.version,
-                                         '.pkgarchive')
-        success = self.build_failed
-        try:
-            checkout_binpkg_archive(self.project, repodir)
-            logging.info('Package archive checked out successfully')
-        except Exception:
-            logging.exception('Checking out package archive failed')
-        else:
-            success = self.has_changes
-        finally:
-            db.reset_busy(self.project.builddir, success)
-
-
 @contextmanager
 def savecwd():
     oldcwd = getcwd()
diff --git a/elbepack/pkgarchive.py b/elbepack/pkgarchive.py
deleted file mode 100644
index 4fca6012dbe0..000000000000
--- a/elbepack/pkgarchive.py
+++ /dev/null
@@ -1,118 +0,0 @@
-# ELBE - Debian Based Embedded Rootfilesystem Builder
-# SPDX-License-Identifier: GPL-3.0-or-later
-# SPDX-FileCopyrightText: 2014-2017 Linutronix GmbH
-
-import logging
-from os import path, remove
-from shutil import copytree, move, rmtree
-
-from elbepack.repomanager import RepoAttributes, RepoBase
-
-
-class ArchiveRepo(RepoBase):
-    def __init__(self, xml, pathname, origin, description, components):
-
-        arch = xml.text('project/arch', key='arch')
-        codename = xml.text('project/suite')
-
-        repo_attrs = RepoAttributes(codename, arch, components)
-
-        RepoBase.__init__(self,
-                          pathname,
-                          None,
-                          repo_attrs,
-                          description,
-                          origin)
-
-
-def checkout_binpkg_archive(ep, repodir):
-
-    repopath = path.join(ep.builddir, repodir)
-    sources_list = ep.buildenv.rfs.fname('etc/apt/sources.list')
-    sources_list_d = ep.buildenv.rfs.fname('etc/apt/sources.list.d')
-    sources_list_backup = path.join(ep.builddir, 'sources.list.orig')
-    sources_list_d_backup = path.join(ep.builddir, 'sources.list.d.orig')
-    pkgarchive = ep.buildenv.rfs.fname('var/cache/elbe/pkgarchive')
-
-    with ep.buildenv:
-        try:
-            # Copy the package archive into the buildenv,
-            # so the RPCAptCache can access it
-            logging.info('Copying package archive into build environment')
-            copytree(repopath, pkgarchive)
-
-            # Move original etc/apt/sources.list and etc/apt/sources.list.d out
-            # of the way
-            logging.info('Moving original APT configuration out of the way')
-            if path.isfile(sources_list):
-                move(sources_list, sources_list_backup)
-            if path.isdir(sources_list_d):
-                move(sources_list_d, sources_list_d_backup)
-
-            # Now create our own, with the package archive being the only
-            # source
-            logging.info('Creating new /etc/apt/sources.list')
-            deb = 'deb file:///var/cache/elbe/pkgarchive '
-            deb += ep.xml.text('/project/suite')
-            deb += ' main'
-            with open(sources_list, 'w') as f:
-                f.write(deb)
-
-            # We need to update the APT cache to apply the changed package
-            # source
-            logging.info('Updating APT cache to use package archive')
-            ep.drop_rpcaptcache()
-            c = ep.get_rpcaptcache()
-            c.update()
-
-            # Iterate over all packages, and mark them for installation or
-            # deletion, using the same logic as in commands/updated.py
-            logging.info('Calculating packages to install/remove')
-            fpl = ep.xml.node('fullpkgs')
-            pkgs = c.get_pkglist('all')
-
-            for p in pkgs:
-                marked = False
-                for fpi in fpl:
-                    if p.name == fpi.et.text:
-                        version = fpi.et.get('version')
-                        logging.info('Install "%s-%s"', p.name, version)
-                        c.mark_install(p.name, version,
-                                       from_user=not fpi.et.get('auto'),
-                                       nodeps=True)
-                        marked = True
-
-                if not marked:
-                    logging.info('Delete "%s-%s"', p.name, version)
-                    c.mark_delete(p.name)
-
-            # Now commit the changes
-            logging.info('Commiting package changes')
-            c.commit()
-        finally:
-            # If we changed the package sources, move back the backup
-            if path.isdir(sources_list_d_backup) or \
-                    path.isfile(sources_list_backup):
-                logging.info('Moving back original APT configuration')
-                update_needed = True
-            else:
-                update_needed = False
-
-            if path.isdir(sources_list_d_backup):
-                move(sources_list_d_backup, sources_list_d)
-
-            if path.isfile(sources_list_backup):
-                if path.isfile(sources_list):
-                    remove(sources_list)
-                move(sources_list_backup, sources_list)
-
-            # Remove the package archive from the buildenv
-            if path.isdir(pkgarchive):
-                logging.info('Removing package archive from build environment')
-                rmtree(pkgarchive)
-
-            # Update APT cache, if we modified the package sources
-            if update_needed:
-                logging.info('Updating APT cache to use original package sources')
-                ep.drop_rpcaptcache()
-                ep.get_rpcaptcache().update()
diff --git a/elbepack/projectmanager.py b/elbepack/projectmanager.py
index 9d22e399a85a..e5dff82a87a3 100644
--- a/elbepack/projectmanager.py
+++ b/elbepack/projectmanager.py
@@ -18,7 +18,6 @@ from elbepack.asyncworker import (
     BuildJob,
     BuildSDKJob,
     BuildSysrootJob,
-    CheckoutVersionJob,
     CreatePbuilderJob,
     GenUpdateJob,
     PdebuildJob,
@@ -176,12 +175,6 @@ class ProjectManager:
             # Make db reload the xml file
             self.db.set_xml(ep.builddir, None)
 
-    def checkout_project_version(self, userid, version):
-        with self.lock:
-            ep = self._get_current_project(userid, allow_busy=False)
-
-            self.worker.enqueue(CheckoutVersionJob(ep, version))
-
     def set_current_project_version_description(self, userid, version,
                                                 description):
         with self.lock:

-- 
2.45.2



More information about the elbe-devel mailing list