def _process_single_deb(self, distro, component, file): if os.path.isfile(file) and file in self.uploaded_files: # if file is still exists and wasn't picked by some _processChangesFile(), # assume that it was meant to be uploaded as signle package with self.uploaded_files_lock: self.uploaded_files.remove(file) self.log.debug("Uploading %s to %s/%s", file, distro, component) try: common.with_retries( repo_manage.upload_package, distro, component, [file], changes=None, forceUpdateMeta=True ) except Exception as e: self.log.error("Error while uploading DEB %s: %s", file, e) os.unlink(file) elif file in self.uploaded_files: self.log.debug("Hm, strange, I was supposed to upload %s, but it's missing now", file)
def _processChangesFile(self, event): self.log.info("Processing .changes file %s", event.pathname) incoming_files = [event.pathname] current_hash = None changes = ChangeFile.ChangeFile() changes.load_from_file(event.pathname) changes.filename = event.pathname if self.gpg_check: try: signer = self._gpgCheck(changes.filename) except errors.GPGMEError as e: self.log.error("Cannot check PGP signature: %s", e) map(os.unlink, incoming_files) return except Exception as e: self.log.error("%s verification failed: %s", event.pathname, e) map(os.unlink, incoming_files) return else: signer = "<not checked>" self.log.info("%s: signed by %s: OK, looking for incoming files", event.pathname, signer) # .changes file contatins all incoming files and its checksums, so # check if all files are available or wait for them for f in changes.getFiles(): filename = os.path.join(event.path, f[2]) self.log.info("Looking for %s from .changes", filename) while True: # uploaded_files stores all files in incoming directory uploaded so far if filename in self.uploaded_files: # eeeh, we're under GIL, yea? do we really need to take a lock here? with self.uploaded_files_lock: self.log.debug("Taking %s for processing", filename) self.uploaded_files.remove(filename) incoming_files.append(filename) break else: self.log.debug("Could not find %s, waiting...", filename) r = self.uploaded_event.wait(self.incoming_wait_timeout) if not r: # we don't get all files from .changes in time, clean up and exit # TODO: add to rejected map(os.unlink, incoming_files) return # TODO: add reject dir and metadb collection and store all rejected files there try: changes.verify(event.path) except ChangeFile.ChangeFileException as e: self.log.error("Checksum verification failed: %s", e) else: # TODO set default component / add per-component upload dirs # for now all new packages are going to component 'unstable' self.log.info( "%s-%s: sign: OK, checksums: OK, uploading to distro '%s', component 'unstable'", changes["source"], changes["version"], self.distro, ) try: common.with_retries( repo_manage.upload_package, self.distro, "unstable", incoming_files, changes=changes, forceUpdateMeta=True, ) self.log.warn("OK") except Exception as e: self.log.error("Error while uploading file: %s", e) # in any case, clean up all incoming files map(os.unlink, incoming_files)