]> git.decadent.org.uk Git - dak.git/commitdiff
Keep track of when a package was last added to a suite
authorAnsgar Burchardt <ansgar@debian.org>
Sun, 1 May 2016 14:55:11 +0000 (16:55 +0200)
committerAnsgar Burchardt <ansgar@debian.org>
Sun, 1 May 2016 14:55:11 +0000 (16:55 +0200)
dak/dakdb/update115.py [new file with mode: 0644]
dak/process_policy.py
daklib/archive.py
daklib/dbconn.py

diff --git a/dak/dakdb/update115.py b/dak/dakdb/update115.py
new file mode 100644 (file)
index 0000000..3dd3e84
--- /dev/null
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+# coding=utf8
+
+"""
+Add last_changed to suite
+
+@contact: Debian FTP Master <ftpmaster@debian.org>
+@copyright: 2016, Ansgar Burchardt <ansgar@debian.org>
+@license: GNU General Public License version 2 or later
+"""
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+################################################################################
+
+import psycopg2
+from daklib.dak_exceptions import DBUpdateError
+from daklib.config import Config
+
+statements = [
+"""
+ALTER TABLE suite
+  ADD COLUMN last_changed TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+""",
+"""
+COMMENT ON COLUMN suite.last_changed
+  IS 'When the suite was last changed by adding/removing packages and needs to be republished'
+"""
+]
+
+################################################################################
+def do_update(self):
+    print __doc__
+    try:
+        cnf = Config()
+
+        c = self.db.cursor()
+
+        for stmt in statements:
+            c.execute(stmt)
+
+        c.execute("UPDATE config SET value = '115' WHERE name = 'db_revision'")
+        self.db.commit()
+
+    except psycopg2.ProgrammingError as msg:
+        self.db.rollback()
+        raise DBUpdateError('Unable to apply sick update 115, rollback issued. Error message: {0}'.format(msg))
index 8966dd6a209b6ec45c3c49a81cfbbc20b44191e2..ab37aa2216b3282fcfeb4657d36944b89b32b3fc 100755 (executable)
@@ -213,6 +213,8 @@ def comment_accept(upload, srcqueue, comments, transaction):
                 extra_archives=[upload.target_suite.archive],
             )
 
+        suite.update_last_changed()
+
     # Copy .changes if needed
     if upload.target_suite.copychanges:
         src = os.path.join(upload.policy_queue.path, upload.changes.changesname)
index fc31b6a5403253e42b5528b95bd428d76d446564..bfab2c64e832ba63f64806a633bb0fc177cbc8b7 100644 (file)
@@ -1068,6 +1068,8 @@ class ArchiveUpload(object):
             dst = os.path.join(suite.archive.path, 'dists', suite.suite_name, self.changes.filename)
             self.transaction.fs.copy(src, dst, mode=suite.archive.mode)
 
+        suite.update_last_changed()
+
         return (db_source, db_binaries)
 
     def _install_changes(self):
index 3d3561f59618b3c03154a31826f8e9d02ad0d7eb..58ad0412232a78f18c01012c1ab5b9b5ba305cb5 100755 (executable)
@@ -1948,6 +1948,9 @@ class Suite(ORMObject):
         else:
             return object_session(self).query(Suite).filter_by(suite_name=self.overridesuite).one()
 
+    def update_last_changed(self):
+        self.last_changed = sqlalchemy.func.now()
+
     @property
     def path(self):
         return os.path.join(self.archive.path, 'dists', self.suite_name)