mirror of
https://git.yoctoproject.org/poky
synced 2026-04-19 15:32:13 +02:00
package_manager: Share more common DEB / IPK code
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. (From OE-Core rev: c4b126e216dfe8251ec55074be78188fcc3fcea8) Signed-off-by: Philip Lorenz <philip.lorenz@bmw.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
f7e9eb03d2
commit
e51697ef90
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user