Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/devbot/distro.py
diff options
context:
space:
mode:
authorDaniel Narvaez <dwnarvaez@gmail.com>2012-11-14 19:09:26 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2012-11-14 19:09:26 (GMT)
commit1f603af6e31adb8e171806f914563607fbba446e (patch)
tree097c54e49b6c410d90ff0c1f892af0de56e06911 /devbot/distro.py
parent4526b912b1e35bfad217a7d4068c7d35b48c7f09 (diff)
Initial work on autoupdate and autoremove
Diffstat (limited to 'devbot/distro.py')
-rw-r--r--devbot/distro.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/devbot/distro.py b/devbot/distro.py
index fe2522d..a08218f 100644
--- a/devbot/distro.py
+++ b/devbot/distro.py
@@ -9,6 +9,51 @@ class FedoraPackageManager:
command.run_with_sudo(args)
+ def remove_packages(self, packages):
+ args = ["rpm", "-e"]
+ args.extend(packages)
+
+ command.run_with_sudo(args)
+
+ def update(self):
+ command.run_with_sudo(["yum", "update"])
+
+ def find_all(self):
+ query_format = "--queryformat=[%{NAME} ]"
+ all = subprocess.check_output(["rpm", "-qa", query_format]).strip()
+ return all.split(" ")
+
+ def find_with_deps(self, packages):
+ result = []
+
+ for package in packages:
+ if package not in result:
+ result.append(package)
+
+ self._find_deps(package, result)
+
+ return result
+
+ def _find_deps(self, package, result):
+ query_format = "--queryformat=[%{REQUIRENAME} ]"
+ capabilities = subprocess.check_output(["rpm", "-q",
+ query_format,
+ package]).strip()
+
+ for capability in capabilities.strip().split(" "):
+ if capability.startswith("rpmlib"):
+ continue
+ query_format = "--queryformat=[%{NAME} ]"
+ deps_packages = subprocess.check_output(["rpm", "-q",
+ query_format,
+ "--whatprovides",
+ capability]).strip()
+
+ for dep_package in deps_packages.split(" "):
+ if dep_package not in result:
+ result.append(dep_package)
+ self._find_deps(dep_package, result)
+
class UbuntuPackageManager:
def install_packages(self, packages):
args = ["apt-get", "install"]
@@ -16,6 +61,15 @@ class UbuntuPackageManager:
command.run_with_sudo(args)
+ def remove_packages(self, packages):
+ raise NotImplementedError
+
+ def update(self):
+ raise NotImplementedError
+
+ def find_with_deps(package_names):
+ raise NotImplementedError
+
def get_package_manager():
name, version = _get_distro_info()