[elbe-devel] [PATCH 02/13] enable updating pbuilder
Manuel Traut
manut at linutronix.de
Thu Sep 28 23:59:50 CEST 2017
If a pbuilder was created the base.tgz can't be updated from outside the
initvm.
So debootstraping the pbuilder rfs needs to be done if a future build
should consider any updated essential packages. To speedup this, the
newly introduced 'elbe pbuilder update' subcommand can be used.
Signed-off-by: Manuel Traut <manut at linutronix.de>
---
elbepack/asyncworker.py | 23 +++++++++++++++++++++++
elbepack/daemons/soap/esoap.py | 8 ++++++++
elbepack/elbeproject.py | 3 +++
elbepack/pbuilderaction.py | 31 +++++++++++++++++++++++++++++++
elbepack/projectmanager.py | 7 ++++++-
elbepack/soapclient.py | 16 ++++++++++++++++
6 files changed, 87 insertions(+), 1 deletion(-)
diff --git a/elbepack/asyncworker.py b/elbepack/asyncworker.py
index 58e967fd..ac9eb273 100644
--- a/elbepack/asyncworker.py
+++ b/elbepack/asyncworker.py
@@ -216,6 +216,29 @@ class CreatePbuilderJob(AsyncWorkerJob):
self.project.log.printo( traceback.format_exc() )
db.reset_busy( self.project.builddir, "build_failed" )
+class UpdatePbuilderJob(AsyncWorkerJob):
+ def __init__ (self, project):
+ AsyncWorkerJob.__init__( self, project )
+
+ def enqueue (self, queue, db):
+ db.set_busy( self.project.builddir,
+ [ "empty_project", "needs_build", "has_changes",
+ "build_done", "build_failed" ] )
+ self.project.log.printo( "Enqueueing project to update the pbuilder" )
+ AsyncWorkerJob.enqueue( self, queue, db )
+
+ def execute (self, db):
+ try:
+ self.project.log.printo( "Updating pbuilder started" )
+ self.project.update_pbuilder()
+ self.project.log.printo( "Updating Pbuilder finished successfully" )
+ db.reset_busy( self.project.builddir, "build_done" )
+ except Exception as e:
+ db.update_project_files( self.project )
+ self.project.log.printo( "update Pbuilder failed" )
+ self.project.log.printo( traceback.format_exc() )
+ db.reset_busy( self.project.builddir, "build_failed" )
+
class APTUpdateJob(AsyncWorkerJob):
def __init__ (self, project):
AsyncWorkerJob.__init__( self, project )
diff --git a/elbepack/daemons/soap/esoap.py b/elbepack/daemons/soap/esoap.py
index 0bdcdf11..a866aee5 100644
--- a/elbepack/daemons/soap/esoap.py
+++ b/elbepack/daemons/soap/esoap.py
@@ -158,6 +158,14 @@ class ESoap (ServiceBase):
self.app.pm.open_project (uid, builddir)
self.app.pm.build_pbuilder (uid)
+
+ @rpc (String)
+ @authenticated_uid
+ @soap_faults
+ def update_pbuilder (self, uid, builddir):
+ self.app.pm.open_project (uid, builddir)
+ self.app.pm.update_pbuilder (uid)
+
@rpc (String)
@authenticated_uid
@soap_faults
diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
index ed033ed2..f120ccc5 100644
--- a/elbepack/elbeproject.py
+++ b/elbepack/elbeproject.py
@@ -412,6 +412,9 @@ class ElbeProject (object):
self.log.printo ('Package fails to build.')
self.log.printo ('Please make sure, that the submitted package builds in pbuilder')
+ def update_pbuilder (self):
+ self.log.do ('pbuilder --update --configfile "%s" --aptconfdir "%s"' % (
+ os.path.join (self.builddir, "pbuilderrc"), os.path.join (self.builddir, "aptconfdir")))
def create_pbuilder (self):
# Remove old pbuilder directory, if it exists
diff --git a/elbepack/pbuilderaction.py b/elbepack/pbuilderaction.py
index b81049f2..0b864a9f 100644
--- a/elbepack/pbuilderaction.py
+++ b/elbepack/pbuilderaction.py
@@ -118,6 +118,37 @@ class CreateAction(PBuilderAction):
PBuilderAction.register(CreateAction)
+class UpdateAction(PBuilderAction):
+
+ tag = 'update'
+
+ def __init__(self, node):
+ PBuilderAction.__init__(self, node)
+
+ def execute(self, opt, args):
+
+ if not opt.project:
+ print ('you need to specify --project option', file=sys.stderr)
+ sys.exit(20)
+
+ prjdir = opt.project
+
+ print ("Updating pbuilder")
+
+ try:
+ system ('%s control update_pbuilder "%s"' % (elbe_exe, prjdir))
+ except CommandError:
+ print ("elbe control update_pbuilder Failed", file=sys.stderr)
+ print ("Giving up", file=sys.stderr)
+ sys.exit(20)
+
+ print ("")
+ print ("Updating Pbuilder finished !")
+ print ("")
+
+PBuilderAction.register(CreateAction)
+
+
class BuildAction(PBuilderAction):
tag = 'build'
diff --git a/elbepack/projectmanager.py b/elbepack/projectmanager.py
index 87390a00..a747de0c 100644
--- a/elbepack/projectmanager.py
+++ b/elbepack/projectmanager.py
@@ -32,7 +32,7 @@ from elbepack.asyncworker import AsyncWorker, BuildJob, APTUpdateJob
from elbepack.asyncworker import APTCommitJob, GenUpdateJob
from elbepack.asyncworker import SaveVersionJob, CheckoutVersionJob
from elbepack.asyncworker import APTUpdUpgrJob, BuildSysrootJob
-from elbepack.asyncworker import PdebuildJob, CreatePbuilderJob
+from elbepack.asyncworker import PdebuildJob, CreatePbuilderJob, UpdatePbuilderJob
from elbepack.asyncworker import BuildChrootTarJob
from elbepack.elbexml import ValidationMode
@@ -284,6 +284,11 @@ class ProjectManager(object):
self.worker.enqueue (BuildJob (ep, build_bin, build_src,
skip_pbuilder))
+ def update_pbuilder (self, userid):
+ with self.lock:
+ ep = self._get_current_project (userid, allow_busy=False)
+ self.worker.enqueue (UpdatePbuilderJob (ep))
+
def build_pbuilder (self, userid):
with self.lock:
ep = self._get_current_project (userid, allow_busy=False)
diff --git a/elbepack/soapclient.py b/elbepack/soapclient.py
index fe2a7646..9832be87 100644
--- a/elbepack/soapclient.py
+++ b/elbepack/soapclient.py
@@ -599,6 +599,22 @@ class BuildPbuilderAction(ClientAction):
ClientAction.register(BuildPbuilderAction)
+class UpdatePbuilderAction(ClientAction):
+
+ tag = 'update_pbuilder'
+
+ def __init__(self, node):
+ ClientAction.__init__(self, node)
+
+ def execute(self, client, opt, args):
+ if len (args) != 1:
+ print ("usage: elbe control update_pbuilder <project_dir>", file=sys.stderr)
+ sys.exit(20)
+
+ builddir = args[0]
+ client.service.update_pbuilder (builddir)
+
+ClientAction.register(UpdatePbuilderAction)
class RepoAction(ClientAction):
repoactiondict = {}
--
2.14.1
More information about the elbe-devel
mailing list