Clean PkgsList return data implementation.
cover Clean PkgsList return data implementation.
From: Mariano Lopez <[email protected]>
Currently the when calling the list() from the classes that inherit from PKgsList, it must pass the format required and it will return a formated string listing all the packages installed. Retruning such string is not the best data structure to manipulate in the callers.
This series of patches change PkgsList to return a dictionary and the callers will format the output as required.
This patches require:
rpmresolve.c: Fix unfreed pointers that keep DB opened
http://patches.openembedded.org/patch/111021/
[YOCTO #7427]
The following changes since commit b9054f22526b89a752a07c5d4e6ca26afbf303aa:
bitbake: fetch/git: Change to use clearer ssh url syntax for broken servers (2016-01-07 15:23:57 +0000)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib mariano/bug7427v3
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=mariano/bug7427v3
Mariano Lopez (4):
lib/oe/package_manager: Add list_pkgs() to PkgsList class lib/oe/utils: Add function format_pkg_list() lib/oe/rootfs: Use list_pkgs() instead of list() lib/oe/package_manager.py: Remove list() from PkgsList class
meta/classes/buildhistory.bbclass | 11 +- meta/classes/license.bbclass | 8 +- meta/classes/populate_sdk_base.bbclass | 8 +- meta/classes/rootfs-postcommands.bbclass | 5 +- meta/lib/oe/package_manager.py | 185 +++++++++++++------------------ meta/lib/oe/rootfs.py | 8 +- meta/lib/oe/sdk.py | 8 +- meta/lib/oe/utils.py | 22 ++++ 8 files changed, 129 insertions(+), 126 deletions(-)
Signature · 1 line
1.8.4.5
PATCH 1/4 lib/oe/package_manager: Add list_pkgs() to PkgsList class
From: Mariano Lopez <[email protected]>
Currently the class PkgList returns a formated string of the installed packages. It would be more clean to pass a standard data structure to the callers instead to format the output inside PkgsList class.
This patch adds list_pkgs() method to PkgsList class to get the all the information for installed packages and return a dictionary with the info.
[YOCTO #7427]
--- meta/lib/oe/package_manager.py | 120 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+)
meta/lib/oe/package_manager.py +120 -0
@@ -296,6 +296,45 @@ class PkgsList(object): def list(self, format=None): pass + @abstractmethod + def list_pkgs(self): + pass + + def opkg_query(self, cmd_output): + verregex = re.compile(' \([=<>]* [^ )]*\)') + output = dict() + filename = "" + dep = [] + for line in cmd_output.splitlines(): + line = line.rstrip() + if ':' in line: + if line.startswith("Package: "): + pkg = line.split(": ")[1] + elif line.startswith("Architecture: "): + arch = line.split(": ")[1] + elif line.startswith("Version: "): + ver = line.split(": ")[1] + elif line.startswith("File: "): + filename = line.split(": ")[1] + elif line.startswith("Depends: "): + depends = verregex.sub('', line.split(": ")[1]) + for depend in depends.split(", "): + dep.append(depend) + elif line.startswith("Recommends: "): + recommends = verregex.sub('', line.split(": ")[1]) + for recommend in recommends.split(", "): + dep.append("%s [REC]" % recommend) + else: + # IPK doesn't include the filename + if not filename: + filename = "%s_%s_%s.ipk" % (pkg, ver, arch) + output[pkg] = {"arch":arch, "ver":ver, + "filename":filename, "deps": dep } + filename = "" + dep = [] + + return output + class RpmPkgsList(PkgsList): def __init__(self, d, rootfs_dir, arch_var=None, os_var=None):
@@ -412,6 +451,59 @@ class RpmPkgsList(PkgsList): return '\n'.join(output) + def list_pkgs(self): + cmd = self.rpm_cmd + ' --root ' + self.rootfs_dir + cmd += ' -D "_dbpath /var/lib/rpm" -qa' + if self.rpm_version == 4: + cmd += " --qf '[%{NAME} %{ARCH} %{VERSION}\n]'" + else: + cmd += " --qf '[%{NAME} %{ARCH} %{VERSION} %{PACKAGEORIGIN}\n]'" + + try: + # bb.note(cmd) + tmp_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip() + except subprocess.CalledProcessError as e: + bb.fatal("Cannot get the installed packages list. Command '%s' " + "returned %d:\n%s" % (cmd, e.returncode, e.output)) + + output = dict() + deps = dict() + if self.rpm_version == 4: + bb.warn("Dependency listings are not supported with rpm 4 since rpmresolve does not work") + dependencies = "" + else: + dependencies = self._list_pkg_deps() + + # Populate deps dictionary for better manipulation + for line in dependencies.splitlines(): + pkg, dep = line.split("|") + if not pkg in deps: + deps[pkg] = list() + if not dep in deps[pkg]: + deps[pkg].append(dep) + + for line in tmp_output.split('\n'): + if len(line.strip()) == 0: + continue + pkg = line.split()[0] + arch = line.split()[1] + ver = line.split()[2] + dep = deps.get(pkg, []) + + # Skip GPG keys + if pkg == 'gpg-pubkey': + continue + if self.rpm_version == 4: + pkgorigin = "unknown" + else: + pkgorigin = line.split()[3] + new_pkg, new_arch = self._pkg_translate_smart_to_oe(pkg, arch) + + output[new_pkg] = {"arch":new_arch, "ver":ver, + "filename":pkgorigin, "deps":dep} + + return output + class OpkgPkgsList(PkgsList): def __init__(self, d, rootfs_dir, config_file):
@@ -466,6 +558,19 @@ class OpkgPkgsList(PkgsList): return '\n'.join(output) + def list_pkgs(self, format=None): + cmd = "%s %s status" % (self.opkg_cmd, self.opkg_args) + + try: + # bb.note(cmd) + cmd_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip() + + except subprocess.CalledProcessError as e: + bb.fatal("Cannot get the installed packages list. Command '%s' " + "returned %d:\n%s" % (cmd, e.returncode, e.output)) + + return self.opkg_query(cmd_output) + class DpkgPkgsList(PkgsList): def list(self, format=None):
@@ -523,6 +628,21 @@ class DpkgPkgsList(PkgsList): return output + def list_pkgs(self): + cmd = [bb.utils.which(os.getenv('PATH'), "dpkg-query"), + "--admindir=%s/var/lib/dpkg" % self.rootfs_dir, + "-W"] + + cmd.append("-f=Package: ${Package}\nArchitecture: ${PackageArch}\nVersion: ${Version}\nFile: ${Package}_${Version}_${Architecture}.deb\nDepends: ${Depends}\nRecommends: ${Recommends}\n\n") + + try: + cmd_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip() + except subprocess.CalledProcessError as e: + bb.fatal("Cannot get the installed packages list. Command '%s' " + "returned %d:\n%s" % (' '.join(cmd), e.returncode, e.output)) + + return self.opkg_query(cmd_output) + class PackageManager(object): """
Signature · 1 line
1.8.4.5
PATCH 2/4 lib/oe/utils: Add function format_pkg_list()
In reply to [email protected]From: Mariano Lopez <[email protected]>
The class PkgsList returns a dictionary with all the installed packages, because the data structure is a dictionary there is needed to format the data in order to write to a file.
The function format_pkg_list returns a formated sting with all packages installed. The output will depend on the requested format when calling the function.
[YOCTO #7427]
--- meta/lib/oe/utils.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
meta/lib/oe/utils.py +22 -0
@@ -208,6 +208,28 @@ def squashspaces(string): import re return re.sub("\s+", " ", string).strip() +def format_pkg_list(pkg_dict, ret_format=None): + output = [] + + if ret_format == "arch": + for pkg in sorted(pkg_dict): + output.append("%s %s" % (pkg, pkg_dict[pkg]["arch"])) + elif ret_format == "file": + for pkg in sorted(pkg_dict): + output.append("%s %s %s" % (pkg, pkg_dict[pkg]["filename"], pkg_dict[pkg]["arch"])) + elif ret_format == "ver": + for pkg in sorted(pkg_dict): + output.append("%s %s %s" % (pkg, pkg_dict[pkg]["arch"], pkg_dict[pkg]["ver"])) + elif ret_format == "deps": + for pkg in sorted(pkg_dict): + for dep in pkg_dict[pkg]["deps"]: + output.append("%s|%s" % (pkg, dep)) + else: + for pkg in sorted(pkg_dict): + output.append(pkg) + + return '\n'.join(output) + # # Python 2.7 doesn't have threaded pools (just multiprocessing) # so implement a version here
Signature · 1 line
1.8.4.5
PATCH 3/4 lib/oe/rootfs: Use list_pkgs() instead of list()
In reply to [email protected]From: Mariano Lopez <[email protected]>
This patch changes the use list_pkgs() instead of list() from class RpmPkgsList. The change is in two functions, image_list_installed_packages from rootfs.py and sdk_list_installed_packages from sdk.py.
With this change the functions calling the functions listed above, must format the output as they required. The formatting can be done using format_pkg_list() from oe.utils.
The classes calling the afected functions are changed too with this patch, to keep the same functionality using the new data structure.
[YOCTO #7427]
--- meta/classes/buildhistory.bbclass | 11 +++++++---- meta/classes/license.bbclass | 8 ++++++-- meta/classes/populate_sdk_base.bbclass | 8 ++++++-- meta/classes/rootfs-postcommands.bbclass | 5 +++-- meta/lib/oe/package_manager.py | 18 ++++++++++-------- meta/lib/oe/rootfs.py | 8 ++++---- meta/lib/oe/sdk.py | 8 ++++---- 7 files changed, 40 insertions(+), 26 deletions(-)
meta/classes/buildhistory.bbclass +7 -4
@@ -337,18 +337,21 @@ def write_pkghistory(pkginfo, d): def buildhistory_list_installed(d, rootfs_type="image"): from oe.rootfs import image_list_installed_packages from oe.sdk import sdk_list_installed_packages + from oe.utils import format_pkg_list process_list = [('file', 'bh_installed_pkgs.txt'),\ ('deps', 'bh_installed_pkgs_deps.txt')] + if rootfs_type == "image": + pkgs = image_list_installed_packages(d) + else: + pkgs = sdk_list_installed_packages(d, rootfs_type == "sdk_target") + for output_type, output_file in process_list: output_file_full = os.path.join(d.getVar('WORKDIR', True), output_file) with open(output_file_full, 'w') as output: - if rootfs_type == "image": - output.write(image_list_installed_packages(d, output_type)) - else: - output.write(sdk_list_installed_packages(d, rootfs_type == "sdk_target", output_type)) + output.write(format_pkg_list(pkgs, output_type)) python buildhistory_list_installed_image() { buildhistory_list_installed(d)
meta/classes/license.bbclass +6 -2
@@ -21,8 +21,12 @@ python write_package_manifest() { license_image_dir = d.expand('${LICENSE_DIRECTORY}/${IMAGE_NAME}') bb.utils.mkdirhier(license_image_dir) from oe.rootfs import image_list_installed_packages + from oe.utils import format_pkg_list + + pkgs = image_list_installed_packages(d) + output = format_pkg_list(pkgs) open(os.path.join(license_image_dir, 'package.manifest'), - 'w+').write(image_list_installed_packages(d)) + 'w+').write(output) } python write_deploy_manifest() {
@@ -38,7 +42,7 @@ python license_create_manifest() { return 0 pkg_dic = {} - for pkg in image_list_installed_packages(d).splitlines(): + for pkg in sorted(image_list_installed_packages(d)): pkg_info = os.path.join(d.getVar('PKGDATA_DIR', True), 'runtime-reverse', pkg) pkg_name = os.path.basename(os.readlink(pkg_info))
meta/classes/populate_sdk_base.bbclass +6 -2
@@ -62,20 +62,24 @@ SDK_TARGET_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.target.manifest" SDK_HOST_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.host.manifest" python write_target_sdk_manifest () { from oe.sdk import sdk_list_installed_packages + from oe.utils import format_pkg_list sdkmanifestdir = os.path.dirname(d.getVar("SDK_TARGET_MANIFEST", True)) + pkgs = sdk_list_installed_packages(d, True) if not os.path.exists(sdkmanifestdir): bb.utils.mkdirhier(sdkmanifestdir) with open(d.getVar('SDK_TARGET_MANIFEST', True), 'w') as output: - output.write(sdk_list_installed_packages(d, True, 'ver')) + output.write(format_pkg_list(pkgs, 'ver')) } python write_host_sdk_manifest () { from oe.sdk import sdk_list_installed_packages + from oe.utils import format_pkg_list sdkmanifestdir = os.path.dirname(d.getVar("SDK_HOST_MANIFEST", True)) + pkgs = sdk_list_installed_packages(d, False) if not os.path.exists(sdkmanifestdir): bb.utils.mkdirhier(sdkmanifestdir) with open(d.getVar('SDK_HOST_MANIFEST', True), 'w') as output: - output.write(sdk_list_installed_packages(d, False, 'ver')) + output.write(format_pkg_list(pkgs, 'ver')) } POPULATE_SDK_POST_TARGET_COMMAND_append = " write_target_sdk_manifest ; "
meta/classes/rootfs-postcommands.bbclass +3 -2
@@ -207,14 +207,15 @@ insert_feed_uris () { python write_image_manifest () { from oe.rootfs import image_list_installed_packages + from oe.utils import format_pkg_list deploy_dir = d.getVar('DEPLOY_DIR_IMAGE', True) link_name = d.getVar('IMAGE_LINK_NAME', True) manifest_name = d.getVar('IMAGE_MANIFEST', True) + pkgs = image_list_installed_packages(d) with open(manifest_name, 'w+') as image_manifest: - image_manifest.write(image_list_installed_packages(d, 'ver')) - image_manifest.write("\n") + image_manifest.write(format_pkg_list(pkgs, "ver")) if manifest_name is not None and os.path.exists(manifest_name): manifest_link = deploy_dir + "/" + link_name + ".manifest"
meta/lib/oe/package_manager.py +10 -8
@@ -693,7 +693,7 @@ class PackageManager(object): pass @abstractmethod - def list_installed(self, format=None): + def list_installed(self): pass @abstractmethod
@@ -713,7 +713,9 @@ class PackageManager(object): installed_pkgs_file = os.path.join(self.d.getVar('WORKDIR', True), "installed_pkgs.txt") with open(installed_pkgs_file, "w+") as installed_pkgs: - installed_pkgs.write(self.list_installed("arch")) + pkgs = self.list_installed() + output = oe.utils.format_pkg_list(pkgs, "arch") + installed_pkgs.write(output) if globs is None: globs = self.d.getVar('IMAGE_INSTALL_COMPLEMENTARY', True)
@@ -1417,8 +1419,8 @@ class RpmPM(PackageManager): self.image_rpmlib, symlinks=True) - def list_installed(self, format=None): - return self.pkgs_list.list(format) + def list_installed(self): + return self.pkgs_list.list_pkgs() ''' If incremental install, we need to determine what we've got,
@@ -1782,8 +1784,8 @@ class OpkgPM(PackageManager): # create the directory back, it's needed by PM lock bb.utils.mkdirhier(self.opkg_dir) - def list_installed(self, format=None): - return OpkgPkgsList(self.d, self.target_rootfs, self.config_file).list(format) + def list_installed(self): + return OpkgPkgsList(self.d, self.target_rootfs, self.config_file).list_pkgs() def handle_bad_recommendations(self): bad_recommendations = self.d.getVar("BAD_RECOMMENDATIONS", True) or ""
@@ -2166,8 +2168,8 @@ class DpkgPM(PackageManager): bb.fatal("Cannot fix broken dependencies. Command '%s' " "returned %d:\n%s" % (cmd, e.returncode, e.output)) - def list_installed(self, format=None): - return DpkgPkgsList(self.d, self.target_rootfs).list() + def list_installed(self): + return DpkgPkgsList(self.d, self.target_rootfs).list_pkgs() def generate_index_files(d):
meta/lib/oe/rootfs.py +4 -4
@@ -963,17 +963,17 @@ def create_rootfs(d, manifest_dir=None): os.environ.update(env_bkp) -def image_list_installed_packages(d, format=None, rootfs_dir=None): +def image_list_installed_packages(d, rootfs_dir=None): if not rootfs_dir: rootfs_dir = d.getVar('IMAGE_ROOTFS', True) img_type = d.getVar('IMAGE_PKGTYPE', True) if img_type == "rpm": - return RpmPkgsList(d, rootfs_dir).list(format) + return RpmPkgsList(d, rootfs_dir).list_pkgs() elif img_type == "ipk": - return OpkgPkgsList(d, rootfs_dir, d.getVar("IPKGCONF_TARGET", True)).list(format) + return OpkgPkgsList(d, rootfs_dir, d.getVar("IPKGCONF_TARGET", True)).list_pkgs() elif img_type == "deb": - return DpkgPkgsList(d, rootfs_dir).list(format) + return DpkgPkgsList(d, rootfs_dir).list_pkgs() if __name__ == "__main__": """
meta/lib/oe/sdk.py +4 -4
@@ -345,7 +345,7 @@ class DpkgSdk(Sdk): -def sdk_list_installed_packages(d, target, format=None, rootfs_dir=None): +def sdk_list_installed_packages(d, target, rootfs_dir=None): if rootfs_dir is None: sdk_output = d.getVar('SDK_OUTPUT', True) target_path = d.getVar('SDKTARGETSYSROOT', True).strip('/')
@@ -356,12 +356,12 @@ def sdk_list_installed_packages(d, target, format=None, rootfs_dir=None): if img_type == "rpm": arch_var = ["SDK_PACKAGE_ARCHS", None][target is True] os_var = ["SDK_OS", None][target is True] - return RpmPkgsList(d, rootfs_dir, arch_var, os_var).list(format) + return RpmPkgsList(d, rootfs_dir, arch_var, os_var).list_pkgs() elif img_type == "ipk": conf_file_var = ["IPKGCONF_SDK", "IPKGCONF_TARGET"][target is True] - return OpkgPkgsList(d, rootfs_dir, d.getVar(conf_file_var, True)).list(format) + return OpkgPkgsList(d, rootfs_dir, d.getVar(conf_file_var, True)).list_pkgs() elif img_type == "deb": - return DpkgPkgsList(d, rootfs_dir).list(format) + return DpkgPkgsList(d, rootfs_dir).list_pkgs() def populate_sdk(d, manifest_dir=None): env_bkp = os.environ.copy()
Signature · 1 line
1.8.4.5
Re: [PATCH 3/4] lib/oe/rootfs: Use list_pkgs() instead of list()
Hi,
I don't have the env to test the patch anymore.
However, I have a question on this patch. I inline the comment in the code here, below the related lines:
2016-01-07 21:07 GMT+01:00 <[email protected]>:
Quoted 136 lines
From: Mariano Lopez <[email protected]>
This patch changes the use
list_pkgs()instead oflist()from class RpmPkgsList. The change is in two functions,image_list_installed_packagesfromrootfs.pyandsdk_list_installed_packagesfromsdk.py.With this change the functions calling the functions listed above, must format the output as they required. The formatting can be done using
format_pkg_list()from oe.utils.The classes calling the afected functions are changed too with this patch, to keep the same functionality using the new data structure.
[YOCTO #7427]
Signed-off-by Mariano Lopez <[email protected]>--- meta/classes/buildhistory.bbclass | 11 +++++++---- meta/classes/license.bbclass | 8 ++++++-- meta/classes/populate_sdk_base.bbclass | 8 ++++++-- meta/classes/rootfs-postcommands.bbclass | 5 +++-- meta/lib/oe/package_manager.py | 18 ++++++++++-------- meta/lib/oe/rootfs.py | 8 ++++---- meta/lib/oe/sdk.py | 8 ++++---- 7 files changed, 40 insertions(+), 26 deletions(-)meta/classes/buildhistory.bbclass +7
-4@@ -337,18 +337,21 @@ def write_pkghistory(pkginfo, d): def buildhistory_list_installed(d, rootfs_type="image"): from oe.rootfs import image_list_installed_packages from oe.sdk import sdk_list_installed_packages + from oe.utils import format_pkg_list process_list = [('file', 'bh_installed_pkgs.txt'),\ ('deps', 'bh_installed_pkgs_deps.txt')] + if rootfs_type == "image": + pkgs = image_list_installed_packages(d) + else: + pkgs = sdk_list_installed_packages(d, rootfs_type == "sdk_target") + for output_type, output_file in process_list: output_file_full = os.path.join(d.getVar('WORKDIR', True), output_file) with open(output_file_full, 'w') as output: - if rootfs_type == "image": - output.write(image_list_installed_packages(d, output_type)) - else: - output.write(sdk_list_installed_packages(d, rootfs_type == "sdk_target", output_type)) + output.write(format_pkg_list(pkgs, output_type))python
buildhistory_list_installed_image(){
buildhistory_list_installed(d)meta/classes/license.bbclass +6
-2@@ -21,8 +21,12 @@ python write_package_manifest() { license_image_dir = d.expand('${LICENSE_DIRECTORY}/${IMAGE_NAME}') bb.utils.mkdirhier(license_image_dir) from oe.rootfs import image_list_installed_packages + from oe.utils import format_pkg_list + + pkgs = image_list_installed_packages(d) + output = format_pkg_list(pkgs) open(os.path.join(license_image_dir, 'package.manifest'), - 'w+').write(image_list_installed_packages(d)) + 'w+').write(output) } python write_deploy_manifest() {@@ -38,7 +42,7 @@ python license_create_manifest() { return 0 pkg_dic = {} - for pkg in image_list_installed_packages(d).splitlines(): + for pkg in sorted(image_list_installed_packages(d)): pkg_info = os.path.join(d.getVar('PKGDATA_DIR', True), 'runtime-reverse', pkg) pkg_name = os.path.basename(os.readlink(pkg_info))meta/classes/populate_sdk_base.bbclass +0
-0@@ -62,20 +62,24 @@ SDK_TARGET_MANIFEST ="${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.target.manifest"
SDK_HOST_MANIFEST= "${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.host.manifest" pythonwrite_target_sdk_manifest() {
from oe.sdk importsdk_list_installed_packages
+ from oe.utils importformat_pkg_list
sdkmanifestdir = os.path.dirname(d.getVar("SDK_TARGET_MANIFEST",
True))meta/classes/populate_sdk_base.bbclass +5
-2+ pkgs = sdk_list_installed_packages(d, True) if not os.path.exists(sdkmanifestdir): bb.utils.mkdirhier(sdkmanifestdir) with open(d.getVar('SDK_TARGET_MANIFEST', True), 'w') as output: - output.write(sdk_list_installed_packages(d, True, 'ver')) + output.write(format_pkg_list(pkgs, 'ver')) } python write_host_sdk_manifest () { from oe.sdk import sdk_list_installed_packages + from oe.utils import format_pkg_list sdkmanifestdir = os.path.dirname(d.getVar("SDK_HOST_MANIFEST", True)) + pkgs = sdk_list_installed_packages(d, False) if not os.path.exists(sdkmanifestdir): bb.utils.mkdirhier(sdkmanifestdir) with open(d.getVar('SDK_HOST_MANIFEST', True), 'w') as output: - output.write(sdk_list_installed_packages(d, False, 'ver')) + output.write(format_pkg_list(pkgs, 'ver')) } POPULATE_SDK_POST_TARGET_COMMAND_append = " write_target_sdk_manifest ; "meta/classes/rootfs-postcommands.bbclass +1
-0@@ -207,14 +207,15 @@ insert_feed_uris () { python write_image_manifest () { from oe.rootfs import image_list_installed_packages + from oe.utils import format_pkg_list deploy_dir = d.getVar('DEPLOY_DIR_IMAGE', True)
meta/classes/rootfs-postcommands.bbclass insert_feed_uris () { · line 220
Quoted 10 lines
meta/classes/rootfs-postcommands.bbclass +2
-2link_name = d.getVar('IMAGE_LINK_NAME', True) manifest_name = d.getVar('IMAGE_MANIFEST', True) + pkgs = image_list_installed_packages(d) with open(manifest_name, 'w+') as image_manifest: - image_manifest.write(image_list_installed_packages(d, 'ver')) - image_manifest.write("\n") + image_manifest.write(format_pkg_list(pkgs, "ver"))
As far as I understand from patch 2/4 in this series, you get something like "pkgInfo0\npkgInfoX\npkInfoLast" when using join() from inside format_pkg_list(), so you get no "\n" at the end of the file, and still you are also removing the line which adds the "\n" at the end. That would break the workaround which was added to fix bug #7427 in yocto right? Or am I missing something?
Quoted 127 lines
meta/classes/rootfs-postcommands.bbclass +0
-0if manifest_name is not None and os.path.exists(manifest_name):
manifest_link=deploy_dir+ "/" +link_name+ ".manifest"meta/lib/oe/package_manager.py +8
-6@@ -693,7 +693,7 @@ class PackageManager(object): pass @abstractmethod - def list_installed(self, format=None): + def list_installed(self): pass @abstractmethod@@ -713,7 +713,9 @@ class PackageManager(object): installed_pkgs_file = os.path.join(self.d.getVar('WORKDIR', True), "installed_pkgs.txt") with open(installed_pkgs_file, "w+") as installed_pkgs: - installed_pkgs.write(self.list_installed("arch")) + pkgs = self.list_installed() + output = oe.utils.format_pkg_list(pkgs, "arch") + installed_pkgs.write(output) if globs is None: globs = self.d.getVar('IMAGE_INSTALL_COMPLEMENTARY', True)@@ -1417,8 +1419,8 @@ class RpmPM(PackageManager): self.image_rpmlib, symlinks=True) - def list_installed(self, format=None): - return self.pkgs_list.list(format) + def list_installed(self): + return self.pkgs_list.list_pkgs() ''' If incremental install, we need to determine what we've got,@@ -1782,8 +1784,8 @@ class OpkgPM(PackageManager): # create the directory back, it's needed by PM lock bb.utils.mkdirhier(self.opkg_dir) - def list_installed(self, format=None): - return OpkgPkgsList(self.d, self.target_rootfs, self.config_file).list(format) + def list_installed(self): + return OpkgPkgsList(self.d, self.target_rootfs, self.config_file).list_pkgs()def
handle_bad_recommendations(self):
bad_recommendations=self.d.getVar("BAD_RECOMMENDATIONS", True)
or ""meta/lib/oe/package_manager.py +2
-2@@ -2166,8 +2168,8 @@ class DpkgPM(PackageManager): bb.fatal("Cannot fix broken dependencies. Command '%s' " "returned %d:\n%s" % (cmd, e.returncode, e.output)) - def list_installed(self, format=None): - return DpkgPkgsList(self.d, self.target_rootfs).list() + def list_installed(self): + return DpkgPkgsList(self.d, self.target_rootfs).list_pkgs() def generate_index_files(d):meta/lib/oe/rootfs.py +4
-4@@ -963,17 +963,17 @@ def create_rootfs(d, manifest_dir=None): os.environ.update(env_bkp) -def image_list_installed_packages(d, format=None, rootfs_dir=None): +def image_list_installed_packages(d, rootfs_dir=None): if not rootfs_dir: rootfs_dir = d.getVar('IMAGE_ROOTFS', True) img_type = d.getVar('IMAGE_PKGTYPE', True) if img_type == "rpm": - return RpmPkgsList(d, rootfs_dir).list(format) + return RpmPkgsList(d, rootfs_dir).list_pkgs() elif img_type == "ipk": - return OpkgPkgsList(d, rootfs_dir, d.getVar("IPKGCONF_TARGET", True)).list(format) + return OpkgPkgsList(d, rootfs_dir, d.getVar("IPKGCONF_TARGET", True)).list_pkgs() elif img_type == "deb": - return DpkgPkgsList(d, rootfs_dir).list(format) + return DpkgPkgsList(d, rootfs_dir).list_pkgs()if
__name__== "__main__":"""meta/lib/oe/sdk.py +1
-1@@ -345,7 +345,7 @@ class DpkgSdk(Sdk): -def sdk_list_installed_packages(d, target, format=None, rootfs_dir=None): +def sdk_list_installed_packages(d, target, rootfs_dir=None): if rootfs_dir is None: sdk_output = d.getVar('SDK_OUTPUT', True) target_path = d.getVar('SDKTARGETSYSROOT', True).strip('/')@@ -356,12 +356,12 @@ def sdk_list_installed_packages(d, target,format=None, rootfs_dir=None):
ifimg_type== "rpm":
arch_var= ["SDK_PACKAGE_ARCHS", None][target is True]os_var= ["SDK_OS", None][target is True]meta/lib/oe/sdk.py +1
-1- return RpmPkgsList(d, rootfs_dir, arch_var, os_var).list(format) + return RpmPkgsList(d, rootfs_dir, arch_var, os_var).list_pkgs() elif img_type == "ipk": conf_file_var = ["IPKGCONF_SDK", "IPKGCONF_TARGET"][target isTrue]
- return OpkgPkgsList(d,rootfs_dir, d.getVar(conf_file_var,
True)).list(format)
+ return OpkgPkgsList(d,rootfs_dir, d.getVar(conf_file_var,
True)).list_pkgs()elif img_type == "deb":meta/lib/oe/sdk.py +1
-2- return DpkgPkgsList(d, rootfs_dir).list(format) + return DpkgPkgsList(d, rootfs_dir).list_pkgs() def populate_sdk(d, manifest_dir=None): env_bkp = os.environ.copy() --1.8.4.5
Quoted 6 lines
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Thanks for your time spent on this,
Pau
Re: [PATCH 3/4] lib/oe/rootfs: Use list_pkgs() instead of list()
Quoted 154 lines · Pau Espin Pedrol
Hi,
I don't have the env to test the patch anymore.
However, I have a question on this patch. I inline the comment in the code here, below the related lines:
2016-01-07 21:07 GMT+01:00 <[email protected] <mailto:[email protected]>>:
From: Mariano Lopez <[email protected] <mailto:[email protected]>>
This patch changes the use
list_pkgs()instead oflist()from class RpmPkgsList. The change is in two functions,image_list_installed_packagesfromrootfs.pyandsdk_list_installed_packagesfromsdk.py.With this change the functions calling the functions listed above, must format the output as they required. The formatting can be done using
format_pkg_list()from oe.utils.The classes calling the afected functions are changed too with this patch, to keep the same functionality using the new data structure.
[YOCTO #7427]
Signed-off-by Mariano Lopez <[email protected]<mailto:[email protected]>>
---
meta/classes/buildhistory.bbclass | 11 +++++++----
meta/classes/license.bbclass | 8 ++++++--
meta/classes/populate_sdk_base.bbclass | 8 ++++++--
meta/classes/rootfs-postcommands.bbclass | 5 +++--
meta/lib/oe/package_manager.py| 18 ++++++++++--------
meta/lib/oe/rootfs.py| 8 ++++----
meta/lib/oe/sdk.py| 8 ++++----
7 files changed, 40 insertions(+), 26 deletions(-)diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
index 4153e58..a2f8ac7 100644
--- a/meta/classes/buildhistory.bbclass
+++ b/meta/classes/buildhistory.bbclass
@@ -337,18 +337,21 @@ defwrite_pkghistory(pkginfo, d):
defbuildhistory_list_installed(d, rootfs_type="image"):
from oe.rootfs importimage_list_installed_packagesfrom oe.sdk importsdk_list_installed_packages
+ from oe.utils importformat_pkg_list
process_list= [('file', 'bh_installed_pkgs.txt'),\
('deps', 'bh_installed_pkgs_deps.txt')]+ if
rootfs_type== "image":
+ pkgs =image_list_installed_packages(d)
+ else:
+ pkgs = sdk_list_installed_packages(d,rootfs_type==
"sdk_target")
+
foroutput_type,output_fileinprocess_list:
output_file_full= os.path.join(d.getVar('WORKDIR',
True),output_file)with
open(output_file_full, 'w')as output:
- ifrootfs_type== "image":
-output.write(image_list_installed_packages(d, output_type))
- else:
-output.write(sdk_list_installed_packages(d, rootfs_type == "sdk_target", output_type))
+output.write(format_pkg_list(pkgs, output_type))python
buildhistory_list_installed_image(){
buildhistory_list_installed(d)
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index 6651d55..fed42ca 100644
--- a/meta/classes/license.bbclass
+++ b/meta/classes/license.bbclass
@@ -21,8 +21,12 @@ pythonwrite_package_manifest(){
license_image_dir=
d.expand('${LICENSE_DIRECTORY}/${IMAGE_NAME}')
bb.utils.mkdirhier(license_image_dir)
from oe.rootfs importimage_list_installed_packages
+ from oe.utils importformat_pkg_list
+
+ pkgs =image_list_installed_packages(d)
+ output =format_pkg_list(pkgs)
open(os.path.join(license_image_dir, 'package.manifest'),
- 'w+').write(image_list_installed_packages(d))
+ 'w+').write(output)
}python
write_deploy_manifest(){
@@ -38,7 +42,7 @@ pythonlicense_create_manifest(){
return 0
pkg_dic= {}
- for pkg in image_list_installed_packages(d).splitlines():
+ for pkg in sorted(image_list_installed_packages(d)):
pkg_info= os.path.join(d.getVar('PKGDATA_DIR', True),
'runtime-reverse', pkg)
pkg_name= os.path.basename(os.readlink(pkg_info))
diff --git a/meta/classes/populate_sdk_base.bbclass b/meta/classes/populate_sdk_base.bbclass
index 23dc115..26e06a5 100644
--- a/meta/classes/populate_sdk_base.bbclass
+++ b/meta/classes/populate_sdk_base.bbclass
@@ -62,20 +62,24 @@SDK_TARGET_MANIFEST= "${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.target.manifest"
SDK_HOST_MANIFEST=
"${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.host.manifest"
pythonwrite_target_sdk_manifest() {
from oe.sdk importsdk_list_installed_packages
+ from oe.utils importformat_pkg_list
sdkmanifestdir =
os.path.dirname(d.getVar("SDK_TARGET_MANIFEST", True))
+ pkgs =sdk_list_installed_packages(d, True)
if notos.path.exists(sdkmanifestdir):
bb.utils.mkdirhier(sdkmanifestdir)
withopen(d.getVar('SDK_TARGET_MANIFEST', True), 'w')as output:
-output.write(sdk_list_installed_packages(d, True, 'ver'))
+output.write(format_pkg_list(pkgs, 'ver'))
}python
write_host_sdk_manifest() {
from oe.sdk importsdk_list_installed_packages
+ from oe.utils importformat_pkg_list
sdkmanifestdir =
os.path.dirname(d.getVar("SDK_HOST_MANIFEST", True))
+ pkgs =sdk_list_installed_packages(d, False)
if notos.path.exists(sdkmanifestdir):
bb.utils.mkdirhier(sdkmanifestdir)
withopen(d.getVar('SDK_HOST_MANIFEST', True), 'w')as output:
-output.write(sdk_list_installed_packages(d, False, 'ver'))
+output.write(format_pkg_list(pkgs, 'ver'))
}
POPULATE_SDK_POST_TARGET_COMMAND_append= "
write_target_sdk_manifest; "
diff --git a/meta/classes/rootfs-postcommands.bbclass b/meta/classes/rootfs-postcommands.bbclass index 96d3051..fe664b7 100644
--- a/meta/classes/rootfs-postcommands.bbclass +++ b/meta/classes/rootfs-postcommands.bbclass @@ -207,14 +207,15 @@insert_feed_uris() {python
write_image_manifest() {
from oe.rootfs importimage_list_installed_packages
+ from oe.utils importformat_pkg_list
deploy_dir=d.getVar('DEPLOY_DIR_IMAGE', True)link_name=d.getVar('IMAGE_LINK_NAME', True)manifest_name=d.getVar('IMAGE_MANIFEST', True)
Quoted 8 lines
+ pkgs =
image_list_installed_packages(d)
withopen(manifest_name, 'w+')asimage_manifest:
-image_manifest.write(image_list_installed_packages(d, 'ver'))
-image_manifest.write("\n")
+image_manifest.write(format_pkg_list(pkgs, "ver"))As far as I understand from patch 2/4 in this series, you get something like "pkgInfo0\npkgInfoX\npkInfoLast" when using
join()from insideformat_pkg_list(), so you get no "\n" at the end of the file, and still you are also removing the line which adds the "\n" at the end. That would break the workaround which was added to fix bug #7427 in yocto right? Or am I missing something?
You are right, I just notice that I sent the incorrect set of patches (this one doesn't list the last deb or ipk package). I'll send the correct set.
Thanks for notice this.
Quoted 144 lines
if
manifest_nameis not None andos.path.exists(manifest_name):
manifest_link=deploy_dir+ "/" +link_name+ ".manifest"
diff --gita/meta/lib/oe/package_manager.pyb/meta/lib/oe/package_manager.py
index 95e7ae7..522cbf7 100644
---a/meta/lib/oe/package_manager.py
+++b/meta/lib/oe/package_manager.py
@@ -693,7 +693,7 @@ class PackageManager(object):
pass@abstractmethod
- deflist_installed(self, format=None):
+ deflist_installed(self):
pass@abstractmethod
@@ -713,7 +713,9 @@ class PackageManager(object):
installed_pkgs_file=
os.path.join(self.d.getVar('WORKDIR', True), "installed_pkgs.txt")
withopen(installed_pkgs_file, "w+")asinstalled_pkgs:
- installed_pkgs.write(self.list_installed("arch"))
+ pkgs =self.list_installed()
+ output =oe.utils.format_pkg_list(pkgs, "arch")
+installed_pkgs.write(output)if globs is None:
globs = self.d.getVar('IMAGE_INSTALL_COMPLEMENTARY',
True)
@@ -1417,8 +1419,8 @@ class RpmPM(PackageManager):
self.image_rpmlib, symlinks=True)- def
list_installed(self, format=None):
- returnself.pkgs_list.list(format)
+ deflist_installed(self):
+ returnself.pkgs_list.list_pkgs()'''
If incremental install, we need to determine what we've got,
@@ -1782,8 +1784,8 @@ class OpkgPM(PackageManager):
# create the directory back, it's needed by PM lockbb.utils.mkdirhier(self.opkg_dir)- def
list_installed(self, format=None):
- return OpkgPkgsList(self.d, self.target_rootfs,
self.config_file).list(format)
+ deflist_installed(self):
+ return OpkgPkgsList(self.d, self.target_rootfs,
self.config_file).list_pkgs()def
handle_bad_recommendations(self):
bad_recommendations=
self.d.getVar("BAD_RECOMMENDATIONS", True)or ""
@@ -2166,8 +2168,8 @@ class DpkgPM(PackageManager):
bb.fatal("Cannot fix broken dependencies. Command '%s' "
"returned %d:\n%s" % (cmd, e.returncode,
e.output))- def
list_installed(self, format=None):
- returnDpkgPkgsList(self.d, self.target_rootfs).list()
+ deflist_installed(self):
+ returnDpkgPkgsList(self.d, self.target_rootfs).list_pkgs()def
generate_index_files(d):
diff --gita/meta/lib/oe/rootfs.pyb/meta/lib/oe/rootfs.pyindex a2af332..45a88fb 100644
---a/meta/lib/oe/rootfs.py
+++b/meta/lib/oe/rootfs.py
@@ -963,17 +963,17 @@ defcreate_rootfs(d, manifest_dir=None):
os.environ.update(env_bkp)-def
image_list_installed_packages(d, format=None, rootfs_dir=None):
+defimage_list_installed_packages(d, rootfs_dir=None):
if notrootfs_dir:
rootfs_dir=d.getVar('IMAGE_ROOTFS', True)
img_type=d.getVar('IMAGE_PKGTYPE', True)ifimg_type== "rpm":
- returnRpmPkgsList(d, rootfs_dir).list(format)
+ returnRpmPkgsList(d, rootfs_dir).list_pkgs()
elifimg_type== "ipk":
- return OpkgPkgsList(d,rootfs_dir,
d.getVar("IPKGCONF_TARGET", True)).list(format)
+ return OpkgPkgsList(d,rootfs_dir,
d.getVar("IPKGCONF_TARGET", True)).list_pkgs()
elifimg_type== "deb":
- returnDpkgPkgsList(d, rootfs_dir).list(format)
+ returnDpkgPkgsList(d, rootfs_dir).list_pkgs()if
__name__== "__main__":
"""
diff --gita/meta/lib/oe/sdk.pyb/meta/lib/oe/sdk.pyindex 6affa40..b308aea 100644
---a/meta/lib/oe/sdk.py
+++b/meta/lib/oe/sdk.py
@@ -345,7 +345,7 @@ class DpkgSdk(Sdk):-def
sdk_list_installed_packages(d, target, format=None, rootfs_dir=None):
+defsdk_list_installed_packages(d, target, rootfs_dir=None):
ifrootfs_diris None:
sdk_output=d.getVar('SDK_OUTPUT', True)target_path=d.getVar('SDKTARGETSYSROOT', True).strip('/')
@@ -356,12 +356,12 @@ defsdk_list_installed_packages(d, target, format=None, rootfs_dir=None):
ifimg_type== "rpm":
arch_var= ["SDK_PACKAGE_ARCHS", None][target is True]os_var= ["SDK_OS", None][target is True]
- return RpmPkgsList(d,rootfs_dir,arch_var,
os_var).list(format)
+ return RpmPkgsList(d,rootfs_dir,arch_var,
os_var).list_pkgs()
elifimg_type== "ipk":
conf_file_var= ["IPKGCONF_SDK",
"IPKGCONF_TARGET"][target is True]
- return OpkgPkgsList(d,rootfs_dir,
d.getVar(conf_file_var, True)).list(format)
+ return OpkgPkgsList(d,rootfs_dir,
d.getVar(conf_file_var, True)).list_pkgs()
elifimg_type== "deb":
- returnDpkgPkgsList(d, rootfs_dir).list(format)
+ returnDpkgPkgsList(d, rootfs_dir).list_pkgs()def
populate_sdk(d, manifest_dir=None):
env_bkp=os.environ.copy()
--
1.8.4.5--
_______________________________________________
Openembedded-core mailing list [email protected] <mailto:[email protected]>
http://lists.openembedded.org/mailman/listinfo/openembedded-coreThanks for your time spent on this,
Pau
Signature · 1 line
Mariano Lopez
PATCH 4/4 lib/oe/package_manager.py: Remove list() from PkgsList class
In reply to [email protected]From: Mariano Lopez <[email protected]>
Now that the method list() is not used anymore, remove it.
[YOCTO #7427]
--- meta/lib/oe/package_manager.py | 153 ----------------------------------------- 1 file changed, 153 deletions(-)
meta/lib/oe/package_manager.py +0 -153
@@ -293,10 +293,6 @@ class PkgsList(object): self.rootfs_dir = rootfs_dir @abstractmethod - def list(self, format=None): - pass - - @abstractmethod def list_pkgs(self): pass
@@ -401,56 +397,6 @@ class RpmPkgsList(PkgsList): return output - def list(self, format=None): - if format == "deps": - if self.rpm_version == 4: - bb.fatal("'deps' format dependency listings are not supported with rpm 4 since rpmresolve does not work") - return self._list_pkg_deps() - - cmd = self.rpm_cmd + ' --root ' + self.rootfs_dir - cmd += ' -D "_dbpath /var/lib/rpm" -qa' - if self.rpm_version == 4: - cmd += " --qf '[%{NAME} %{ARCH} %{VERSION}\n]'" - else: - cmd += " --qf '[%{NAME} %{ARCH} %{VERSION} %{PACKAGEORIGIN}\n]'" - - try: - # bb.note(cmd) - tmp_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip() - - except subprocess.CalledProcessError as e: - bb.fatal("Cannot get the installed packages list. Command '%s' " - "returned %d:\n%s" % (cmd, e.returncode, e.output)) - - output = list() - for line in tmp_output.split('\n'): - if len(line.strip()) == 0: - continue - pkg = line.split()[0] - arch = line.split()[1] - ver = line.split()[2] - # Skip GPG keys - if pkg == 'gpg-pubkey': - continue - if self.rpm_version == 4: - pkgorigin = "unknown" - else: - pkgorigin = line.split()[3] - new_pkg, new_arch = self._pkg_translate_smart_to_oe(pkg, arch) - - if format == "arch": - output.append('%s %s' % (new_pkg, new_arch)) - elif format == "file": - output.append('%s %s %s' % (new_pkg, pkgorigin, new_arch)) - elif format == "ver": - output.append('%s %s %s' % (new_pkg, new_arch, ver)) - else: - output.append('%s' % (new_pkg)) - - output.sort() - - return '\n'.join(output) - def list_pkgs(self): cmd = self.rpm_cmd + ' --root ' + self.rootfs_dir cmd += ' -D "_dbpath /var/lib/rpm" -qa'
@@ -513,51 +459,6 @@ class OpkgPkgsList(PkgsList): self.opkg_args = "-f %s -o %s " % (config_file, rootfs_dir) self.opkg_args += self.d.getVar("OPKG_ARGS", True) - def list(self, format=None): - opkg_query_cmd = bb.utils.which(os.getenv('PATH'), "opkg-query-helper.py") - - if format == "arch": - cmd = "%s %s status | %s -a" % \ - (self.opkg_cmd, self.opkg_args, opkg_query_cmd) - elif format == "file": - cmd = "%s %s status | %s -f" % \ - (self.opkg_cmd, self.opkg_args, opkg_query_cmd) - elif format == "ver": - cmd = "%s %s status | %s -v" % \ - (self.opkg_cmd, self.opkg_args, opkg_query_cmd) - elif format == "deps": - cmd = "%s %s status | %s" % \ - (self.opkg_cmd, self.opkg_args, opkg_query_cmd) - else: - cmd = "%s %s list_installed | cut -d' ' -f1" % \ - (self.opkg_cmd, self.opkg_args) - - try: - # bb.note(cmd) - tmp_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip() - - except subprocess.CalledProcessError as e: - bb.fatal("Cannot get the installed packages list. Command '%s' " - "returned %d:\n%s" % (cmd, e.returncode, e.output)) - - output = list() - for line in tmp_output.split('\n'): - if len(line.strip()) == 0: - continue - if format == "file": - pkg, pkg_file, pkg_arch = line.split() - full_path = os.path.join(self.rootfs_dir, pkg_arch, pkg_file) - if os.path.exists(full_path): - output.append('%s %s %s' % (pkg, full_path, pkg_arch)) - else: - output.append('%s %s %s' % (pkg, pkg_file, pkg_arch)) - else: - output.append(line) - - output.sort() - - return '\n'.join(output) - def list_pkgs(self, format=None): cmd = "%s %s status" % (self.opkg_cmd, self.opkg_args)
@@ -573,60 +474,6 @@ class OpkgPkgsList(PkgsList): class DpkgPkgsList(PkgsList): - def list(self, format=None): - cmd = [bb.utils.which(os.getenv('PATH'), "dpkg-query"), - "--admindir=%s/var/lib/dpkg" % self.rootfs_dir, - "-W"] - - if format == "arch": - cmd.append("-f=${Package} ${PackageArch}\n") - elif format == "file": - cmd.append("-f=${Package} ${Package}_${Version}_${Architecture}.deb ${PackageArch}\n") - elif format == "ver": - cmd.append("-f=${Package} ${PackageArch} ${Version}\n") - elif format == "deps": - cmd.append("-f=Package: ${Package}\nDepends: ${Depends}\nRecommends: ${Recommends}\n\n") - else: - cmd.append("-f=${Package}\n") - - try: - output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip() - except subprocess.CalledProcessError as e: - bb.fatal("Cannot get the installed packages list. Command '%s' " - "returned %d:\n%s" % (' '.join(cmd), e.returncode, e.output)) - - if format == "file": - tmp_output = "" - for line in tuple(output.split('\n')): - if not line.strip(): - continue - pkg, pkg_file, pkg_arch = line.split() - full_path = os.path.join(self.rootfs_dir, pkg_arch, pkg_file) - if os.path.exists(full_path): - tmp_output += "%s %s %s\n" % (pkg, full_path, pkg_arch) - else: - tmp_output += "%s %s %s\n" % (pkg, pkg_file, pkg_arch) - - output = tmp_output - elif format == "deps": - opkg_query_cmd = bb.utils.which(os.getenv('PATH'), "opkg-query-helper.py") - file_out = tempfile.NamedTemporaryFile() - file_out.write(output) - file_out.flush() - - try: - output = subprocess.check_output("cat %s | %s" % - (file_out.name, opkg_query_cmd), - stderr=subprocess.STDOUT, - shell=True) - except subprocess.CalledProcessError as e: - file_out.close() - bb.fatal("Cannot compute packages dependencies. Command '%s' " - "returned %d:\n%s" % (e.cmd, e.returncode, e.output)) - - file_out.close() - - return output def list_pkgs(self): cmd = [bb.utils.which(os.getenv('PATH'), "dpkg-query"),
Signature · 1 line
1.8.4.5