@@ -20,9 +20,15 @@ class OpkgDpkgPM(PackageManager):
"""
super(OpkgDpkgPM, self).__init__(d, target_rootfs)
- def package_info(self, pkg, cmd):
+ def package_info(self, pkg):
"""
Returns a dictionary with the package info.
+ """
+ raise NotImplementedError
+
+ def _common_package_info(self, cmd):
+ """
+ "Returns a dictionary with the package info.
This method extracts the common parts for Opkg and Dpkg
"""
@@ -36,14 +42,16 @@ class OpkgDpkgPM(PackageManager):
return opkg_query(proc.stdout)
- def extract(self, pkg, pkg_info):
+ def extract(self, pkg):
"""
Returns the path to a tmpdir where resides the contents of a package.
Deleting the tmpdir is responsability of the caller.
-
- This method extracts the common parts for Opkg and Dpkg
"""
+ pkg_info = self.package_info(pkg)
+ if not pkg_info:
+ bb.fatal("Unable to get information for package '%s' while "
+ "trying to extract the package." % pkg)
ar_cmd = bb.utils.which(os.getenv("PATH"), "ar")
tar_cmd = bb.utils.which(os.getenv("PATH"), "tar")
@@ -7,7 +7,7 @@
import re
import subprocess
from oe.package_manager import *
-from oe.package_manager import OpkgDpkgPM
+from oe.package_manager.common_deb_ipk import OpkgDpkgPM
class DpkgIndexer(Indexer):
def _create_configs(self):
@@ -431,7 +431,7 @@ class DpkgPM(OpkgDpkgPM):
Returns a dictionary with the package info.
"""
cmd = "%s show %s" % (self.apt_cache_cmd, pkg)
- pkg_info = super(DpkgPM, self).package_info(pkg, cmd)
+ pkg_info = self._common_package_info(cmd)
pkg_arch = pkg_info[pkg]["pkgarch"]
pkg_filename = pkg_info[pkg]["filename"]
@@ -439,18 +439,3 @@ class DpkgPM(OpkgDpkgPM):
os.path.join(self.deploy_dir, pkg_arch, pkg_filename)
return pkg_info
-
- def extract(self, pkg):
- """
- Returns the path to a tmpdir where resides the contents of a package.
-
- Deleting the tmpdir is responsability of the caller.
- """
- pkg_info = self.package_info(pkg)
- if not pkg_info:
- bb.fatal("Unable to get information for package '%s' while "
- "trying to extract the package." % pkg)
-
- tmp_dir = super(DpkgPM, self).extract(pkg, pkg_info)
-
- return tmp_dir
@@ -416,7 +416,7 @@ class OpkgPM(OpkgDpkgPM):
Returns a dictionary with the package info.
"""
cmd = "%s %s info %s" % (self.opkg_cmd, self.opkg_args, pkg)
- pkg_info = super(OpkgPM, self).package_info(pkg, cmd)
+ pkg_info = self._common_package_info(cmd)
pkg_arch = pkg_info[pkg]["arch"]
pkg_filename = pkg_info[pkg]["filename"]
@@ -424,16 +424,3 @@ class OpkgPM(OpkgDpkgPM):
os.path.join(self.deploy_dir, pkg_arch, pkg_filename)
return pkg_info
-
- def extract(self, pkg):
- """
- Returns the path to a tmpdir where resides the contents of a package.
-
- Deleting the tmpdir is responsability of the caller.
- """
- pkg_info = self.package_info(pkg)
- if not pkg_info:
- bb.fatal("Unable to get information for package '%s' while "
- "trying to extract the package." % pkg)
-
- return super(OpkgPM, self).extract(pkg, pkg_info)
Avoid code duplication by making `extract` a shared method (and retrieving the package manager specific input via an abstract method). Additionally, follow Python conventions and prefix class internal methods with "_" to indicate that they shouldn't be called externally. Signed-off-by: Philip Lorenz <philip.lorenz@bmw.de> --- meta/lib/oe/package_manager/common_deb_ipk.py | 16 ++++++++++++---- meta/lib/oe/package_manager/deb/__init__.py | 19 ++----------------- meta/lib/oe/package_manager/ipk/__init__.py | 15 +-------------- 3 files changed, 15 insertions(+), 35 deletions(-)