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')
-rw-r--r--devbot/build.py17
-rw-r--r--devbot/command.py3
-rw-r--r--devbot/config.py29
-rw-r--r--devbot/distro.py13
-rw-r--r--devbot/environ.py16
-rw-r--r--devbot/git.py10
-rw-r--r--devbot/plugins/debian.py11
-rw-r--r--devbot/plugins/fedora.py4
-rw-r--r--devbot/plugins/interfaces.py4
-rw-r--r--devbot/plugins/ubuntu.py12
-rw-r--r--devbot/plugins/unknown.py4
-rw-r--r--devbot/release.py6
-rw-r--r--devbot/run.py5
-rw-r--r--devbot/shell.py1
-rw-r--r--devbot/state.py13
-rw-r--r--devbot/system.py44
-rw-r--r--devbot/test.py3
-rw-r--r--devbot/utils.py1
-rw-r--r--devbot/xvfb.py7
19 files changed, 156 insertions, 47 deletions
diff --git a/devbot/build.py b/devbot/build.py
index 5ea9422..5c35999 100644
--- a/devbot/build.py
+++ b/devbot/build.py
@@ -16,6 +16,7 @@ from devbot import release
_builders = {}
_distributors = {}
+
def build_one(module_name):
environ.setup()
@@ -25,6 +26,7 @@ def build_one(module_name):
return False
+
def pull_one(module_name):
environ.setup()
@@ -34,6 +36,7 @@ def pull_one(module_name):
return False
+
def pull():
environ.setup()
@@ -43,6 +46,7 @@ def pull():
return True
+
def build(full=False):
if full or state.full_build_is_required():
state.clean_build_state()
@@ -64,6 +68,7 @@ def build(full=False):
return True
+
def distribute():
environ.setup()
@@ -74,6 +79,7 @@ def distribute():
return True
+
def clean():
_empty_dir(config.install_dir)
_empty_dir(config.get_build_dir())
@@ -83,13 +89,16 @@ def clean():
if module.get_git_module().clean():
print "Cleaned %s git repository." % module.name
+
def _ccache_reset():
subprocess.check_call(["ccache", "-z"], stdout=utils.devnull)
+
def _ccache_print_stats():
print "\n=== ccache statistics ===\n"
subprocess.check_call(["ccache", "-s"])
+
def _unlink_libtool_files():
def func(arg, dirname, fnames):
for fname in fnmatch.filter(fnames, "*.la"):
@@ -97,6 +106,7 @@ def _unlink_libtool_files():
os.path.walk(config.lib_dir, func, None)
+
def _pull_module(module):
print "\n=== Pulling %s ===\n" % module.name
@@ -107,9 +117,11 @@ def _pull_module(module):
return True
+
def _eval_option(option):
return eval(option, {"prefix": config.prefix_dir})
+
def _build_autotools(module, log):
# Workaround for aclocal 1.11 (fixed in 1.12)
aclocal_path = os.path.join(config.share_dir, "aclocal")
@@ -139,12 +151,14 @@ def _build_autotools(module, log):
_builders["autotools"] = _build_autotools
+
def _build_activity(module, log):
setup = os.path.join(module.get_source_dir(), "setup.py")
command.run([setup, "install", "--prefix", config.prefix_dir], log)
_builders["activity"] = _build_activity
+
def _distribute_autotools(module):
makefile = parse_makefile("Makefile")
filename = makefile["DIST_ARCHIVES"]
@@ -184,6 +198,7 @@ def _distribute_autotools(module):
_distributors["autotools"] = _distribute_autotools
+
def _build_module(module, log=None):
print "\n=== Building %s ===\n" % module.name
@@ -217,6 +232,7 @@ def _build_module(module, log=None):
return True
+
def _distribute_module(module, log=None):
print "\n=== Distribute %s ===\n" % module.name
@@ -240,6 +256,7 @@ def _distribute_module(module, log=None):
return True
+
def _empty_dir(dir_path):
print "Emptying %s directory" % dir_path
shutil.rmtree(dir_path, ignore_errors=True)
diff --git a/devbot/command.py b/devbot/command.py
index aaef58f..8ccef6c 100644
--- a/devbot/command.py
+++ b/devbot/command.py
@@ -3,10 +3,12 @@ import time
_logger = None
+
def set_logger(logger):
global _logger
_logger = logger
+
def run(args, log=None, test=False, retry=0):
print " ".join(args)
if test:
@@ -30,6 +32,7 @@ def run(args, log=None, test=False, retry=0):
else:
raise e
+
def run_with_sudo(args, test=False, retry=0):
args_with_sudo = ["sudo"]
args_with_sudo.extend(args)
diff --git a/devbot/config.py b/devbot/config.py
index a66a196..4c129eb 100644
--- a/devbot/config.py
+++ b/devbot/config.py
@@ -27,6 +27,7 @@ _source_dir = None
_build_dir = None
_prefs_path = None
+
class Module:
def __init__(self, info):
self.name = info["name"]
@@ -66,6 +67,7 @@ class Module:
"delete it and pull\nthe source again."
return None
+
def setup(**kwargs):
_load_plugins()
@@ -90,6 +92,7 @@ def setup(**kwargs):
_setup_state_dir(kwargs["state_dir"])
_setup_install_dir(kwargs["install_dir"], relocatable)
+
def _setup_state_dir(state_dir):
utils.ensure_dir(state_dir)
@@ -104,6 +107,7 @@ def _setup_state_dir(state_dir):
home_dir = os.path.join(base_home_dir, get_pref("PROFILE"))
utils.ensure_dir(home_dir)
+
def _setup_prefix_dir(dir, relocatable):
global prefix_dir
@@ -129,6 +133,7 @@ def _setup_prefix_dir(dir, relocatable):
os.remove(prefix_dir)
os.symlink(dir, prefix_dir)
+
def _setup_install_dir(dir, relocatable=False):
global system_lib_dirs
global install_dir
@@ -161,16 +166,19 @@ def _setup_install_dir(dir, relocatable=False):
if distro_info.lib_dir is not None:
system_lib_dirs.append(os.path.join("/usr", distro_info.lib_dir))
+
def get_source_dir():
global _source_dir
utils.ensure_dir(_source_dir)
return _source_dir
+
def get_build_dir():
global _build_dir
utils.ensure_dir(_build_dir)
return _build_dir
+
def _read_prefs():
global _prefs_path
@@ -186,6 +194,7 @@ def _read_prefs():
return prefs
+
def _save_prefs(prefs):
global _prefs_path
@@ -196,6 +205,7 @@ def _save_prefs(prefs):
for pref in prefs.items():
f.write("%s\n" % "=".join(pref))
+
def get_log_path(prefix):
logfile_path = None
number = 0
@@ -211,31 +221,36 @@ def get_log_path(prefix):
return logfile_path
+
def get_pref(name):
- defaults = { "PROFILE": "default" }
+ defaults = {"PROFILE": "default"}
prefs = _read_prefs()
return prefs.get(name, defaults.get(name, None))
+
def set_pref(name, value):
prefs = _read_prefs()
prefs[name] = value
_save_prefs(prefs)
+
def _load_plugins():
for loader, name, ispkg in pkgutil.iter_modules(plugins.__path__):
f, filename, desc = imp.find_module(name, plugins.__path__)
imp.load_module(name, f, filename, desc)
+
def _read_index(dir_name):
if config_dir is None:
return []
index_dir = os.path.join(config_dir, dir_name)
with open(os.path.join(index_dir, "index.json")) as f:
- return [os.path.join(index_dir, json_file) \
+ return [os.path.join(index_dir, json_file)
for json_file in json.load(f)]
+
def get_full_build():
config = None
with open(os.path.join(config_dir, "config.json")) as f:
@@ -243,6 +258,7 @@ def get_full_build():
return config["full_build"]
+
def load_packages():
packages = {}
@@ -251,20 +267,23 @@ def load_packages():
return packages
+
def load_prerequisites():
path = os.path.join(config_dir, "deps", "prerequisites.json")
return json.load(open(path))
+
def _filter_if(item):
if "if" not in item:
return True
distro_info = distro.get_distro_info()
- globals = { "gstreamer_version": distro_info.gstreamer_version,
- "gnome_version": distro_info.gnome_version }
+ globals = {"gstreamer_version": distro_info.gstreamer_version,
+ "gnome_version": distro_info.gnome_version}
return eval(item["if"], globals)
+
def load_checks():
checks = []
for path in _read_index("deps"):
@@ -272,6 +291,7 @@ def load_checks():
return filter(_filter_if, checks)
+
def load_modules():
modules = []
for path in _read_index("modules"):
@@ -280,6 +300,7 @@ def load_modules():
return [Module(info) for info in filter(_filter_if, modules)]
+
def clean():
try:
os.rmdir(logs_dir)
diff --git a/devbot/distro.py b/devbot/distro.py
index 951ea21..c44fff7 100644
--- a/devbot/distro.py
+++ b/devbot/distro.py
@@ -5,29 +5,34 @@ _package_managers = {}
_supported_distros = []
_distro_info = None
+
def register_distro_info(distro_info):
- global _supported_distros
- _supported_distros.append(distro_info)
+ global _supported_distros
+ _supported_distros.append(distro_info)
+
def register_package_manager(name, package_manager):
global _package_managers
_package_managers[name] = package_manager
+
def get_package_manager(test=False, interactive=True):
global _package_managers
package_manager_class = _package_managers[get_distro_info().name]
return package_manager_class(test=test, interactive=interactive)
+
def print_distro_info():
info = get_distro_info()
print "== Distribution information ==\n"
print "Name: %s" % info.name
print "Version: %s" % info.version
print "GNOME version: %s" % info.gnome_version
- print "Gstreamer version: %s" % info.gstreamer_version
+ print "Gstreamer version: %s" % info.gstreamer_version
print "Lib directory: %s" % info.lib_dir
print "Supported: %s\n" % info.supported
+
def get_distro_info():
global _supported_distros
global _distro_info
@@ -47,7 +52,7 @@ def get_distro_info():
if _distro_info is None:
_distro_info = unknown_distro
- if not _distro_info.supported:
+ if not _distro_info.supported:
print "*********************************************************\n" \
"You are running an unsupported distribution. You might be\n" \
"able to make sugar work by installing or building \n" \
diff --git a/devbot/environ.py b/devbot/environ.py
index e90b174..ae39c54 100644
--- a/devbot/environ.py
+++ b/devbot/environ.py
@@ -3,10 +3,12 @@ import os
from devbot import config
+
def setup():
_setup_gconf()
_setup_variables()
+
def add_path(name, path):
if not path.endswith("/"):
path = "%s/" % path
@@ -21,6 +23,7 @@ def add_path(name, path):
os.environ[name] = ":".join(splitted)
+
def _setup_variables():
add_path("LD_LIBRARY_PATH", config.lib_dir)
add_path("PATH", config.bin_dir)
@@ -30,7 +33,7 @@ def _setup_variables():
add_path("PKG_CONFIG_PATH",
os.path.join(config.lib_dir, "pkgconfig"))
add_path("GST_PLUGIN_PATH",
- os.path.join(config.lib_dir , "gstreamer-1.0"))
+ os.path.join(config.lib_dir, "gstreamer-1.0"))
add_path("PYTHONPATH",
sysconfig.get_python_lib(prefix=config.prefix_dir))
add_path("PYTHONPATH",
@@ -40,30 +43,31 @@ def _setup_variables():
os.path.dirname(os.path.dirname(__file__)))
add_path("ACLOCAL_PATH", "/usr/share/aclocal")
- add_path("ACLOCAL_FLAGS", "-I /usr/share/aclocal")
+ add_path("ACLOCAL_FLAGS", "-I /usr/share/aclocal")
add_path("XDG_DATA_DIRS", "/usr/share")
add_path("XDG_DATA_DIRS", config.share_dir)
add_path("XDG_CONFIG_DIRS", "/etc")
- add_path("XDG_CONFIG_DIRS", config.etc_dir)
+ add_path("XDG_CONFIG_DIRS", config.etc_dir)
for system_lib_dir in config.system_lib_dirs:
modules_path = os.path.join(system_lib_dir, "gio", "modules")
- if os.path.exists(modules_path):
+ if os.path.exists(modules_path):
add_path("GIO_EXTRA_MODULES", modules_path)
typelib_path = os.path.join(system_lib_dir, "girepository-1.0")
- if os.path.exists(typelib_path):
+ if os.path.exists(typelib_path):
add_path("GI_TYPELIB_PATH", typelib_path)
add_path("GI_TYPELIB_PATH",
os.path.join(config.lib_dir, "girepository-1.0"))
-
+
os.environ["GTK_DATA_PREFIX"] = config.prefix_dir
os.environ["GTK_PATH"] = os.path.join(config.lib_dir, "gtk-2.0")
os.environ["CC"] = "ccache gcc"
+
def _setup_gconf():
gconf_dir = os.path.join(config.etc_dir, "gconf")
gconf_pathdir = os.path.join(gconf_dir, "2")
diff --git a/devbot/git.py b/devbot/git.py
index 4a86bd6..4e7d86c 100644
--- a/devbot/git.py
+++ b/devbot/git.py
@@ -6,6 +6,7 @@ from devbot import utils
_root_path = None
+
def _chdir(func):
def wrapped(*args, **kwargs):
orig_cwd = os.getcwd()
@@ -18,6 +19,7 @@ def _chdir(func):
return wrapped
+
class Module:
def __init__(self, path=None, name=None, remote=None,
branch="master", tag=None, retry=10):
@@ -43,7 +45,7 @@ class Module:
if self.tag:
command.run(["git", "checkout", self.tag])
- else:
+ else:
command.run(["git", "checkout", self._branch])
def update(self):
@@ -68,7 +70,7 @@ class Module:
if revision is None:
revision = self._branch
- command.run(["git", "checkout", revision])
+ command.run(["git", "checkout", revision])
@_chdir
def describe(self):
@@ -93,7 +95,7 @@ class Module:
def get_annotation(self, tag):
# FIXME this is fragile, there must be a better way
- show = subprocess.check_output(["git", "show", tag])
+ show = subprocess.check_output(["git", "show", tag])
annotation = []
for line in show.split("\n"):
@@ -120,10 +122,12 @@ class Module:
return True
+
def set_root_path(path):
global _root_path
_root_path = path
+
def get_root_module():
remote = "git://git.sugarlabs.org/sugar-build/sugar-build.git"
diff --git a/devbot/plugins/debian.py b/devbot/plugins/debian.py
index 53e6bc4..26cb08c 100644
--- a/devbot/plugins/debian.py
+++ b/devbot/plugins/debian.py
@@ -5,6 +5,7 @@ from devbot import command
from devbot import distro
from devbot.plugins import interfaces
+
class PackageManager(interfaces.PackageManager):
def __init__(self, test=False, interactive=True):
import apt
@@ -70,7 +71,7 @@ class PackageManager(interfaces.PackageManager):
self._find_deps(dependency_name, result)
def find_with_deps(self, package_names):
- result = []
+ result = []
for package in package_names:
if package is not None:
@@ -83,11 +84,13 @@ class PackageManager(interfaces.PackageManager):
distro.register_package_manager("debian", PackageManager)
+
class DistroInfo(interfaces.DistroInfo):
_DEBIAN_VERSION_PATH = "/etc/debian_version"
+
def __init__(self):
- arch = self._get_architecture()
-
+ arch = self._get_architecture()
+
self.name = "debian"
self.version = "unknown"
self.gnome_version = "3.4"
@@ -116,6 +119,6 @@ class DistroInfo(interfaces.DistroInfo):
self.supported = False
def _get_architecture(self):
- return subprocess.check_output(["arch"]).strip()
+ return subprocess.check_output(["arch"]).strip()
distro.register_distro_info(DistroInfo)
diff --git a/devbot/plugins/fedora.py b/devbot/plugins/fedora.py
index df0aef7..3b6b694 100644
--- a/devbot/plugins/fedora.py
+++ b/devbot/plugins/fedora.py
@@ -5,6 +5,7 @@ from devbot import command
from devbot import distro
from devbot.plugins import interfaces
+
class PackageManager(interfaces.PackageManager):
def __init__(self, test=False, interactive=True):
self._test = test
@@ -72,7 +73,7 @@ class PackageManager(interfaces.PackageManager):
"--queryformat=[%{NAME} ]",
"--whatprovides"]
args.extend(filtered)
-
+
deps_packages = subprocess.check_output(args).strip()
for dep_package in deps_packages.split(" "):
if dep_package not in result:
@@ -81,6 +82,7 @@ class PackageManager(interfaces.PackageManager):
distro.register_package_manager("fedora", PackageManager)
+
class DistroInfo(interfaces.DistroInfo):
_FEDORA_RELEASE_PATH = "/etc/fedora-release"
diff --git a/devbot/plugins/interfaces.py b/devbot/plugins/interfaces.py
index 8c97c65..ecd2d3a 100644
--- a/devbot/plugins/interfaces.py
+++ b/devbot/plugins/interfaces.py
@@ -4,6 +4,7 @@ import subprocess
from devbot import command
from devbot import distro
+
class PackageManager:
"""Package management"""
@@ -33,6 +34,7 @@ class PackageManager:
:returns: list of packages with all the dependencies
"""
+
class DistroInfo:
"""Informations about the distribution"""
@@ -42,7 +44,7 @@ class DistroInfo:
self.version = None
"""The distribution version."""
-
+
self.gnome_version = None
"""The major version of GNOME shipped with the distribution."""
diff --git a/devbot/plugins/ubuntu.py b/devbot/plugins/ubuntu.py
index 005871c..dd0efde 100644
--- a/devbot/plugins/ubuntu.py
+++ b/devbot/plugins/ubuntu.py
@@ -6,11 +6,13 @@ from devbot.plugins import debian
distro.register_package_manager("ubuntu", debian.PackageManager)
+
class DistroInfo(interfaces.DistroInfo):
- _OS_RELEASE_PATH="/etc/os-release"
+ _OS_RELEASE_PATH = "/etc/os-release"
+
def __init__(self):
arch = self._get_architecture()
-
+
self.name = "ubuntu"
self.version = "unknown"
self.gnome_version = "3.4"
@@ -33,10 +35,10 @@ class DistroInfo(interfaces.DistroInfo):
except IOError:
release = None
self.valid = False
-
+
if os_info["ID"] != "ubuntu":
self.valid = False
-
+
self.version = os_info.get("VERSION_ID", None)
if self.version != "12.10":
@@ -46,6 +48,6 @@ class DistroInfo(interfaces.DistroInfo):
self.gnome_version = "3.6"
def _get_architecture(self):
- return subprocess.check_output(["uname", "-i"]).strip()
+ return subprocess.check_output(["uname", "-i"]).strip()
distro.register_distro_info(DistroInfo)
diff --git a/devbot/plugins/unknown.py b/devbot/plugins/unknown.py
index 576edef..5e3f530 100644
--- a/devbot/plugins/unknown.py
+++ b/devbot/plugins/unknown.py
@@ -5,6 +5,7 @@ from devbot import command
from devbot import distro
from devbot.plugins import interfaces
+
class PackageManager(interfaces.PackageManager):
def __init__(self, test=False, interactive=True):
pass
@@ -26,6 +27,7 @@ class PackageManager(interfaces.PackageManager):
distro.register_package_manager("unknown", PackageManager)
+
class DistroInfo(interfaces.DistroInfo):
def __init__(self):
self.lib_dir = None
@@ -35,5 +37,5 @@ class DistroInfo(interfaces.DistroInfo):
self.gstreamer_version = "0.10"
self.valid = True
self.supported = False
-
+
distro.register_distro_info(DistroInfo)
diff --git a/devbot/release.py b/devbot/release.py
index a9f5a64..c82f358 100644
--- a/devbot/release.py
+++ b/devbot/release.py
@@ -7,16 +7,19 @@ upload_root = "/upload/sources/sucrose/glucose"
download_uri = "http://download.sugarlabs.org/sources/sucrose/glucose"
announce_to = "sugar-devel@lists.sugarlabs.org"
+
def exists(module, filename):
release_path = os.path.join(upload_root, module.name, filename)
result = subprocess.call(["ssh", upload_host, "test", "-f", release_path])
return result == 0
+
def upload(module, path):
upload_path = os.path.join(upload_root, module.name)
upload_dest = "%s:%s" % (upload_host, upload_path)
return subprocess.call(["scp", path, upload_dest]) == 0
+
def announce(module, filename, version, annotation):
fd, announce_path = tempfile.mkstemp(prefix="announce-")
@@ -34,7 +37,7 @@ def announce(module, filename, version, annotation):
upload_dest = "%s:~" % upload_host
if subprocess.call(["scp", announce_path, upload_dest]) == 0:
announce_basename = os.path.basename(announce_path)
-
+
if subprocess.call(["ssh", upload_host, "sendmail", "-t",
"<", announce_basename]):
result = True
@@ -45,5 +48,6 @@ def announce(module, filename, version, annotation):
return result
+
def _get_email():
return subprocess.check_output(['git', 'config', 'user.email']).strip()
diff --git a/devbot/run.py b/devbot/run.py
index 110fe1a..34edab9 100644
--- a/devbot/run.py
+++ b/devbot/run.py
@@ -11,6 +11,7 @@ import tempfile
from devbot import environ
from devbot import config
+
def run(command):
environ.setup()
@@ -26,6 +27,7 @@ def run(command):
os.execlp(args[0], *args)
+
def run_test(command, test_path, virtual=False):
environ.setup()
@@ -60,6 +62,7 @@ def run_test(command, test_path, virtual=False):
return result
+
def collect_logs(source_path, log_name):
logs = {}
for filename in os.listdir(source_path):
@@ -82,6 +85,6 @@ def collect_logs(source_path, log_name):
os.symlink(log_path, last_log_path)
+
def _get_random_id():
return ''.join(random.choice(string.letters) for i in xrange(8))
-
diff --git a/devbot/shell.py b/devbot/shell.py
index 66f26f9..ba9dfc1 100644
--- a/devbot/shell.py
+++ b/devbot/shell.py
@@ -5,6 +5,7 @@ import os
from devbot import environ
from devbot import config
+
def start(rcfile):
environ.setup()
diff --git a/devbot/state.py b/devbot/state.py
index 7c2a839..41d458b 100644
--- a/devbot/state.py
+++ b/devbot/state.py
@@ -9,9 +9,11 @@ _BUILT_MODULES = "builtmodules"
_FULL_BUILD = "fullbuild"
_SYSTEM_CHECK = "syscheck"
+
def _get_state_path(name):
return os.path.join(config.build_state_dir, "%s.json" % name)
+
def _load_state(name, default=None):
state = default
@@ -23,11 +25,13 @@ def _load_state(name, default=None):
return state
+
def _save_state(name, state):
with open(_get_state_path(name), "w+") as f:
json.dump(state, f, indent=4)
f.write('\n')
+
def _get_diff_hash(git_module):
diff = git_module.diff().strip()
if diff:
@@ -35,6 +39,7 @@ def _get_diff_hash(git_module):
else:
return None
+
def _get_root_commit_id():
git_module = git.get_root_module()
if git_module:
@@ -44,6 +49,7 @@ def _get_root_commit_id():
return commit_id
+
def built_module_touch(module):
git_module = module.get_git_module()
built_modules = _load_state(_BUILT_MODULES, {})
@@ -54,6 +60,7 @@ def built_module_touch(module):
_save_state(_BUILT_MODULES, built_modules)
+
def built_module_is_unchanged(module):
git_module = module.get_git_module()
built_modules = _load_state(_BUILT_MODULES, {})
@@ -65,6 +72,7 @@ def built_module_is_unchanged(module):
return info["diff_hash"] == _get_diff_hash(git_module) and \
info["commit"] == git_module.get_commit_id()
+
def system_check_is_unchanged():
system_check = _load_state(_SYSTEM_CHECK)
if not system_check:
@@ -72,11 +80,13 @@ def system_check_is_unchanged():
return system_check["commit"] == _get_root_commit_id()
+
def system_check_touch():
system_check = _load_state(_SYSTEM_CHECK, {})
system_check["commit"] = _get_root_commit_id()
_save_state(_SYSTEM_CHECK, system_check)
+
def full_build_is_required():
full_build = _load_state(_FULL_BUILD)
if not full_build:
@@ -84,11 +94,13 @@ def full_build_is_required():
return not (full_build["last"] == config.get_full_build())
+
def full_build_touch():
full_build = _load_state(_FULL_BUILD, {})
full_build["last"] = config.get_full_build()
_save_state(_FULL_BUILD, full_build)
+
def clean_build_state():
try:
for name in _BUILT_MODULES, _FULL_BUILD:
@@ -96,6 +108,7 @@ def clean_build_state():
except OSError:
pass
+
def clean():
_state = None
diff --git a/devbot/system.py b/devbot/system.py
index 4b014a8..72e21cd 100644
--- a/devbot/system.py
+++ b/devbot/system.py
@@ -11,79 +11,93 @@ from devbot import state
from devbot import utils
from devbot import xvfb
+
def check_binary(check):
return subprocess.call(["which", check],
stdout=utils.devnull,
stderr=subprocess.STDOUT)
+
def check_pkgconfig(check):
return subprocess.call(["pkg-config", "--exists", check]) == 1
+
def check_python(check):
return subprocess.call(["python", "-c", check],
stdout=utils.devnull,
stderr=subprocess.STDOUT) == 1
+
def check_gtkmodule(check):
# Not sure we can do better than this, the gtkmodule stuff is private
missing = True
-
+
for libdir in config.system_lib_dirs:
if os.path.exists("%s/gtk-2.0/modules/lib%s.so" % (libdir, check)):
missing = False
return missing
+
def check_include(check):
return not os.path.exists(os.path.join("/usr/include/", check))
+
def check_dbus(check):
return not os.path.exists("/usr/share/dbus-1/services/%s.service" % check)
+
def check_metacity_theme(check):
- return not os.path.exists("/usr/share/themes/%s/metacity-1/metacity-theme-3.xml" % check)
+ theme = "/usr/share/themes/%s/metacity-1/metacity-theme-3.xml"
+ return not os.path.exists(theme % check)
+
def check_gstreamer(check, version):
missing = True
-
+
for libdir in config.system_lib_dirs:
- if os.path.exists("%s/gstreamer-%s/libgst%s.so" % \
+ if os.path.exists("%s/gstreamer-%s/libgst%s.so" %
(libdir, version, check)):
missing = False
return missing
+
def check_gstreamer_0_10(check):
return check_gstreamer(check, "0.10")
+
def check_gstreamer_1_0(check):
return check_gstreamer(check, "1.0")
-checkers = { "binary": check_binary,
- "python": check_python,
- "pkgconfig": check_pkgconfig,
- "gtkmodule": check_gtkmodule,
- "dbus": check_dbus,
- "gstreamer-0.10": check_gstreamer_0_10,
- "gstreamer-1.0": check_gstreamer_1_0,
- "metacity-theme": check_metacity_theme,
- "include": check_include }
+checkers = {"binary": check_binary,
+ "python": check_python,
+ "pkgconfig": check_pkgconfig,
+ "gtkmodule": check_gtkmodule,
+ "dbus": check_dbus,
+ "gstreamer-0.10": check_gstreamer_0_10,
+ "gstreamer-1.0": check_gstreamer_1_0,
+ "metacity-theme": check_metacity_theme,
+ "include": check_include}
+
def _print_checks(checks):
for check in checks:
print "[%s] %s" % (check["checker"], check["check"])
+
def _eval_check_if(check):
if "check_if" not in check:
return True
distro_info = distro.get_distro_info()
- globals = { "distro": "%s-%s" % (distro_info.name, distro_info.version) }
+ globals = {"distro": "%s-%s" % (distro_info.name, distro_info.version)}
print eval(check["check_if"], globals)
return eval(check["check_if"], globals) == "True"
+
def run_checks(package_manager, checks, packages):
distro_info = distro.get_distro_info()
@@ -129,6 +143,7 @@ def run_checks(package_manager, checks, packages):
return True
+
def remove_packages(package_manager, packages):
distro_name = distro.get_distro_info().name
@@ -154,6 +169,7 @@ def remove_packages(package_manager, packages):
if to_remove:
package_manager.remove_packages(to_remove)
+
def check(remove=False, update=False, test=False, interactive=True,
skip_if_unchanged=False):
if skip_if_unchanged:
diff --git a/devbot/test.py b/devbot/test.py
index fc2839b..6f57b63 100644
--- a/devbot/test.py
+++ b/devbot/test.py
@@ -6,6 +6,7 @@ from devbot import environ
from devbot import command
from devbot import xvfb
+
def test_one(module_name):
environ.setup()
@@ -15,6 +16,7 @@ def test_one(module_name):
return False
+
def test():
environ.setup()
@@ -25,6 +27,7 @@ def test():
return True
+
def _test_module(module):
result = True
diff --git a/devbot/utils.py b/devbot/utils.py
index a8988f1..3b26afb 100644
--- a/devbot/utils.py
+++ b/devbot/utils.py
@@ -2,6 +2,7 @@ import os
devnull = open("/dev/null", "w")
+
def ensure_dir(path):
try:
os.mkdir(path)
diff --git a/devbot/xvfb.py b/devbot/xvfb.py
index adc72f0..41110f7 100644
--- a/devbot/xvfb.py
+++ b/devbot/xvfb.py
@@ -3,14 +3,16 @@ import subprocess
from devbot import utils
+
def _find_free_display():
- for i in range (100, 1000):
+ for i in range(100, 1000):
display = ":%s" % i
result = subprocess.call(args=["xdpyinfo", "--display", display],
stdout=utils.devnull,
stderr=subprocess.STDOUT)
if result > 0:
- return display
+ return display
+
def start():
xvfb_display = _find_free_display()
@@ -22,6 +24,7 @@ def start():
return (xvfb_proc, orig_display)
+
def stop(xvfb_proc, orig_display):
if orig_display is not None:
os.environ["DISPLAY"] = orig_display