+def britney_changelog(packages, suite, session):
+
+ old = {}
+ current = {}
+
+ q = session.execute("""SELECT s.source, s.version, sa.id
+ FROM source s, src_associations sa
+ WHERE sa.suite = :suiteid
+ AND sa.source = s.id""", {'suiteid': suite.suite_id})
+
+ for p in q.fetchall():
+ current[p[0]] = p[1]
+ for p in packages.keys():
+ p = p.split()
+ if p[2] == "source":
+ old[p[0]] = p[1]
+
+ new = {}
+ for p in current.keys():
+ if p in old.keys():
+ if apt_pkg.VersionCompare(current[p], old[p]) > 0:
+ new[p] = [current[p], old[p]]
+ else:
+ new[p] = [current[p], 0]
+
+ query = "SELECT source, changelog FROM changelogs WHERE"
+ for p in new.keys():
+ query += " source = '%s' AND version > '%s' AND version <= '%s'" \
+ % (p, new[p][1], new[p][0])
+ query += " AND architecture LIKE '%source%' OR"
+ query += " False ORDER BY source, version DESC"
+ q = session.execute(query)
+
+ pu = None
+ brit = utils.open_file(Config()["Changelogs::Britney"], 'w')
+
+ for u in q:
+ if pu and pu != u[0]:
+ brit.write("\n")
+ brit.write("%s\n" % u[1])
+ pu = u[0]
+ if len(u): brit.write("\n\n\n")
+
+ for p in list(set(old.keys()).difference(current.keys())):
+ brit.write("REMOVED: %s %s\n" % (p, old[p]))
+
+ brit.flush()
+ brit.close()
+
+#######################################################################################
+
+def set_suite(file, suite, session, britney=False):