blob: 05819f1971a41b6916171eb571fe6bd2ec159ab2 [file] [log] [blame]
Ray Milkeyb46b11b2016-11-29 10:35:51 -08001#! /usr/bin/env python
2
3# Spot checks some published artifacts to be sure that they uploaded correctly
4# to the release repository
5
6import requests
7import sys
8import sha
9import os
10
11
12from requests.auth import HTTPBasicAuth
13
14if len(sys.argv) != 4:
15 print "usage: check-uploaded-maven-artifact version buildRoot repoRoot"
16 sys.exit(1)
17
18version = sys.argv[1]
19buildRoot = sys.argv[2]
20repoRoot = sys.argv[3]
21
22def checkArtifact(localPath, remoteUrl):
23
24 repoResponse = requests.head(remoteUrl)
25
26 if repoResponse.status_code != 200:
Ray Milkeyf3aba5f2017-01-09 16:47:14 -080027 print 'Cannot find jar file artifact at ' + remoteUrl
Ray Milkeyb46b11b2016-11-29 10:35:51 -080028 print repoResponse.text
29 sys.exit(1)
30
31 remoteSize = int(repoResponse.headers['content-length'])
32 etag = repoResponse.headers['etag']
33
34 localSize = os.path.getsize(localPath)
35
36 localArtifact = open(localPath)
37 localArtifactSha = sha.new(localArtifact.read())
38 expectedSha1 = localArtifactSha.hexdigest()
39
40 if localSize != remoteSize:
Ray Milkey3ac00792016-12-01 14:28:15 -080041 print 'Size for ' + remoteUrl + ' is wrong local ' + str(localSize) + ' but found remote ' + str(remoteSize)
Ray Milkeyb46b11b2016-11-29 10:35:51 -080042 sys.exit(1)
43
44 sha1 = ''
45 if '{SHA1{' in etag:
46 # this is a sonatype style artifact
47 sha1 = etag[7:len(etag)-3]
48 else:
49 sha1 = repoResponse.headers['x-checksum-sha1']
50
51 if sha1 != expectedSha1:
Ray Milkeyf4eefc42017-08-29 13:57:13 -070052 print 'SHA1 hash is wrong for ' + remoteUrl + ' expected ' + \
53 expectedSha1 + ' but found ' + sha1
Ray Milkeyb46b11b2016-11-29 10:35:51 -080054 sys.exit(1)
55
56def checkArtifactsForComponent(version, name, component, buildRoot, repoRoot):
57 localArtifactRootPath = buildRoot + '/buck-out/gen/' + component
58 localArtifactJarPath = localArtifactRootPath + '/lib__' + name + '__output/' + name + '.jar'
59 localArtifactJavadocPath = localArtifactRootPath + '/' + name + '#javadoc,maven-sources.jar'
60 localArtifactSourcesPath = localArtifactRootPath + '/' + name + '#maven,src-sources.jar'
61
62 remoteArtifactBaseUrl = repoRoot + '/org/onosproject/' + name + '/' + version + '/' + name + '-' + version
63 remoteArtifactJarUrl = remoteArtifactBaseUrl + '.jar'
64 remoteArtifactJavadocUrl = remoteArtifactBaseUrl + '-javadoc.jar'
65 remoteArtifactSourcesUrl = remoteArtifactBaseUrl + '-sources.jar'
66
67 checkArtifact(localArtifactJarPath, remoteArtifactJarUrl)
68 checkArtifact(localArtifactJavadocPath, remoteArtifactJavadocUrl)
69 checkArtifact(localArtifactSourcesPath, remoteArtifactSourcesUrl)
70
71checkArtifactsForComponent(version, 'onos-api', 'core/api', buildRoot, repoRoot)
72checkArtifactsForComponent(version, 'onos-protocols-openflow-api', 'protocols/openflow/api', buildRoot, repoRoot)
Ray Milkeyf3aba5f2017-01-09 16:47:14 -080073checkArtifactsForComponent(version, 'onos-core-serializers', 'core/store/serializers', buildRoot, repoRoot)
74checkArtifactsForComponent(version, 'onos-cli', 'cli', buildRoot, repoRoot)
75checkArtifactsForComponent(version, 'onos-apps-optical-model', 'apps/optical-model', buildRoot, repoRoot)
76
77
78
Ray Milkeyb46b11b2016-11-29 10:35:51 -080079