diff -Nur plague-0.4.4.1-fe/builder/builder.py plague-0.4.4.1/builder/builder.py --- plague-0.4.4.1-fe/builder/builder.py 2007-11-14 18:41:33.000000000 +0100 +++ plague-0.4.4.1/builder/builder.py 2007-11-14 18:46:29.000000000 +0100 @@ -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+") @@ -218,12 +216,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)) @@ -257,33 +255,14 @@ def _mock_is_prepping(self): mock_status = self._get_mock_status() if mock_status: - if mock_status == 'prep': - return True - elif mock_status == 'setu': - return True - return False - - def _mock_using_repo(self): - mock_status = self._get_mock_status() - if mock_status: - if mock_status == 'init': - return True - elif mock_status == 'clea': - return True - elif mock_status == 'prep': - return True - elif mock_status == 'setu': - return True - return False - - def _mock_is_closed(self): - mock_status = self._get_mock_status() - if mock_status and mock_status == "done": - return True + prepstates = ['enabl','creating cache','unpacking cache','setup'] + for s in prepstates: + 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 @@ -292,8 +271,7 @@ while True: try: - f.seek(0, 0) - string = f.read(4) + lines = f.readlines() except OSError, e: if e.errno == errno.EAGAIN: try: @@ -302,12 +280,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') @@ -373,8 +358,7 @@ # Refresh mock status to see whether it changed during sleep. # Avoid mock/plague race condition. if not self._mock_is_prepping(): - if not self._mock_using_repo(): # status changed during sleep - self._status = 'building' + self._status = 'building' return # Mock shouldn't exit at all during the prepping stage, if it does # something is wrong @@ -384,8 +368,7 @@ # 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 @@ -410,9 +393,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")):