/[smecontribs]/rpms/plague/contribs7/plague-0.4.4.1-repolock.patch
ViewVC logotype

Contents of /rpms/plague/contribs7/plague-0.4.4.1-repolock.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download)
Mon Sep 8 14:04:49 2008 UTC (16 years, 2 months ago) by slords
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
FILE REMOVED
Import of plague-0.4.5.4-1.el4.sme.1.src.rpm

1 - add the Fedora Extras pushscript lock
2 - change the Repo.py locking and exception handling
3 [and add debug output to investigate a mysterious exception in
4 _update_repo() shutil.copy()]
5
6 diff -Nur plague-0.4.4.1-orig/server/PackageJob.py plague-0.4.4.1/server/PackageJob.py
7 --- plague-0.4.4.1-orig/server/PackageJob.py 2006-03-13 05:10:49.000000000 +0100
8 +++ plague-0.4.4.1/server/PackageJob.py 2007-12-30 23:13:50.000000000 +0100
9 @@ -701,6 +701,7 @@
10
11 def _stage_repodone(self):
12 resultstring = " %s (%s): Build on target %s succeeded." % (self.uid, self.name, self._target_str)
13 + log(resultstring)
14 self.result = 'success'
15 self._set_cur_stage('needsign', resultstring)
16
17 diff -Nur plague-0.4.4.1-orig/server/Repo.py plague-0.4.4.1/server/Repo.py
18 --- plague-0.4.4.1-orig/server/Repo.py 2005-11-29 07:17:07.000000000 +0100
19 +++ plague-0.4.4.1/server/Repo.py 2007-12-30 21:55:34.000000000 +0100
20 @@ -25,6 +25,9 @@
21 import EmailUtils
22 from plague import DebugUtils
23
24 +# Lockfile used by external scripts to ensure mutual exclusion
25 +# from concurrent access to the repository's directory
26 +REPO_LOCKFILE_NAME = ".repo-update.lock"
27
28 class Repo(threading.Thread):
29 """ Represents an on-disk repository of RPMs and manages updates to the repo. """
30 @@ -41,6 +44,7 @@
31 self._repodir = os.path.join(repodir, target_str)
32 if not os.path.exists(self._repodir):
33 os.makedirs(self._repodir)
34 + self._lockfile_path = os.path.join(self._repodir, REPO_LOCKFILE_NAME)
35
36 self._repo_cache_dir = os.path.join(repodir, "cache", target_str)
37 if not os.path.exists(self._repo_cache_dir):
38 @@ -87,8 +91,29 @@
39 return True
40 return False
41
42 + def _update_repo_with_pushlock(self):
43 + lockfile = None
44 + try:
45 + lockfile = open(self._lockfile_path, 'w')
46 + rc = fcntl.flock(lockfile, fcntl.LOCK_EX)
47 + except IOError, (errno, strerr):
48 + print "Repo Error (%s): opening lockfile %s failed. Output: (errno %d) '%s'" % (target_string, self._lockfile_path, errno, strerr)
49 +
50 + try:
51 + self._update_repo()
52 + except:
53 + if lockfile:
54 + fcntl.flock(lockfile, fcntl.LOCK_UN)
55 + lockfile.close()
56 + raise
57 + if lockfile:
58 + fcntl.flock(lockfile, fcntl.LOCK_UN)
59 + lockfile.close()
60 +
61 def _update_repo(self):
62 """ Copy new RPMS to each repo, and update each repo at the end """
63 + target_string = self._target_cfg.target_string()
64 +
65 for buildjob in self._repo_additions:
66 # Ensure all the files are accessible
67 success = True
68 @@ -97,6 +122,9 @@
69 if not os.path.exists(src) or not os.access(src, os.R_OK):
70 success = False
71 bad_file = src
72 + print "Repo: %s is inaccessible." % src
73 + else:
74 + print "Repo: %s is accessible." % src
75
76 if success:
77 for src in buildjob.repofiles.keys():
78 @@ -199,7 +229,12 @@
79 if self._lock_count == 2:
80 target_str = self._target_cfg.target_string()
81 print "Repo '%s': updating repository metadata..." % target_str
82 - self._update_repo()
83 + try:
84 + self._update_repo_with_pushlock()
85 + except IOError, (err, strerr):
86 + print "Repo '%s': %s (%d)" % (target_str, strerr, err)
87 + except OSError, e:
88 + print "Repo '%s': %s" % (target_str, e)
89 print "Repo '%s': Done updating." % target_str
90
91 # If there's a repo script for this target, enter level 3

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed