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