X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=daklib%2Fqueue.py;h=e2ab8467b66ec7901e967e68e0ce513dd24dd8fa;hb=ad8367d4ad22c161a57936d4d7e97a47dc2ac224;hp=12e027190d32fb61bc98bf2ad2e3fb9c92c8f05e;hpb=27e00376e81d1c37ff327ee0d39670b266418869;p=dak.git diff --git a/daklib/queue.py b/daklib/queue.py index 12e02719..e2ab8467 100755 --- a/daklib/queue.py +++ b/daklib/queue.py @@ -51,7 +51,7 @@ from holding import Holding from urgencylog import UrgencyLog from dbconn import * from summarystats import SummaryStats -from utils import parse_changes, check_dsc_files, build_package_set +from utils import parse_changes, check_dsc_files, build_package_list from textutils import fix_maintainer from lintian import parse_lintian_output, generate_reject_messages from contents import UnpackedSource @@ -133,8 +133,8 @@ def determine_new(filename, changes, files, warn=1, session = None, dsc = None, # Try to get the Package-Set field from an included .dsc file (if possible). if dsc: - for package, entry in build_package_set(dsc, session).items(): - if not new.has_key(package): + for package, entry in build_package_list(dsc, session).items(): + if package not in new: new[package] = entry # Build up a list of potentially new things @@ -290,9 +290,9 @@ class TarTime(object): def callback(self, member, data): if member.mtime > self.future_cutoff: - self.future_files[Name] = MTime + self.future_files[Name] = member.mtime if member.mtime < self.past_cutoff: - self.ancient_files[Name] = MTime + self.ancient_files[Name] = member.mtime ############################################################################### @@ -386,8 +386,9 @@ def edit_note(note, upload, session, trainee=False): ############################################################################### +# FIXME: Should move into the database # suite names DMs can upload to -dm_suites = ['unstable', 'experimental'] +dm_suites = ['unstable', 'experimental', 'squeeze-backports'] def get_newest_source(source, session): 'returns the newest DBSource object in dm_suites' @@ -714,7 +715,7 @@ class Upload(object): try: control = apt_pkg.ParseSection(apt_inst.debExtractControl(deb_file)) except: - self.rejects.append("%s: debExtractControl() raised %s." % (f, sys.exc_type)) + self.rejects.append("%s: debExtractControl() raised %s." % (f, sys.exc_info()[0])) deb_file.close() # Can't continue, none of the checks on control would work. return @@ -1654,9 +1655,12 @@ class Upload(object): self.rejects.append("%s: has %s file(s) with a time stamp too ancient (e.g. %s [%s])." % (filename, num_ancient_files, ancient_file, time.ctime(ancient_date))) except: - self.rejects.append("%s: deb contents timestamp check failed [%s: %s]" % (filename, sys.exc_type, sys.exc_value)) + self.rejects.append("%s: deb contents timestamp check failed [%s: %s]" % (filename, sys.exc_info()[0], sys.exc_info()[1])) def check_if_upload_is_sponsored(self, uid_email, uid_name): + for key in "maintaineremail", "changedbyemail", "maintainername", "changedbyname": + if not self.pkg.changes.has_key(key): + return False uid_email = '@'.join(uid_email.split('@')[:2]) if uid_email in [self.pkg.changes["maintaineremail"], self.pkg.changes["changedbyemail"]]: sponsored = False @@ -1804,7 +1808,7 @@ class Upload(object): r = get_newest_source(self.pkg.changes["source"], session) if r is None: - rej = "Could not find existing source package %s in unstable or experimental and this is a DM upload" % self.pkg.changes["source"] + rej = "Could not find existing source package %s in the DM allowed suites and this is a DM upload" % self.pkg.changes["source"] self.rejects.append(rej) return @@ -1930,8 +1934,7 @@ transition is done.""" # This is for direport's benefit... f = re_fdnic.sub("\n .\n", self.pkg.changes.get("changes", "")) - if byhand or new: - summary += "Changes: " + f + summary += "\n\nChanges:\n" + f summary += "\n\nOverride entries for your package:\n" + override_summary + "\n" @@ -2225,7 +2228,7 @@ distribution.""" filename = "%s/%s" % (cnf["Dir::BTSVersionTrack"], self.pkg.changes_file[:-8]+".versions") os.rename(temp_filename, filename) - os.chmod(filename, 0644) + os.chmod(filename, 0o644) # Write out the binary -> source mapping. (fd, temp_filename) = utils.temp_filename(cnf["Dir::BTSVersionTrack"], prefix=".") @@ -2240,7 +2243,7 @@ distribution.""" filename = "%s/%s" % (cnf["Dir::BTSVersionTrack"], self.pkg.changes_file[:-8]+".debinfo") os.rename(temp_filename, filename) - os.chmod(filename, 0644) + os.chmod(filename, 0o644) session.commit() @@ -2342,7 +2345,7 @@ distribution.""" dest_file = os.path.join(cnf["Dir::Reject"], file_entry) try: - dest_fd = os.open(dest_file, os.O_RDWR | os.O_CREAT | os.O_EXCL, 0644) + dest_fd = os.open(dest_file, os.O_RDWR | os.O_CREAT | os.O_EXCL, 0o644) except OSError as e: # File exists? Let's find a new name by adding a number if e.errno == errno.EEXIST: @@ -2356,7 +2359,7 @@ distribution.""" # Make sure we really got it try: - dest_fd = os.open(dest_file, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0644) + dest_fd = os.open(dest_file, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0o644) except OSError as e: # Likewise utils.warn("**WARNING** failed to claim %s in the reject directory." % (file_entry)) @@ -2365,7 +2368,7 @@ distribution.""" raise # If we got here, we own the destination file, so we can # safely overwrite it. - utils.move(file_entry, dest_file, 1, perms=0660) + utils.move(file_entry, dest_file, 1, perms=0o660) os.close(dest_fd) ########################################################################### @@ -2422,16 +2425,25 @@ distribution.""" reason_filename = self.pkg.changes_file[:-8] + ".reason" reason_filename = os.path.join(cnf["Dir::Reject"], reason_filename) + changesfile = os.path.join(cnf["Dir::Reject"], self.pkg.changes_file) # Move all the files into the reject directory reject_files = self.pkg.files.keys() + [self.pkg.changes_file] self.force_reject(reject_files) + # Change permissions of the .changes file to be world readable + try: + os.chmod(changesfile, os.stat(changesfile).st_mode | stat.S_IROTH) + except OSError as (errno, strerror): + # Ignore 'Operation not permitted' error. + if errno != 1: + raise + # If we fail here someone is probably trying to exploit the race # so let's just raise an exception ... if os.path.exists(reason_filename): os.unlink(reason_filename) - reason_fd = os.open(reason_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0644) + reason_fd = os.open(reason_filename, os.O_RDWR|os.O_CREAT|os.O_EXCL, 0o644) rej_template = os.path.join(cnf["Dir::Templates"], "queue.rejected")