Make --setup command independent
A user can run 'gitian-build.py --setup' ignoring signer and version options. Get rid of warning about macOS build during setup for free.
This commit is contained in:
parent
f49b8d4783
commit
e0eae1b4a4
1 changed files with 23 additions and 21 deletions
|
@ -152,7 +152,7 @@ def verify():
|
||||||
def main():
|
def main():
|
||||||
global args, workdir
|
global args, workdir
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(usage='%(prog)s [options] signer version')
|
parser = argparse.ArgumentParser(description='Script for running full Gitian builds.')
|
||||||
parser.add_argument('-c', '--commit', action='store_true', dest='commit', help='Indicate that the version argument is for a commit or branch')
|
parser.add_argument('-c', '--commit', action='store_true', dest='commit', help='Indicate that the version argument is for a commit or branch')
|
||||||
parser.add_argument('-p', '--pull', action='store_true', dest='pull', help='Indicate that the version argument is the number of a github repository pull request')
|
parser.add_argument('-p', '--pull', action='store_true', dest='pull', help='Indicate that the version argument is the number of a github repository pull request')
|
||||||
parser.add_argument('-u', '--url', dest='url', default='https://github.com/bitcoin/bitcoin', help='Specify the URL of the repository. Default is %(default)s')
|
parser.add_argument('-u', '--url', dest='url', default='https://github.com/bitcoin/bitcoin', help='Specify the URL of the repository. Default is %(default)s')
|
||||||
|
@ -168,27 +168,17 @@ def main():
|
||||||
parser.add_argument('-S', '--setup', action='store_true', dest='setup', help='Set up the Gitian building environment. Only works on Debian-based systems (Ubuntu, Debian)')
|
parser.add_argument('-S', '--setup', action='store_true', dest='setup', help='Set up the Gitian building environment. Only works on Debian-based systems (Ubuntu, Debian)')
|
||||||
parser.add_argument('-D', '--detach-sign', action='store_true', dest='detach_sign', help='Create the assert file for detached signing. Will not commit anything.')
|
parser.add_argument('-D', '--detach-sign', action='store_true', dest='detach_sign', help='Create the assert file for detached signing. Will not commit anything.')
|
||||||
parser.add_argument('-n', '--no-commit', action='store_false', dest='commit_files', help='Do not commit anything to git')
|
parser.add_argument('-n', '--no-commit', action='store_false', dest='commit_files', help='Do not commit anything to git')
|
||||||
parser.add_argument('signer', help='GPG signer to sign each build assert file')
|
parser.add_argument('signer', nargs='?', help='GPG signer to sign each build assert file')
|
||||||
parser.add_argument('version', help='Version number, commit, or branch to build. If building a commit or branch, the -c option must be specified')
|
parser.add_argument('version', nargs='?', help='Version number, commit, or branch to build. If building a commit or branch, the -c option must be specified')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
workdir = os.getcwd()
|
workdir = os.getcwd()
|
||||||
|
|
||||||
args.linux = 'l' in args.os
|
|
||||||
args.windows = 'w' in args.os
|
|
||||||
args.macos = 'm' in args.os
|
|
||||||
|
|
||||||
args.is_bionic = b'bionic' in subprocess.check_output(['lsb_release', '-cs'])
|
args.is_bionic = b'bionic' in subprocess.check_output(['lsb_release', '-cs'])
|
||||||
|
|
||||||
if args.buildsign:
|
|
||||||
args.build = True
|
|
||||||
args.sign = True
|
|
||||||
|
|
||||||
if args.kvm and args.docker:
|
if args.kvm and args.docker:
|
||||||
raise Exception('Error: cannot have both kvm and docker')
|
raise Exception('Error: cannot have both kvm and docker')
|
||||||
|
|
||||||
args.sign_prog = 'true' if args.detach_sign else 'gpg --detach-sign'
|
|
||||||
|
|
||||||
# Ensure no more than one environment variable for gitian-builder (USE_LXC, USE_VBOX, USE_DOCKER) is set as they
|
# Ensure no more than one environment variable for gitian-builder (USE_LXC, USE_VBOX, USE_DOCKER) is set as they
|
||||||
# can interfere (e.g., USE_LXC being set shadows USE_DOCKER; for details see gitian-builder/libexec/make-clean-vm).
|
# can interfere (e.g., USE_LXC being set shadows USE_DOCKER; for details see gitian-builder/libexec/make-clean-vm).
|
||||||
os.environ['USE_LXC'] = ''
|
os.environ['USE_LXC'] = ''
|
||||||
|
@ -203,19 +193,34 @@ def main():
|
||||||
if 'LXC_GUEST_IP' not in os.environ.keys():
|
if 'LXC_GUEST_IP' not in os.environ.keys():
|
||||||
os.environ['LXC_GUEST_IP'] = '10.0.3.5'
|
os.environ['LXC_GUEST_IP'] = '10.0.3.5'
|
||||||
|
|
||||||
|
if args.setup:
|
||||||
|
setup()
|
||||||
|
|
||||||
|
if args.buildsign:
|
||||||
|
args.build = True
|
||||||
|
args.sign = True
|
||||||
|
|
||||||
|
if not args.build and not args.sign and not args.verify:
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
args.linux = 'l' in args.os
|
||||||
|
args.windows = 'w' in args.os
|
||||||
|
args.macos = 'm' in args.os
|
||||||
|
|
||||||
# Disable for MacOS if no SDK found
|
# Disable for MacOS if no SDK found
|
||||||
if args.macos and not os.path.isfile('gitian-builder/inputs/MacOSX10.11.sdk.tar.gz'):
|
if args.macos and not os.path.isfile('gitian-builder/inputs/MacOSX10.11.sdk.tar.gz'):
|
||||||
print('Cannot build for MacOS, SDK does not exist. Will build for other OSes')
|
print('Cannot build for MacOS, SDK does not exist. Will build for other OSes')
|
||||||
args.macos = False
|
args.macos = False
|
||||||
|
|
||||||
|
args.sign_prog = 'true' if args.detach_sign else 'gpg --detach-sign'
|
||||||
|
|
||||||
script_name = os.path.basename(sys.argv[0])
|
script_name = os.path.basename(sys.argv[0])
|
||||||
# Signer and version shouldn't be empty
|
if not args.signer:
|
||||||
if args.signer == '':
|
print(script_name+': Missing signer')
|
||||||
print(script_name+': Missing signer.')
|
|
||||||
print('Try '+script_name+' --help for more information')
|
print('Try '+script_name+' --help for more information')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if args.version == '':
|
if not args.version:
|
||||||
print(script_name+': Missing version.')
|
print(script_name+': Missing version')
|
||||||
print('Try '+script_name+' --help for more information')
|
print('Try '+script_name+' --help for more information')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -224,9 +229,6 @@ def main():
|
||||||
raise Exception('Cannot have both commit and pull')
|
raise Exception('Cannot have both commit and pull')
|
||||||
args.commit = ('' if args.commit else 'v') + args.version
|
args.commit = ('' if args.commit else 'v') + args.version
|
||||||
|
|
||||||
if args.setup:
|
|
||||||
setup()
|
|
||||||
|
|
||||||
os.chdir('bitcoin')
|
os.chdir('bitcoin')
|
||||||
if args.pull:
|
if args.pull:
|
||||||
subprocess.check_call(['git', 'fetch', args.url, 'refs/pull/'+args.version+'/merge'])
|
subprocess.check_call(['git', 'fetch', args.url, 'refs/pull/'+args.version+'/merge'])
|
||||||
|
|
Loading…
Reference in a new issue