X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fqueue.py;h=72804059ce940f307477060787758ab7e2d82d38;hb=fc35ff4d09d4c622b21dabdc10afbb09c78d1d02;hp=0433a9648883163f81fe5f0d4be448ed8456bf6f;hpb=0d607ab20be45ec2f0c223c906be83f0fab4f376;p=dak.git diff --git a/daklib/queue.py b/daklib/queue.py index 0433a964..72804059 100755 --- a/daklib/queue.py +++ b/daklib/queue.py @@ -288,6 +288,8 @@ class Upload(object): self.warnings = [] self.notes = [] + self.later_check_files = [] + self.pkg.reset() def package_info(self): @@ -305,7 +307,7 @@ class Upload(object): for title, messages in msgs: if messages: msg += '\n\n%s:\n%s' % (title, '\n'.join(messages)) - msg += '\n' + msg += '\n\n' return msg @@ -820,8 +822,7 @@ class Upload(object): for f in file_keys: ret = holding.copy_to_holding(f) if ret is not None: - # XXX: Should we bail out here or try and continue? - self.rejects.append(ret) + self.warnings.append('Could not copy %s to holding; will attempt to find in DB later' % f) os.chdir(cwd) @@ -863,7 +864,9 @@ class Upload(object): if os.path.exists(f): self.rejects.append("Can't read `%s'. [permission denied]" % (f)) else: - self.rejects.append("Can't read `%s'. [file not found]" % (f)) + # Don't directly reject, mark to check later to deal with orig's + # we can find in the pool + self.later_check_files.append(f) entry["type"] = "unreadable" continue @@ -1008,6 +1011,10 @@ class Upload(object): self.check_dsc_against_db(dsc_filename, session) session.close() + # Finally, check if we're missing any files + for f in self.later_check_files: + self.rejects.append("Could not find file %s references in changes" % f) + return True ########################################################################### @@ -1830,7 +1837,7 @@ distribution.""" # Add the .dsc file to the DB first for newfile, entry in self.pkg.files.items(): if entry["type"] == "dsc": - dsc_component, dsc_location_id, pfs = add_dsc_to_db(self, newfile, session) + source, dsc_component, dsc_location_id, pfs = add_dsc_to_db(self, newfile, session) for j in pfs: poolfiles.append(j) @@ -1842,6 +1849,7 @@ distribution.""" # If this is a sourceful diff only upload that is moving # cross-component we need to copy the .orig files into the new # component too for the same reasons as above. + # XXX: mhy: I think this should be in add_dsc_to_db if self.pkg.changes["architecture"].has_key("source"): for orig_file in self.pkg.orig_files.keys(): if not self.pkg.orig_files[orig_file].has_key("id"): @@ -1859,21 +1867,45 @@ distribution.""" new_filename = os.path.join(utils.poolify(self.pkg.changes["source"], dsc_component), os.path.basename(old_filename)) # TODO: Care about size/md5sum collisions etc - (found, newf) = check_poolfile(new_filename, file_size, file_md5sum, dsc_location_id, session) + (found, newf) = check_poolfile(new_filename, old_dat['size'], old_dat['md5sum'], dsc_location_id, session) + # TODO: Uhm, what happens if newf isn't None - something has gone badly and we should cope if newf is None: utils.copy(old_filename, os.path.join(cnf["Dir::Pool"], new_filename)) newf = add_poolfile(new_filename, old_dat, dsc_location_id, session) - # TODO: Check that there's only 1 here - source = get_sources_from_name(self.pkg.changes["source"], self.pkg.changes["version"])[0] - dscf = get_dscfiles(source_id=source.source_id, poolfile_id=orig_file_id, session=session)[0] - dscf.poolfile_id = newf.file_id - session.add(dscf) session.flush() + # Don't reference the old file from this changes + for p in poolfiles: + if p.file_id == oldf.file_id: + poolfiles.remove(p) + poolfiles.append(newf) + # Fix up the DSC references + toremove = [] + + for df in source.srcfiles: + if df.poolfile.file_id == oldf.file_id: + # Add a new DSC entry and mark the old one for deletion + # Don't do it in the loop so we don't change the thing we're iterating over + newdscf = DSCFile() + newdscf.source_id = source.source_id + newdscf.poolfile_id = newf.file_id + session.add(newdscf) + + toremove.append(df) + + for df in toremove: + session.delete(df) + + # Flush our changes + session.flush() + + # Make sure that our source object is up-to-date + session.expire(source) + # 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) @@ -1902,16 +1934,13 @@ distribution.""" if self.pkg.changes["architecture"].has_key("source") and cnf.get("Dir::UrgencyLog"): UrgencyLog().log(self.pkg.dsc["source"], self.pkg.dsc["version"], self.pkg.changes["urgency"]) - # Send accept mail, announce to lists, close bugs and check for - # override disparities - if not cnf["Dinstall::Options::No-Mail"]: - self.update_subst() - self.Subst["__SUITE__"] = "" - self.Subst["__SUMMARY__"] = summary - mail_message = utils.TemplateSubst(self.Subst, - os.path.join(cnf["Dir::Templates"], 'process-unchecked.accepted')) - utils.send_mail(mail_message) - self.announce(short_summary, 1) + self.update_subst() + self.Subst["__SUITE__"] = "" + self.Subst["__SUMMARY__"] = summary + mail_message = utils.TemplateSubst(self.Subst, + os.path.join(cnf["Dir::Templates"], 'process-unchecked.accepted')) + utils.send_mail(mail_message) + self.announce(short_summary, 1) ## Helper stuff for DebBugs Version Tracking if cnf.Find("Dir::Queue::BTSVersionTrack"): @@ -1973,11 +2002,8 @@ distribution.""" cnf = Config() - # Abandon the check if: - # a) override disparity checks have been disabled - # b) we're not sending mail - if not cnf.FindB("Dinstall::OverrideDisparityCheck") or \ - cnf["Dinstall::Options::No-Mail"]: + # Abandon the check if override disparity checks have been disabled + if not cnf.FindB("Dinstall::OverrideDisparityCheck"): return summary = self.pkg.check_override() @@ -2052,17 +2078,17 @@ distribution.""" try: dest_fd = os.open(dest_file, os.O_RDWR | os.O_CREAT | os.O_EXCL, 0644) except OSError, e: - # File exists? Let's try and move it to the morgue + # File exists? Let's find a new name by adding a number if e.errno == errno.EEXIST: - morgue_file = os.path.join(cnf["Dir::Morgue"], cnf["Dir::MorgueReject"], file_entry) try: - morgue_file = utils.find_next_free(morgue_file) + dest_file = utils.find_next_free(dest_file, 255) except NoFreeFilenameError: # Something's either gone badly Pete Tong, or # someone is trying to exploit us. - utils.warn("**WARNING** failed to move %s from the reject directory to the morgue." % (file_entry)) + utils.warn("**WARNING** failed to find a free filename for %s in %s." % (file_entry, cnf["Dir::Queue::Reject"])) return - utils.move(dest_file, morgue_file, perms=0660) + + # Make sure we really got it try: dest_fd = os.open(dest_file, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0644) except OSError, e: @@ -2167,9 +2193,8 @@ distribution.""" os.close(reason_fd) - # Send the rejection mail if appropriate - if not cnf["Dinstall::Options::No-Mail"]: - utils.send_mail(reject_mail_message) + # Send the rejection mail + utils.send_mail(reject_mail_message) if self.logger: self.logger.log(["rejected", self.pkg.changes_file]) @@ -2421,6 +2446,13 @@ distribution.""" orig_files[dsc_name]["path"] = os.path.join(i.location.path, i.filename) match = 1 + # Don't bitch that we couldn't find this file later + try: + self.later_check_files.remove(dsc_name) + except ValueError: + pass + + if not match: self.rejects.append("can not overwrite existing copy of '%s' already in the archive." % (dsc_name))