MCPcopy Create free account
hub / github.com/apache/solr / checkJARMetaData

Function checkJARMetaData

dev-tools/scripts/smokeTestRelease.py:135–195  ·  view source on GitHub ↗
(desc, jarFile, gitRevision, version)

Source from the content-addressed store, hash-verified

133 return content
134
135
136def noJavaPackageClasses(desc, file):
137 with zipfile.ZipFile(file) as z2:
138 for name2 in z2.namelist():
139 if name2.endswith('.class') and (name2.startswith('java/') or name2.startswith('javax/')):
140 raise RuntimeError('%s contains java or javax class "%s"' % (desc, name2))
141
142
143def decodeUTF8(bytes):
144 return codecs.getdecoder('UTF-8')(bytes)[0]
145
146
147MANIFEST_FILE_NAME = 'META-INF/MANIFEST.MF'
148NOTICE_FILE_NAME = 'META-INF/NOTICE.txt'
149LICENSE_FILE_NAME = 'META-INF/LICENSE.txt'
150
151
152def checkJARMetaData(desc, jarFile, gitRevision, version):
153
154 with zipfile.ZipFile(jarFile, 'r') as z:
155 for name in (MANIFEST_FILE_NAME, NOTICE_FILE_NAME, LICENSE_FILE_NAME):
156 try:
157 # The Python docs state a KeyError is raised ... so this None
158 # check is just defensive:
159 if z.getinfo(name) is None:
160 raise RuntimeError('%s is missing %s' % (desc, name))
161 except KeyError:
162 raise RuntimeError('%s is missing %s' % (desc, name))
163
164 s = decodeUTF8(z.read(MANIFEST_FILE_NAME))
165
166 compileJDK = BASE_JAVA_VERSION
167 if 'solrj' in desc or 'api' in desc:
168 compileJDK = SOLRJ_JAVA_VERSION
169 for verify in (
170 'Specification-Vendor: The Apache Software Foundation',
171 'Implementation-Vendor: The Apache Software Foundation',
172 'Specification-Title: Apache Solr Search Server:',
173 'Implementation-Title: org.apache.solr',
174 'X-Compile-Source-JDK: %s' % compileJDK,
175 'X-Compile-Target-JDK: %s' % compileJDK,
176 'Specification-Version: %s' % version.replace('-SNAPSHOT', ''),
177 'X-Build-JDK: %s' % BASE_JAVA_VERSION,
178 'Extension-Name: org.apache.solr'):
179 if type(verify) is not tuple:
180 verify = (verify,)
181 for x in verify:
182 if s.find(x) != -1:
183 break
184 else:
185 if len(verify) == 1:
186 raise RuntimeError('%s is missing "%s" inside its META-INF/MANIFEST.MF' % (desc, verify[0]))
187 else:
188 raise RuntimeError('%s is missing one of "%s" inside its META-INF/MANIFEST.MF' % (desc, verify))
189
190 if gitRevision != 'skip':
191 # Make sure this matches the version and git revision we think we are releasing:
192 match = re.search("Implementation-Version: (.+\r\n .+)", s, re.MULTILINE)

Callers 1

checkAllJARsFunction · 0.85

Calls 5

decodeUTF8Function · 0.85
readMethod · 0.65
replaceMethod · 0.45
findMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…