mirror of https://github.com/apache/lucene.git
convert to python3 (merged lucene_solr_4_1 r1434374 and r1434377)
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1434409 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d87c74f104
commit
0178e8e625
|
@ -19,9 +19,9 @@ import shutil
|
|||
import os
|
||||
import sys
|
||||
|
||||
# Usage: python -u buildRelease.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)
|
||||
#
|
||||
# EG: python -u buildRelease.py -prepare -push -sign 6E68DA61 mikemccand /lucene/34x 3.4.0 0
|
||||
# EG: python3.2 -u buildAndPushRelease.py -prepare -push -sign 6E68DA61 mikemccand /lucene/34x 3.4.0 0
|
||||
|
||||
# NOTE: if you specify -sign, you have to type in your gpg password at
|
||||
# some point while this runs; it's VERY confusing because the output
|
||||
|
@ -32,15 +32,15 @@ import sys
|
|||
LOG = '/tmp/release.log'
|
||||
|
||||
def log(msg):
|
||||
f = open(LOG, 'ab')
|
||||
f.write(msg)
|
||||
f = open(LOG, mode='ab')
|
||||
f.write(msg.encode('utf-8'))
|
||||
f.close()
|
||||
|
||||
def run(command):
|
||||
log('\n\n%s: RUN: %s\n' % (datetime.datetime.now(), command))
|
||||
if os.system('%s >> %s 2>&1' % (command, LOG)):
|
||||
msg = ' FAILED: %s [see log %s]' % (command, LOG)
|
||||
print msg
|
||||
print(msg)
|
||||
raise RuntimeError(msg)
|
||||
|
||||
def scrubCheckout():
|
||||
|
@ -53,7 +53,7 @@ def scrubCheckout():
|
|||
if match:
|
||||
s = match.group(1)
|
||||
if os.path.exists(s):
|
||||
print ' delete %s' % s
|
||||
print(' delete %s' % s)
|
||||
if os.path.isdir(s) and not os.path.islink(s):
|
||||
shutil.rmtree(s)
|
||||
else:
|
||||
|
@ -69,29 +69,29 @@ def getSVNRev():
|
|||
|
||||
|
||||
def prepare(root, version, gpgKeyID, doTest):
|
||||
print
|
||||
print 'Prepare release...'
|
||||
print()
|
||||
print('Prepare release...')
|
||||
if os.path.exists(LOG):
|
||||
os.remove(LOG)
|
||||
|
||||
os.chdir(root)
|
||||
print ' svn up...'
|
||||
print(' svn up...')
|
||||
run('svn up')
|
||||
|
||||
rev = getSVNRev()
|
||||
print ' svn rev: %s' % rev
|
||||
print(' svn rev: %s' % rev)
|
||||
log('\nSVN rev: %s\n' % rev)
|
||||
|
||||
if doTest:
|
||||
# Don't run tests if we are gonna smoke test after the release...
|
||||
print ' ant clean test'
|
||||
print(' ant clean test')
|
||||
run('ant clean test')
|
||||
|
||||
print ' clean checkout'
|
||||
print(' clean checkout')
|
||||
scrubCheckout()
|
||||
open('rev.txt', 'wb').write(rev)
|
||||
open('rev.txt', mode='wb').write(rev.encode('UTF-8'))
|
||||
|
||||
print ' lucene prepare-release'
|
||||
print(' lucene prepare-release')
|
||||
os.chdir('lucene')
|
||||
cmd = 'ant -Dversion=%s -Dspecversion=%s' % (version, version)
|
||||
if gpgKeyID is not None:
|
||||
|
@ -100,7 +100,7 @@ def prepare(root, version, gpgKeyID, doTest):
|
|||
cmd += ' prepare-release-no-sign'
|
||||
run(cmd)
|
||||
|
||||
print ' solr prepare-release'
|
||||
print(' solr prepare-release')
|
||||
os.chdir('../solr')
|
||||
cmd = 'ant -Dversion=%s -Dspecversion=%s' % (version, version)
|
||||
if gpgKeyID is not None:
|
||||
|
@ -108,48 +108,48 @@ def prepare(root, version, gpgKeyID, doTest):
|
|||
else:
|
||||
cmd += ' prepare-release-no-sign'
|
||||
run(cmd)
|
||||
print ' done!'
|
||||
print
|
||||
print(' done!')
|
||||
print()
|
||||
return rev
|
||||
|
||||
def push(version, root, rev, rcNum, username):
|
||||
print 'Push...'
|
||||
print('Push...')
|
||||
dir = 'lucene-solr-%s-RC%d-rev%s' % (version, rcNum, rev)
|
||||
s = os.popen('ssh %s@people.apache.org "ls -ld public_html/staging_area/%s" 2>&1' % (username, dir)).read()
|
||||
if s.lower().find('no such file or directory') == -1:
|
||||
print ' Remove old dir...'
|
||||
s = os.popen('ssh %s@people.apache.org "ls -ld public_html/staging_area/%s" 2>&1' % (username, dir)).read().decode('UTF-8')
|
||||
if 'no such file or directory' not in s.lower():
|
||||
print(' Remove old dir...')
|
||||
run('ssh %s@people.apache.org "chmod -R u+rwX public_html/staging_area/%s; rm -rf public_html/staging_area/%s"' %
|
||||
(username, dir, dir))
|
||||
run('ssh %s@people.apache.org "mkdir -p public_html/staging_area/%s/lucene public_html/staging_area/%s/solr"' % \
|
||||
(username, dir, dir))
|
||||
print ' Lucene'
|
||||
print(' Lucene')
|
||||
os.chdir('%s/lucene/dist' % root)
|
||||
print ' zip...'
|
||||
print(' zip...')
|
||||
if os.path.exists('lucene.tar.bz2'):
|
||||
os.remove('lucene.tar.bz2')
|
||||
run('tar cjf lucene.tar.bz2 *')
|
||||
print ' copy...'
|
||||
print(' copy...')
|
||||
run('scp lucene.tar.bz2 %s@people.apache.org:public_html/staging_area/%s/lucene' % (username, dir))
|
||||
print ' unzip...'
|
||||
print(' unzip...')
|
||||
run('ssh %s@people.apache.org "cd public_html/staging_area/%s/lucene; tar xjf lucene.tar.bz2; rm -f lucene.tar.bz2"' % (username, dir))
|
||||
os.remove('lucene.tar.bz2')
|
||||
print ' copy changes...'
|
||||
print(' copy changes...')
|
||||
os.chdir('..')
|
||||
run('scp -r build/docs/changes %s@people.apache.org:public_html/staging_area/%s/lucene/changes-%s' % (username, dir, version))
|
||||
|
||||
print ' Solr'
|
||||
print(' Solr')
|
||||
os.chdir('%s/solr/package' % root)
|
||||
print ' zip...'
|
||||
print(' zip...')
|
||||
if os.path.exists('solr.tar.bz2'):
|
||||
os.remove('solr.tar.bz2')
|
||||
run('tar cjf solr.tar.bz2 *')
|
||||
print ' copy...'
|
||||
print(' copy...')
|
||||
run('scp solr.tar.bz2 %s@people.apache.org:public_html/staging_area/%s/solr' % (username, dir))
|
||||
print ' unzip...'
|
||||
print(' unzip...')
|
||||
run('ssh %s@people.apache.org "cd public_html/staging_area/%s/solr; tar xjf solr.tar.bz2; rm -f solr.tar.bz2"' % (username, dir))
|
||||
os.remove('solr.tar.bz2')
|
||||
|
||||
print ' KEYS'
|
||||
print(' KEYS')
|
||||
run('wget http://people.apache.org/keys/group/lucene.asc')
|
||||
os.rename('lucene.asc', 'KEYS')
|
||||
run('chmod a+r-w KEYS')
|
||||
|
@ -157,56 +157,56 @@ def push(version, root, rev, rcNum, username):
|
|||
run('scp KEYS %s@people.apache.org:public_html/staging_area/%s/solr' % (username, dir))
|
||||
os.remove('KEYS')
|
||||
|
||||
print ' chmod...'
|
||||
print(' chmod...')
|
||||
run('ssh %s@people.apache.org "chmod -R a+rX-w public_html/staging_area/%s"' % (username, dir))
|
||||
|
||||
print ' done!'
|
||||
print(' done!')
|
||||
url = 'https://people.apache.org/~%s/staging_area/%s' % (username, dir)
|
||||
return url
|
||||
|
||||
def pushLocal(version, root, rev, rcNum, localDir):
|
||||
print 'Push local [%s]...' % localDir
|
||||
print('Push local [%s]...' % localDir)
|
||||
os.makedirs(localDir)
|
||||
|
||||
dir = 'lucene-solr-%s-RC%d-rev%s' % (version, rcNum, rev)
|
||||
os.makedirs('%s/%s/lucene' % (localDir, dir))
|
||||
os.makedirs('%s/%s/solr' % (localDir, dir))
|
||||
print ' Lucene'
|
||||
print(' Lucene')
|
||||
os.chdir('%s/lucene/dist' % root)
|
||||
print ' zip...'
|
||||
print(' zip...')
|
||||
if os.path.exists('lucene.tar.bz2'):
|
||||
os.remove('lucene.tar.bz2')
|
||||
run('tar cjf lucene.tar.bz2 *')
|
||||
|
||||
os.chdir('%s/%s/lucene' % (localDir, dir))
|
||||
print ' unzip...'
|
||||
print(' unzip...')
|
||||
run('tar xjf "%s/lucene/dist/lucene.tar.bz2"' % root)
|
||||
os.remove('%s/lucene/dist/lucene.tar.bz2' % root)
|
||||
print ' copy changes...'
|
||||
print(' copy changes...')
|
||||
run('cp -r "%s/lucene/build/docs/changes" changes-%s' % (root, version))
|
||||
|
||||
print ' Solr'
|
||||
print(' Solr')
|
||||
os.chdir('%s/solr/package' % root)
|
||||
print ' zip...'
|
||||
print(' zip...')
|
||||
if os.path.exists('solr.tar.bz2'):
|
||||
os.remove('solr.tar.bz2')
|
||||
run('tar cjf solr.tar.bz2 *')
|
||||
print ' unzip...'
|
||||
print(' unzip...')
|
||||
os.chdir('%s/%s/solr' % (localDir, dir))
|
||||
run('tar xjf "%s/solr/package/solr.tar.bz2"' % root)
|
||||
os.remove('%s/solr/package/solr.tar.bz2' % root)
|
||||
|
||||
print ' KEYS'
|
||||
print(' KEYS')
|
||||
run('wget http://people.apache.org/keys/group/lucene.asc')
|
||||
os.rename('lucene.asc', 'KEYS')
|
||||
run('chmod a+r-w KEYS')
|
||||
run('cp KEYS ../lucene')
|
||||
|
||||
print ' chmod...'
|
||||
print(' chmod...')
|
||||
os.chdir('..')
|
||||
run('chmod -R a+rX-w .')
|
||||
|
||||
print ' done!'
|
||||
print(' done!')
|
||||
return 'file://%s/%s' % (os.path.abspath(localDir), dir)
|
||||
|
||||
def main():
|
||||
|
@ -231,9 +231,9 @@ def main():
|
|||
smokeTmpDir = sys.argv[idx+1]
|
||||
del sys.argv[idx:idx+2]
|
||||
if os.path.exists(smokeTmpDir):
|
||||
print
|
||||
print 'ERROR: smoke tmpDir "%s" exists; please remove first' % smokeTmpDir
|
||||
print
|
||||
print()
|
||||
print('ERROR: smoke tmpDir "%s" exists; please remove first' % smokeTmpDir)
|
||||
print()
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
|
@ -245,15 +245,15 @@ def main():
|
|||
localStagingDir = sys.argv[idx+1]
|
||||
del sys.argv[idx:idx+2]
|
||||
if os.path.exists(localStagingDir):
|
||||
print
|
||||
print 'ERROR: pushLocal dir "%s" exists; please remove first' % localStagingDir
|
||||
print
|
||||
print()
|
||||
print('ERROR: pushLocal dir "%s" exists; please remove first' % localStagingDir)
|
||||
print()
|
||||
sys.exit(1)
|
||||
|
||||
if doPushRemote and doPushLocal:
|
||||
print
|
||||
print 'ERROR: specify at most one of -push or -pushLocal (got both)'
|
||||
print
|
||||
print()
|
||||
print('ERROR: specify at most one of -push or -pushLocal (got both)')
|
||||
print()
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
|
@ -272,17 +272,17 @@ def main():
|
|||
rev = prepare(root, version, gpgKeyID, smokeTmpDir is None)
|
||||
else:
|
||||
os.chdir(root)
|
||||
rev = open('rev.txt').read()
|
||||
rev = open('rev.txt', encoding='UTF-8').read()
|
||||
|
||||
if doPushRemote:
|
||||
url = push(version, root, rev, rcNum, username)
|
||||
elif doPushLocal:
|
||||
url = pushLocal(version, root, rev, rcNum, localStagingDir)
|
||||
else:
|
||||
url = NOne
|
||||
url = None
|
||||
|
||||
if url is not None:
|
||||
print ' URL: %s' % url
|
||||
print(' URL: %s' % url)
|
||||
|
||||
if smokeTmpDir is not None:
|
||||
import smokeTestRelease
|
||||
|
@ -290,4 +290,8 @@ def main():
|
|||
smokeTestRelease.smokeTest(url, version, smokeTmpDir, gpgKeyID is not None)
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
main()
|
||||
except:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
|
Loading…
Reference in New Issue