def test_private_source_dispatch(self): archive = self.factory.makeArchive(private=True) slave = OkSlave() builder = self.factory.makeBuilder() builder.setCleanStatus(BuilderCleanStatus.CLEAN) vitals = extract_vitals_from_db(builder) build = self.factory.makeBinaryPackageBuild(builder=builder, archive=archive) sprf = build.source_package_release.addFile( self.factory.makeLibraryFileAlias(db_only=True), filetype=SourcePackageFileType.ORIG_TARBALL) sprf_url = ( 'http://private-ppa.launchpad.dev/%s/%s/ubuntu/pool/%s/%s' % (archive.owner.name, archive.name, poolify(build.source_package_release.sourcepackagename.name, 'main'), sprf.libraryfile.filename)) lf = self.factory.makeLibraryFileAlias() transaction.commit() build.distro_arch_series.addOrUpdateChroot(lf) bq = build.queueBuild() bq.markAsBuilding(builder) interactor = BuilderInteractor() yield interactor._startBuild( bq, vitals, builder, slave, interactor.getBuildBehaviour(bq, builder, slave), BufferLogger()) yield self.assertExpectedInteraction( slave.call_log, builder, build, lf, archive, ArchivePurpose.PPA, extra_uploads=[(sprf_url, 'buildd', 'sekrit')], filemap_names=[sprf.libraryfile.filename])
def testPoolificationOkay(self): """poolify should poolify properly""" cases = ( ("foo", "main", "main/f/foo"), ("foo", "universe", "universe/f/foo"), ("libfoo", "main", "main/libf/libfoo"), ) for case in cases: self.assertEqual(case[2], poolify(case[0], case[1]))
def _getPackageReleaseURLFromPublishingRecord(self, publishing_record): """Return the URL on this mirror from where the BinaryPackageRelease. Given a BinaryPackagePublishingHistory, return the URL on this mirror from where the BinaryPackageRelease file can be downloaded. """ bpr = publishing_record.binarypackagerelease base_url = self.distribution_mirror.base_url path = poolify(bpr.sourcepackagename, self.component.name) file = BinaryPackageFile.selectOneBy( binarypackagerelease=bpr, filetype=BinaryPackageFileType.DEB) full_path = 'pool/%s/%s' % (path, file.libraryfile.filename) return urlappend(base_url, full_path)
def _getPackageReleaseURLFromPublishingRecord(self, publishing_record): """Return the URL on this mirror from where the BinaryPackageRelease. Given a BinaryPackagePublishingHistory, return the URL on this mirror from where the BinaryPackageRelease file can be downloaded. """ bpr = publishing_record.binarypackagerelease base_url = self.distribution_mirror.base_url path = poolify(bpr.sourcepackagename, self.component.name) file = BinaryPackageFile.selectOneBy( binarypackagerelease=bpr, filetype=BinaryPackageFileType.DEB) full_path = 'pool/%s/%s' % (path, file.libraryfile.filename) return urlappend(base_url, full_path)
def get_dsc_path(name, version, component, archive_root): pool_root = os.path.join(archive_root, "pool") version = epoch_re.sub("", version) filename = "%s_%s.dsc" % (name, version) # We do a first attempt using the obvious directory name, composed # with the component. However, this may fail if a binary is being # published in another component. pool_dir = poolify(name, component) fullpath = os.path.join(pool_root, pool_dir, filename) if os.path.exists(fullpath): return filename, fullpath, component # Do a second pass, scrubbing through all components in the pool. for alt_component_entry in scandir.scandir(pool_root): if not alt_component_entry.is_dir(): continue pool_dir = poolify(name, alt_component_entry.name) fullpath = os.path.join(pool_root, pool_dir, filename) if os.path.exists(fullpath): return filename, fullpath, alt_component_entry.name # Couldn't find the file anywhere -- too bad. raise PoolFileNotFound("File %s not in archive" % filename)
def get_dsc_path(name, version, component, archive_root): pool_root = os.path.join(archive_root, "pool") version = epoch_re.sub("", version) filename = "%s_%s.dsc" % (name, version) # We do a first attempt using the obvious directory name, composed # with the component. However, this may fail if a binary is being # published in another component. pool_dir = poolify(name, component) fullpath = os.path.join(pool_root, pool_dir, filename) if os.path.exists(fullpath): return filename, fullpath, component # Do a second pass, scrubbing through all components in the pool. for alt_component in os.listdir(pool_root): if not os.path.isdir(os.path.join(pool_root, alt_component)): continue pool_dir = poolify(name, alt_component) fullpath = os.path.join(pool_root, pool_dir, filename) if os.path.exists(fullpath): return filename, fullpath, alt_component # Couldn't find the file anywhere -- too bad. raise PoolFileNotFound("File %s not in archive" % filename)
def _getSourcePackageDataFromDSC(self, sp_name, sp_version, sp_component, sp_section): try: dsc_name, dsc_path, sp_component = get_dsc_path(sp_name, sp_version, sp_component, self.archive_root) except PoolFileNotFound: # Aah well, no source package in archive either. return None log.debug("Found a source package for %s (%s) in %s" % (sp_name, sp_version, sp_component)) dsc_contents = parse_tagfile(dsc_path) dsc_contents = dict([ (name.lower(), value) for (name, value) in dsc_contents.iteritems()]) # Since the dsc doesn't know, we add in the directory, package # component and section dsc_contents['directory'] = os.path.join("pool", poolify(sp_name, sp_component)) dsc_contents['package'] = sp_name dsc_contents['component'] = sp_component dsc_contents['section'] = sp_section # the dsc doesn't list itself so add it ourselves if 'files' not in dsc_contents: log.error('DSC for %s didn\'t contain a files entry: %r' % (dsc_name, dsc_contents)) return None if not dsc_contents['files'].endswith("\n"): dsc_contents['files'] += "\n" # XXX kiko 2005-10-21: Why do we hack the md5sum and size of the DSC? # Should probably calculate it properly. dsc_contents['files'] += "xxx 000 %s" % dsc_name # SourcePackageData requires capitals capitalized_dsc = {} for k, v in dsc_contents.items(): capitalized_dsc[k.capitalize()] = v return SourcePackageData(**capitalized_dsc)
def _getSourcePackageDataFromDSC(self, sp_name, sp_version, sp_component, sp_section): try: dsc_name, dsc_path, sp_component = get_dsc_path( sp_name, sp_version, sp_component, self.archive_root) except PoolFileNotFound: # Aah well, no source package in archive either. return None log.debug("Found a source package for %s (%s) in %s" % (sp_name, sp_version, sp_component)) dsc_contents = parse_tagfile(dsc_path) dsc_contents = dict([(name.lower(), value) for (name, value) in dsc_contents.iteritems()]) # Since the dsc doesn't know, we add in the directory, package # component and section dsc_contents['directory'] = os.path.join( "pool", poolify(sp_name, sp_component)) dsc_contents['package'] = sp_name dsc_contents['component'] = sp_component dsc_contents['section'] = sp_section # the dsc doesn't list itself so add it ourselves if 'files' not in dsc_contents: log.error('DSC for %s didn\'t contain a files entry: %r' % (dsc_name, dsc_contents)) return None if not dsc_contents['files'].endswith("\n"): dsc_contents['files'] += "\n" # XXX kiko 2005-10-21: Why do we hack the md5sum and size of the DSC? # Should probably calculate it properly. dsc_contents['files'] += "xxx 000 %s" % dsc_name # SourcePackageData requires capitals capitalized_dsc = {} for k, v in dsc_contents.items(): capitalized_dsc[k.capitalize()] = v return SourcePackageData(**capitalized_dsc)