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/distro.py24
-rw-r--r--devbot/system.py18
2 files changed, 26 insertions, 16 deletions
diff --git a/devbot/distro.py b/devbot/distro.py
index 34f54bc..fe2522d 100644
--- a/devbot/distro.py
+++ b/devbot/distro.py
@@ -1,5 +1,29 @@
import subprocess
+from devbot import command
+
+class FedoraPackageManager:
+ def install_packages(self, packages):
+ args = ["yum", "install"]
+ args.extend(packages)
+
+ command.run_with_sudo(args)
+
+class UbuntuPackageManager:
+ def install_packages(self, packages):
+ args = ["apt-get", "install"]
+ args.extend(packages)
+
+ command.run_with_sudo(args)
+
+def get_package_manager():
+ name, version = _get_distro_info()
+
+ if name == "fedora":
+ return FedoraPackageManager()
+ elif name == "ubuntu":
+ return UbuntuPackageManager()
+
def get_system_version():
name, version = _get_distro_info()
if (name == "ubuntu" and version == "12.10") or \
diff --git a/devbot/system.py b/devbot/system.py
index fb65bbd..aa8d3f8 100644
--- a/devbot/system.py
+++ b/devbot/system.py
@@ -64,21 +64,6 @@ checkers = { "binary": check_binary,
"metacity-theme": check_metacity_theme,
"include": check_include }
-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_name == "fedora":
- args = ["yum", "install"]
- elif distro_name == "ubuntu":
- args = ["apt-get", "install"]
-
- args.extend(packages)
- command.run_with_sudo(args)
-
def load_deps_json(name):
path = os.path.join(scriptdir, "deps", "%s.json" % name)
return json.load(open(path))
@@ -104,7 +89,8 @@ def run_checks(distro_name, checks, packages):
failed_checks.append(check)
if to_install:
- install_packages(distro_name, to_install)
+ package_manager = distro.get_package_manager()
+ package_manager.install_packages(to_install)
if failed_checks:
print "Failed checks\n"