]> code.ossystems Code Review - openembedded-core.git/commitdiff
lib/oe/package_manager: Avoid race problems when calling list_pkgs()
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 15 Nov 2018 11:28:11 +0000 (11:28 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 16 Nov 2018 09:32:17 +0000 (09:32 +0000)
list_pkgs() for rpm calls RpmPM() which would try and create a copy of the
package feed. This can be called for example from buildhistory whilst some
other task may be working on an SDK or image construction, causing the package
feed to disappear part way through an operation.

Avoid the need to copy the package index just to list the installed
packages, avoiding the race.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oe/package_manager.py

index aa4de6e7c3036543d6d7799e52b5d8dbaf0c4d83..02cf2b762181df2181265ba5f658f33450666b3c 100644 (file)
@@ -320,7 +320,7 @@ class PkgsList(object, metaclass=ABCMeta):
 
 class RpmPkgsList(PkgsList):
     def list_pkgs(self):
-        return RpmPM(self.d, self.rootfs_dir, self.d.getVar('TARGET_VENDOR')).list_installed()
+        return RpmPM(self.d, self.rootfs_dir, self.d.getVar('TARGET_VENDOR'), needfeed=False).list_installed()
 
 class OpkgPkgsList(PkgsList):
     def __init__(self, d, rootfs_dir, config_file):
@@ -724,7 +724,8 @@ class RpmPM(PackageManager):
                  arch_var=None,
                  os_var=None,
                  rpm_repo_workdir="oe-rootfs-repo",
-                 filterbydependencies=True):
+                 filterbydependencies=True,
+                 needfeed=True):
         super(RpmPM, self).__init__(d, target_rootfs)
         self.target_vendor = target_vendor
         self.task_name = task_name
@@ -737,8 +738,9 @@ class RpmPM(PackageManager):
         else:
             self.primary_arch = self.d.getVar('MACHINE_ARCH')
 
-        self.rpm_repo_dir = oe.path.join(self.d.getVar('WORKDIR'), rpm_repo_workdir)
-        create_packages_dir(self.d, oe.path.join(self.rpm_repo_dir, "rpm"), d.getVar("DEPLOY_DIR_RPM"), "package_write_rpm", filterbydependencies)
+        if needfeed:
+            self.rpm_repo_dir = oe.path.join(self.d.getVar('WORKDIR'), rpm_repo_workdir)
+            create_packages_dir(self.d, oe.path.join(self.rpm_repo_dir, "rpm"), d.getVar("DEPLOY_DIR_RPM"), "package_write_rpm", filterbydependencies)
 
         self.saved_packaging_data = self.d.expand('${T}/saved_packaging_data/%s' % self.task_name)
         if not os.path.exists(self.d.expand('${T}/saved_packaging_data')):
@@ -967,10 +969,11 @@ class RpmPM(PackageManager):
         standard_dnf_args = ["-v", "--rpmverbosity=debug", "-y",
                              "-c", oe.path.join(self.target_rootfs, "etc/dnf/dnf.conf"),
                              "--setopt=reposdir=%s" %(oe.path.join(self.target_rootfs, "etc/yum.repos.d")),
-                             "--repofrompath=oe-repo,%s" % (self.rpm_repo_dir),
                              "--installroot=%s" % (self.target_rootfs),
                              "--setopt=logdir=%s" % (self.d.getVar('T'))
                             ]
+        if hasattr(self, "rpm_repo_dir"):
+            standard_dnf_args.append("--repofrompath=oe-repo,%s" % (self.rpm_repo_dir))
         cmd = [dnf_cmd] + standard_dnf_args + dnf_args
         bb.note('Running %s' % ' '.join(cmd))
         try: