From 6e3cdf1b4855fd0c82ae9abcfcf91400e7341c45 Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Fri, 15 Jun 2012 20:09:31 +0000 Subject: Run the import checks under Xvfb Otherwise we require to be running under X to build. --- (limited to 'scripts') diff --git a/scripts/check-system b/scripts/check-system index 0801656..1469621 100755 --- a/scripts/check-system +++ b/scripts/check-system @@ -4,6 +4,9 @@ import os import subprocess import sys +xvfb_packages = { "fedora": "Xvfb", + "ubuntu": "xvfb" } + binaries = [{ "name": "git", "packages": { "fedora": "git", "ubuntu": "git" } }, @@ -123,15 +126,40 @@ elif os.path.exists("/etc/lsb-release"): devnull = open("/dev/null", "w") +def install_packages(packages): + args = ["sudo"] + + if "SUGAR_BUILDBOT" in os.environ: + print "Missing packages %s" % " ".join(packages) + sys.exit(1) + + if distro == "fedora": + args.extend(["yum", "install"]) + elif distro == "ubuntu": + args.extend(["apt-get", "install"]) + + args.extend(packages) + subprocess.call(args) + +def check_binary(name): + return subprocess.call(["which", name], + stdout=devnull, + stderr=subprocess.STDOUT) + +if check_binary("Xvfb"): + if distro in xvfb_packages: + install_packages([xvfb_packages[distro]]) + else: + print "Xvfb is required to check dependecies." + sys.exit(1) + missing_binaries = [] missing_libs = [] missing_imports = [] packages = [] for info in binaries: - if subprocess.call(["which", info["name"]], - stdout=devnull, - stderr=subprocess.STDOUT): + if check_binary(info["name"]): if distro in info["packages"]: packages.append(info["packages"][distro]) else: @@ -145,7 +173,8 @@ for info in libs: missing_libs.append(info) for info in imports: - if subprocess.call(["python", "-c", info["import"]], + if subprocess.call(["Xvfb", ":100", "-ac", + "python", "-c", info["import"]], stdout=devnull, stderr=subprocess.STDOUT) == 1: if distro in info["packages"]: packages.append(info["packages"][distro]) @@ -153,19 +182,7 @@ for info in imports: missing_libs.append(info) if packages: - args = ["sudo"] - - if "SUGAR_BUILDBOT" in os.environ: - print "Missing packages %s" % " ".join(packages) - sys.exit(1) - - if distro == "fedora": - args.extend(["yum", "install"]) - elif distro == "ubuntu": - args.extend(["apt-get", "install"]) - - args.extend(packages) - subprocess.call(args) + install_packages(packages) if missing_binaries: print "Missing binaries\n" -- cgit v0.9.1