Depend on 0compile using the feed
authorThomas Leonard <talex5@gmail.com>
Thu, 28 Feb 2013 09:45:57 +0000 (28 09:45 +0000)
committerThomas Leonard <talex5@gmail.com>
Thu, 28 Feb 2013 10:00:32 +0000 (28 10:00 +0000)
We only need 0compile when releasing compiled binaries. The process was:

1. master runs user command on slave, typically "0launch .../0release.xml --build-slave"
2. the 0release build slave runs "0launch .../0compile.xml"

Now, we add a new <command name='build-slave'> with a 0compile dependency. So:

1. master runs user command on slave, typically "0launch --command=build-slave .../0release.xml"

This means we only need to run 0install once.

0release.xml
compile.py
tests/testrelease.py

index 3c456bb..f407490 100644 (file)
 
   <group license="OSI Approved :: GNU Lesser General Public License (LGPL)" main="0release">
     <command name="run" path="0release">
-      <runner interface="http://repo.roscidus.com/python/python">
-       <version before="3"/>
-      </runner>
+      <runner interface="http://repo.roscidus.com/python/python"/>
+    </command>
+    <command name="build-slave" path="0release">
+      <runner interface="http://repo.roscidus.com/python/python"/>
+      <arg>--build-slave</arg>
+      <requires interface='http://0install.net/2006/interfaces/0compile.xml'>
+       <version not-before='0.30'/>
+       <executable-in-var name='0COMPILE'/>
+      </requires>
     </command>
     <command name="test" path="tests/testall.py">
-      <runner interface="http://repo.roscidus.com/python/python">
-       <version before="3"/>
-      </runner>
+      <runner interface="http://repo.roscidus.com/python/python"/>
       <executable-in-path name="0release"/>
       <requires interface="http://repo.roscidus.com/devel/make">
        <executable-in-path name="make"/>
       </requires>
     </command>
+    <requires interface="http://repo.roscidus.com/python/python">
+      <version before="3"/>
+    </requires>
     <requires interface="http://0install.net/2006/interfaces/0publish">
       <version not-before="0.17"/>
       <environment if-0install-version="..!1.13" insert="0publish" mode="replace" name="0PUBLISH"/>
index 573f86d..aa80035 100644 (file)
@@ -1,15 +1,13 @@
 # Copyright (C) 2009, Thomas Leonard
 # See the README file for details, or visit http://0install.net.
 
-import tempfile, shutil, os
+import tempfile, shutil, os, sys
 import ConfigParser
 from logging import info
 from zeroinstall.support import basedir
 
 import support
 
-COMPILE = 'http://0install.net/2006/interfaces/0compile.xml'
-
 class Compiler:
        def __init__(self, options, src_feed_name):
                self.src_feed_name = src_feed_name
@@ -24,7 +22,8 @@ class Compiler:
                self.config.set('global', 'builders', 'host')
 
                self.config.add_section('builder-host')
-               self.config.set('builder-host', 'build', '0launch --not-before 0.10 http://0install.net/2007/interfaces/0release.xml --build-slave "$@"')
+               #self.config.set('builder-host', 'build', '0launch --not-before 0.10 http://0install.net/2007/interfaces/0release.xml --build-slave "$@"')
+               self.config.set('builder-host', 'build', '0launch --command=build-slave http://0install.net/2007/interfaces/0release.xml "$@"')
 
                self.src_impl = support.get_singleton_impl(self.src_feed)
                if self.src_impl.arch and self.src_impl.arch.endswith('-src'):
@@ -95,6 +94,14 @@ class Compiler:
 
 # This is the actual build process, running on the build machine
 def build_slave(src_feed, archive_file, archive_dir_public_url, target_feed):
+       try:
+               COMPILE = [os.environ['0COMPILE']]
+       except KeyError:
+               print >>sys.stdout, ("\n\n*****\n"
+                       "Please update your ~/.config/0install.net/0release/builders.conf file to use --command=build-slave."
+                       "\n*****\n\n")
+               COMPILE = ['0launch', '--not-before=0.30', 'http://0install.net/2006/interfaces/0compile.xml']
+
        feed = support.load_feed(src_feed)
 
        src_feed = os.path.abspath(src_feed)
@@ -125,8 +132,8 @@ def build_slave(src_feed, archive_file, archive_dir_public_url, target_feed):
                finally:
                        stream.close()
 
-               support.check_call(['0launch', '--not-before=0.30', COMPILE, 'build'], cwd = tmpdir)
-               support.check_call(['0launch', '--not-before=0.30', COMPILE, 'publish', '--target-feed', target_feed], cwd = tmpdir)
+               support.check_call(COMPILE + ['build'], cwd = tmpdir)
+               support.check_call(COMPILE + ['publish', '--target-feed', target_feed], cwd = tmpdir)
 
                # TODO: run unit-tests
 
index 3add727..b1b00a9 100755 (executable)
@@ -8,6 +8,7 @@ from zeroinstall.injector.config import load_config
 from zeroinstall.support import basedir, ro_rmtree
 
 sys.path.insert(0, '..')
+os.environ['http_proxy'] = 'localhost:1111'    # Prevent accidental network access
 
 import support