source: vendor/current/script/land-remote.py@ 987

Last change on this file since 987 was 740, checked in by Silvan Scherrer, 13 years ago

Samba Server: update vendor to 3.6.0

File size: 5.0 KB
Line 
1#!/usr/bin/python
2# Ship a local branch to a remote host (sn-104?) over ssh and run autobuild in it.
3# Copyright (C) 2010 Jelmer Vernooij <jelmer@samba.org>
4# Published under the GPL, v3 or later
5
6import optparse
7import os
8import subprocess
9import sys
10
11samba_master = os.getenv('SAMBA_MASTER', 'git://git.samba.org/samba.git')
12
13parser = optparse.OptionParser("autoland-remote [options] [trees...]")
14parser.add_option("--remote-repo", help="Location of remote repository (default: temporary repository)", type=str, default=None)
15parser.add_option("--host", help="Host to land on (SSH connection string)", type=str, default="sn-devel-104.sn.samba.org")
16parser.add_option("--foreground", help="Don't daemonize", action="store_true", default=False)
17parser.add_option("--email", help="Email address to send build/test output to", type=str, default=None, metavar="EMAIL")
18parser.add_option("--always-email", help="always send email, even on success", action="store_true")
19parser.add_option("--rebase-master", help="rebase on master before testing", default=False, action='store_true')
20parser.add_option("--push-master", help="push to samba.org master on success",
21 default=False, action='store_true')
22parser.add_option("--pushto", help="push to a git url on success",
23 default=None, type='str')
24parser.add_option("--rebase", help="rebase on the given tree before testing", default=None, type='str')
25parser.add_option("--passcmd", help="command to run on success", default=None)
26parser.add_option("--tail", help="show output while running", default=False, action="store_true")
27parser.add_option("--keeplogs", help="keep logs", default=False, action="store_true")
28parser.add_option("--nocleanup", help="don't remove test tree", default=False, action="store_true")
29parser.add_option("--revision", help="revision to compile if not HEAD", default=None, type=str)
30parser.add_option("--fix-whitespace", help="fix whitespace on rebase",
31 default=False, action="store_true")
32parser.add_option("--fail-slowly", help="continue running tests even after one has already failed",
33 action="store_true")
34
35(opts, extra_args) = parser.parse_args()
36
37if opts.email is None and os.getenv("EMAIL") is not None:
38 opts.email = os.getenv("EMAIL")
39
40if opts.email:
41 print "Sending email to %s" % opts.email
42
43if not opts.foreground and not opts.email:
44 print "Not running in foreground and --email not specified."
45 sys.exit(1)
46
47if not opts.foreground and opts.push_master:
48 print "Pushing to master, forcing run in foreground."
49 opts.foreground = True
50
51if not opts.remote_repo:
52 print "%s$ mktemp -d" % opts.host
53 f = subprocess.Popen(["ssh", opts.host, "mktemp", "-d"], stdout=subprocess.PIPE)
54 (stdout, stderr) = f.communicate()
55 if f.returncode != 0:
56 sys.exit(1)
57 remote_repo = stdout.rstrip()
58 print "Remote tempdir: %s" % remote_repo
59 # Bootstrap, git.samba.org is usually more easily accessible.
60 #remote_args = ["git", "clone", samba_master, remote_repo]
61 remote_args = ["if [ -d /data/git/samba.git ]; then git clone --shared /data/git/samba.git %s; else git clone --shared %s %s; fi" % (remote_repo, samba_master, remote_repo)]
62 #remote_args = ["git", "init", remote_repo]
63 print "%s$ %s" % (opts.host, " ".join(remote_args))
64 subprocess.check_call(["ssh", opts.host] + remote_args)
65else:
66 remote_repo = opts.remote_repo
67
68print "Pushing local branch"
69
70if opts.revision is not None:
71 revision = opts.revision
72else:
73 revision = "HEAD"
74args = ["git", "push", "--force", "git+ssh://%s/%s" % (opts.host, remote_repo), "%s:land" % revision]
75print "$ " + " ".join(args)
76subprocess.check_call(args)
77remote_args = ["cd", remote_repo, ";", "git", "checkout", "land", ";", "python", "-u", "./script/land.py", "--repository=%s" % remote_repo]
78
79if (opts.email and not (opts.foreground or opts.pushto or opts.push_master)):
80 # Force always emailing if there's nothing else to do
81 opts.always_email = True
82
83if opts.email:
84 remote_args.append("--email=%s" % opts.email)
85if opts.always_email:
86 remote_args.append("--always-email")
87if not opts.foreground:
88 remote_args.append("--daemon")
89if opts.nocleanup:
90 remote_args.append("--nocleanup")
91if opts.fix_whitespace:
92 remote_args.append("--fix-whitespace")
93if opts.tail:
94 remote_args.append("--tail")
95if opts.keeplogs:
96 remote_args.append("--keeplogs")
97if opts.rebase_master:
98 remote_args.append("--rebase-master")
99if opts.rebase:
100 remote_args.append("--rebase=%s" % opts.rebase)
101if opts.passcmd:
102 remote_args.append("--passcmd=%s" % opts.passcmd)
103if opts.pushto:
104 remote_args.append("--pushto=%s" % opts.pushto)
105if opts.push_master:
106 remote_args.append("--push-master")
107if opts.fail_slowly:
108 remote_args.append("--fail-slowly")
109
110remote_args += extra_args
111print "%s$ %s" % (opts.host, " ".join(remote_args))
112args = ["ssh", "-A", opts.host] + remote_args
113sys.exit(subprocess.call(args))
Note: See TracBrowser for help on using the repository browser.