mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-19 21:30:10 +01:00
Run 2to3 on makebuildserver
Mostly just print conversion.
This commit is contained in:
parent
d42c612c9a
commit
49ac25270e
@ -26,7 +26,7 @@ def vagrant(params, cwd=None, printout=False):
|
|||||||
line = p.stdout.readline()
|
line = p.stdout.readline()
|
||||||
if len(line) == 0:
|
if len(line) == 0:
|
||||||
break
|
break
|
||||||
print line,
|
print(line)
|
||||||
out += line
|
out += line
|
||||||
p.wait()
|
p.wait()
|
||||||
else:
|
else:
|
||||||
@ -63,13 +63,13 @@ config = {
|
|||||||
|
|
||||||
# load config file, if present
|
# load config file, if present
|
||||||
if os.path.exists('makebuildserver.config.py'):
|
if os.path.exists('makebuildserver.config.py'):
|
||||||
execfile('makebuildserver.config.py', config)
|
exec(compile(open('makebuildserver.config.py').read(), 'makebuildserver.config.py', 'exec'), config)
|
||||||
elif os.path.exists('makebs.config.py'):
|
elif os.path.exists('makebs.config.py'):
|
||||||
# this is the old name for the config file
|
# this is the old name for the config file
|
||||||
execfile('makebs.config.py', config)
|
exec(compile(open('makebs.config.py').read(), 'makebs.config.py', 'exec'), config)
|
||||||
|
|
||||||
if not os.path.exists('makebuildserver') or not os.path.exists(serverdir):
|
if not os.path.exists('makebuildserver') or not os.path.exists(serverdir):
|
||||||
print 'This must be run from the correct directory!'
|
print('This must be run from the correct directory!')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if os.path.exists(boxfile):
|
if os.path.exists(boxfile):
|
||||||
@ -81,7 +81,7 @@ if options.clean:
|
|||||||
# Update cached files.
|
# Update cached files.
|
||||||
cachedir = config['cachedir']
|
cachedir = config['cachedir']
|
||||||
if not os.path.exists(cachedir):
|
if not os.path.exists(cachedir):
|
||||||
os.makedirs(cachedir, 0755)
|
os.makedirs(cachedir, 0o755)
|
||||||
|
|
||||||
cachefiles = [
|
cachefiles = [
|
||||||
('android-sdk_r24.4.1-linux.tgz',
|
('android-sdk_r24.4.1-linux.tgz',
|
||||||
@ -318,17 +318,17 @@ for f, src, shasum in cachefiles:
|
|||||||
if os.path.exists(relpath) and os.stat(relpath).st_size == 0:
|
if os.path.exists(relpath) and os.stat(relpath).st_size == 0:
|
||||||
os.remove(relpath)
|
os.remove(relpath)
|
||||||
if not os.path.exists(relpath):
|
if not os.path.exists(relpath):
|
||||||
print "Downloading " + f + " to cache"
|
print("Downloading " + f + " to cache")
|
||||||
if subprocess.call(['wget', src, '-O', f], cwd=cachedir) != 0:
|
if subprocess.call(['wget', src, '-O', f], cwd=cachedir) != 0:
|
||||||
print "...download of " + f + " failed."
|
print("...download of " + f + " failed.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if shasum:
|
if shasum:
|
||||||
v = sha256_for_file(relpath)
|
v = sha256_for_file(relpath)
|
||||||
if v != shasum:
|
if v != shasum:
|
||||||
print "Invalid shasum of '" + v + "' detected for " + f
|
print("Invalid shasum of '" + v + "' detected for " + f)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
print "...shasum verified for " + f
|
print("...shasum verified for " + f)
|
||||||
|
|
||||||
wanted.append(f)
|
wanted.append(f)
|
||||||
|
|
||||||
@ -418,57 +418,57 @@ if os.path.exists(vf):
|
|||||||
with open(vf, 'r') as f:
|
with open(vf, 'r') as f:
|
||||||
oldvf = f.read()
|
oldvf = f.read()
|
||||||
if oldvf != vagrantfile:
|
if oldvf != vagrantfile:
|
||||||
print "Server configuration has changed, rebuild from scratch is required"
|
print("Server configuration has changed, rebuild from scratch is required")
|
||||||
vagrant(['destroy', '-f'], serverdir)
|
vagrant(['destroy', '-f'], serverdir)
|
||||||
else:
|
else:
|
||||||
print "Re-provisioning existing server"
|
print("Re-provisioning existing server")
|
||||||
writevf = False
|
writevf = False
|
||||||
else:
|
else:
|
||||||
print "No existing server - building from scratch"
|
print("No existing server - building from scratch")
|
||||||
if writevf:
|
if writevf:
|
||||||
with open(vf, 'w') as f:
|
with open(vf, 'w') as f:
|
||||||
f.write(vagrantfile)
|
f.write(vagrantfile)
|
||||||
|
|
||||||
|
|
||||||
print "Configuring build server VM"
|
print("Configuring build server VM")
|
||||||
returncode, out = vagrant(['up', '--provision'], serverdir, printout=True)
|
returncode, out = vagrant(['up', '--provision'], serverdir, printout=True)
|
||||||
with open(os.path.join(serverdir, 'up.log'), 'w') as log:
|
with open(os.path.join(serverdir, 'up.log'), 'w') as log:
|
||||||
log.write(out)
|
log.write(out)
|
||||||
if returncode != 0:
|
if returncode != 0:
|
||||||
print "Failed to configure server"
|
print("Failed to configure server")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
print "Writing buildserver ID"
|
print("Writing buildserver ID")
|
||||||
p = subprocess.Popen(['git', 'rev-parse', 'HEAD'], stdout=subprocess.PIPE)
|
p = subprocess.Popen(['git', 'rev-parse', 'HEAD'], stdout=subprocess.PIPE)
|
||||||
buildserverid = p.communicate()[0].strip()
|
buildserverid = p.communicate()[0].strip()
|
||||||
print "...ID is " + buildserverid
|
print("...ID is " + buildserverid)
|
||||||
subprocess.call(
|
subprocess.call(
|
||||||
['vagrant', 'ssh', '-c', 'sh -c "echo {0} >/home/vagrant/buildserverid"'
|
['vagrant', 'ssh', '-c', 'sh -c "echo {0} >/home/vagrant/buildserverid"'
|
||||||
.format(buildserverid)],
|
.format(buildserverid)],
|
||||||
cwd=serverdir)
|
cwd=serverdir)
|
||||||
|
|
||||||
print "Stopping build server VM"
|
print("Stopping build server VM")
|
||||||
vagrant(['halt'], serverdir)
|
vagrant(['halt'], serverdir)
|
||||||
|
|
||||||
print "Waiting for build server VM to be finished"
|
print("Waiting for build server VM to be finished")
|
||||||
ready = False
|
ready = False
|
||||||
while not ready:
|
while not ready:
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
returncode, out = vagrant(['status'], serverdir)
|
returncode, out = vagrant(['status'], serverdir)
|
||||||
if returncode != 0:
|
if returncode != 0:
|
||||||
print "Error while checking status"
|
print("Error while checking status")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
for line in out.splitlines():
|
for line in out.splitlines():
|
||||||
if line.startswith("default"):
|
if line.startswith("default"):
|
||||||
if line.find("poweroff") != -1:
|
if line.find("poweroff") != -1:
|
||||||
ready = True
|
ready = True
|
||||||
else:
|
else:
|
||||||
print "Status: " + line
|
print("Status: " + line)
|
||||||
|
|
||||||
print "Packaging"
|
print("Packaging")
|
||||||
vagrant(['package', '--output', os.path.join('..', boxfile)], serverdir,
|
vagrant(['package', '--output', os.path.join('..', boxfile)], serverdir,
|
||||||
printout=options.verbose)
|
printout=options.verbose)
|
||||||
print "Adding box"
|
print("Adding box")
|
||||||
vagrant(['box', 'add', 'buildserver', boxfile, '-f'],
|
vagrant(['box', 'add', 'buildserver', boxfile, '-f'],
|
||||||
printout=options.verbose)
|
printout=options.verbose)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user