11 class Error(Exception):
12 def __init__(self, value):
19 parser = argparse.ArgumentParser()
20 parser.add_argument('command')
21 parser.add_argument('-p', '--project', help='project name')
22 parser.add_argument('--minor', help='minor version number bump', action='store_true')
23 parser.add_argument('--micro', help='micro version number bump', action='store_true')
24 parser.add_argument('--major', help='major version to return with latest', type=int)
25 parser.add_argument('-c', '--checkout', help='string to pass to git for checkout')
26 parser.add_argument('-o', '--output', help='output directory', default='.')
27 parser.add_argument('-q', '--quiet', help='be quiet', action='store_true')
28 parser.add_argument('-t', '--target', help='target')
29 parser.add_argument('-k', '--keep', help='keep working tree', action='store_true')
30 parser.add_argument('--debug', help='build with debugging symbols where possible', action='store_true')
31 parser.add_argument('-w', '--work', help='override default work directory')
32 parser.add_argument('-g', '--git-prefix', help='override configured git prefix')
33 args = parser.parse_args()
35 cdist_cmd = 'cdist %s -t host ' % args.command
36 if args.project is not None:
37 cdist_cmd += '-p %s ' % args.project
38 if args.minor is True:
39 cdist_cmd += '--minor '
40 if args.micro is True:
41 cdist_cmd += '--micro '
42 if args.major is True:
43 cdist_cmd += '--major '
44 if args.checkout is not None:
45 cdist_cmd += '--checkout %s ' % args.checkout
46 if args.output is not None:
47 cdist_cmd += '--output cdistvm '
48 if args.quiet is True:
49 cdist_cmd += '--quiet '
51 cdist_cmd += '--keep '
52 if args.debug is True:
53 cdist_cmd += '--debug '
54 if args.work is not None:
55 cdist_cmd += '--work %s ' % args.work
56 if args.git_prefix is not None:
57 cdist_cmd += '--git-prefix %s ' % args.git_prefix
62 raise Error('command %s failed' % c)
64 ports = { 'fedora-22-32': 2000,
75 vbox = subprocess.Popen('vboxheadless --startvm %s' % args.target, shell=True)
81 command('ssh -p %d carl@localhost "rm -rf cdistvm /var/tmp/tmp*"' % ports[args.target])
84 print('Ignoring: %s' % e)
87 command('ssh -p %d carl@localhost %s' % (ports[args.target], cdist_cmd))
88 if args.command in ['package', 'doxygen', 'manual', 'changelog', 'pot']:
89 tmp = tempfile.mkdtemp()
90 command('scp -r -P %d carl@localhost:cdistvm/* %s/' % (ports[args.target], tmp))
91 command('scp -r %s/* %s/' % (tmp, args.output))
95 command('ssh -p %d carl@localhost "sudo /sbin/poweroff"' % ports[args.target])
99 print("wait for vm to terminate...")