Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Narvaez <dwnarvaez@gmail.com>2012-11-15 14:15:53 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2012-11-15 14:15:53 (GMT)
commitb97e30a31ab62cbbecec46326f86b77b23b9f409 (patch)
tree1520f3b8a8774db9133e41f040250d91b62821af
parent105d696bce5413e82ae69ac0fc8e2b39ba3a09ea (diff)
Initial implementation of ubuntu packages removal
-rw-r--r--devbot/distro.py38
1 files changed, 36 insertions, 2 deletions
diff --git a/devbot/distro.py b/devbot/distro.py
index e20cb3e..53a3c6f 100644
--- a/devbot/distro.py
+++ b/devbot/distro.py
@@ -78,7 +78,10 @@ class FedoraPackageManager:
class UbuntuPackageManager:
def __init__(self, test=False):
+ import apt
+
self._test = test
+ self._cache = apt.cache.Cache()
def install_packages(self, packages):
args = ["apt-get", "install"]
@@ -87,14 +90,45 @@ class UbuntuPackageManager:
command.run_with_sudo(args, test=self._test)
def remove_packages(self, packages):
- raise NotImplementedError
+ args = ["rpm", "-e"]
+ args.extend(packages)
+
+ command.run_with_sudo(args, test=True)
def update(self):
command.run_with_sudo(["apt-get", "update"], test=self._test)
command.run_with_sudo(["apt-get", "upgrade"], test=self._test)
+ def find_all(self):
+ return [package for package in self._cache]
+
+ def find_deps(package, result):
+ if self._cache.is_virtual_package(package):
+ for providing in self._cache.get_providing_packages(package):
+ find_deps(providing.name, result)
+ return
+
+ if package not in self._cache:
+ print package
+ return
+
+ candidate = self._cache[package].candidate
+ for dependency in candidate.dependencies:
+ for base_dependency in dependency.or_dependencies:
+ dependency_name = base_dependency.name
+ if dependency_name not in result:
+ result.append(dependency_name)
+ find_deps(dependency_name, result)
+
def find_with_deps(self, package_names):
- raise NotImplementedError
+ result = []
+
+ for package in package_names:
+ find_deps(package, result)
+ if package not in result:
+ result.append(package)
+
+ return result
def get_package_manager(test=False):
name, version = _get_distro_info()