[elbe-devel] [PATCH 03/13] enable updating pbuilder
Torben Hohn
torben.hohn at linutronix.de
Tue Dec 5 16:19:32 CET 2017
On Thu, Nov 30, 2017 at 03:15:05PM +0100, Manuel Traut wrote:
> 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>
Reviewed-by: Torben Hohn <torbenh 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.15.1
>
>
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel
--
Mit freundlichen Grüßen
Torben Hohn
Linutronix GmbH
Standort: Bremen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99
Firmensitz / Registered Office: D-88690 Uhldingen, Bahnhofstr. 3
Registergericht / Local District Court: Amtsgericht Freiburg i. Br.; HRB
Nr. / Trade register no.: 700 806
Geschäftsführer / Managing Directors: Heinz Egger, Thomas Gleixner
Eine Bitte von uns: Sollten Sie diese E-Mail irrtümlich erhalten haben,
benachrichtigen Sie uns in diesem Falle bitte sobald wie es Ihnen
möglich ist, durch Antwort-Mail. Vielen Dank!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.linutronix.de/pipermail/elbe-devel/attachments/20171205/0416f9a6/attachment.sig>
More information about the elbe-devel
mailing list