All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Fredrik Gustafsson" <fredrik.gustafsson@axis.com>
To: <openembedded-core@lists.openembedded.org>
Cc: <tools-cfpbuild-internal@axis.com>, <hugo.cedervall@axis.com>,
	Fredrik Gustafsson <fredrigu@axis.com>
Subject: [PATCH v2 22/26] package_manager: Rename Indexer classes
Date: Thu, 25 Jun 2020 12:21:41 +0200	[thread overview]
Message-ID: <20200625102145.7139-23-fredrigu@axis.com> (raw)
In-Reply-To: <20200625102145.7139-1-fredrigu@axis.com>

Rename all *Indexer classeds to PkgIndexer to enable dynamic calling.

Signed-off-by: Fredrik Gustafsson <fredrigu@axis.com>
---
 meta/lib/oe/package_manager.py                | 22 +++++--------------
 .../package_managers/deb/package_manager.py   |  8 +++++--
 .../package_managers/ipk/package_manager.py   |  7 ++++--
 .../package_managers/rpm/package_manager.py   |  5 ++++-
 4 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index 111845d903..bfddbce93c 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -149,8 +149,6 @@ class Indexer(object, metaclass=ABCMeta):
     def write_index(self):
         pass
 
-
-
 class PkgsList(object, metaclass=ABCMeta):
     def __init__(self, d, rootfs_dir):
         self.d = d
@@ -576,22 +574,12 @@ def create_packages_dir(d, subrepo_dir, deploydir, taskname, filterbydependencie
                         raise
 
 def generate_index_files(d):
-    classes = d.getVar('PACKAGE_CLASSES').replace("package_", "").split()
-
-    indexer_map = {
-        "rpm": (RpmSubdirIndexer, d.getVar('DEPLOY_DIR_RPM')),
-        "ipk": (OpkgIndexer, d.getVar('DEPLOY_DIR_IPK')),
-        "deb": (DpkgIndexer, d.getVar('DEPLOY_DIR_DEB'))
-    }
-
+    classes = d.getVar('PACKAGE_CLASSES').split()
     result = None
 
     for pkg_class in classes:
-        if not pkg_class in indexer_map:
-            continue
-
-        if os.path.exists(indexer_map[pkg_class][1]):
-            result = indexer_map[pkg_class][0](d, indexer_map[pkg_class][1]).write_index()
+        import importlib
+        result = importlib.import_module('oe.package_managers.' + classes + '.manifest').PkgIndexer(d).write_index()
 
-            if result is not None:
-                bb.fatal(result)
+        if result is not None:
+            bb.fatal(result)
diff --git a/meta/lib/oe/package_managers/deb/package_manager.py b/meta/lib/oe/package_managers/deb/package_manager.py
index 5d3c300700..0dc4004f66 100644
--- a/meta/lib/oe/package_managers/deb/package_manager.py
+++ b/meta/lib/oe/package_managers/deb/package_manager.py
@@ -94,7 +94,7 @@ class PkgPM(OpkgDpkgPM):
 
         self._create_configs(archs, base_archs)
 
-        self.indexer = DpkgIndexer(self.d, self.deploy_dir)
+        self.indexer = PkgIndexer(self.d, self.deploy_dir)
 
     def mark_packages(self, status_tag, packages=None):
         """
@@ -400,7 +400,7 @@ class PkgPM(OpkgDpkgPM):
         return tmp_dir
 
 
-class DpkgIndexer(Indexer):
+class PkgIndexer(Indexer):
     def _create_configs(self):
         bb.utils.mkdirhier(self.apt_conf_dir)
         bb.utils.mkdirhier(os.path.join(self.apt_conf_dir, "lists", "partial"))
@@ -423,6 +423,10 @@ class DpkgIndexer(Indexer):
                     apt_conf.write(line + "\n")
 
     def write_index(self):
+        if self.deploy_dir == "":
+            self.deploy_dir = self.d.getVar('DEPLOY_DIR_DEB')
+
+
         self.apt_conf_dir = os.path.join(self.d.expand("${APTCONF_TARGET}"),
                 "apt-ftparchive")
         self.apt_conf_file = os.path.join(self.apt_conf_dir, "apt.conf")
diff --git a/meta/lib/oe/package_managers/ipk/package_manager.py b/meta/lib/oe/package_managers/ipk/package_manager.py
index 8abc6c1c98..133af27182 100644
--- a/meta/lib/oe/package_managers/ipk/package_manager.py
+++ b/meta/lib/oe/package_managers/ipk/package_manager.py
@@ -106,7 +106,7 @@ class PkgPM(OpkgDpkgPM):
         else:
             self._create_config()
 
-        self.indexer = OpkgIndexer(self.d, self.deploy_dir)
+        self.indexer = PkgIndexer(self.d, self.deploy_dir)
 
     def mark_packages(self, status_tag, packages=None):
         """
@@ -423,8 +423,11 @@ class PkgPM(OpkgDpkgPM):
 
         return tmp_dir
 
-class OpkgIndexer(Indexer):
+class PkgIndexer(Indexer):
     def write_index(self):
+        if self.deploy_dir == "":
+            self.deploy_dir = self.d.getVar('DEPLOY_DIR_IPK')
+
         arch_vars = ["ALL_MULTILIB_PACKAGE_ARCHS",
                      "SDK_PACKAGE_ARCHS",
                      ]
diff --git a/meta/lib/oe/package_managers/rpm/package_manager.py b/meta/lib/oe/package_managers/rpm/package_manager.py
index 025e8cdfd2..e781676183 100644
--- a/meta/lib/oe/package_managers/rpm/package_manager.py
+++ b/meta/lib/oe/package_managers/rpm/package_manager.py
@@ -384,8 +384,11 @@ class RpmIndexer(Indexer):
                                self.d.getVar('PACKAGE_FEED_GPG_PASSPHRASE_FILE'),
                                armor=is_ascii_sig)
 
-class RpmSubdirIndexer(RpmIndexer):
+class PkgIndexer(RpmIndexer):
     def write_index(self):
+        if self.deploy_dir == "":
+            self.deploy_dir = self.d.getVar('DEPLOY_DIR_RPM')
+
         bb.note("Generating package index for %s" %(self.deploy_dir))
         self.do_write_index(self.deploy_dir)
         for entry in os.walk(self.deploy_dir):
-- 
2.20.1


  parent reply	other threads:[~2020-06-25 10:22 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-25 10:21 Add package managers as a plugin Fredrik Gustafsson
2020-06-25 10:21 ` [PATCH v2 01/26] nopackages.bbclass: Get tasks from variable Fredrik Gustafsson
2020-06-25 10:41   ` [OE-core] " Paul Barker
2020-06-25 10:21 ` [PATCH v2 02/26] package_managers: Add directory structure Fredrik Gustafsson
2020-06-25 10:41   ` [OE-core] " Paul Barker
2020-06-25 10:21 ` [PATCH v2 03/26] manifest: Move RpmManifest Fredrik Gustafsson
2020-06-25 10:21 ` [PATCH v2 04/26] manifest: Move DpkgManifest Fredrik Gustafsson
2020-06-25 10:21 ` [PATCH v2 05/26] manifest: Move OpkgManifest Fredrik Gustafsson
2020-06-25 10:21 ` [PATCH v2 06/26] manifest.py: Dynamic load of manifest Fredrik Gustafsson
2020-06-25 10:41   ` [OE-core] " Paul Barker
2020-06-25 10:21 ` [PATCH v2 07/26] sdk.py: Move RpmSdk Fredrik Gustafsson
2020-06-25 10:21 ` [PATCH v2 08/26] sdk.py: Move DpkgSdk Fredrik Gustafsson
2020-06-25 10:21 ` [PATCH v2 09/26] sdk.py: Move OpkgSdk Fredrik Gustafsson
2020-06-25 10:21 ` [PATCH v2 10/26] sdk.py: Dynamic load of sdk Fredrik Gustafsson
2020-06-25 10:41   ` [OE-core] " Paul Barker
2020-06-25 10:21 ` [PATCH v2 11/26] rootfs.py: Move RpmRootfs Fredrik Gustafsson
2020-06-25 10:21 ` [PATCH v2 12/26] rootfs.py: Move DpkgRootfs Fredrik Gustafsson
2020-06-25 10:21 ` [PATCH v2 13/26] rootfs.py: Move OpkgRootfs Fredrik Gustafsson
2020-06-25 10:21 ` [PATCH v2 14/26] rootfs.py: Dynamic load of rootfs Fredrik Gustafsson
2020-06-25 10:42   ` [OE-core] " Paul Barker
2020-06-25 10:21 ` [PATCH v2 15/26] package_manager.py: Move RpmPM Fredrik Gustafsson
2020-06-25 10:21 ` [PATCH v2 16/26] package_manager.py: Move DpkgPM Fredrik Gustafsson
2020-06-25 10:21 ` [PATCH v2 17/26] package_manager.py: Move OpkgPM Fredrik Gustafsson
2020-06-25 10:21 ` [PATCH v2 18/26] package_manager: Rename RpmPM to PkgPM, etc Fredrik Gustafsson
2020-06-25 10:42   ` [OE-core] " Paul Barker
2020-06-25 10:21 ` [PATCH v2 19/26] package_manager.py: Move RpmIndexer Fredrik Gustafsson
2020-06-25 10:21 ` [PATCH v2 20/26] package_manager.py: Move OpkgIndexer Fredrik Gustafsson
2020-06-25 10:21 ` [PATCH v2 21/26] package_manager.py: Move DpkgIndexer Fredrik Gustafsson
2020-06-25 10:42   ` [OE-core] " Paul Barker
2020-06-25 10:21 ` Fredrik Gustafsson [this message]
2020-06-25 10:42   ` [OE-core] [PATCH v2 22/26] package_manager: Rename Indexer classes Paul Barker
2020-06-25 10:21 ` [PATCH v2 23/26] package_manager.py: Move RpmPkgsList Fredrik Gustafsson
2020-06-25 10:21 ` [PATCH v2 24/26] package_manager.py: Move OpkgPkgsList Fredrik Gustafsson
2020-06-25 10:21 ` [PATCH v2 25/26] package_manager.py: Move DpkgPkgsList Fredrik Gustafsson
2020-06-25 10:21 ` [PATCH v2 26/26] package_manager: Rename PkgsList classes Fredrik Gustafsson
2020-06-25 10:43   ` [OE-core] " Paul Barker
2020-06-25 10:40 ` [OE-core] Add package managers as a plugin Paul Barker
2020-06-30 18:39   ` Fredrik Gustafsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200625102145.7139-23-fredrigu@axis.com \
    --to=fredrik.gustafsson@axis.com \
    --cc=fredrigu@axis.com \
    --cc=hugo.cedervall@axis.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=tools-cfpbuild-internal@axis.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.