[yocto] PermissionError when using image_list_installed_packages

Norman Stetter Norman.Stetter at garz-fricke.com
Mon Nov 19 23:43:51 PST 2018


Hi,

I am currently working on a BitBake task, which generates a html file containing a table of all packages used in my image.

To get a list of all packages I want to use 'image_list_installed_packages' from 'oe.rootfs', the way it is used in 'license.bbclass'.

My minimal test recipe looks like this:

SUMMARY = "Test recipe"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302<file://$%7bCOMMON_LICENSE_DIR%7d/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302>"

inherit license


python do_licensesinfo() {
  from oe.rootfs import image_list_installed_packages
  pkgs = image_list_installed_packages(d)
}
addtask licensesinfo
When I run the task 'licensesinfo' it fails giving this log:

DEBUG: Executing python function do_licensesinfo
ERROR: Error executing a python function in exec_python_func() autogenerated:

The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
     0001:
 *** 0002:do_licensesinfo(d)
     0003:
File: '/home/norman.stetter/build/yocto-rocko/sources/meta-guf/meta/recipes-bsp/images/guf-image-licenses.bb', lineno: 11, function: do_licensesinfo
     0007:
     0008:
     0009:python do_licensesinfo() {
     0010:  from oe.rootfs import image_list_installed_packages
 *** 0011:  pkgs = image_list_installed_packages(d)
     0012:}
     0013:addtask licensesinfo
     0014:
     0015:
File: '/home/norman.stetter/build/yocto-rocko/sources/poky/meta/lib/oe/rootfs.py', lineno: 1026, function: image_list_installed_packages
     1022:        rootfs_dir = d.getVar('IMAGE_ROOTFS')
     1023:
     1024:    img_type = d.getVar('IMAGE_PKGTYPE')
     1025:    if img_type == "rpm":
 *** 1026:        return RpmPkgsList(d, rootfs_dir).list_pkgs()
     1027:    elif img_type == "ipk":
     1028:        return OpkgPkgsList(d, rootfs_dir, d.getVar("IPKGCONF_TARGET")).list_pkgs()
     1029:    elif img_type == "deb":
     1030:        return DpkgPkgsList(d, rootfs_dir).list_pkgs()
File: '/home/norman.stetter/build/yocto-rocko/sources/poky/meta/lib/oe/package_manager.py', lineno: 258, function: list_pkgs
     0254:        pass
     0255:
     0256:class RpmPkgsList(PkgsList):
     0257:    def list_pkgs(self):
 *** 0258:        return RpmPM(self.d, self.rootfs_dir, self.d.getVar('TARGET_VENDOR')).list_installed()
     0259:
     0260:class OpkgPkgsList(PkgsList):
     0261:    def __init__(self, d, rootfs_dir, config_file):
     0262:        super(OpkgPkgsList, self).__init__(d, rootfs_dir)
File: '/home/norman.stetter/build/yocto-rocko/sources/poky/meta/lib/oe/package_manager.py', lineno: 689, function: list_installed
     0685:                            symlinks=True)
     0686:
     0687:    def list_installed(self):
     0688:        output = self._invoke_dnf(["repoquery", "--installed", "--queryformat", "Package: %{name} %{arch} %{version} %{name}-%{version}-%{release}.%{arch}.rpm\nDependencies:\n%{requires}\nRecommendations:\n%{recommends}\nDependenciesEndHere:\n"],
 *** 0689:                                  print_output = False)
     0690:        packages = {}
     0691:        current_package = None
     0692:        current_deps = None
     0693:        current_state = "initial"
File: '/home/norman.stetter/build/yocto-rocko/sources/poky/meta/lib/oe/package_manager.py', lineno: 734, function: _invoke_dnf
     0730:                             "--setopt=logdir=%s" % (self.d.getVar('T'))
     0731:                            ]
     0732:        cmd = [dnf_cmd] + standard_dnf_args + dnf_args
     0733:        try:
 *** 0734:            output = subprocess.check_output(cmd,stderr=subprocess.STDOUT).decode("utf-8")
     0735:            if print_output:
     0736:                bb.note(output)
     0737:            return output
     0738:        except subprocess.CalledProcessError as e:
File: '/usr/lib/python3.5/subprocess.py', lineno: 626, function: check_output
     0622:        # empty string. That is maintained here for backwards compatibility.
     0623:        kwargs['input'] = '' if kwargs.get('universal_newlines', False) else b''
     0624:
     0625:    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
 *** 0626:               **kwargs).stdout
     0627:
     0628:
     0629:class CompletedProcess(object):
     0630:    """A process that has finished running.
File: '/usr/lib/python3.5/subprocess.py', lineno: 693, function: run
     0689:        if 'stdin' in kwargs:
     0690:            raise ValueError('stdin and input arguments may not both be used.')
     0691:        kwargs['stdin'] = PIPE
     0692:
 *** 0693:    with Popen(*popenargs, **kwargs) as process:
     0694:        try:
     0695:            stdout, stderr = process.communicate(input, timeout=timeout)
     0696:        except TimeoutExpired:
     0697:            process.kill()
File: '/usr/lib/python3.5/subprocess.py', lineno: 947, function: __init__
     0943:                                startupinfo, creationflags, shell,
     0944:                                p2cread, p2cwrite,
     0945:                                c2pread, c2pwrite,
     0946:                                errread, errwrite,
 *** 0947:                                restore_signals, start_new_session)
     0948:        except:
     0949:            # Cleanup if the child failed starting.
     0950:            for f in filter(None, (self.stdin, self.stdout, self.stderr)):
     0951:                try:
File: '/usr/lib/python3.5/subprocess.py', lineno: 1551, function: _execute_child
     1547:                                # The error must be from chdir(cwd).
     1548:                                err_msg += ': ' + repr(cwd)
     1549:                            else:
     1550:                                err_msg += ': ' + repr(orig_executable)
 *** 1551:                    raise child_exception_type(errno_num, err_msg)
     1552:                raise child_exception_type(err_msg)
     1553:
     1554:
     1555:        def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,
Exception: PermissionError: [Errno 13] Permission denied

DEBUG: Python function do_licensesinfo finished
ERROR: Function failed: do_licensesinfo

So it looks like the invoked 'dnf' can't open a file due to permission issues.

But I never experienced any problems during my regular builds, which obviously also use 'image_list_installed_packages'.

Does someone know why I encounter this error only, when calling 'image_list_installed_packages' in my own recipe?


Regards,

Norman


Mit freundlichen Grüßen / Best regards
Norman Stetter
SW ENWICKLUNG EMBEDDED SYSTEMS
Garz & Fricke GmbH

21079 Hamburg
Direct: +49 40 791899 - 477
Fax: +49 40 791899 - 39
Norman.Stetter at garz-fricke.com
www.garz-fricke.com<http://www.garz-fricke.com/>
WE MAKE IT YOURS!
[cid:image001.jpg at 01D480AD.2A332740]
Sitz der Gesellschaft: D-21079 Hamburg
Registergericht: Amtsgericht Hamburg, HRB 60514
Geschäftsführer: Matthias Fricke, Manfred Garz, Marc-Michael Braun

[cid:image002.jpg at 01D480AD.2A332740]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20181120/d87125a2/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 14804 bytes
Desc: image001.jpg
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20181120/d87125a2/attachment-0002.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.jpg
Type: image/jpeg
Size: 4908 bytes
Desc: image002.jpg
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20181120/d87125a2/attachment-0003.jpg>


More information about the yocto mailing list