X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fqueue.py;h=ca3c133e1fd23e3b62bc00fca013124e2c973064;hb=6965c0b6d6f9524879272c123d1547f82c949931;hp=dd654cd2d67e06162057c348b4c4e461c70a3438;hpb=26957544e0bbb7e6aa08850f9f5da178b2d1453a;p=dak.git diff --git a/daklib/queue.py b/daklib/queue.py index dd654cd2..ca3c133e 100755 --- a/daklib/queue.py +++ b/daklib/queue.py @@ -187,7 +187,7 @@ def determine_new(changes, files, warn=1): ################################################################################ -def check_valid(new): +def check_valid(new, session = None): """ Check if section and priority for NEW packages exist in database. Additionally does sanity checks: @@ -204,13 +204,13 @@ def check_valid(new): priority_name = new[pkg]["priority"] file_type = new[pkg]["type"] - section = get_section(section_name) + section = get_section(section_name, session) if section is None: new[pkg]["section id"] = -1 else: new[pkg]["section id"] = section.section_id - priority = get_priority(priority_name) + priority = get_priority(priority_name, session) if priority is None: new[pkg]["priority id"] = -1 else: @@ -231,17 +231,6 @@ def check_valid(new): ############################################################################### -def check_status(files): - new = byhand = 0 - for f in files.keys(): - if files[f].has_key("byhand"): - byhand = 1 - elif files[f].has_key("new"): - new = 1 - return (new, byhand) - -############################################################################### - # Used by Upload.check_timestamps class TarTime(object): def __init__(self, future_cutoff, past_cutoff): @@ -364,8 +353,8 @@ class Upload(object): Load a changes file and setup a dictionary around it. Also checks for mandantory fields within. - @type: string - @param: Changes filename, full path. + @type filename: string + @param filename: Changes filename, full path. @rtype: boolean @return: whether the changes file was valid or not. We may want to @@ -465,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 @@ -580,8 +569,8 @@ class Upload(object): architecture = control.Find("Architecture") upload_suite = self.pkg.changes["distribution"].keys()[0] - if architecture not in [a.arch_string for a in get_suite_architectures(default_suite, session)] \ - and architecture not in [a.arch_string for a in get_suite_architectures(upload_suite, session)]: + if architecture not in [a.arch_string for a in get_suite_architectures(default_suite, session = session)] \ + and architecture not in [a.arch_string for a in get_suite_architectures(upload_suite, session = session)]: self.rejects.append("Unknown architecture '%s'." % (architecture)) # Ensure the architecture of the .deb is one of the ones @@ -940,7 +929,7 @@ class Upload(object): # Parse the .dsc file try: - self.pkg.dsc.update(utils.parse_changes(dsc_filename, signing_rules=1)) + self.pkg.dsc.update(utils.parse_changes(dsc_filename, signing_rules=1, dsc_file=1)) except CantOpenError: # if not -n copy_to_holding() will have done this for us... if not action: @@ -1236,7 +1225,7 @@ class Upload(object): found = False # Look in the pool - for poolfile in get_poolfile_like_name('/%s' % filename, session_): + for poolfile in get_poolfile_like_name('%s' % filename, session_): poolfile_path = os.path.join( poolfile.location.path, poolfile.filename ) @@ -1910,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) @@ -2683,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()