def importSpec(pspec, local_uri=None): # Add or update developer maintained_by = createUser(pspec.source.packager.email, pspec.source.packager.name) review_flag = False # Create the source package information part_of = pspec.source.partOf if not local_uri: source_uri = pspec.source.sourceURI else: index = local_uri.find("review") source_uri = local_uri[index:] review_flag = True print ' Source URI: %s' % source_uri home_page = pspec.source.homepage print ' Homepage: %s' % home_page source_info = SourcePackageDetail.objects.create(part_of=part_of, source_uri=source_uri, home_page=home_page) for is_a in pspec.source.isA: print ' IsA: %s' % is_a source_info.isa_set.create(name=is_a) for license in pspec.source.license: print ' License: %s' % license source_info.license_set.create(name=license) summary = pspec.source.summary for language in summary.keys(): print ' Summary Language: %s' % language print ' Summary Text: %s' % summary[language] source_info.summary_set.create(language=language, text=summary[language]) description = pspec.source.description for language in description.keys(): print ' Description Language: %s' % language print ' Description Text: %s' % description[language] source_info.description_set.create(language=language, text=description[language]) # Add source or update maintainer try: source = Source.objects.get(name=pspec.source.name, distribution=distribution) source.maintained_by = maintained_by source.info = source_info except Source.DoesNotExist: source = Source(name=pspec.source.name, distribution=distribution, maintained_by=maintained_by, info=source_info) print ' Source: %s' % source.name # Save the traverse time of the review path for the next check if review_flag: review = ReviewInfo.objects.create(check_time=traverse_time,status=True) else: review = ReviewInfo.objects.create(status=False) source.review = review source.save() # Update build dependencies for dep in BuildDependency.objects.filter(source=source): dep.delete() for dep in pspec.source.buildDependencies: dependency = BuildDependency(source=source, name=dep.package, version=toString(dep.version), version_to=toString(dep.versionTo), version_from=toString(dep.versionFrom), release=toInt(dep.release), release_to=toInt(dep.releaseTo), release_from=toInt(dep.releaseFrom)) dependency.save() # Add or update package info for pack in pspec.packages: try: package = Package.objects.get(name=pack.name, source=source) package.save() except Package.DoesNotExist: package = Package(name=pack.name, source=source) package.save() print ' New package: %s' % package.name for rep in pack.replaces: replaces = Replaces(name=str(rep), package=package) replaces.save() for bin in Binary.objects.filter(package__name=str(rep), package__source__distribution=distribution): bin.resolution = 'removed' bin.save() print ' Marking %s-%s as removed' % (rep, bin.no) # Update runtime dependencies for dep in RuntimeDependency.objects.filter(package=package): dep.delete() for dep in pack.runtimeDependencies(): try: if isinstance(dep, pisi.specfile.AnyDependency): # Any dependencies for any_dep in dep.dependencies: dependency = RuntimeDependency(package=package, name=any_dep.package, version=toString(any_dep.version), version_to=toString(any_dep.versionTo), version_from=toString(any_dep.versionFrom), release=toInt(any_dep.release), release_to=toInt(any_dep.releaseTo), release_from=toInt(any_dep.releaseFrom)) dependency.save() else: dependency = RuntimeDependency(package=package, name=dep.package, version=toString(dep.version), version_to=toString(dep.versionTo), version_from=toString(dep.versionFrom), release=toInt(dep.release), release_to=toInt(dep.releaseTo), release_from=toInt(dep.releaseFrom)) dependency.save() except: dependency = RuntimeDependency(package=package, name=dep.package, version=toString(dep.version), version_to=toString(dep.versionTo), version_from=toString(dep.versionFrom), release=toInt(dep.release), release_to=toInt(dep.releaseTo), release_from=toInt(dep.releaseFrom)) dependency.save() up_count = 0 for up in pspec.history: updated_by = createUser(up.email, up.name) try: update = Update.objects.get(no=up.release, source=source) update.updated_on = up.date update.updated_by = updated_by #update.version_no = up.version_no update.comment = up.comment update.save() except Update.DoesNotExist: update = Update(no=up.release, source=source, version_no=up.version, updated_by=updated_by, updated_on=up.date, comment=up.comment) update.save() up_count += 1 if up_count > 0: print ' New Updates: %s' % up_count
def importSpec(_spec): print ' Importing %s' % _spec pspec = pisi.specfile.SpecFile(_spec) # Add or update developer maintained_by = createUser(pspec.source.packager.email, pspec.source.packager.name) # Add source or update maintainer try: source = Source.objects.get(name=pspec.source.name, distribution=distribution) source.maintained_by = maintained_by source.save() except Source.DoesNotExist: source = Source(name=pspec.source.name, distribution=distribution, maintained_by=maintained_by) source.save() print ' New source: %s' % source.name # Update build dependencies for dep in BuildDependency.objects.filter(source=source): dep.delete() for dep in pspec.source.buildDependencies: dependency = BuildDependency(source=source, name=dep.package, version=toString(dep.version), version_to=toString(dep.versionTo), version_from=toString(dep.versionFrom), release=toInt(dep.release), release_to=toInt(dep.releaseTo), release_from=toInt(dep.releaseFrom)) dependency.save() # Add or update package info for pack in pspec.packages: try: package = Package.objects.get(name=pack.name, source=source) package.save() except Package.DoesNotExist: package = Package(name=pack.name, source=source) package.save() print ' New package: %s' % package.name """ for rep in pack.replaces: count = 0 for bin in Binary.objects.filter(package__name=str(rep), package__source__distribution=distribution): bin.resolution = 'removed' bin.save() count += 1 print ' Replaces package: %s (%d binaries)' % (rep, count) """ # Update runtime dependencies for dep in RuntimeDependency.objects.filter(package=package): dep.delete() for dep in pack.runtimeDependencies(): dependency = RuntimeDependency(package=package, name=dep.package, version=toString(dep.version), version_to=toString(dep.versionTo), version_from=toString(dep.versionFrom), release=toInt(dep.release), release_to=toInt(dep.releaseTo), release_from=toInt(dep.releaseFrom)) dependency.save() up_count = 0 for up in pspec.history: updated_by = createUser(up.email, up.name) try: update = Update.objects.get(no=up.release, source=source) update.updated_on = up.date update.updated_by = updated_by #update.version_no = up.version_no update.comment = up.comment update.save() except Update.DoesNotExist: update = Update(no=up.release, source=source, version_no=up.version, updated_by=updated_by, updated_on=up.date, comment=up.comment) update.save() up_count += 1 if up_count > 0: print ' New Updates: %s' % up_count
def importSpec(_spec): print ' Importing %s' % _spec pspec = pisi.specfile.SpecFile(_spec) # Add or update developer maintained_by = createUser(pspec.source.packager.email, pspec.source.packager.name) # Add source or update maintainer try: source = Source.objects.get(name=pspec.source.name, distribution=distribution) source.maintained_by = maintained_by source.save() except Source.DoesNotExist: source = Source(name=pspec.source.name, distribution=distribution, maintained_by=maintained_by) source.save() print ' New source: %s' % source.name # Update build dependencies for dep in BuildDependency.objects.filter(source=source): dep.delete() for dep in pspec.source.buildDependencies: dependency = BuildDependency(source=source, name=dep.package, version=toString(dep.version), version_to=toString(dep.versionTo), version_from=toString( dep.versionFrom), release=toInt(dep.release), release_to=toInt(dep.releaseTo), release_from=toInt(dep.releaseFrom)) dependency.save() # Add or update package info for pack in pspec.packages: try: package = Package.objects.get(name=pack.name, source=source) package.save() except Package.DoesNotExist: package = Package(name=pack.name, source=source) package.save() print ' New package: %s' % package.name """ for rep in pack.replaces: count = 0 for bin in Binary.objects.filter(package__name=str(rep), package__source__distribution=distribution): bin.resolution = 'removed' bin.save() count += 1 print ' Replaces package: %s (%d binaries)' % (rep, count) """ # Update runtime dependencies for dep in RuntimeDependency.objects.filter(package=package): dep.delete() for dep in pack.runtimeDependencies(): dependency = RuntimeDependency( package=package, name=dep.package, version=toString(dep.version), version_to=toString(dep.versionTo), version_from=toString(dep.versionFrom), release=toInt(dep.release), release_to=toInt(dep.releaseTo), release_from=toInt(dep.releaseFrom)) dependency.save() up_count = 0 for up in pspec.history: updated_by = createUser(up.email, up.name) try: update = Update.objects.get(no=up.release, source=source) update.updated_on = up.date update.updated_by = updated_by #update.version_no = up.version_no update.comment = up.comment update.save() except Update.DoesNotExist: update = Update(no=up.release, source=source, version_no=up.version, updated_by=updated_by, updated_on=up.date, comment=up.comment) update.save() up_count += 1 if up_count > 0: print ' New Updates: %s' % up_count