2
"""Build and package juju for an non-debian OS."""
4
from __future__ import print_function
6
from argparse import ArgumentParser
11
from candidate import run_command
22
DEFAULT_JUJU_RELEASE_TOOLS = os.path.realpath(
23
os.path.join(__file__, '..', '..', 'juju-release-tools'))
26
def get_script(juju_release_tools=None):
27
"""Return the full path to the crossbuild script.
29
The juju-release-tools dir is assumed to be a sibling of the juju-ci-tools
32
if not juju_release_tools:
33
juju_release_tools = DEFAULT_JUJU_RELEASE_TOOLS
34
script = os.path.join(juju_release_tools, 'crossbuild.py')
38
def build_juju(credentials, product, workspace_dir, build,
39
juju_release_tools=None, dry_run=False, verbose=False):
40
"""Build the juju product from a Juju CI build-revision in a workspace.
42
The product is passed to juju-release-tools/crossbuild.py. The options
43
include osx-client, win-client, win-agent.
45
The tarfile from the build-revision build number is downloaded and passed
48
setup_workspace(workspace_dir, dry_run=dry_run, verbose=verbose)
49
artifacts = get_artifacts(
50
credentials, BUILD_REVISION, build, 'juju-core_*.tar.gz',
51
workspace_dir, archive=False, dry_run=dry_run, verbose=verbose)
52
tar_artifact = artifacts[0]
53
crossbuild = get_script(juju_release_tools)
55
crossbuild, product, '-b', '~/crossbuild', tar_artifact.file_name]
56
run_command(command, dry_run=dry_run, verbose=verbose)
58
'juju-setup-*.exe', 'juju-*-win2012-amd64.tgz', 'juju-*-osx.tar.gz',
59
'juju-*-centos7-amd64.tgz', 'juju-*-centos7.tar.gz']
60
add_artifacts(workspace_dir, globs, dry_run=dry_run, verbose=verbose)
63
def parse_args(args=None):
64
"""Return the argument parser for this program."""
65
parser = ArgumentParser("Build and package juju for an non-debian OS.")
67
'-d', '--dry-run', action='store_true', default=False,
68
help='Do not make changes.')
70
'-v', '--verbose', action='store_true', default=False,
71
help='Increase verbosity.')
73
'-b', '--build', default='lastSuccessfulBuild',
74
help="The specific revision-build number to get the tarball from")
76
'-t', '--juju-release-tools',
77
help='The path to the juju-release-tools dir, default: %s' %
78
DEFAULT_JUJU_RELEASE_TOOLS)
80
'product', choices=['win-client', 'win-agent', 'osx-client', 'centos'],
81
help='the kind of juju to make and package.')
83
'workspace', help='The path to the workspace to build in.')
84
add_credential_args(parser)
85
parsed = parser.parse_args(args)
86
return parsed, get_credentials(parsed)
90
"""Build and package juju for an non-debian OS."""
91
args, credentials = parse_args(argv)
94
credentials, args.product, args.workspace, args.build,
95
juju_release_tools=args.juju_release_tools,
96
dry_run=args.dry_run, verbose=args.verbose)
97
except Exception as e:
99
print(getattr(e, 'output', ''))
101
traceback.print_tb(sys.exc_info()[2])
108
if __name__ == '__main__':
109
sys.exit(main(sys.argv[1:]))