prompt for GPG password up front

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1469041 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2013-04-17 19:35:47 +00:00
parent 6cce8ceb60
commit 9c56dccf19
1 changed files with 38 additions and 4 deletions

View File

@ -15,9 +15,11 @@
import datetime import datetime
import re import re
import time
import shutil import shutil
import os import os
import sys import sys
import subprocess
# Usage: python3.2 -u buildAndPushRelease.py [-sign gpgKey(eg: 6E68DA61)] [-prepare] [-push userName] [-pushLocal dirName] [-smoke tmpDir] /path/to/checkout version(eg: 3.4.0) rcNum(eg: 0) # Usage: python3.2 -u buildAndPushRelease.py [-sign gpgKey(eg: 6E68DA61)] [-prepare] [-push userName] [-pushLocal dirName] [-smoke tmpDir] /path/to/checkout version(eg: 3.4.0) rcNum(eg: 0)
# #
@ -43,6 +45,25 @@ def run(command):
print(msg) print(msg)
raise RuntimeError(msg) raise RuntimeError(msg)
def runAndSendGPGPassword(command, password):
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE)
f = open(LOG, 'ab')
while True:
line = p.stdout.readline()
if len(line) == 0:
break
f.write(line)
if line.find(b'Enter GPG keystore password:') != -1:
time.sleep(1.0)
p.stdin.write((password + '\n').encode('UTF-8'))
p.stdin.write('\n'.encode('UTF-8'))
result = p.poll()
if result != 0:
msg = ' FAILED: %s [see log %s]' % (command, LOG)
print(msg)
raise RuntimeError(msg)
def scrubCheckout(): def scrubCheckout():
# removes any files not checked into svn # removes any files not checked into svn
@ -68,7 +89,7 @@ def getSVNRev():
return rev return rev
def prepare(root, version, gpgKeyID, doTest): def prepare(root, version, gpgKeyID, gpgPassword, doTest):
print() print()
print('Prepare release...') print('Prepare release...')
if os.path.exists(LOG): if os.path.exists(LOG):
@ -98,7 +119,11 @@ def prepare(root, version, gpgKeyID, doTest):
cmd += ' -Dgpg.key=%s prepare-release' % gpgKeyID cmd += ' -Dgpg.key=%s prepare-release' % gpgKeyID
else: else:
cmd += ' prepare-release-no-sign' cmd += ' prepare-release-no-sign'
run(cmd)
if gpgPassword is not None:
runAndSendGPGPassword(cmd, gpgPassword)
else:
run(cmd)
print(' solr prepare-release') print(' solr prepare-release')
os.chdir('../solr') os.chdir('../solr')
@ -107,7 +132,12 @@ def prepare(root, version, gpgKeyID, doTest):
cmd += ' -Dgpg.key=%s prepare-release' % gpgKeyID cmd += ' -Dgpg.key=%s prepare-release' % gpgKeyID
else: else:
cmd += ' prepare-release-no-sign' cmd += ' prepare-release-no-sign'
run(cmd)
if gpgPassword is not None:
runAndSendGPGPassword(cmd, gpgPassword)
else:
run(cmd)
print(' done!') print(' done!')
print() print()
return rev return rev
@ -253,12 +283,16 @@ def main():
gpgKeyID = sys.argv[idx+1] gpgKeyID = sys.argv[idx+1]
del sys.argv[idx:idx+2] del sys.argv[idx:idx+2]
sys.stdout.flush()
import getpass
gpgPassword = getpass.getpass('Enter GPG keystore password: ')
root = os.path.abspath(sys.argv[1]) root = os.path.abspath(sys.argv[1])
version = sys.argv[2] version = sys.argv[2]
rcNum = int(sys.argv[3]) rcNum = int(sys.argv[3])
if doPrepare: if doPrepare:
rev = prepare(root, version, gpgKeyID, smokeTmpDir is None) rev = prepare(root, version, gpgKeyID, gpgPassword, smokeTmpDir is None)
else: else:
os.chdir(root) os.chdir(root)
rev = open('rev.txt', encoding='UTF-8').read() rev = open('rev.txt', encoding='UTF-8').read()