extras-buildsys/builder builder.py, 1.44.2.8.2.1.2.5, 1.44.2.8.2.1.2.6

Dennis Gilmore ausil at fedoraproject.org
Thu Sep 4 02:14:50 UTC 2008


Author: ausil

Update of /cvs/fedora/extras-buildsys/builder
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv4025/builder

Modified Files:
      Tag: Plague-0_4_5
	builder.py 
Log Message:
- update to 0.4.5.1  applying Michael schwendt's logging and mock patches
- using pysqlite2 on fedora and python-sqlite on RHEL
- requires mock > 0.8
- requires createrepo >= 0.4.7




Index: builder.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/builder/Attic/builder.py,v
retrieving revision 1.44.2.8.2.1.2.5
retrieving revision 1.44.2.8.2.1.2.6
diff -u -r1.44.2.8.2.1.2.5 -r1.44.2.8.2.1.2.6
--- builder.py	31 Jan 2008 18:16:28 -0000	1.44.2.8.2.1.2.5
+++ builder.py	4 Sep 2008 02:14:19 -0000	1.44.2.8.2.1.2.6
@@ -108,9 +108,7 @@
         if not os.path.exists(self._result_dir):
             os.makedirs(self._result_dir)
 
-        self._state_dir = os.path.join(self._work_dir, self._uniqid, "mock-state")
-        if not os.path.exists(self._state_dir):
-            os.makedirs(self._state_dir)
+        self._state_file = os.path.join(self._result_dir,"state.log")
 
         logfile = os.path.join(self._result_dir, "job.log")
         self._log_fd = open(logfile, "w+")
@@ -216,12 +214,12 @@
                 args.append(arg)
             cmd = os.path.abspath(arg_list[0])
         args.append(builder_cmd)
+        args.append("rebuild")
         args.append("-r")
         args.append(self.buildroot)
         args.append("--arch")
         args.append(self.buildarch)
         args.append("--resultdir=%s" % self._result_dir)
-        args.append("--statedir=%s" % self._state_dir)
         args.append("--uniqueext=%s" % self._uniqid)
         args.append(self._srpm_path)
         self._log("   %s\n" % string.join(args))
@@ -255,14 +253,14 @@
     def _mock_is_prepping(self):
         mock_status = self._get_mock_status()
         if mock_status:
-            prepstates = ['init','prep','unpa','crea','setu']
+            prepstates = ['enabl','creating cache','unpacking cache','setup']
             for s in prepstates:
-                if mock_status == s:
+                if mock_status.startswith(s):
                     return True
         return False
 
     def _get_mock_status(self):
-        mockstatusfile = os.path.join(self._state_dir, 'status')
+        mockstatusfile = self._state_file
         if not os.path.exists(mockstatusfile):
             return None
 
@@ -271,8 +269,7 @@
         
         while True:
             try:
-                f.seek(0, 0)
-                string = f.read(4)
+                lines = f.readlines()
             except OSError, e:
                 if e.errno == errno.EAGAIN:
                     try:
@@ -281,12 +278,19 @@
                         pass
                     continue
             else:
-                if len(string) < 4:
+                if not len(lines):
                     continue
                 break
         f.close()
-        string = string.lower()
-        return string
+        mockstat = None
+        lastline = lines[len(lines)-1].lower()
+        statedelim = "state changed:"
+        stateidx = lastline.rfind(statedelim)
+        if stateidx>0:
+            mockstat = lastline[stateidx+len(statedelim):].lstrip()
+            return mockstat
+        else:
+            return None
 
     def _read_mock_config(self):
         mockconfigfile = os.path.join(self._result_dir, 'mockconfig.log')
@@ -351,8 +355,7 @@
     def _status_prepping(self):
         # We need to make sure that mock has dumped the status file withing a certain
         # amount of time, otherwise we can't tell what it's doing
-        mockstatusfile = os.path.join(self._state_dir, 'status')
-        if not os.path.exists(mockstatusfile):
+        if not os.path.exists(self._state_file):
             # something is wrong if mock takes more than 15s to write the status file
             if time.time() > self._mockstarttime + 15:
                 self._mockstarttime = 0
@@ -381,9 +384,6 @@
                     if mock_root_dir.endswith(self._uniqid):
                         shutil.rmtree(mock_root_dir, ignore_errors=True)
 
-                if self._mock_config.has_key('statedir'):
-                    shutil.rmtree(self._mock_config['statedir'], ignore_errors=True)
-
                 source_dir = os.path.abspath(os.path.join(self._mock_config['rootdir'], "../source"))
                 # Ensure we're actually deleteing the job's sourcedir
                 if source_dir.endswith(os.path.join(self._uniqid, "source")):




More information about the fedora-extras-commits mailing list