From: Joerg Jaspert Date: Tue, 14 Aug 2012 06:09:42 +0000 (+0200) Subject: Merge remote-tracking branch 'ansgar/pu/multiarchive-1' X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=3699a62a0ff7b4c5d0b5635190dca1946f7bbbd1;hp=4a54d9d1be2fbe9a996b57046a6a720cdeeccd4c;p=dak.git Merge remote-tracking branch 'ansgar/pu/multiarchive-1' * ansgar/pu/multiarchive-1: daklib/archive.py: don't check hashes when copying upload to temporary location dak/clean_suites.py: use '>' instead of '>=' daklib/utils.py (gpg_get_key_addresses): prefer @debian.org addresses dak/process_upload.py: remove old inactive code; update some comments dak/dakdb/update79.py: fix typo: workd → world Signed-off-by: Joerg Jaspert --- diff --git a/dak/clean_suites.py b/dak/clean_suites.py index e9360012..e571ae0e 100755 --- a/dak/clean_suites.py +++ b/dak/clean_suites.py @@ -214,7 +214,7 @@ def clean_binaries(now_date, session): AND NOT EXISTS (SELECT 1 FROM files_archive_map af JOIN archive_delete_date ad ON af.archive_id = ad.archive_id WHERE af.file_id = b.file - AND (af.last_used IS NULL OR af.last_used >= ad.delete_date)) + AND (af.last_used IS NULL OR af.last_used > ad.delete_date)) RETURNING f.filename """) for b in q: @@ -254,7 +254,7 @@ def clean(now_date, archives, max_delete, session): AND NOT EXISTS (SELECT 1 FROM files_archive_map af JOIN archive_delete_date ad ON af.archive_id = ad.archive_id WHERE af.file_id = source.file - AND (af.last_used IS NULL OR af.last_used >= ad.delete_date)) + AND (af.last_used IS NULL OR af.last_used > ad.delete_date)) RETURNING source.id AS id, f.filename AS filename ), deleted_dsc_files AS ( diff --git a/dak/dakdb/update79.py b/dak/dakdb/update79.py index d03fc066..81a7b239 100755 --- a/dak/dakdb/update79.py +++ b/dak/dakdb/update79.py @@ -38,7 +38,7 @@ def do_update(self): c = self.db.cursor() c.execute("CREATE SCHEMA world"); - c.execute("GRANT USAGE ON SCHEMA workd TO PUBLIC") + c.execute("GRANT USAGE ON SCHEMA world TO PUBLIC") c.execute("ALTER DEFAULT PRIVILEGES IN SCHEMA world GRANT SELECT ON TABLES TO PUBLIC") c.execute("ALTER DEFAULT PRIVILEGES IN SCHEMA world GRANT ALL ON TABLES TO ftpmaster") c.execute("ALTER DEFAULT PRIVILEGES IN SCHEMA world GRANT SELECT ON SEQUENCES TO PUBLIC") diff --git a/dak/process_upload.py b/dak/process_upload.py index 93d30f85..f0705667 100755 --- a/dak/process_upload.py +++ b/dak/process_upload.py @@ -245,6 +245,7 @@ def subst_for_upload(upload): else: addresses = utils.mail_addresses_for_upload(maintainer_field, maintainer_field, changes.primary_fingerprint) + # debian-{devel-,}-changes@lists.debian.org toggles writes access based on this header bcc = 'X-DAK: dak process-upload' if 'Dinstall::Bcc' in cnf: bcc = '{0}\nBcc: {1}'.format(bcc, cnf['Dinstall::Bcc']) @@ -357,7 +358,7 @@ def accept_to_new(directory, upload): Logger.log(['ACCEPT-TO-NEW', upload.changes.filename]) upload.install_to_new() - # TODO: tag bugs pending, send announcement + # TODO: tag bugs pending subst = subst_for_upload(upload) message = utils.TemplateSubst(subst, os.path.join(cnf['Dir::Templates'], 'process-unchecked.new')) @@ -402,7 +403,6 @@ def real_reject(directory, upload, reason=None, notify=True): fh.write(reason) fh.close() - # TODO: fix if notify: subst = subst_for_upload(upload) subst['__REJECTOR_ADDRESS__'] = cnf['Dinstall::MyEmailAddress'] @@ -498,7 +498,6 @@ def action(directory, upload): elif answer == 'S': processed = False - #raise Exception("FAIL") if not Options['No-Action']: upload.commit() @@ -519,19 +518,6 @@ def process_it(directory, changes, keyrings, session): print "\n{0}\n".format(changes.filename) Logger.log(["Processing changes file", changes.filename]) - cnf = Config() - - # Some defaults in case we can't fully process the .changes file - #u.pkg.changes["maintainer2047"] = cnf["Dinstall::MyEmailAddress"] - #u.pkg.changes["changedby2047"] = cnf["Dinstall::MyEmailAddress"] - - # debian-{devel-,}-changes@lists.debian.org toggles writes access based on this header - bcc = "X-DAK: dak process-upload" - #if cnf.has_key("Dinstall::Bcc"): - # u.Subst["__BCC__"] = bcc + "\nBcc: %s" % (cnf["Dinstall::Bcc"]) - #else: - # u.Subst["__BCC__"] = bcc - with daklib.archive.ArchiveUpload(directory, changes, keyrings) as upload: processed = action(directory, upload) if processed and not Options['No-Action']: diff --git a/daklib/archive.py b/daklib/archive.py index 54f925a3..2badae72 100644 --- a/daklib/archive.py +++ b/daklib/archive.py @@ -49,12 +49,18 @@ class ArchiveTransaction(object): self.fs = FilesystemTransaction() self.session = DBConn().session() - def get_file(self, hashed_file, source_name): + def get_file(self, hashed_file, source_name, check_hashes=True): """Look for file C{hashed_file} in database @type hashed_file: L{daklib.upload.HashedFile} @param hashed_file: file to look for in the database + @type source_name: str + @param source_name: source package name + + @type check_hashes: bool + @param check_hashes: check size and hashes match + @raise KeyError: file was not found in the database @raise HashMismatchException: hash mismatch @@ -64,7 +70,10 @@ class ArchiveTransaction(object): poolname = os.path.join(utils.poolify(source_name), hashed_file.filename) try: poolfile = self.session.query(PoolFile).filter_by(filename=poolname).one() - if poolfile.filesize != hashed_file.size or poolfile.md5sum != hashed_file.md5sum or poolfile.sha1sum != hashed_file.sha1sum or poolfile.sha256sum != hashed_file.sha256sum: + if check_hashes and (poolfile.filesize != hashed_file.size + or poolfile.md5sum != hashed_file.md5sum + or poolfile.sha1sum != hashed_file.sha1sum + or poolfile.sha256sum != hashed_file.sha256sum): raise HashMismatchException('{0}: Does not match file already existing in the pool.'.format(hashed_file.filename)) return poolfile except NoResultFound: @@ -635,7 +644,7 @@ class ArchiveUpload(object): dst = os.path.join(self.directory, f.filename) if not os.path.exists(dst): try: - db_file = self.transaction.get_file(f, source.dsc['Source']) + db_file = self.transaction.get_file(f, source.dsc['Source'], check_hashes=False) db_archive_file = session.query(ArchiveFile).filter_by(file=db_file).first() fs.copy(db_archive_file.path, dst, symlink=True) except KeyError: diff --git a/daklib/utils.py b/daklib/utils.py index 31c22cbb..be3c6516 100644 --- a/daklib/utils.py +++ b/daklib/utils.py @@ -1396,7 +1396,14 @@ def gpg_get_key_addresses(fingerprint): if result == 0: for l in output.split('\n'): m = re_gpg_uid.match(l) - if m: + if not m: + continue + address = m.group(1) + if address.endswith('@debian.org'): + # prefer @debian.org addresses + # TODO: maybe not hardcode the domain + addresses.insert(0, address) + else: addresses.append(m.group(1)) key_uid_email_cache[fingerprint] = addresses return addresses