rpms/plague/F-9 plague-0.4.5-logtail.patch, NONE, 1.1 plague-0.4.5-mock-0.8.patch, NONE, 1.1 plague-0.4.5-sqlite3.patch, NONE, 1.1 plague.spec, 1.32, 1.33

Michael Schwendt mschwendt at fedoraproject.org
Wed Sep 3 12:06:43 UTC 2008


Author: mschwendt

Update of /cvs/pkgs/rpms/plague/F-9
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv25033/F-9

Modified Files:
	plague.spec 
Added Files:
	plague-0.4.5-logtail.patch plague-0.4.5-mock-0.8.patch 
	plague-0.4.5-sqlite3.patch 
Log Message:
* Wed Sep  3 2008 Michael Schwendt <mschwendt at fedoraproject.org> - 0.4.5-2
- add the patches from 0.4.5-0.4 (sqlite3, mock08, logtail)
- merge more spec changes


plague-0.4.5-logtail.patch:

--- NEW FILE plague-0.4.5-logtail.patch ---
diff -Nur plague-0.4.5-orig/server/PackageJob.py plague-0.4.5/server/PackageJob.py
--- plague-0.4.5-orig/server/PackageJob.py	2008-01-31 15:30:57.000000000 +0100
+++ plague-0.4.5/server/PackageJob.py	2008-07-14 23:44:47.000000000 +0200
@@ -729,30 +729,9 @@
 
         self.bm.notify_job_done(self)
 
-    def _get_log_tail(self, arch):
-        """ Returns the last 30 lines of the most relevant log file """
-
-        pkg_dir = "%s-%s-%s-%s" % (self.uid, self.name, self.ver, self.release)
-        work_dir = self._server_cfg.get_str("Directories", "server_work_dir")
-        log_dir = os.path.join(work_dir, self._target_str, pkg_dir, arch)
-        final_log = None
-        build_log = "%s/%s" % (log_dir, "build.log")
-        root_log = "%s/%s" % (log_dir, "root.log")
-        job_log = "%s/%s" % (log_dir, "job.log")
-
-        # Try the most relevant log file first
-        if os.path.exists(build_log) and os.path.getsize(build_log) > 0:
-            final_log = build_log
-        elif os.path.exists(root_log) and os.path.getsize(root_log) > 0:
-            final_log = root_log
-        elif os.path.exists(job_log) and os.path.getsize(job_log) > 0:
-            final_log = job_log
-
-        if not final_log:
-            return ""
-
-        seek_pos = os.path.getsize(final_log) - 4096
-        f = open(final_log, "r", 4096);
+    def _get_log_file_tail(self, logfile):
+        seek_pos = os.path.getsize(logfile) - 4096
+        f = open(logfile, "r", 4096);
         if seek_pos > 0:
             f.seek(seek_pos)
         try:
@@ -770,9 +749,28 @@
             lines.append(line)
             if len(lines) > 30:  # only want last 30 lines
                 del lines[0]
-
         f.close()
-        return "".join(lines)
+        return lines
+
+    def _get_log_tail(self, arch):
+        """ Returns the last 30 lines of the most relevant log file(s) """
+
+        pkg_dir = "%s-%s-%s-%s" % (self.uid, self.name, self.ver, self.release)
+        work_dir = self._server_cfg.get_str("Directories", "server_work_dir")
+        log_dir = os.path.join(work_dir, self._target_str, pkg_dir, arch)
+
+        logtail = []
+        for l in ["build.log", "root.log", "job.log"]:
+            lpath = os.path.join(log_dir, l)
+            if os.path.exists(lpath) and os.path.getsize(lpath)>0:
+                lines = self._get_log_file_tail(lpath)
+                if l=="build.log" and len(lines)<10:
+                    logtail += lines
+                    logtail.append("\n\n"+">"*40+"\n\n")
+                else:
+                    logtail += lines
+                    break
+        return "".join(logtail)
 
     def email_result(self, to, resultstring, subject=None):
         """send 'resultstring' to self.username"""

plague-0.4.5-mock-0.8.patch:

--- NEW FILE plague-0.4.5-mock-0.8.patch ---
diff -Nur plague-0.4.5-orig/builder/builder.py plague-0.4.5/builder/builder.py
--- plague-0.4.5-orig/builder/builder.py	2008-01-31 18:21:32.000000000 +0100
+++ plague-0.4.5/builder/builder.py	2008-01-31 18:58:40.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,14 +255,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
 
@@ -273,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:
@@ -283,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')
@@ -353,8 +357,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
@@ -383,9 +386,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")):

plague-0.4.5-sqlite3.patch:

--- NEW FILE plague-0.4.5-sqlite3.patch ---
diff -Nur plague-0.4.5-orig/server/BuildMaster.py plague-0.4.5/server/BuildMaster.py
--- plague-0.4.5-orig/server/BuildMaster.py	2008-01-31 15:21:09.000000000 +0100
+++ plague-0.4.5/server/BuildMaster.py	2008-06-14 14:25:54.000000000 +0200
@@ -65,10 +65,6 @@
         self._building_jobs = {}
         self._building_jobs_lock = threading.Lock()
 
-        self._dbcx = self._db_manager.dbcx()
-        self._cursor = self._dbcx.cursor()
-
-        self._requeue_interrupted_jobs()
         threading.Thread.__init__(self)
         self.setName("BuildMaster")
 
@@ -397,6 +393,12 @@
 
     def run(self):
         DebugUtils.registerThreadName(self)
+
+        self._dbcx = self._db_manager.dbcx()
+        self._cursor = self._dbcx.cursor()
+
+        self._requeue_interrupted_jobs()
+
         while self.should_stop == False:
             # Write update status for jobs to the database
             self._save_job_status()
diff -Nur plague-0.4.5-orig/server/DBManager.py plague-0.4.5/server/DBManager.py
--- plague-0.4.5-orig/server/DBManager.py	2008-01-31 15:21:09.000000000 +0100
+++ plague-0.4.5/server/DBManager.py	2008-06-14 14:25:54.000000000 +0200
@@ -124,11 +124,15 @@
 
     def fetchall(self, cursor):
         """ sqlite returns the items in a dict-like class already """
-        return cursor.fetchall()
+        rows = cursor.fetchall()
+        return [ResultSet(row, cursor.description) for row in rows]
 
     def fetchone(self, cursor):
         """ sqlite returns the items in a dict-like class already """
-        return cursor.fetchone()
+        row = cursor.fetchone()
+        if not row:
+            return None
+        return ResultSet(row, cursor.description)
 
     def _connect(self):
         try:
@@ -143,7 +147,7 @@
             tm = 3
 
         try:
-            dbcx = sqlite.connect(dbloc, encoding="utf-8", timeout=tm)
+            dbcx = sqlite.connect(dbloc)
         except StandardError, e:
             print "Error: %s" % e
             os._exit(1)
@@ -266,8 +270,8 @@
 # isn't present, remove its class entry from
 # the db engine dict
 try:
-    import sqlite
-except ImportError, e:
+    import sqlite3 as sqlite
+except ImportError:
     db_engines['sqlite'] = None
 
 try:
diff -Nur plague-0.4.5-orig/server/UserInterface.py plague-0.4.5/server/UserInterface.py
--- plague-0.4.5-orig/server/UserInterface.py	2008-01-31 15:21:09.000000000 +0100
+++ plague-0.4.5/server/UserInterface.py	2008-06-14 14:25:54.000000000 +0200
@@ -84,6 +84,12 @@
     return target_cfg
 
 
+def _fetchone(cursor,row):  # sqlite3 helper
+    if not row:
+        return None
+    return DBManager.ResultSet(row, cursor.description)
+
+
 class UserInterface:
     """
     Base UserInterface class. NO AUTHENTICATION.  Subclass this to provide some.
@@ -184,7 +190,7 @@
             del curs, dbcx
             return (-1, "Unable to access job database: '%s'" % e)
         curs.execute(sql)
-        job = dbcx.fetchone(curs)
+        job = _fetchone(curs,dbcx.fetchone(curs))
         result = None
         if not job:
             result = (-1, "Error: Invalid job UID.")
@@ -318,7 +324,7 @@
             del curs, dbcx
             return (-1, "Unable to access job database: '%s'" % e, [])
         curs.execute(sql)
-        data = dbcx.fetchall(curs)
+        data = [DBManager.ResultSet(row,curs.description) for row in curs.fetchall()]
         jobs = []
         for row in data:
             jobrec = {}
@@ -349,7 +355,7 @@
             sql = "SELECT jobid, parent_uid, starttime, endtime, arch, builder_addr, "  \
                     "status, builder_status FROM archjobs WHERE " + uids
             curs.execute(sql)
-            data = dbcx.fetchall(curs)
+            data = [DBManager.ResultSet(row,curs.description) for row in curs.fetchall()]
             for row in data:
                 ajrec = {}
                 ajrec['jobid'] = row['jobid']
@@ -386,7 +392,7 @@
         except StandardError, e:
             return (-1, "Unable to access job database: '%s'" % e, {})
         curs.execute(sql)
-        job = dbcx.fetchone(curs)
+        job = _fetchone(curs,dbcx.fetchone(curs))
         if not job:
             del curs, dbcx
             return (-1, "Error: Invalid job UID.", {})
@@ -420,7 +426,7 @@
         sql = "SELECT jobid, parent_uid, starttime, endtime, arch, builder_addr, "    \
                 "status, builder_status FROM archjobs WHERE parent_uid=%d " % uid
         curs.execute(sql)
-        data = dbcx.fetchall(curs)
+        data = [DBManager.ResultSet(row,curs.description) for row in curs.fetchall()]
         for row in data:
             ajrec = {}
             ajrec['jobid'] = row['jobid']
@@ -541,7 +547,7 @@
             return (-1, "Unable to access job database: '%s'" % e)
 
         curs.execute(sql)
-        job = dbcx.fetchone(curs)
+        job = _fetchone(curs,dbcx.fetchone(curs))
 
         result = None
         if not job:
@@ -630,7 +636,7 @@
             return (-1, "Unable to access job database: '%s'" % e)
 
         curs.execute(sql)
-        data = dbcx.fetchall(curs)
+        data = [DBManager.ResultSet(row,curs.description) for row in curs.fetchall()]
 
         # Ensure that the user can actually finish the jobs they requested
         final_uid_list = []
diff -Nur plague-0.4.5-orig/server/User.py plague-0.4.5/server/User.py
--- plague-0.4.5-orig/server/User.py	2008-01-31 15:21:09.000000000 +0100
+++ plague-0.4.5/server/User.py	2008-06-14 14:25:54.000000000 +0200
@@ -15,7 +15,11 @@
 # Copyright 2005 Dan Williams <dcbw at redhat.com> and Red Hat, Inc.
 
 
-import sqlite
+import sqlite3 as sqlite
+
+import sys
+sys.path.append('/usr/share/plague/server')
+from DBManager import ResultSet
 
 CONFIG_LOCATION = "/etc/plague/server/"
 
@@ -30,10 +34,9 @@
         self.user_admin = False
         self.server_admin = False
 
-
 def get_userdb_dbcx():
     try:
-        dbcx = sqlite.connect(CONFIG_LOCATION + "userdb", encoding="utf-8", timeout=4)
+        dbcx = sqlite.connect(CONFIG_LOCATION + "userdb")
         curs = dbcx.cursor()
         return (dbcx, curs)
     except sqlite.DatabaseError, e:
@@ -57,7 +60,7 @@
         try:
             curs.execute('SELECT * FROM users')
             dbcx.commit()
-        except sqlite._sqlite.DatabaseError, e:
+        except sqlite.DatabaseError, e:
             create = True
 
         if create:
@@ -81,6 +84,7 @@
         dbcx.commit()
         item = curs.fetchone()
         if item:
+            item = ResultSet(item, curs.description)
             user = User(email, False)
             user.own_jobs = item['own_jobs']
             user.job_admin = item['job_admin']
diff -Nur plague-0.4.5-orig/utils/user-manager.py plague-0.4.5/utils/user-manager.py
--- plague-0.4.5-orig/utils/user-manager.py	2005-08-08 18:15:18.000000000 +0200
+++ plague-0.4.5/utils/user-manager.py	2008-06-14 14:25:54.000000000 +0200
@@ -18,7 +18,10 @@
 
 
 import sys, os
-import sqlite
+import sqlite3
+
+sys.path.append('/usr/share/plague/server')
+from DBManager import ResultSet
 
 
 def print_usage(prog):
@@ -38,7 +41,7 @@
 
 class UserManager:
     def __init__(self, dbfile):
-        self.dbcx = sqlite.connect(dbfile, encoding="utf-8", timeout=2)
+        self.dbcx = sqlite3.connect(dbfile)
         self.curs = self.dbcx.cursor()
 
         # Ensure the table exists in the database
@@ -176,7 +179,7 @@
 
         self.curs.execute(sql)
         self.dbcx.commit()
-        data = self.curs.fetchall()
+        data = [ResultSet(row,self.curs.description) for row in self.curs.fetchall()]
         if not len(data):
             raise UserManagerException("No matching users found.")
 


Index: plague.spec
===================================================================
RCS file: /cvs/pkgs/rpms/plague/F-9/plague.spec,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- plague.spec	3 Sep 2008 05:08:37 -0000	1.32
+++ plague.spec	3 Sep 2008 12:06:11 -0000	1.33
@@ -3,20 +3,26 @@
 Summary: Distributed build system for RPMs
 Name: plague
 Version: 0.4.5
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: GPLv2+
 Group: Development/Tools
-Source: http://fedoraproject.org/projects/plague/releases/%{name}-%{version}.tar.bz2
+#Source: http://fedoraproject.org/projects/plague/releases/%{name}-%{version}.tar.bz2
+Source: %{name}-%{version}.tar.bz2
 URL: http://www.fedoraproject.org/wiki/Projects/Plague
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires: python
-Requires: python-sqlite, createrepo >= 0.4.3
+Requires: createrepo >= 0.4.3
 Requires: %{name}-common = %{version}-%{release}
 Requires(post): /sbin/chkconfig
 Requires(post): /sbin/service
 Requires(preun): /sbin/chkconfig
 Requires(preun): /sbin/service
 
+Patch1: plague-0.4.5-sqlite3.patch
+Patch2: plague-0.4.5-mock-0.8.patch
+Patch3: plague-0.4.5-logtail.patch
+
+
 %description
 The Plague build system is a client/server distributed build system for
 building RPM packages.  This package provides the plague server.
@@ -28,14 +34,20 @@
 Requires: pyOpenSSL
 
 %description common
-This package includes the common Python module that all Plague services require.
+This package includes the common Python module that all Plague services
+require.
 
 
 %package builder
 Summary: Builder daemon for Plague builder slaves
 Group: Development/Tools
 Requires: %{name}-common = %{version}-%{release}
-Requires: yum >= 2.2.1, mock >= 0.3
+Requires: yum >= 2.2.1
+%if 0%{?fedora} > 6
+Requires: mock >= 0.8
+%else
+Requires: mock < 0.8
+%endif
 Requires(post): /sbin/chkconfig
 Requires(post): /sbin/service
 Requires(preun): /sbin/chkconfig
@@ -51,7 +63,8 @@
 Requires: %{name}-common = %{version}-%{release}
 
 %description client
-Client program for enqueueing package builds and interrogating the build system.
+Client program for enqueueing package builds and interrogating the build
+system.
 
 
 %package utils
@@ -66,6 +79,12 @@
 
 %prep
 %setup -q
+%if 0%{?fedora} > 6
+%patch1 -p1 -b .sqlite3
+%patch2 -p1 -b .mock8
+%endif
+%patch3 -p1 -b .logtail
+
 
 %build
 make
@@ -73,12 +92,13 @@
 
 %install
 rm -rf $RPM_BUILD_ROOT
-make DESTDIR=$RPM_BUILD_ROOT install
-install -D -m 0644 etc/plague-builder.config $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/%{name}-builder
-install -D -m 0755 etc/plague-builder.init $RPM_BUILD_ROOT%{_initrddir}/%{name}-builder
-install -D -m 0644 etc/plague-server.config $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/%{name}-server
-install -D -m 0755 etc/plague-server.init $RPM_BUILD_ROOT%{_initrddir}/%{name}-server
-mkdir -p $RPM_BUILD_ROOT/srv/plague_builder
+make DESTDIR=$RPM_BUILD_ROOT INSTALL="install -p" install
+chmod +x $RPM_BUILD_ROOT%{_bindir}/*
+install -p -D -m 0644 etc/plague-builder.config $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/%{name}-builder
+install -p -D -m 0755 etc/plague-builder.init $RPM_BUILD_ROOT%{_initrddir}/%{name}-builder
+install -p -D -m 0644 etc/plague-server.config $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/%{name}-server
+install -p -D -m 0755 etc/plague-server.init $RPM_BUILD_ROOT%{_initrddir}/%{name}-server
+mkdir -p $RPM_BUILD_ROOT/var/lib/plague/builder
 
 
 %clean
@@ -96,7 +116,7 @@
 fi
 
 %pre builder
-/usr/sbin/useradd -G mock -s /sbin/nologin -M -r -d /srv/plague_builder plague-builder 2>/dev/null || :
+/usr/sbin/useradd -G mock -s /sbin/nologin -M -r -d /var/lib/plague/builder plague-builder 2>/dev/null || :
 
 %post builder
 /sbin/chkconfig --add plague-builder
@@ -135,7 +155,8 @@
 %dir %{_sysconfdir}/%{name}/builder/certs
 %config(noreplace) %{_sysconfdir}/sysconfig/%{name}-builder
 %{_initrddir}/%{name}-builder
-%attr(0755, plague-builder, plague-builder) /srv/plague_builder
+%dir /var/lib/plague
+%attr(0755, plague-builder, plague-builder) /var/lib/plague/builder
 
 %files client
 %defattr(-, root, root)
@@ -148,13 +169,17 @@
 
 
 %changelog
+* Wed Sep  3 2008 Michael Schwendt <mschwendt at fedoraproject.org> - 0.4.5-2
+- add the patches from 0.4.5-0.4 (sqlite3, mock08, logtail)
+- merge more spec changes
+
 * Tue Sep 02 2008 Dennis Gilmore <dennis at ausil.us> - 0.4.5-1
 - update to 0.4.5  lots of fixes 
 
 * Thu May 22 2008 Seth Vidal <skvidal at fedoraproject.org> - 0.4.4.1-6
 - licensing tag fix
 
-* Tue Sep 18 2007 Michael Schwendt <mschwendt at users.sf.net> - 0.4.4.1-5
+* Tue Sep 18 2007 Michael Schwendt <mschwendt at fedoraproject.org> - 0.4.4.1-5
 - Add dirs /etc/plague and /usr/share/plague to plague-common
   since "plague-builder" and "plague" use them (#233904).
 
@@ -321,7 +346,7 @@
 
 * Sat Jul 16 2005 Dan Williams <dcbw at redhat.com>
 - Bump version to 0.2
-- Grab python files from /usr/lib, not %{_libdir} until the
+- Grab python files from /usr/lib, not %%{_libdir} until the
     multiarch issues get worked out
 
 * Sun Jun 26 2005 Dan Williams <dcbw at redhat.com>




More information about the fedora-extras-commits mailing list