This is for mock.

-- 
Jesse Keating
Fedora -- All my bits are free, are yours?
From b935ce5cc96914d612fe746f65d06cb887373b9b Mon Sep 17 00:00:00 2001
From: Jesse Keating <[EMAIL PROTECTED]>
Date: Wed, 12 Dec 2007 12:15:41 -0500
Subject: [PATCH] Add --update call, to update existing buildroot.

Useful for things like pungi which continuously reuse a buildroot
---
 docs/mock.1        |    4 ++++
 py/mock.py         |    8 +++++++-
 py/mock/backend.py |    9 +++++++++
 3 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/docs/mock.1 b/docs/mock.1
index 624c026..ac295e6 100644
--- a/docs/mock.1
+++ b/docs/mock.1
@@ -14,6 +14,8 @@ mock  [options] \fB\-\-installdeps\fR {SRPM|RPM}
 .LP
 mock  [options] \fB\-\-install\fR PACKAGE
 .LP
+mock  [options] \fB\-\-update\fR
+.LP
 mock  [options] \fB\-\-orphanskill\fR
 
 .SH "DESCRIPTION"
@@ -109,6 +111,8 @@ Show version number and exit.
 .TP
 \fB\-\-install\fR \- Do a yum install PACKAGE inside the buildroot. Buildroot must already be initialized -- no 'clean' is performed
 .TP
+\fB\-\-update\fR \- Do a yum update inside the buildroot. Buildroot must already be initialized -- no 'clean' is performed
+.TP
 \fB\-\-orphanskill\fP
 Noop mode that simply checks that no stray processes are running in the chroot. Kills any processes that it finds using specified root.
 .SH "FILES"
diff --git a/py/mock.py b/py/mock.py
index c4b9a68..75d4104 100755
--- a/py/mock.py
+++ b/py/mock.py
@@ -83,6 +83,9 @@ def command_parse(config_opts):
     parser.add_option("--install", action="store_const", const="install",
                       dest="mode",
                       help="install packages using yum")
+    parser.add_option("--update", action="store_const", const="update",
+                      dest="mode",
+                      help="update installed packages using yum")
     parser.add_option("--orphanskill", action="store_const", const="orphanskill",
                       dest="mode",
                       help="Kill all processes using specified buildroot.")
@@ -150,7 +153,7 @@ def command_parse(config_opts):
 
     (options, args) = parser.parse_args()
     if len(args) and args[0] in ('chroot', 'shell',
-            'rebuild', 'install', 'installdeps', 'init', 'clean'):
+            'rebuild', 'install', 'update', 'installdeps', 'init', 'clean'):
         options.mode = args[0]
         args = args[1:]
 
@@ -512,6 +515,9 @@ def main(ret):
 
         chroot.tryLockBuildRoot()
         chroot.yumInstall(*args)
+    
+    elif options.mode == 'update':
+        chroot.yumUpdate()
 
     elif options.mode == 'rebuild':
         do_rebuild(config_opts, chroot, args)
diff --git a/py/mock/backend.py b/py/mock/backend.py
index c18026f..8d968bb 100644
--- a/py/mock/backend.py
+++ b/py/mock/backend.py
@@ -304,6 +304,15 @@ class Root(object):
             self._umountall()
 
     decorate(traceLog())
+    def yumUpdate(self):
+        """use yum to update the chroot"""
+        try:
+            self._mountall()
+            self._yum('update', returnOutput=1)
+        finally:
+            self._umountall()
+            
+    decorate(traceLog())
     def installSrpmDeps(self, *srpms):
         """figure out deps from srpm. call yum to install them"""
         arg_string = self.preExistingDeps
-- 
1.5.3.6

Attachment: signature.asc
Description: PGP signature

--
Fedora-buildsys-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/fedora-buildsys-list

Reply via email to