rpms/plague/devel plague-0.4.5.5-sqlite-alter.patch, NONE, 1.1 plague.spec, 1.40, 1.41

Michael Schwendt mschwendt at fedoraproject.org
Fri Sep 19 23:29:53 UTC 2008


Author: mschwendt

Update of /cvs/pkgs/rpms/plague/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv5309

Modified Files:
	plague.spec 
Added Files:
	plague-0.4.5.5-sqlite-alter.patch 
Log Message:
* Sat Sep 20 2008 Michael Schwendt <mschwendt at fedoraproject.org> - 0.4.5.5-2
- add fix for sqlite's limited ALTER TABLE


plague-0.4.5.5-sqlite-alter.patch:

--- NEW FILE plague-0.4.5.5-sqlite-alter.patch ---
diff -Nur plague-0.4.5.5-orig/server/DBManager.py plague-0.4.5.5/server/DBManager.py
--- plague-0.4.5.5-orig/server/DBManager.py	2008-09-08 17:56:46.000000000 +0200
+++ plague-0.4.5.5/server/DBManager.py	2008-09-20 01:26:20.000000000 +0200
@@ -312,6 +312,7 @@
         if not dbcx:
             os._exit(1)
         self._ensure_tables(dbcx)
+        self._fix_tables(dbcx)
         del dbcx
 
     def dbcx(self):
@@ -358,22 +359,6 @@
                 print "Could not access the job database.  Reason: '%s'.  Exiting..." % e
                 os._exit(1)
 
-        # Rename columns in jobs table, because `RELEASE` is a new
-        # reserved keyword in MySQL 5, and the quote character is
-        # different for Postgresql.
-        for i in range(len(curs.description or [])):
-            if curs.description[i][0].upper() == 'RELEASE':
-                if self.engine == 'mysql':
-                    curs.execute('ALTER TABLE jobs CHANGE `release` rpm_release VARCHAR(25);')
-                    curs.execute('ALTER TABLE jobs CHANGE `version` rpm_version VARCHAR(25);')
-                    curs.execute('ALTER TABLE jobs CHANGE `epoch` rpm_epoch VARCHAR(4);')
-                else:
-                    curs.execute('ALTER TABLE jobs CHANGE release rpm_release VARCHAR(25);')
-                    curs.execute('ALTER TABLE jobs CHANGE version rpm_version VARCHAR(25);')
-                    curs.execute('ALTER TABLE jobs CHANGE epoch rpm_epoch VARCHAR(4);')
-                dbcx.commit()
-                break
-
         # Create the archjobs table
         try:
             curs.execute('SELECT * FROM archjobs LIMIT 4')
@@ -396,3 +381,32 @@
                 print "Could not access the job database.  Reason: '%s'.  Exiting..." % e
                 os._exit(1)
 
+    def _fix_tables(self, dbcx):
+        """ Fix database tables for compatibility with e.g. MySQL 5 """
+
+        # Rename columns in jobs table, because `RELEASE` is a new
+        # reserved keyword in MySQL 5, and the quote character is
+        # different for Postgresql.
+        curs = dbcx.cursor()
+        curs.execute('SELECT * FROM jobs LIMIT 1')
+        for i in range(len(curs.description or [])):
+            if curs.description[i][0].upper() == 'RELEASE':
+                if self.engine == 'mysql':
+                    curs.execute('ALTER TABLE jobs CHANGE `release` rpm_release VARCHAR(25);')
+                    curs.execute('ALTER TABLE jobs CHANGE `version` rpm_version VARCHAR(25);')
+                    curs.execute('ALTER TABLE jobs CHANGE `epoch` rpm_epoch VARCHAR(4);')
+                    dbcx.commit()
+                elif self.engine == 'sqlite':
+                    # No column rename available, so reconstruct a new table.
+                    curs.execute('ALTER TABLE jobs RENAME TO oldjobs;')
+                    self._ensure_tables(dbcx)
+                    curs.execute('INSERT INTO jobs SELECT * FROM oldjobs;')
+                    curs.execute('DROP TABLE oldjobs;')
+                    dbcx.commit()
+                else:
+                    curs.execute('ALTER TABLE jobs CHANGE release rpm_release VARCHAR(25);')
+                    curs.execute('ALTER TABLE jobs CHANGE version rpm_version VARCHAR(25);')
+                    curs.execute('ALTER TABLE jobs CHANGE epoch rpm_epoch VARCHAR(4);')
+                    dbcx.commit()
+                break
+


Index: plague.spec
===================================================================
RCS file: /cvs/pkgs/rpms/plague/devel/plague.spec,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- plague.spec	8 Sep 2008 16:00:43 -0000	1.40
+++ plague.spec	19 Sep 2008 23:29:23 -0000	1.41
@@ -3,11 +3,12 @@
 Summary: Distributed build system for RPMs
 Name: plague
 Version: 0.4.5.5
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: GPLv2+
 Group: Development/Tools
 #Source: http://fedoraproject.org/projects/plague/releases/%{name}-%{version}.tar.bz2
 Source: %{name}-%{version}.tar.bz2
+Patch1: plague-0.4.5.5-sqlite-alter.patch
 URL: http://www.fedoraproject.org/wiki/Projects/Plague
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires: python
@@ -79,6 +80,7 @@
 
 %prep
 %setup -q
+%patch1 -p1 -b .sqlite-alter
 
 
 %build
@@ -165,6 +167,9 @@
 
 
 %changelog
+* Sat Sep 20 2008 Michael Schwendt <mschwendt at fedoraproject.org> - 0.4.5.5-2
+- add fix for sqlite's limited ALTER TABLE
+
 * Mon Sep  8 2008 Michael Schwendt <mschwendt at fedoraproject.org> - 0.4.5.5-1
 - update to 0.4.5.5
 




More information about the fedora-extras-commits mailing list