[elbe-devel] [PATCH 7/8] elbepack: projectmanager: remove build_update_package()
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Wed Aug 14 11:26:33 CEST 2024
This method was never used since its introduction in 2014.
Update packages are built can be built with "elbe gen_update" as before.
Also propagate the deletion to other now unused functions.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
elbepack/asyncworker.py | 51 +---------------------------------------------
elbepack/db.py | 19 -----------------
elbepack/projectmanager.py | 23 ---------------------
elbepack/rpcaptcache.py | 4 ----
4 files changed, 1 insertion(+), 96 deletions(-)
diff --git a/elbepack/asyncworker.py b/elbepack/asyncworker.py
index 08851493bd09..02208c37c90a 100644
--- a/elbepack/asyncworker.py
+++ b/elbepack/asyncworker.py
@@ -4,15 +4,13 @@
import logging
from contextlib import contextmanager
-from os import chdir, getcwd, path
+from os import chdir, getcwd
from queue import Queue
from threading import Thread
-from urllib.parse import quote
from elbepack.elbeproject import AptCacheCommitError, AptCacheUpdateError
from elbepack.log import elbe_logging, read_maxlevel, reset_level
from elbepack.rfs import DebootstrapException
-from elbepack.updatepkg import gen_update_pkg
class AsyncWorkerJob:
@@ -281,53 +279,6 @@ class UpdatePbuilderJob(AsyncWorkerJob):
db.reset_busy(self.project.builddir, success)
-class GenUpdateJob(AsyncWorkerJob):
- def __init__(self, project, base_version):
- AsyncWorkerJob.__init__(self, project)
- self.name = project.xml.text('/project/name')
- self.base_version = base_version
- self.current_version = project.xml.text('/project/version')
- self.old_status = None
- self.base_version_xml = None
-
- def enqueue(self, queue, db):
- self.old_status = db.set_busy(self.project.builddir,
- ['build_done', 'has_changes'])
- self.base_version_xml = db.get_version_xml(self.project.builddir,
- self.base_version)
-
- logging.info('Enqueueing project for generating update package')
- AsyncWorkerJob.enqueue(self, queue, db)
-
- def execute(self, db):
- upd_filename = self._gen_upd_filename()
- upd_pathname = path.join(self.project.builddir, upd_filename)
-
- logging.info('Generating update package')
-
- try:
- gen_update_pkg(self.project, self.base_version_xml, upd_pathname)
- logging.info('Update package generated successfully')
- except Exception:
- logging.exception('Generating update package failed')
- finally:
- # Update generation does not change the project, so we always
- # keep the old status
- db.add_project_file(
- self.project.builddir, upd_filename,
- 'application/octet-stream',
- f'Update package from {self.base_version} to '
- f'{self.current_version}')
- db.reset_busy(self.project.builddir, self.old_status)
-
- def _gen_upd_filename(self):
- filename = quote(self.name, ' ') + '_'
- filename += quote(self.base_version) + '_'
- filename += quote(self.current_version) + '.upd'
-
- return filename
-
-
@contextmanager
def savecwd():
oldcwd = getcwd()
diff --git a/elbepack/db.py b/elbepack/db.py
index 9217b4e4ad2c..e27479efa7a2 100644
--- a/elbepack/db.py
+++ b/elbepack/db.py
@@ -11,7 +11,6 @@ from contextlib import contextmanager
from datetime import datetime
from shutil import copyfile, rmtree
from threading import Thread
-from urllib.parse import quote
with warnings.catch_warnings():
# passlib has code to handle absence of the crypt module and will work just
@@ -75,10 +74,6 @@ def session_scope(session):
session.remove()
-def get_versioned_filename(name, version, suffix):
- return quote(name, ' ') + '_' + quote(version, ' ') + suffix
-
-
def _update_project_file(s, builddir, name, mime_type, description):
filename = os.path.join(builddir, name)
@@ -430,20 +425,6 @@ class ElbeDB:
return int(p.owner_id)
- def get_version_xml(self, builddir, version):
- with session_scope(self.session) as s:
- try:
- v = s.query(ProjectVersion).\
- filter(ProjectVersion.builddir == builddir).\
- filter(ProjectVersion.version == version).one()
- except NoResultFound:
- raise ElbeDBError(
- f'no such project version: {builddir} (version {version})')
-
- xmlname = get_versioned_filename(v.project.name, version,
- '.version.xml')
- return os.path.join(builddir, xmlname)
-
def get_project_files(self, builddir):
# Can throw: ElbeDBError
with session_scope(self.session) as s:
diff --git a/elbepack/projectmanager.py b/elbepack/projectmanager.py
index e771acafd26a..c571d9f53773 100644
--- a/elbepack/projectmanager.py
+++ b/elbepack/projectmanager.py
@@ -14,7 +14,6 @@ from elbepack.asyncworker import (
BuildSDKJob,
BuildSysrootJob,
CreatePbuilderJob,
- GenUpdateJob,
PdebuildJob,
UpdatePbuilderJob,
)
@@ -243,17 +242,6 @@ class ProjectManager:
ep = self._get_current_project(userid, allow_busy=False)
self.worker.enqueue(BuildCDROMsJob(ep, build_bin, build_src))
- def build_update_package(self, userid, base_version):
- with self.lock:
- c = self._get_current_project_apt_cache(userid)
- if c.get_changes():
- raise InvalidState(
- 'project %s has uncommited package changes, '
- 'please commit them first')
-
- ep = self._get_current_project(userid)
- self.worker.enqueue(GenUpdateJob(ep, base_version))
-
def rm_log(self, userid):
ep = self._get_current_project(userid)
with open(os.path.join(ep.builddir, 'log.txt'), 'wb', 0):
@@ -320,14 +308,3 @@ class ProjectManager:
raise PermissionDenied(builddir)
# User is owner, so allow it
-
- def _get_current_project_apt_cache(self, userid):
- # Must be called with self.lock held
- ep = self._get_current_project(userid, allow_busy=False)
-
- if not ep.has_full_buildenv():
- raise InvalidState(
- f'project in directory {ep.builddir} does not have a '
- 'functional build environment')
-
- return ep.get_rpcaptcache()
diff --git a/elbepack/rpcaptcache.py b/elbepack/rpcaptcache.py
index 0b697c91704f..c6fe489fc6f8 100644
--- a/elbepack/rpcaptcache.py
+++ b/elbepack/rpcaptcache.py
@@ -251,10 +251,6 @@ class RPCAPTCache(InChRootObject):
return index
- def get_changes(self):
- changes = self.cache.get_changes()
- return [APTPackage(p) for p in changes]
-
def has_pkg(self, pkgname):
return pkgname in self.cache
--
2.46.0
More information about the elbe-devel
mailing list