~ubuntu-branches/debian/jessie/armory/jessie

« back to all changes in this revision

Viewing changes to release_scripts/Step3_Online_VerifyAndUpload.py

  • Committer: Package Import Robot
  • Author(s): Joseph Bisch
  • Date: 2014-10-07 10:22:45 UTC
  • Revision ID: package-import@ubuntu.com-20141007102245-2s3x3rhjxg689hek
Tags: upstream-0.92.3
ImportĀ upstreamĀ versionĀ 0.92.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/python
 
2
 
 
3
# This script doesn't actually do the verification stuff yet.  You should 
 
4
# manually check, after this script completes, that signed_release_unpack:
 
5
#   dpkg-sig --verify *.deb
 
6
#   gpg -v *.asc
 
7
#   cd BitcoinArmory; git tag -v v0.90-beta  (or whatever the tag is)
 
8
from sys import argv
 
9
import os
 
10
import time
 
11
import shutil
 
12
from release_utils import *
 
13
import json
 
14
from datetime import datetime
 
15
 
 
16
#####
 
17
from release_settings import getReleaseParams, getMasterPackageList
 
18
#####
 
19
 
 
20
if len(argv)<2:
 
21
   import textwrap
 
22
   print textwrap.dedent("""
 
23
      Script Arguments (* is optional)
 
24
            argv[0]   "python %s"
 
25
            argv[1]   inputDir       (from Step2)
 
26
            argv[2]*  isDryRun       (default ~ 0)
 
27
            argv[3]*  useTestParams  (default ~ 0)
 
28
      """) % argv[0]
 
29
   exit(1)
 
30
   
 
31
 
 
32
# Parse CLI args
 
33
inDir      = checkExists(argv[1])
 
34
isDryRun   = (len(argv)>2 and not argv[2]=='0')
 
35
testParams = (len(argv)>3 and not argv[3]=='0')
 
36
 
 
37
 
 
38
masterPkgList = getMasterPackageList()
 
39
RELEASE = getReleaseParams(testParams)
 
40
 
 
41
signAddress    = RELEASE['SignAddr']
 
42
announceName   = RELEASE['AnnounceFile']
 
43
bucketPrefix   = RELEASE['BucketPrefix']
 
44
htmlRelease    = bucketPrefix + RELEASE['BucketReleases']
 
45
htmlAnnounce   = bucketPrefix + RELEASE['BucketAnnounce']
 
46
s3Release      = 's3://%s' % RELEASE['BucketReleases']
 
47
s3Announce     = 's3://%s' % RELEASE['BucketAnnounce']
 
48
gpgKeyID       = RELEASE['GPGKeyID']
 
49
btcWltID       = RELEASE['BTCWltID']
 
50
 
 
51
 
 
52
#uploadlog = open('step3_log_%d.txt' % long(time.time()), 'w')
 
53
uploadlog = open('step3_log.txt', 'w')
 
54
def logprint(s):
 
55
   print s
 
56
   uploadlog.write(s + '\n')
 
57
 
 
58
srcGitRepo  = checkExists(os.path.join(inDir, 'BitcoinArmory'))
 
59
srcInstalls = checkExists(os.path.join(inDir, 'installers'))
 
60
srcAnnounce = checkExists(os.path.join(inDir, 'signedannounce'))
 
61
 
 
62
# Scan the list of files in installers dir to get latest 
 
63
instList = [fn for fn in os.listdir(srcInstalls)]
 
64
topVerInt,topVerStr,topVerType = getLatestVerFromList(instList)
 
65
 
 
66
 
 
67
def getPkgFilename(pkgName, offline=False):
 
68
   if pkgName=='SHAFILE_TXT':
 
69
      suffix = 'sha256sum.txt'
 
70
   elif pkgName=='SHAFILE_ASC':
 
71
      suffix = 'sha256sum.txt.asc'
 
72
   else:
 
73
      suffixType = 'BundleSuffix' if offline else 'FileSuffix'
 
74
      suffix = masterPkgList[pkgName][suffixType]
 
75
 
 
76
   return 'armory_%s%s_%s' % (topVerStr, topVerType, suffix)
 
77
 
 
78
 
 
79
 
 
80
#uploads.sort(key=lambda x: x[1])
 
81
   
 
82
# Now actually execute the uploads and make them public
 
83
forumTextList = []
 
84
htmlTextList  = []
 
85
rawUrlList    = []
 
86
s3cmdList     = []
 
87
 
 
88
 
 
89
# Try to make things sorted properly
 
90
osSort = ['Windows', 'MacOSX', 'Ubuntu', 'RaspberryPi'][::-1]
 
91
 
 
92
pkgPairs = []
 
93
while len(osSort)>0:
 
94
   thisOS = osSort.pop()
 
95
   for pkgName,pkgInfo in masterPkgList.iteritems():
 
96
      if thisOS == pkgInfo['OSNameDisp']:
 
97
         pkgPairs.append([pkgName,pkgInfo])
 
98
      
 
99
 
 
100
uploadsRegular = []
 
101
uploadsOffline = []
 
102
for pkgName,pkgInfo in pkgPairs:
 
103
   pkgDict = {}
 
104
   pkgDict['SrcFile']   = getPkgFilename(pkgName)
 
105
   pkgDict['SrcPath']   = os.path.join(inDir, 'installers', pkgDict['SrcFile'])
 
106
   pkgDict['OSName']    = pkgInfo['OSNameDisp']
 
107
   pkgDict['OSVar']     = pkgInfo['OSVarDisp']
 
108
   pkgDict['OSArch']    = pkgInfo['OSArchDisp']
 
109
   pkgDict['IsHash']    = False
 
110
   pkgDict['IsBundle']  = False
 
111
   pkgDict['DstUpload'] = '%s%s' % (s3Release,   pkgDict['SrcFile'])
 
112
   pkgDict['DownLink']  = '%s%s' % (htmlRelease, pkgDict['SrcFile'])
 
113
   uploadsRegular.append(pkgDict)
 
114
 
 
115
   if pkgInfo['HasBundle']:
 
116
      pkgDict = {}
 
117
      pkgDict['SrcFile']   = getPkgFilename(pkgName, offline=True)
 
118
      pkgDict['SrcPath']   = os.path.join(inDir, 'installers', pkgDict['SrcFile'])
 
119
      pkgDict['OSName']    = pkgInfo['OSNameDisp']
 
120
      pkgDict['OSVar']     = pkgInfo['BundleOSVar']
 
121
      pkgDict['OSArch']    = pkgInfo['OSArchDisp']
 
122
      pkgDict['IsHash']    = False
 
123
      pkgDict['IsBundle']  = True
 
124
      pkgDict['DstUpload'] = '%s%s' % (s3Release,   pkgDict['SrcFile'])
 
125
      pkgDict['DownLink']  = '%s%s' % (htmlRelease, pkgDict['SrcFile'])
 
126
      uploadsOffline.append(pkgDict)
 
127
 
 
128
uploads = uploadsRegular + uploadsOffline
 
129
   
 
130
 
 
131
ascDict = {}
 
132
ascDict['SrcFile']   = getPkgFilename('SHAFILE_ASC')
 
133
ascDict['SrcPath']   = os.path.join(inDir, 'installers', ascDict['SrcFile'])
 
134
ascDict['IsHash']    = True
 
135
ascDict['IsBundle']  = False
 
136
ascDict['DstUpload'] = '%s%s' % (s3Release,   ascDict['SrcFile'])
 
137
ascDict['DownLink']   = '%s%s' % (htmlRelease, ascDict['SrcFile'])
 
138
uploads.append(ascDict)
 
139
 
 
140
 
 
141
jsonOut = {}
 
142
jsonOut['VersionStr'] = topVerStr + topVerType
 
143
jsonOut['ReleaseDate'] = datetime.fromtimestamp(time.time()).strftime("%B %d, %Y")
 
144
jsonOut['Downloads'] = uploads
 
145
 
 
146
print json.dumps(jsonOut, indent=4)
 
147
 
 
148
for upl in uploads:
 
149
   print 'Going to upload:'
 
150
   for key,val in upl.iteritems():
 
151
      print '   ', key.ljust(10), ':', val
 
152
   print ''
 
153
 
 
154
 
 
155
 
 
156
for pkgDict in uploads:
 
157
 
 
158
   #osStr, subOS, bits, vi, vs = fivevals
 
159
   #print fullfn, fn, isbundle, ishash, osStr, subOS, bits, vi, vs
 
160
   verFullStr = topVerStr + topVerType
 
161
 
 
162
   humanText = 'Armory %s' % verFullStr
 
163
   if pkgDict['IsBundle']:
 
164
      humanText += ' Offline Bundle'
 
165
 
 
166
   if pkgDict['IsHash']: 
 
167
      humanText += ': Signed hashes of all installers '
 
168
   else:
 
169
      osParams = [pkgDict[a] for a in ['OSName', 'OSVar', 'OSArch']]
 
170
      humanText += ' for %s %s (%s)' % tuple(osParams)
 
171
            
 
172
   uploadurl = pkgDict['DstUpload']
 
173
   linkurl   = pkgDict['DownLink']
 
174
 
 
175
   s3cmd = 's3cmd put --acl-public %s %s' % (pkgDict['SrcPath'], uploadurl)
 
176
   forumText = '[url=%s]%s[/url]' % (linkurl, humanText)
 
177
   htmlText  = '<a href="%s">%s</a>' % (linkurl, humanText)
 
178
 
 
179
   forumTextList.append(forumText)
 
180
   htmlTextList.append(htmlText)
 
181
   rawUrlList.append(linkurl)
 
182
   s3cmdList.append(s3cmd)
 
183
 
 
184
 
 
185
announceDir = os.path.join(inDir, 'signedannounce')
 
186
for fn in os.listdir(announceDir):
 
187
   fpath = os.path.join(announceDir, fn)
 
188
   uploadurl = '%s%s' % (s3Announce, fn)
 
189
   s3cmd = 's3cmd put --acl-public %s %s' % (fpath, uploadurl)
 
190
   s3cmdList.append(s3cmd)
 
191
   
 
192
   
 
193
logprint('\nRAW URL LIST')
 
194
for txt in rawUrlList:
 
195
   logprint('  '+txt)
 
196
 
 
197
logprint('\nFORUM POSTING LINKS')
 
198
for txt in forumTextList:
 
199
   logprint('  '+txt)
 
200
 
 
201
logprint('\nWEBSITE POSTING LINKS')
 
202
for txt in htmlTextList:
 
203
   logprint('  '+txt)
 
204
 
 
205
logprint('\nS3CMD UPLOAD COMMANDS')
 
206
for txt in s3cmdList:
 
207
   logprint('  '+txt)
 
208
 
 
209
 
 
210
if not isDryRun:
 
211
   
 
212
   logprint('')
 
213
   yn = raw_input('Continue with upload? [y/N]')
 
214
 
 
215
   if yn.lower().startswith('y'):
 
216
      logprint('STARTING UPLOADS')
 
217
      for s3cmd in s3cmdList:
 
218
         logprint('Uploading: ' + s3cmd.split()[-1].strip())
 
219
         execAndWait(s3cmd, usepipes=False)
 
220
 
 
221
 
 
222
   logprint('')
 
223
   logprint('Not actually pushing the signed tag; do it manually --')
 
224
   logprint('Copy the following command to push the tag:')
 
225
   logprint('   cd %s/BitcoinArmory; git push origin v%s' % (inDir, verFullStr))
 
226