From 05b2c03cf3971303354b3a188fbbb0bbb8d554fc Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Thu, 29 Nov 2012 16:18:29 +0000 Subject: Make json configs a bit smarter To get rid of the duplication in deps --- diff --git a/Makefile.config b/Makefile.config index 4d91956..913c8f8 100644 --- a/Makefile.config +++ b/Makefile.config @@ -5,10 +5,9 @@ CONFIG_DEPS_DIR=config/deps CONFIG_DEPS= \ $(CONFIG_DEPS_DIR)/prerequisites.json \ $(CONFIG_DEPS_DIR)/sugar-build.json \ - $(CONFIG_DEPS_DIR)/sugar-buildtime-3.4.json \ - $(CONFIG_DEPS_DIR)/sugar-buildtime-3.6.json \ - $(CONFIG_DEPS_DIR)/sugar-runtime-3.4.json \ - $(CONFIG_DEPS_DIR)/sugar-runtime-3.6.json \ + $(CONFIG_DEPS_DIR)/sugar-buildtime.json \ + $(CONFIG_DEPS_DIR)/sugar-buildtime.json \ + $(CONFIG_DEPS_DIR)/sugar-runtime.json \ $(CONFIG_DEPS_DIR)/system.json CONFIG_MODULES_DIR=config/modules diff --git a/commands/common.py b/commands/common.py index 06c1b47..54d20b2 100644 --- a/commands/common.py +++ b/commands/common.py @@ -42,8 +42,8 @@ def setup(): dep_files = ["system", "sugar-build", - "sugar-buildtime-%s" % version, - "sugar-runtime-%s" % version] + "sugar-buildtime", + "sugar-runtime"] config.set_dep_files(dep_files) diff --git a/config/deps/sugar-buildtime-3.4.json b/config/deps/sugar-buildtime-3.4.json deleted file mode 100644 index c647484..0000000 --- a/config/deps/sugar-buildtime-3.4.json +++ /dev/null @@ -1,127 +0,0 @@ -[ - { - "check": "aclocal", - "checker": "binary", - "name": "aclocal" - }, - { - "check": "alsa", - "checker": "pkgconfig", - "name": "alsa" - }, - { - "check": "autoreconf", - "checker": "binary", - "name": "autoreconf" - }, - { - "check": "gcc", - "checker": "binary", - "name": "gcc" - }, - { - "check": "gconf-2.0", - "checker": "pkgconfig", - "name": "gconf-2.0" - }, - { - "check": "glib-2.0", - "checker": "pkgconfig", - "name": "glib-2.0" - }, - { - "check": "gnome-doc-common", - "checker": "binary", - "name": "gnome-doc-common" - }, - { - "check": "gobject-introspection-1.0", - "checker": "pkgconfig", - "name": "gobject-introspection-1.0" - }, - { - "check": "gsettings-desktop-schemas", - "checker": "pkgconfig", - "name": "gsettings-desktop-schemas" - }, - { - "check": "gtk+-3.0", - "checker": "pkgconfig", - "name": "gtk+-3.0" - }, - { - "check": "ice", - "checker": "pkgconfig", - "name": "ice" - }, - { - "check": "icon-naming-utils", - "checker": "pkgconfig", - "name": "icon-naming-utils" - }, - { - "check": "icon-slicer", - "checker": "binary", - "name": "icon-slicer" - }, - { - "check": "intltoolize", - "checker": "binary", - "name": "intltoolize" - }, - { - "check": "libcanberra-gtk", - "checker": "pkgconfig", - "name": "libcanberra-gtk" - }, - { - "check": "librsvg-2.0", - "checker": "pkgconfig", - "name": "librsvg-2.0" - }, - { - "check": "libtool", - "checker": "binary", - "name": "libtool" - }, - { - "check": "pycairo", - "checker": "pkgconfig", - "name": "pycairo" - }, - { - "check": "pygtk-2.0", - "checker": "pkgconfig", - "name": "pygtk-2.0" - }, - { - "check": "python-2.7", - "checker": "pkgconfig", - "name": "python" - }, - { - "check": "sm", - "checker": "pkgconfig", - "name": "sm" - }, - { - "check": "sphinx-build", - "checker": "binary", - "name": "sphinx-build" - }, - { - "check": "tar", - "checker": "binary", - "name": "tar" - }, - { - "check": "xcursorgen", - "checker": "binary", - "name": "xcursorgen" - }, - { - "check": "xrdb", - "checker": "binary", - "name": "xrdb" - } -] diff --git a/config/deps/sugar-buildtime-3.6.json b/config/deps/sugar-buildtime.json index 71df305..fb78ab2 100644 --- a/config/deps/sugar-buildtime-3.6.json +++ b/config/deps/sugar-buildtime.json @@ -47,11 +47,13 @@ { "check": "gstreamer-1.0", "checker": "pkgconfig", + "if": "gstreamer_version == '1.0'", "name": "gstreamer-1.0" }, { "check": "gstreamer-plugins-base-1.0", "checker": "pkgconfig", + "if": "gstreamer_version == '1.0'", "name": "gstreamer-plugins-base-1.0" }, { @@ -105,7 +107,7 @@ "name": "pygtk-2.0" }, { - "check": "python", + "check": "python-2.7", "checker": "pkgconfig", "name": "python" }, diff --git a/config/deps/sugar-runtime-3.4.json b/config/deps/sugar-runtime-3.4.json deleted file mode 100644 index c3dee6d..0000000 --- a/config/deps/sugar-runtime-3.4.json +++ /dev/null @@ -1,162 +0,0 @@ -[ - { - "check": "Adwaita", - "checker": "metacity-theme", - "name": "Adwaita" - }, - { - "check": "X", - "checker": "binary", - "name": "X" - }, - { - "check": "from gi.repository import Gdk, Gtk; window = Gtk.Window(0); window.realize();context = Gdk.cairo_create(window.get_window())", - "checker": "python", - "name": "cairo foreign" - }, - { - "check": "from gi.repository import cairo", - "checker": "python", - "name": "cairo typelib" - }, - { - "check": "import dateutil", - "checker": "python", - "name": "dateutil python" - }, - { - "check": "dconf", - "checker": "binary", - "name": "dconf" - }, - { - "check": "import decorator", - "checker": "python", - "name": "decorator python" - }, - { - "check": "espeak", - "checker": "binary", - "name": "espeak" - }, - { - "check": "from gi.repository import EvinceDocument", - "checker": "python", - "name": "evince typelib" - }, - { - "check": "import gconf", - "checker": "python", - "name": "gconf python" - }, - { - "check": "from gi.repository import GConf", - "checker": "python", - "name": "gconf typelib" - }, - { - "check": "import gi", - "checker": "python", - "name": "gi python" - }, - { - "check": "gnome-keyring-daemon", - "checker": "binary", - "name": "gnome-keyring-daemon" - }, - { - "check": "from gi.repository import Gst", - "checker": "python", - "name": "gst typelib" - }, - { - "check": "from gi.repository import GtkSource", - "checker": "python", - "name": "gtksource typelib" - }, - { - "check": "import gtksourceview2", - "checker": "python", - "name": "gtksourceview2 python" - }, - { - "check": "import hippo", - "checker": "python", - "name": "hippo python" - }, - { - "check": "metacity", - "checker": "binary", - "name": "metacity" - }, - { - "check": "org.freedesktop.Telepathy.AccountManager", - "checker": "dbus", - "name": "org.freedesktop.Telepathy.AccountManager" - }, - { - "check": "org.freedesktop.Telepathy.ConnectionManager.gabble", - "checker": "dbus", - "name": "org.freedesktop.Telepathy.ConnectionManager.gabble" - }, - { - "check": "org.freedesktop.Telepathy.ConnectionManager.salut", - "checker": "dbus", - "name": "org.freedesktop.Telepathy.ConnectionManager.salut" - }, - { - "check": "import pygst", - "checker": "python", - "name": "pygst python" - }, - { - "check": "import rsvg", - "checker": "python", - "name": "rsvg python" - }, - { - "check": "import simplejson", - "checker": "python", - "name": "simplejson python" - }, - { - "check": "import telepathy", - "checker": "python", - "name": "telepathy python" - }, - { - "check": "video4linux2", - "checker": "gstreamer-0.10", - "name": "video4linux2" - }, - { - "check": "import vte", - "checker": "python", - "name": "vte python" - }, - { - "check": "from gi.repository import Vte", - "checker": "python", - "name": "vte typelib" - }, - { - "check": "from gi.repository import WebKit", - "checker": "python", - "name": "webkit typelib" - }, - { - "check": "import wnck", - "checker": "python", - "name": "wnck python" - }, - { - "check": "from gi.repository import Wnck", - "checker": "python", - "name": "wnck typelib" - }, - { - "check": "import xapian", - "checker": "python", - "name": "xapian python" - } -] diff --git a/config/deps/sugar-runtime-3.6.json b/config/deps/sugar-runtime.json index 5231b70..cb00657 100644 --- a/config/deps/sugar-runtime-3.6.json +++ b/config/deps/sugar-runtime.json @@ -12,6 +12,7 @@ { "check": "autodetect", "checker": "gstreamer-1.0", + "if": "gstreamer_version == '1.0'", "name": "autodetect gstreamer" }, { @@ -70,8 +71,21 @@ "name": "gnome-keyring-daemon" }, { + "check": "from gi.repository import Gst", + "checker": "python", + "if": "gstreamer_version == '1.0'", + "name": "gst typelib" + }, + { + "check": "from gi.repository import Gst", + "checker": "python", + "if": "gstreamer_version == '0.10'", + "name": "gst typelib" + }, + { "check": "import gi; gi.require_version('Gst', '1.0'); from gi.repository import Gst; Gst.init([])", "checker": "python", + "if": "gstreamer_version == '1.0'", "name": "gst typelib" }, { @@ -112,11 +126,13 @@ { "check": "pango", "checker": "gstreamer-1.0", + "if": "gstreamer_version == '1.0'", "name": "pango gstreamer" }, { "check": "playback", "checker": "gstreamer-1.0", + "if": "gstreamer_version == '1.0'", "name": "playback gstreamer" }, { diff --git a/config/packages/deps-3.4.json b/config/packages/deps-3.4.json index 02009f8..136f35d 100644 --- a/config/packages/deps-3.4.json +++ b/config/packages/deps-3.4.json @@ -10,28 +10,28 @@ "gnome-themes-standard" ] }, - "Xephyr": { + "X": { "debian": [ - "xserver-xephyr" + "xserver-xorg" ], "fedora": [ - "xorg-x11-server-Xephyr" + "xorg-x11-server-Xorg" ], "ubuntu": [ - "xserver-xephyr" + "xvfb" ] }, - "X": { + "Xephyr": { "debian": [ - "xserver-xorg" + "xserver-xephyr" ], "fedora": [ - "xorg-x11-server-Xorg" + "xorg-x11-server-Xephyr" ], "ubuntu": [ - "xvfb" + "xserver-xephyr" ] - }, + }, "Xvfb": { "debian": [ "xvfb" diff --git a/config/packages/deps-3.6.json b/config/packages/deps-3.6.json index 30a7df7..0b04778 100644 --- a/config/packages/deps-3.6.json +++ b/config/packages/deps-3.6.json @@ -7,20 +7,20 @@ "gnome-themes-standard" ] }, - "Xephyr": { + "X": { "fedora": [ - "xorg-x11-server-Xephyr" + "xorg-x11-server-Xor" ], "ubuntu": [ - "xserver-xephyr" + "xserver-xorg" ] }, - "X": { + "Xephyr": { "fedora": [ - "xorg-x11-server-Xor" + "xorg-x11-server-Xephyr" ], "ubuntu": [ - "xserver-xorg" + "xserver-xephyr" ] }, "Xvfb": { diff --git a/devbot/config.py b/devbot/config.py index a264ccb..259c4f2 100644 --- a/devbot/config.py +++ b/devbot/config.py @@ -223,6 +223,15 @@ 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 } + + return eval(item["if"], globals) + def load_checks(): version = distro.get_distro_info().system_version @@ -231,7 +240,7 @@ def load_checks(): path = os.path.join(config_dir, "deps", "%s.json" % file) checks.extend(json.load(open(path))) - return checks + return filter(_filter_if, checks) def load_modules(): version = distro.get_distro_info().system_version diff --git a/devbot/plugins/debian.py b/devbot/plugins/debian.py index 8ba62b0..38d5be4 100644 --- a/devbot/plugins/debian.py +++ b/devbot/plugins/debian.py @@ -90,6 +90,7 @@ class DistroInfo(interfaces.DistroInfo): self.name = "debian" self.version = "unknown" self.system_version = "3.4" + self.gstreamer_version = "0.10" self.valid = True self.supported = (arch in ["i686", "x86_64"]) self.use_lib64 = False diff --git a/devbot/plugins/fedora.py b/devbot/plugins/fedora.py index 083c479..3cfdfef 100644 --- a/devbot/plugins/fedora.py +++ b/devbot/plugins/fedora.py @@ -88,6 +88,7 @@ class DistroInfo(interfaces.DistroInfo): self.name = "fedora" self.version = "unknown" self.system_version = "3.6" + self.gstreamer_version = "1.0" self.use_lib64 = (arch == "x86_64") self.valid = True self.supported = (arch in ["i386", "i686", "x86_64"]) @@ -101,6 +102,7 @@ class DistroInfo(interfaces.DistroInfo): if release == "Fedora release 17 (Beefy Miracle)": self.version = "17" self.system_version = "3.4" + self.gstreamer_version = "0.10" elif release == "Fedora release 18 (Spherical Cow)": self.version = "18" else: diff --git a/devbot/plugins/interfaces.py b/devbot/plugins/interfaces.py index 0c9c0b6..c6db014 100644 --- a/devbot/plugins/interfaces.py +++ b/devbot/plugins/interfaces.py @@ -48,6 +48,9 @@ class DistroInfo: major version of GNOME installed on the system. """ + self.gstreamer_version = None + """The version of gstreamer shipped with the distribution.""" + self.valid = False """If set to True we are running on this distribution and the attributes are all valid. diff --git a/devbot/plugins/ubuntu.py b/devbot/plugins/ubuntu.py index 4db0dd1..556aaab 100644 --- a/devbot/plugins/ubuntu.py +++ b/devbot/plugins/ubuntu.py @@ -13,6 +13,7 @@ class DistroInfo(interfaces.DistroInfo): self.name = "ubuntu" self.version = "unknown" self.system_version = "3.4" + self.gstreamer_version = "1.0" self.valid = True self.supported = (arch in ["i386", "i686", "x86_64"]) self.use_lib64 = False diff --git a/devbot/plugins/unknown.py b/devbot/plugins/unknown.py index 826f643..f843fd5 100644 --- a/devbot/plugins/unknown.py +++ b/devbot/plugins/unknown.py @@ -32,6 +32,7 @@ class DistroInfo(interfaces.DistroInfo): self.name = "unknown" self.version = "unknown" self.system_version = "3.4" + self.gstreamer_version = "0.10" self.valid = True self.supported = False diff --git a/devbot/system.py b/devbot/system.py index 0bbfe8d..5757424 100644 --- a/devbot/system.py +++ b/devbot/system.py @@ -77,6 +77,17 @@ 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) } + + 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() @@ -85,6 +96,10 @@ def run_checks(package_manager, checks, packages): to_install = [] for check in checks: + if not _eval_check_if(check): + print "uuuuu" + continue + checker = checkers[check["checker"]] if checker(check["check"]): if distro_info.name in packages[check["name"]]: -- cgit v0.9.1