SOLR-4766: detect when maven war/jar has different contents (file name + size) from the corresponding binary release

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1476154 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2013-04-26 12:03:13 +00:00
parent a03e38d5d0
commit 08a6f78510
1 changed files with 23 additions and 4 deletions

View File

@ -14,6 +14,7 @@
# limitations under the License. # limitations under the License.
import os import os
import zipfile
import codecs import codecs
import tarfile import tarfile
import zipfile import zipfile
@ -973,7 +974,7 @@ def getDistributionsForMavenChecks(tmpDir, version, baseURL):
def checkJavadocAndSourceArtifacts(nonMavenizedDeps, artifacts, version): def checkJavadocAndSourceArtifacts(nonMavenizedDeps, artifacts, version):
for project in ('lucene', 'solr'): for project in ('lucene', 'solr'):
for artifact in artifacts[project]: for artifact in artifacts[project]:
if artifact.endswith(version + '.jar') and artifact not in list(nonMavenizedDeps.keys()): if artifact.endswith(version + '.jar') and artifact not in nonMavenizedDeps:
javadocJar = artifact[:-4] + '-javadoc.jar' javadocJar = artifact[:-4] + '-javadoc.jar'
if javadocJar not in artifacts[project]: if javadocJar not in artifacts[project]:
raise RuntimeError('missing: %s' % javadocJar) raise RuntimeError('missing: %s' % javadocJar)
@ -986,7 +987,7 @@ def checkIdenticalNonMavenizedDeps(distributionFiles, nonMavenizedDeps):
distFilenames = dict() distFilenames = dict()
for file in distributionFiles[project]: for file in distributionFiles[project]:
distFilenames[os.path.basename(file)] = file distFilenames[os.path.basename(file)] = file
for dep in list(nonMavenizedDeps.keys()): for dep in nonMavenizedDeps.keys():
if ('/%s/' % project) in dep: if ('/%s/' % project) in dep:
depOrigFilename = os.path.basename(nonMavenizedDeps[dep]) depOrigFilename = os.path.basename(nonMavenizedDeps[dep])
if not depOrigFilename in distFilenames: if not depOrigFilename in distFilenames:
@ -996,6 +997,15 @@ def checkIdenticalNonMavenizedDeps(distributionFiles, nonMavenizedDeps):
raise RuntimeError('Deployed non-mavenized dep %s differs from distribution dep %s' raise RuntimeError('Deployed non-mavenized dep %s differs from distribution dep %s'
% (dep, distFilenames[depOrigFilename])) % (dep, distFilenames[depOrigFilename]))
def getZipFileEntries(fileName):
entries = []
with zipfile.ZipFile(fileName) as zf:
for zi in zf.infolist():
entries.append((zi.filename, zi.file_size))
# Sort by name:
entries.sort()
return entries
def checkIdenticalMavenArtifacts(distributionFiles, nonMavenizedDeps, artifacts, version): def checkIdenticalMavenArtifacts(distributionFiles, nonMavenizedDeps, artifacts, version):
reJarWar = re.compile(r'%s\.[wj]ar$' % version) # exclude *-javadoc.jar and *-sources.jar reJarWar = re.compile(r'%s\.[wj]ar$' % version) # exclude *-javadoc.jar and *-sources.jar
for project in ('lucene', 'solr'): for project in ('lucene', 'solr'):
@ -1005,11 +1015,20 @@ def checkIdenticalMavenArtifacts(distributionFiles, nonMavenizedDeps, artifacts,
distFilenames[baseName] = file distFilenames[baseName] = file
for artifact in artifacts[project]: for artifact in artifacts[project]:
if reJarWar.search(artifact): if reJarWar.search(artifact):
if artifact not in list(nonMavenizedDeps.keys()): entries = getZipFileEntries(artifact)
if artifact not in nonMavenizedDeps:
artifactFilename = os.path.basename(artifact) artifactFilename = os.path.basename(artifact)
if artifactFilename not in list(distFilenames.keys()): if artifactFilename not in distFilenames:
raise RuntimeError('Maven artifact %s is not present in %s binary distribution' raise RuntimeError('Maven artifact %s is not present in %s binary distribution'
% (artifact, project)) % (artifact, project))
else:
binaryEntries = getZipFileEntries(distFilenames[artifactFilename])
if binaryEntries != entries:
raise RuntimeError('Maven artifact %s has different contents than binary distribution\n maven:\n%s\n binary:\n%s\n' % \
(artifactFilename,
'\n'.join(' %s [%d bytes]' % (name, size) for name, size in entries),
'\n'.join(' %s [%d bytes]' % (name, size) for name, size in binaryEntries)))
# TODO: Either fix the build to ensure that maven artifacts *are* identical, or recursively compare contents # TODO: Either fix the build to ensure that maven artifacts *are* identical, or recursively compare contents
# identical = filecmp.cmp(artifact, distFilenames[artifactFilename], shallow=False) # identical = filecmp.cmp(artifact, distFilenames[artifactFilename], shallow=False)
# if not identical: # if not identical: