def verifyVersion(self): """Check if control version is valid matches the filename version. Binary version doesn't need to match the changesfile version, because the changesfile version refers to the SOURCE version. """ if not re_valid_version.match(self.control_version): yield UploadError("%s: invalid version number %r." % (self.filename, self.control_version)) binary_match = re_isadeb.match(self.filename) filename_version = binary_match.group(2) control_version_chopped = re_no_epoch.sub('', self.control_version) if filename_version != control_version_chopped: yield UploadError("%s: should be %s according to control file." % (filename_version, control_version_chopped))
def verifyVersion(self): """Check if control version is valid matches the filename version. Binary version doesn't need to match the changesfile version, because the changesfile version refers to the SOURCE version. """ if not re_valid_version.match(self.control_version): yield UploadError("%s: invalid version number %r." % (self.filename, self.control_version)) binary_match = re_isadeb.match(self.filename) filename_version = binary_match.group(2) control_version_chopped = re_no_epoch.sub('', self.control_version) if filename_version != control_version_chopped: yield UploadError("%s: should be %s according to control file." % (filename_version, control_version_chopped))
def verify(self): """Verify the uploaded .dsc file. This method is an error generator, i.e, it returns an iterator over all exceptions that are generated while processing DSC file checks. """ for error in SourceUploadFile.verify(self): yield error # Check size and checksum of the DSC file itself try: self.checkSizeAndCheckSum() except UploadError as error: yield error try: raw_files = parse_and_merge_file_lists(self._dict, changes=False) except UploadError as e: yield e return files = [] for attr in raw_files: filename, hashes, size = attr if not re_issource.match(filename): # DSC files only really hold on references to source # files; they are essentially a description of a source # package. Anything else is crack. yield UploadError("%s: File %s does not look sourceful." % (self.filename, filename)) continue filepath = os.path.join(self.dirname, filename) try: file_instance = DSCUploadedFile(filepath, hashes, size, self.policy, self.logger) except UploadError as error: yield error else: files.append(file_instance) self.files = files if not re_valid_pkg_name.match(self.source): yield UploadError("%s: invalid source name %s" % (self.filename, self.source)) if not re_valid_version.match(self.dsc_version): yield UploadError("%s: invalid version %s" % (self.filename, self.dsc_version)) if not self.policy.distroseries.isSourcePackageFormatPermitted( self.format): yield UploadError( "%s: format '%s' is not permitted in %s." % (self.filename, self.format, self.policy.distroseries.name)) # Validate the build dependencies for field_name in ['Build-Depends', 'Build-Depends-Indep']: field = self._dict.get(field_name, None) if field is not None: if field.startswith("ARRAY"): yield UploadError( "%s: invalid %s field produced by a broken version " "of dpkg-dev (1.10.11)" % (self.filename, field_name)) try: with warnings.catch_warnings(): warnings.simplefilter("error") PkgRelation.parse_relations(field) except Warning as error: yield UploadError( "%s: invalid %s field; cannot be parsed by deb822: %s" % (self.filename, field_name, error)) # Verify if version declared in changesfile is the same than that # in DSC (including epochs). if self.dsc_version != self.version: yield UploadError( "%s: version ('%s') in .dsc does not match version " "('%s') in .changes." % (self.filename, self.dsc_version, self.version)) for error in self.checkFiles(): yield error
def verify(self): """Verify the uploaded .dsc file. This method is an error generator, i.e, it returns an iterator over all exceptions that are generated while processing DSC file checks. """ for error in SourceUploadFile.verify(self): yield error # Check size and checksum of the DSC file itself try: self.checkSizeAndCheckSum() except UploadError as error: yield error try: raw_files = parse_and_merge_file_lists(self._dict, changes=False) except UploadError as e: yield e return files = [] for attr in raw_files: filename, hashes, size = attr if not re_issource.match(filename): # DSC files only really hold on references to source # files; they are essentially a description of a source # package. Anything else is crack. yield UploadError("%s: File %s does not look sourceful." % ( self.filename, filename)) continue filepath = os.path.join(self.dirname, filename) try: file_instance = DSCUploadedFile( filepath, hashes, size, self.policy, self.logger) except UploadError as error: yield error else: files.append(file_instance) self.files = files if not re_valid_pkg_name.match(self.source): yield UploadError( "%s: invalid source name %s" % (self.filename, self.source)) if not re_valid_version.match(self.dsc_version): yield UploadError( "%s: invalid version %s" % (self.filename, self.dsc_version)) if not self.policy.distroseries.isSourcePackageFormatPermitted( self.format): yield UploadError( "%s: format '%s' is not permitted in %s." % (self.filename, self.format, self.policy.distroseries.name)) # Validate the build dependencies for field_name in ['Build-Depends', 'Build-Depends-Indep']: field = self._dict.get(field_name, None) if field is not None: if field.startswith("ARRAY"): yield UploadError( "%s: invalid %s field produced by a broken version " "of dpkg-dev (1.10.11)" % (self.filename, field_name)) try: apt_pkg.parse_src_depends(field) except (SystemExit, KeyboardInterrupt): raise except Exception as error: # Swallow everything apt_pkg throws at us because # it is not desperately pythonic and can raise odd # or confusing exceptions at times and is out of # our control. yield UploadError( "%s: invalid %s field; cannot be parsed by apt: %s" % (self.filename, field_name, error)) # Verify if version declared in changesfile is the same than that # in DSC (including epochs). if self.dsc_version != self.version: yield UploadError( "%s: version ('%s') in .dsc does not match version " "('%s') in .changes." % (self.filename, self.dsc_version, self.version)) for error in self.checkFiles(): yield error