[Buildbot-commits] buildbot/buildbot/scripts runner.py,1.22,1.23 sample.mk,1.2,NONE

Brian Warner warner at users.sourceforge.net
Tue May 17 20:04:22 UTC 2005


Update of /cvsroot/buildbot/buildbot/buildbot/scripts
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9329/buildbot/scripts

Modified Files:
	runner.py 
Removed Files:
	sample.mk 
Log Message:
Revision: arch at buildbot.sf.net--2004/buildbot--dev--0--patch-191
Creator:  Brian Warner <warner at monolith.lothar.com>

clean up 'buildbot start', change to Makefile.buildbot

	* buildbot/scripts/runner.py (start): change 'buildbot start' to
	look for Makefile.buildbot instead of a bare Makefile . The
	'buildbot start' does not install this file, so you have to
	manually copy it if you want to customize startup behavior.
	(createMaster): change 'buildbot master' command to create
	Makefile.sample instead of Makefile, to create master.cfg.sample
	instead of master.cfg (requiring you to copy it before the
	buildmaster can be started). Both sample files are kept up to
	date, i.e. they are overwritten if they have been changed. The
	'buildbot.tac' file is *not* overwritten, but if the new contents
	don't match the old, a 'buildbot.tac.new' file is created and the
	user is warned. This seems to be a much more sane way to handle
	startup files. Also, don't sys.exit(0) when done, so we can run
	unit tests against it.
	(createSlave): same. Don't overwrite the sample info/ files.
	* buildbot/scripts/sample.mk: remove. the contents were pulled
	into runner.py, since they need to match the behavior of start()
	* setup.py: same
	* MANIFEST.in: same


Index: runner.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/scripts/runner.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- runner.py	17 May 2005 03:36:54 -0000	1.22
+++ runner.py	17 May 2005 20:04:09 -0000	1.23
@@ -34,6 +34,28 @@
             raise usage.UsageError("<basedir> parameter is required")
         self['basedir'] = os.path.abspath(self['basedir'])
 
+makefile_sample = """
+# -*- makefile -*-
+
+# This is a simple makefile which lives in a buildmaster/buildslave
+# directory (next to the buildbot.tac file). It allows you to start/stop the
+# master or slave by doing 'make start' or 'make stop'.
+
+# The 'reconfig' target will tell a buildmaster to reload its config file.
+
+start:
+	twistd --no_save -y buildbot.tac
+
+stop:
+	kill `cat twistd.pid`
+
+reconfig:
+	kill -HUP `cat twistd.pid`
+
+log:
+	tail -f twistd.log
+"""
+
 class Maker:
     def __init__(self, config):
         self.config = config
@@ -42,31 +64,37 @@
         self.quiet = config['quiet']
 
     def mkdir(self):
-        if os.path.exists(self.basedir) and not self.force:
-            print ("basedir %s already exists and --force not used"
-                   % self.basedir)
-            print "refusing to touch existing setup"
-            sys.exit(1)
-        if not os.path.exists(self.basedir):
-            if not self.quiet: print "mkdir", self.basedir
-            os.mkdir(self.basedir)
+        if os.path.exists(self.basedir):
+            if not self.quiet:
+                print "updating existing installation"
+            return
+        if not self.quiet: print "mkdir", self.basedir
+        os.mkdir(self.basedir)
 
     def mkinfo(self):
         path = os.path.join(self.basedir, "info")
         if not os.path.exists(path):
             if not self.quiet: print "mkdir", path
             os.mkdir(path)
+        created = False
         admin = os.path.join(path, "admin")
         if not os.path.exists(admin):
+            if not self.quiet:
+                print "Creating info/admin, you need to edit it appropriately"
             f = open(admin, "wt")
             f.write("Your Name Here <admin at youraddress.invalid>\n")
             f.close()
+            created = True
         host = os.path.join(path, "host")
         if not os.path.exists(host):
+            if not self.quiet:
+                print "Creating info/host, you need to edit it appropriately"
             f = open(host, "wt")
             f.write("Please put a description of this build host here\n")
             f.close()
-        print "Please edit the files in %s appropriately." % path
+            created = True
+        if created and not self.quiet:
+            print "Please edit the files in %s appropriately." % path
 
     def chdir(self):
         if not self.quiet: print "chdir", self.basedir
@@ -77,10 +105,12 @@
         if os.path.exists(tacfile):
             oldcontents = open(tacfile, "rt").read()
             if oldcontents == contents:
-                print "buildbot.tac already exists and is correct"
+                if not self.quiet:
+                    print "buildbot.tac already exists and is correct"
                 return
-            print "not touching existing buildbot.tac"
-            print "creating buildbot.tac.new instead"
+            if not self.quiet:
+                print "not touching existing buildbot.tac"
+                print "creating buildbot.tac.new instead"
             tacfile = "buildbot.tac.new"
         f = open(tacfile, "wt")
         f.write(contents)
@@ -103,21 +133,40 @@
         f.write(contents)
         f.close()
 
-    def makefile(self, source):
-        target = "Makefile"
+    def makefile(self):
+        target = "Makefile.sample"
         if os.path.exists(target):
-            print "not touching existing Makefile"
-            print "installing sample in Makefile.sample instead"
-            target = "Makefile.sample"
-        shutil.copy(source, target)
+            oldcontents = open(target, "rt").read()
+            if oldcontents == makefile_sample:
+                if not self.quiet:
+                    print "Makefile.sample already exists and is correct"
+                return
+            if not self.quiet:
+                print "replacing Makefile.sample"
+        else:
+            if not self.quiet:
+                print "creating Makefile.sample"
+        f = open(target, "wt")
+        f.write(makefile_sample)
+        f.close()
 
     def sampleconfig(self, source):
-        target = "master.cfg"
+        target = "master.cfg.sample"
+        config_sample = open(source, "rt").read()
         if os.path.exists(target):
-            print "not touching existing master.cfg"
-            print "installing sample in master.cfg.sample instead"
-            target = "master.cfg.sample"
-        shutil.copy(source, target)
+            oldcontents = open(target, "rt").read()
+            if oldcontents == config_sample:
+                if not self.quiet:
+                    print "master.cfg.sample already exists and is up-to-date"
+                return
+            if not self.quiet:
+                print "replacing master.cfg.sample"
+        else:
+            if not self.quiet:
+                print "creating master.cfg.sample"
+        f = open(target, "wt")
+        f.write(config_sample)
+        f.close()
         os.chmod(target, 0600)
 
 class MasterOptions(MakerBase):
@@ -161,10 +210,9 @@
     contents = masterTAC % config
     m.makeTAC(contents)
     m.sampleconfig(util.sibpath(__file__, "sample.cfg"))
-    m.makefile(util.sibpath(__file__, "sample.mk"))
+    m.makefile()
 
     if not m.quiet: print "buildmaster configured in %s" % m.basedir
-    sys.exit(0)
 
 class SlaveOptions(MakerBase):
     optFlags = [
@@ -247,20 +295,20 @@
 
     m.makeTAC(contents, secret=True)
 
-    m.makefile(util.sibpath(__file__, "sample.mk"))
+    m.makefile()
     m.mkinfo()
 
     if not m.quiet: print "buildslave configured in %s" % m.basedir
-    sys.exit(0)
+
 
 def start(config):
     basedir = config['basedir']
     quiet = config['quiet']
     os.chdir(basedir)
-    if os.path.exists("/usr/bin/make") and os.path.exists("Makefile"):
-        # yes, this is clunky. Preferring the Makefile lets slave admins do
-        # useful things like set up environment variables for the buildslave.
-        cmd = "make start"
+    if os.path.exists("/usr/bin/make") and os.path.exists("Makefile.buildbot"):
+        # Preferring the Makefile lets slave admins do useful things like set
+        # up environment variables for the buildslave.
+        cmd = "make -f Makefile.buildbot start"
         if not quiet: print cmd
         os.system(cmd)
     else:

--- sample.mk DELETED ---





More information about the Commits mailing list