Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rwxr-xr-xcommands/check-system8
-rw-r--r--commands/common.py12
-rw-r--r--devbot/__init__.py0
-rw-r--r--devbot/config.py32
-rw-r--r--devbot/distro.py47
-rw-r--r--[-rwxr-xr-x]devbot/system.py (renamed from scripts/check-system)67
7 files changed, 132 insertions, 37 deletions
diff --git a/Makefile b/Makefile
index f9c3beb..9f71991 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
TIMESTAMP := $(shell date +%Y%m%d-%H%M%S)
LOGFILE = $(CURDIR)/logs/build-$(TIMESTAMP).log
SCRIPTS = $(CURDIR)/scripts
+COMMANDS = $(CURDIR)/commands
DNBUILD = $(SCRIPTS)/dn-build
LOG = $(SCRIPTS)/log-command
@@ -26,7 +27,7 @@ scripts/find-free-display: scripts/find-free-display.c
x11-utils: scripts/list-outputs scripts/find-free-display
check-system:
- $(TYPESCRIPT) $(SCRIPTS)/check-system $(LOGFILE)
+ $(TYPESCRIPT) $(COMMANDS)/check-system $(LOGFILE)
build: check-system
$(LOG) "$(DNBUILD) build" $(LOGFILE)
diff --git a/commands/check-system b/commands/check-system
new file mode 100755
index 0000000..aca432f
--- /dev/null
+++ b/commands/check-system
@@ -0,0 +1,8 @@
+#!/usr/bin/python
+
+import common
+
+from devbot import system
+
+common.setup()
+system.check()
diff --git a/commands/common.py b/commands/common.py
new file mode 100644
index 0000000..2836291
--- /dev/null
+++ b/commands/common.py
@@ -0,0 +1,12 @@
+import os
+import sys
+
+base_path = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
+
+sys.path.append(base_path)
+
+from devbot import system
+from devbot import config
+
+def setup():
+ config.set_path(os.path.join(base_path, "scripts", "deps"))
diff --git a/devbot/__init__.py b/devbot/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/devbot/__init__.py
diff --git a/devbot/config.py b/devbot/config.py
new file mode 100644
index 0000000..b63c6e6
--- /dev/null
+++ b/devbot/config.py
@@ -0,0 +1,32 @@
+import json
+import os
+
+from devbot import distro
+
+config_path = None
+
+def set_path(path):
+ global config_path
+ config_path = path
+
+def load_packages():
+ packages = _load_deps_json("packages-%s" % distro.get_system_version())
+
+def load_prerequisites():
+ return _load_deps_json("prerequisites")
+
+def load_checks():
+ version = distro.get_system_version()
+
+ checks = []
+ checks.extend(_load_deps_json("system"))
+ checks.extend(_load_deps_json("sugar-build"))
+ checks.extend(_load_deps_json("sugar-buildtime-%s" % version))
+ checks.extend(_load_deps_json("sugar-runtime-%s" % version))
+
+ return checks
+
+def _load_deps_json(name):
+ path = os.path.join(config_path, "%s.json" % name)
+ return json.load(open(path))
+
diff --git a/devbot/distro.py b/devbot/distro.py
new file mode 100644
index 0000000..34f54bc
--- /dev/null
+++ b/devbot/distro.py
@@ -0,0 +1,47 @@
+import subprocess
+
+def get_system_version():
+ name, version = _get_distro_info()
+ if (name == "ubuntu" and version == "12.10") or \
+ (name == "fedora" and version == "18"):
+ return "3.6"
+ else:
+ return "3.4"
+
+def get_distro_name():
+ name, version = _get_distro_info()
+ return name
+
+def _get_distro_info():
+ distro = "unsupported"
+ version = "unknown"
+
+ # Fedora
+ try:
+ fedora_release = open("/etc/fedora-release").read().strip()
+ if fedora_release == "Fedora release 17 (Beefy Miracle)":
+ distro = "fedora"
+ version = "17"
+ elif fedora_release == "Fedora release 18 (Spherical Cow)":
+ distro = "fedora"
+ version = "18"
+ except IOError:
+ pass
+
+ # Ubuntu
+ try:
+ distributor = subprocess.check_output(["lsb_release", "-si"]).strip()
+ release = subprocess.check_output(["lsb_release", "-sr"]).strip()
+
+ if distributor == "Ubuntu" and release == "12.10":
+ distro = "ubuntu"
+ version = "12.10"
+ except OSError:
+ pass
+
+ arch = subprocess.check_output(["uname", "-i"]).strip()
+ if arch not in ["i386", "i686", "x86_64"]:
+ distro = "unsupported"
+ version = "unknown"
+
+ return distro, version
diff --git a/scripts/check-system b/devbot/system.py
index 40ca8b7..e3e5d67 100755..100644
--- a/scripts/check-system
+++ b/devbot/system.py
@@ -1,13 +1,11 @@
-#!/usr/bin/python
-
import json
import os
import subprocess
import sys
-import sysinfo
+from devbot import config
+from devbot import distro
-scriptdir = os.path.dirname(__file__)
devnull = open("/dev/null", "w")
xvfb_display = ":100"
@@ -72,16 +70,16 @@ def run_with_sudo(args):
print " ".join(args_with_sudo)
subprocess.call(args_with_sudo)
-def install_packages(distro, packages):
+def install_packages(distro_name, packages):
if "SUGAR_BUILDBOT" in os.environ:
print "Missing packages %s" % " ".join(packages)
sys.exit(1)
print "Installing required system packages"
- if distro == "fedora":
+ if distro_name == "fedora":
args = ["yum", "install"]
- elif distro == "ubuntu":
+ elif distro_name == "ubuntu":
args = ["apt-get", "install"]
args.extend(packages)
@@ -91,7 +89,7 @@ def load_deps_json(name):
path = os.path.join(scriptdir, "deps", "%s.json" % name)
return json.load(open(path))
-def run_checks(distro, checks, packages):
+def run_checks(distro_name, checks, packages):
failed_checks = []
to_install = []
@@ -99,20 +97,20 @@ def run_checks(distro, checks, packages):
checker = checkers[check["checker"]]
if checker(check["check"]):
check_name = check.get("check_name", check["check"])
- if distro in packages[check_name]:
- package_list = packages[check_name][distro]
+ if distro_name in packages[check_name]:
+ package_list = packages[check_name][distro_name]
if not isinstance(package_list, list):
package_list = [package_list]
for package in package_list:
- # Might be none, if so skip on this distro
+ # Might be none, if so skip on this distro_name
if package and package not in packages:
to_install.append(package)
else:
failed_checks.append(check)
if to_install:
- install_packages(distro, to_install)
+ install_packages(distro_name, to_install)
if failed_checks:
print "Failed checks\n"
@@ -133,7 +131,7 @@ def start_xvfb():
return (xvfb_proc, orig_display)
-def stop_xvfb(proc, orig_display):
+def stop_xvfb(xvfb_proc, orig_display):
if orig_display:
os.environ["DISPLAY"] = xvfb_display
else:
@@ -142,6 +140,10 @@ def stop_xvfb(proc, orig_display):
xvfb_proc.terminate()
def apply_ubuntu_tweaks():
+ # FIXME we don't want the package to depend on external scripts
+ devbot_dir = os.path.abspath(os.path.dirname(__file__))
+ scripts_dir = os.path.join(os.path.dirname(devbot_dir), "scripts")
+
wrapper_config = open("/etc/X11/Xwrapper.config").read()
if "allowed_users=anybody" not in wrapper_config:
if "SUGAR_BUILDBOT" in os.environ:
@@ -149,15 +151,15 @@ def apply_ubuntu_tweaks():
" sudo dpkg-reconfigure x11-common"
else:
print "\nWe are going to allow anybody to run the X server"
- ubuntu_tweaks = os.path.join(scriptdir, "ubuntu-tweaks")
+ ubuntu_tweaks = os.path.join(scripts_dir, "ubuntu-tweaks")
run_with_sudo([ubuntu_tweaks])
-def apply_distro_tweaks(distro):
- if distro == "ubuntu":
+def apply_distro_tweaks(distro_name):
+ if distro_name == "ubuntu":
apply_ubuntu_tweaks()
-def warn_if_unsupported(distro):
- if distro == "unsupported":
+def warn_if_unsupported(distro_name):
+ if distro_name == "unsupported":
print "*********************************************************\n" \
"You are running an unsupported distribution. You might be\n" \
"able to make sugar work by installing or building \n" \
@@ -166,27 +168,20 @@ def warn_if_unsupported(distro):
"distributions listed in the README.\n" \
"*********************************************************\n"
-distro = sysinfo.get_distro_name()
+def check():
+ distro_name = distro.get_distro_name()
-packages = load_deps_json("packages-%s" %
- sysinfo.get_system_version())
+ packages = config.load_packages()
-checks = load_deps_json("prerequisites")
-if not run_checks(distro, checks, packages):
- sys.exit(1)
+ checks = config.load_prerequisites()
+ if not run_checks(distro_name, checks, packages):
+ sys.exit(1)
-xvfb_proc, orig_display = start_xvfb()
+ xvfb_proc, orig_display = start_xvfb()
-checks = []
-checks.extend(load_deps_json("system"))
-checks.extend(load_deps_json("sugar-build"))
-checks.extend(load_deps_json("sugar-buildtime-%s" %
- sysinfo.get_system_version()))
-checks.extend(load_deps_json("sugar-runtime-%s" %
- sysinfo.get_system_version()))
-run_checks(distro, checks, packages)
+ run_checks(distro_name, config.load_checks(), config.load_packages())
-warn_if_unsupported(distro)
-apply_distro_tweaks(distro)
+ warn_if_unsupported(distro_name)
+ apply_distro_tweaks(distro_name)
-stop_xvfb(xvfb_proc, orig_display)
+ stop_xvfb(xvfb_proc, orig_display)