[SCM] Samba Shared Repository - branch master updated

Jelmer Vernooij jelmer at samba.org
Tue Sep 21 17:07:50 MDT 2010


The branch, master has been updated
       via  93c9582 s4: Add script for landing a branch through a remote server, such as sn.
       via  fd25d67 s4: Add convenience script for building and landing a tree in the background, sending results by email.
      from  049c4fa pytalloc: Add default compare function.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 93c95824c754384f12891f1c8daf527e178a2bff
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Sep 21 15:54:34 2010 -0700

    s4: Add script for landing a branch through a remote server, such as sn.

commit fd25d67d0d7a0837dfcba882cf60700189a41f37
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Sep 21 14:18:21 2010 -0700

    s4: Add convenience script for building and landing a tree in the
    background, sending results by email.

-----------------------------------------------------------------------

Summary of changes:
 source4/script/land-remote.py |   40 ++++++++++++++
 source4/script/land.py        |  118 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 158 insertions(+), 0 deletions(-)
 create mode 100755 source4/script/land-remote.py
 create mode 100755 source4/script/land.py


Changeset truncated at 500 lines:

diff --git a/source4/script/land-remote.py b/source4/script/land-remote.py
new file mode 100755
index 0000000..2ac1eb6
--- /dev/null
+++ b/source4/script/land-remote.py
@@ -0,0 +1,40 @@
+#!/usr/bin/python
+# Land a branch by building and testing it on sn-104 before landing it on master.
+# Copyright (C) 2010 Jelmer Vernooij <jelmer at samba.org>
+# Published under the GPL, v3 or later
+
+import os
+import optparse
+import subprocess
+import sys
+
+parser = optparse.OptionParser("land-remote [options]")
+parser.add_option("--host", help="Host to land on (SSH connection string)", type=str, default="sn-devel-104.sn.samba.org")
+parser.add_option("--dry-run", help="Dry run (don't actually land)", action="store_true", default=False)
+parser.add_option("--foreground", help="Don't daemonize", action="store_true", default=False)
+parser.add_option("--mail-to", help="Email address to send build/test output to", type=str, default=None, metavar="MAIL-TO")
+
+(opts, args) = parser.parse_args()
+
+f = subprocess.Popen(["ssh", opts.host, "mktemp", "-d"], stdout=subprocess.PIPE)
+(stdout, stderr) = f.communicate()
+remote_tmpdir = stdout.rstrip()
+
+print "Remote tempdir: %s" % remote_tmpdir
+
+if subprocess.call(["ssh", opts.host, "git", "clone", "git://git.samba.org/samba.git", "%s/repo" % remote_tmpdir]) != 0:
+    sys.exit(1)
+
+print "Pushing local branch"
+subprocess.call(["git", "push", "--force", "git+ssh://%s/%s/repo" % (opts.host, remote_tmpdir), "HEAD:refs/heads/land"])
+args = ["ssh", "-A", opts.host, "python", "%s/repo/source4/script/land.py" % remote_tmpdir]
+if opts.mail_to:
+    args.append("--mail-to=%s" % opts.mail_to)
+if not opts.foreground:
+    args.append("--daemon")
+if opts.dry_run:
+    args.append("--dry-run")
+args.append("--branch=land")
+args.append(os.path.join(remote_tmpdir, "repo"))
+print "Running remotely: %s" % " ".join(args)
+sys.exit(subprocess.call(args))
diff --git a/source4/script/land.py b/source4/script/land.py
new file mode 100755
index 0000000..69f386b
--- /dev/null
+++ b/source4/script/land.py
@@ -0,0 +1,118 @@
+#!/usr/bin/python
+# Compile a Samba 4 branch from scratch and land it onto master.
+# (C) 2010 Jelmer Vernooij <jelmer at samba.org>
+# Published under the GPL, v3 or later.
+
+from email.mime.text import MIMEText
+import optparse
+import os
+import shutil
+import smtplib
+import subprocess
+import sys
+import tempfile
+
+parser = optparse.OptionParser("land [options] <repo>")
+parser.add_option("--branch", help="Branch to land", type=str, default=None, metavar="BRANCH")
+parser.add_option("--dry-run", help="Dry run (don't actually land)", action="store_true", default=False)
+parser.add_option("--daemon", help="Daemonize", action="store_true", default=False)
+parser.add_option("--mail-to", help="Email address to send build/test output to", type=str, default=None, metavar="MAIL-TO")
+
+(opts, args) = parser.parse_args()
+
+if opts.mail_to:
+    from_addr = opts.mail_to
+    smtp = smtplib.SMTP()
+
+if len(args) != 1:
+    parser.print_usage()
+    sys.exit(1)
+
+[repo] = args
+tmpdir = tempfile.mkdtemp()
+rootpath = os.path.join(tmpdir, "repo")
+
+if subprocess.call(["git", "clone", repo, rootpath]) != 0:
+    print "Unable to clone repository at %s" % repo
+    sys.exit(1)
+
+if opts.branch:
+    if subprocess.call(["git", "checkout", opts.branch], cwd=rootpath) != 0:
+        sys.exit(1)
+if subprocess.call(["git", "remote", "add", "upstream", "git://git.samba.org/samba.git"], cwd=rootpath) != 0:
+    sys.exit(1)
+if subprocess.call(["git", "fetch", "upstream"], cwd=rootpath) != 0:
+    sys.exit(1)
+if subprocess.call(["git", "rebase", "upstream/master"], cwd=rootpath) != 0:
+    sys.exit(1)
+
+if opts.daemon:
+    pid = os.fork()
+    if pid == 0: # Parent
+        os.setsid()
+        pid = os.fork()
+        if pid != 0: # Actual daemon
+            os._exit(0)
+    else: # Grandparent
+        os._exit(0)
+
+    import resource      # Resource usage information.
+    maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1]
+    if maxfd == resource.RLIM_INFINITY:
+        maxfd = 1024 # Rough guess at maximum number of open file descriptors.
+    for fd in range(0, maxfd):
+        try:
+            os.close(fd)
+        except OSError:
+            pass
+    os.open(os.devnull, os.O_RDWR)
+    os.dup2(0, 1)
+    os.dup2(0, 2)
+
+if opts.mail_to:
+    (outfd, name) = tempfile.mkstemp()
+    outf = os.fdopen(outfd, 'w')
+else:
+    outf = sys.stdout
+
+def fail(stage):
+    if opts.mail_to:
+        outf.close()
+        f = open(name, 'r')
+        msg = MIMEText(f.read())
+        f.close()
+        msg["Subject"] = "Failure for %s during %s" % (repo, stage)
+        msg["To"] = opts.mail_to
+        msg["From"] = from_addr
+        smtp.connect()
+        smtp.sendmail(from_addr, [opts.mail_to], msg.as_string())
+        smtp.quit()
+    shutil.rmtree(tmpdir)
+    sys.exit(1)
+
+s4path = os.path.join(rootpath, "source4")
+
+if subprocess.call(["./autogen.sh"], cwd=s4path, stdout=outf, stderr=outf) != 0:
+    fail("Generating configure")
+if subprocess.call(["./configure.developer"], cwd=s4path, stdout=outf, stderr=outf) != 0:
+    fail("Running configure")
+if subprocess.call(["make"], cwd=s4path, stderr=outf, stdout=outf) != 0:
+    fail("Building")
+if subprocess.call(["make", "check"], cwd=s4path, stderr=outf, stdout=outf) != 0:
+    fail("Running testsuite")
+if not opts.dry_run:
+    if subprocess.call(["git", "push", "git+ssh://git.samba.org/data/git/samba.git", "HEAD:master"], cwd=rootpath, stderr=outf, stdout=outf) != 0:
+        fail("Pushing to master")
+shutil.rmtree(tmpdir)
+
+if opts.mail_to:
+    outf.close()
+    f = open(name, 'r')
+    msg = MIMEText(f.read())
+    f.close()
+    msg["Subject"] = "Success landing %s" % repo
+    msg["To"] = opts.mail_to
+    msg["From"] = from_addr
+    smtp.connect()
+    smtp.sendmail(from_addr, [opts.mail_to], msg.as_string())
+    smtp.quit()


-- 
Samba Shared Repository


More information about the samba-cvs mailing list