mock ChangeLog, 1.8.2.5, 1.8.2.6 mock.py, 1.53.2.8, 1.53.2.9 mock.spec, 1.16.2.16, 1.16.2.17

John Clark Williams (jcwillia) fedora-extras-commits at redhat.com
Wed Feb 7 15:40:33 UTC 2007


Author: jcwillia

Update of /cvs/fedora/mock
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv14688

Modified Files:
      Tag: mock-0-6-branch
	ChangeLog mock.py mock.spec 
Log Message:
added error() calls for printing command output on failed commands; added installdeps command for long-term chroot management; fixed invalid call to os.file (rather than os.path)


Index: ChangeLog
===================================================================
RCS file: /cvs/fedora/mock/ChangeLog,v
retrieving revision 1.8.2.5
retrieving revision 1.8.2.6
diff -u -r1.8.2.5 -r1.8.2.6
--- ChangeLog	8 Jan 2007 17:39:13 -0000	1.8.2.5
+++ ChangeLog	7 Feb 2007 15:40:31 -0000	1.8.2.6
@@ -1,3 +1,13 @@
+2007-02-07  Clark Williams  <williams at redhat.com>
+
+	* Added error() calls to print command output on failed commands
+
+2007-02-06  Clark Williams  <williams at redhat.com>
+
+	* mock.py
+	added installdeps command for long-term chroot management
+	fixed invalid reference to os.file (rather than os.path)
+	
 2007-01-08  Clark Williams  <williams at redhat.com>
 	* Makefile
 	changed archive creation to keep tarball clean


Index: mock.py
===================================================================
RCS file: /cvs/fedora/mock/mock.py,v
retrieving revision 1.53.2.8
retrieving revision 1.53.2.9
diff -u -r1.53.2.8 -r1.53.2.9
--- mock.py	8 Jan 2007 17:36:38 -0000	1.53.2.8
+++ mock.py	7 Feb 2007 15:40:31 -0000	1.53.2.9
@@ -21,6 +21,7 @@
 import rpmUtils
 try:
     test = rpmUtils.transaction.initReadOnlyTransaction()
+    test = None
 except:
     import rpmUtils.transaction
 import rpm
@@ -193,7 +194,7 @@
             (retval, output) = self.do(cmd)
 
             if retval != 0:
-                error("Errors cleaning out chroot: %s" % output)
+                error(output)
                 if os.path.exists(self.rootdir):
                     raise RootError, "Failed to clean basedir, exiting"
 
@@ -269,6 +270,7 @@
         (retval, output) = self.do(command)
 
         if retval != 0:
+            error(output)
             raise YumError, "Error performing yum command: %s" % command
         
         return (retval, output)
@@ -295,6 +297,7 @@
         if retval != 0:
             msg = "Error installing srpm: %s" % srpmfn
             self.root_log(msg)
+            error(output)
             raise RootError, msg
         
         specdir = os.path.join(bd_out, 'SPECS')
@@ -314,6 +317,7 @@
         
         (retval, output) = self.do_chroot(cmd)
         if retval != 0:
+            error(output)
             raise PkgError, "Error building srpm from installed spec. See Root log."
             
         srpmdir = os.path.join(bd_out, 'SRPMS')
@@ -342,12 +346,20 @@
             for line in output.split('\n'):
                 if line.find('No Package Found for') != -1:
                     errorpkg = line.replace('No Package Found for', '')
+                    error(output)
                     raise BuildError, "Cannot find build req %s. Exiting." % errorpkg
             # nothing made us exit, so we continue
             self.yum('install %s' % arg_string)
-
         return srpm
 
+    def installdeps(self, srpm):
+        """build an srpm into binary rpms, capture log"""
+        
+        self.state("setup")
+        # take srpm, pass to install_build_deps() to rebuild it to a valid srpm
+        # and do build deps
+        self.install_build_deps(srpm)
+        
     def build(self, srpm):
         """build an srpm into binary rpms, capture log"""
         
@@ -370,6 +382,7 @@
         (retval, output) = self.do_chroot(cmd)
         
         if retval != 0:
+            error(output)
             raise BuildError, "Error building package from %s, See build log" % srpmfn
         
         bd_out = self.rootdir + self.builddir 
@@ -441,6 +454,7 @@
 
         if retval != 0:
             if output.find('already mounted') == -1: # probably won't work in other LOCALES
+                error(output)
                 raise RootError, "could not mount /dev/pts error was: %s" % output
         
 
@@ -452,6 +466,7 @@
     
         if retval != 0:
             if output.find('not mounted') == -1: # this probably won't work in other LOCALES
+                error(output)
                 raise RootError, "could not umount %s error was: %s" % (path, output)
 
     
@@ -529,10 +544,9 @@
             self.close()
             if exitcode:
                 ret = exitcode
-            
             error("Non-zero return value %d on executing %s\n" % (ret, cmd))
+            error(output)
             sys.exit(ret)
-        
         return (ret, output)
 
     def _text_requires_from_hdr(self, hdr, srpm):
@@ -606,6 +620,7 @@
             if not os.path.exists(devpath):
                 (retval, output) = self.do(cmd)
                 if retval != 0:
+                    error(output)
                     raise RootError, "could not mknod error was: %s" % output
 
         # link fd to ../proc/self/fd
@@ -736,7 +751,9 @@
         chroot - run the specified command within the chroot
         shell - run an interactive shell within specified chroot
         clean - clean out the specified chroot
-        init - initialize the chroot, do not build anything"""
+        init - initialize the chroot, do not build anything
+        installdeps - install build dependencies"""
+
     parser = OptionParser(usage=usage, version=__VERSION__)
     parser.add_option("-r", action="store", type="string", dest="chroot",
                       help="chroot name/config file name default: %default", 
@@ -938,7 +955,7 @@
     if os.path.exists(cfg):
         execfile(cfg)
     else:
-        if config_path != "/etc/mock" and os.file.exists("/etc/mock/defaults.cfg"):
+        if config_path != "/etc/mock" and os.path.exists("/etc/mock/defaults.cfg"):
             execfile("/etc/mock/defaults.cfg")
     
     # read in the config file by chroot name
@@ -976,6 +993,35 @@
         config_opts['clean'] = config_opts['quiet'] = False
         do_run_cmd(config_opts, "/bin/bash", env='PS1="mock-chroot> "', raw_chroot=1)
 
+    elif args[0] == 'installdeps':
+        if len(args) > 1:
+            srpm = args[1]
+        else:
+            error("No package specified to installdeps command.")
+            sys.exit(50)
+        ts = rpmUtils.transaction.initReadOnlyTransaction()
+        try:
+            hdr = rpmUtils.miscutils.hdrFromPackage(ts, srpm)
+        except rpmUtils.RpmUtilsError, e:
+            error("Specified srpm %s cannot be found/opened" % srpm)
+            sys.exit(50)
+        if hdr[rpm.RPMTAG_SOURCEPACKAGE] != 1:
+            error("Specified srpm isn't a srpm!  Can't go on")
+            sys.exit(50)
+        try:
+            my = None  # if Root() fails, my will be undefined so we force it to None
+            my = Root(config_opts)
+            os.umask(0022) # set a umask- protects from paranoid whackjobs with an 002 umask
+            my.prep()
+            my.installdeps(srpm)
+        except Error, e:
+            error(e)
+            if my:
+                my.close()
+            sys.exit(e.resultcode)
+        my.close()
+        print "Logs in: %s" % my.resultdir
+
     else:
         if args[0] == 'rebuild':
             if len(args) > 1:


Index: mock.spec
===================================================================
RCS file: /cvs/fedora/mock/mock.spec,v
retrieving revision 1.16.2.16
retrieving revision 1.16.2.17
diff -u -r1.16.2.16 -r1.16.2.17
--- mock.spec	8 Jan 2007 17:39:13 -0000	1.16.2.16
+++ mock.spec	7 Feb 2007 15:40:31 -0000	1.16.2.17
@@ -1,6 +1,6 @@
 Summary: Builds packages inside chroots
 Name: mock
-Version: 0.6.10
+Version: 0.6.11
 Release: 1%{?dist}
 License: GPL
 Group: Development/Tools
@@ -11,7 +11,6 @@
 Requires(pre): shadow-utils
 BuildRequires: libselinux-devel
 
-
 %description
 Mock takes a srpm and builds it in a chroot
 
@@ -67,6 +66,12 @@
 %{_libdir}/libselinux-mock.so
 
 %changelog
+* Wed Feb  7 2007 Clark Williams <williams at redhat.com> - 0.6.11-1
+- added error() calls to print command output on failed commands
+
+* Tue Feb  6 2007 Clark Williams <williams at redhat.com> - 0.6.11-1
+- added installdeps command for long-term chroot management
+
 * Mon Jan  8 2007 Clark Williams <williams at redhat.com> - 0.6.10-1
 - Added Josh Boyer's EPEL config files
 




More information about the scm-commits mailing list