X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fqueue.py;h=3ab87246d1601f1fc5dd52912293deb155f95b38;hb=c9398d303256dfedc13975b79b6b691048cfcc05;hp=c177602c3c55bf627af9258048419ecfc6f03861;hpb=3d8f1f7a48b565b6d6a4b36c827e256586558e40;p=dak.git diff --git a/daklib/queue.py b/daklib/queue.py index c177602c..3ab87246 100755 --- a/daklib/queue.py +++ b/daklib/queue.py @@ -454,7 +454,7 @@ class Upload(object): # Check the .changes is non-empty if not self.pkg.files: - self.rejects.append("%s: nothing to do (Files field is empty)." % (base_filename)) + self.rejects.append("%s: nothing to do (Files field is empty)." % (os.path.basename(self.pkg.changes_file))) return False # Changes was syntactically valid even if we'll reject @@ -1899,6 +1899,9 @@ distribution.""" # Make sure that our source object is up-to-date session.expire(source) + # Add changelog information to the database + self.store_changelog() + # Install the files into the pool for newfile, entry in self.pkg.files.items(): destination = os.path.join(cnf["Dir::Pool"], entry["pool name"], newfile) @@ -2672,3 +2675,35 @@ distribution.""" os.chdir(cwd) return too_new + + def store_changelog(self): + + # Skip binary-only upload if it is not a bin-NMU + if not self.pkg.changes['architecture'].has_key('source'): + from daklib.regexes import re_bin_only_nmu + if not re_bin_only_nmu.search(self.pkg.changes['version']): + return + + session = DBConn().session() + + # Check if upload already has a changelog entry + query = """SELECT changelog_id FROM changes WHERE source = :source + AND version = :version AND architecture = :architecture AND changelog_id != 0""" + if session.execute(query, {'source': self.pkg.changes['source'], \ + 'version': self.pkg.changes['version'], \ + 'architecture': " ".join(self.pkg.changes['architecture'].keys())}).rowcount: + session.commit() + return + + # Add current changelog text into changelogs_text table, return created ID + query = "INSERT INTO changelogs_text (changelog) VALUES (:changelog) RETURNING id" + ID = session.execute(query, {'changelog': self.pkg.changes['changes']}).fetchone()[0] + + # Link ID to the upload available in changes table + query = """UPDATE changes SET changelog_id = :id WHERE source = :source + AND version = :version AND architecture = :architecture""" + session.execute(query, {'id': ID, 'source': self.pkg.changes['source'], \ + 'version': self.pkg.changes['version'], \ + 'architecture': " ".join(self.pkg.changes['architecture'].keys())}) + + session.commit()