Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/devbot
diff options
context:
space:
mode:
Diffstat (limited to 'devbot')
-rwxr-xr-xdevbot/autoinstall.py52
-rw-r--r--devbot/build.py12
-rw-r--r--devbot/config.py6
3 files changed, 64 insertions, 6 deletions
diff --git a/devbot/autoinstall.py b/devbot/autoinstall.py
new file mode 100755
index 0000000..ed94b1e
--- /dev/null
+++ b/devbot/autoinstall.py
@@ -0,0 +1,52 @@
+#!/usr/bin/python
+
+from distutils.sysconfig import parse_makefile
+import os
+import shutil
+
+import common
+
+from gi.repository import Gio
+from gi.repository import GLib
+
+from devbot import config
+
+monitors = []
+
+def install(module, file):
+ print "Installing %s" % file.get_path()
+
+ source_dir = config.get_module_source_dir(module)
+ build_dir = config.get_module_build_dir(module)
+
+ dir = os.path.dirname(file.get_path())
+ relative_path = os.path.relpath(dir, source_dir)
+ makefile_path = os.path.join(build_dir, relative_path, "Makefile")
+ makefile = parse_makefile(makefile_path)
+
+ for variable in makefile:
+ if variable.endswith("_PYTHON"):
+ dir_variable = "%sdir" % variable.replace("_PYTHON", "")
+ install_dir = makefile[dir_variable]
+ shutil.copy(file.get_path(), install_dir)
+
+def changed_cb(monitor, file, other_file, event_flags, module):
+ if event_flags == Gio.FileMonitorEvent.CHANGED:
+ if file.get_path().endswith(".py"):
+ install(module, file)
+
+def observe():
+ for module in config.load_modules():
+ if module.get("autoinstall", False):
+ source_dir = config.get_module_source_dir(module)
+ for root, dirs, files in os.walk(source_dir):
+ for dir in dirs:
+ file = Gio.File.new_for_path(os.path.join(root, dir))
+ monitor = file.monitor(Gio.FileMonitorFlags.NONE, None)
+ monitor.connect("changed", changed_cb, module)
+
+ monitors.append(monitor)
+
+
+ main_loop = GLib.MainLoop()
+ main_loop.run()
diff --git a/devbot/build.py b/devbot/build.py
index fbf45b1..4d09b0d 100644
--- a/devbot/build.py
+++ b/devbot/build.py
@@ -46,7 +46,7 @@ def get_module_build_dir(module):
def get_module_commit_id(module):
orig_cwd = os.getcwd()
- os.chdir(get_module_source_dir(module))
+ os.chdir(config.get_module_source_dir(module))
commit_id = subprocess.check_output(["git", "rev-parse", "HEAD"])
@@ -64,7 +64,7 @@ def unlink_libtool_files():
os.chdir(orig_cwd)
def pull_source(module):
- module_dir = get_module_source_dir(module)
+ module_dir = config.get_module_source_dir(module)
if os.path.exists(module_dir):
os.chdir(module_dir)
@@ -81,7 +81,7 @@ def pull_source(module):
command.run(["git", "checkout", branch])
def build_autotools(module):
- autogen = os.path.join(get_module_source_dir(module), "autogen.sh")
+ autogen = os.path.join(config.get_module_source_dir(module), "autogen.sh")
jobs = multiprocessing.cpu_count() * 2
@@ -98,10 +98,10 @@ def build_activity(module):
command.run(["./setup.py", "install", "--prefix", config.install_dir])
def build_module(module):
- module_source_dir = get_module_source_dir(module)
+ module_source_dir = config.get_module_source_dir(module)
if module.get("out-of-source", True):
- module_build_dir = get_module_build_dir(module)
+ module_build_dir = config.get_module_build_dir(module)
if not os.path.exists(module_build_dir):
os.mkdir(module_build_dir)
@@ -161,4 +161,4 @@ def clean():
for module in config.load_modules():
if not module.get("out-of-source", True):
- rmtree(get_module_source_dir(module))
+ rmtree(config.get_module_source_dir(module))
diff --git a/devbot/config.py b/devbot/config.py
index bfcc966..3207584 100644
--- a/devbot/config.py
+++ b/devbot/config.py
@@ -60,6 +60,12 @@ def set_commands_dir(dir):
global commands_dir
commands_dir = dir
+def get_module_source_dir(module):
+ return os.path.join(source_dir, module["name"])
+
+def get_module_build_dir(module):
+ return os.path.join(build_dir, module["name"])
+
def load_packages():
return _load_deps_json("packages-%s" % distro.get_system_version())