diff mbox series

[RFC,v2,2/6] package_manager: Add feed support to generate_index_files.

Message ID 20230731215310.3949441-3-charlie.johnston@ni.com
State New
Headers show
Series Add new packagefeed recipe class. | expand

Commit Message

Charlie Johnston July 31, 2023, 9:42 p.m. UTC
Currently, the generate_index_files function only handles
the creation of index files in the DEPLOY_DIR_<PKG_TYPE>
directories. This change adds an optional feedname input
that will instead point the index generation at a package
specific feed directory. If no feedname is specified,
the original behavior persists.

The directory for index creation will be
${DEPLOY_DIR_FEED_<PKG_TYPE>}/feedname.

Signed-off-by: Charlie Johnston <charlie.johnston@ni.com>
---
 meta/lib/oe/package_manager/__init__.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Alexander Kanavin Aug. 1, 2023, 10:06 a.m. UTC | #1
I think it's better to change indexer_map either to three different
dictionaries, or a dictionary of dictionaries. Putting more than two
things in a tuple (that aren't of the same kind) results in a code
that's hard to read. For example:

feedpath = indexer_map[pkg_class][1] if feedname is None else
indexer_map[pkg_class][2]
if os.path.exists(feedpath):
            result = indexer_map[pkg_class][0](d, feedpath).write_index()

What is '1' and what is '2' and what is '0'? They should be named
properly, and not numbered.

Same applies to patch 4/6.

Alex



On Mon, 31 Jul 2023 at 23:53, Charlie Johnston <charlie.johnston@ni.com> wrote:
>
> Currently, the generate_index_files function only handles
> the creation of index files in the DEPLOY_DIR_<PKG_TYPE>
> directories. This change adds an optional feedname input
> that will instead point the index generation at a package
> specific feed directory. If no feedname is specified,
> the original behavior persists.
>
> The directory for index creation will be
> ${DEPLOY_DIR_FEED_<PKG_TYPE>}/feedname.
>
> Signed-off-by: Charlie Johnston <charlie.johnston@ni.com>
> ---
>  meta/lib/oe/package_manager/__init__.py | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/meta/lib/oe/package_manager/__init__.py b/meta/lib/oe/package_manager/__init__.py
> index 0c313190cf..0934cda89d 100644
> --- a/meta/lib/oe/package_manager/__init__.py
> +++ b/meta/lib/oe/package_manager/__init__.py
> @@ -533,7 +533,7 @@ def create_packages_dir(d, subrepo_dir, deploydir, taskname, filterbydependencie
>                          raise
>
>
> -def generate_index_files(d):
> +def generate_index_files(d, feedname = None):
>      from oe.package_manager.rpm import RpmSubdirIndexer
>      from oe.package_manager.ipk import OpkgIndexer
>      from oe.package_manager.deb import DpkgIndexer
> @@ -541,9 +541,9 @@ 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'))
> +        "rpm": (RpmSubdirIndexer, d.getVar('DEPLOY_DIR_RPM'), d.expand('${DEPLOY_DIR_FEED_RPM}/%s' % feedname)),
> +        "ipk": (OpkgIndexer, d.getVar('DEPLOY_DIR_IPK'), d.expand('${DEPLOY_DIR_FEED_IPK}/%s' % feedname)),
> +        "deb": (DpkgIndexer, d.getVar('DEPLOY_DIR_DEB'), d.expand('${DEPLOY_DIR_FEED_DEB}/%s' % feedname))
>      }
>
>      result = None
> @@ -552,8 +552,9 @@ def generate_index_files(d):
>          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()
> +        feedpath = indexer_map[pkg_class][1] if feedname is None else indexer_map[pkg_class][2]
> +        if os.path.exists(feedpath):
> +            result = indexer_map[pkg_class][0](d, feedpath).write_index()
>
>              if result is not None:
>                  bb.fatal(result)
> --
> 2.41.0
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#185176): https://lists.openembedded.org/g/openembedded-core/message/185176
> Mute This Topic: https://lists.openembedded.org/mt/100471803/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta/lib/oe/package_manager/__init__.py b/meta/lib/oe/package_manager/__init__.py
index 0c313190cf..0934cda89d 100644
--- a/meta/lib/oe/package_manager/__init__.py
+++ b/meta/lib/oe/package_manager/__init__.py
@@ -533,7 +533,7 @@  def create_packages_dir(d, subrepo_dir, deploydir, taskname, filterbydependencie
                         raise
 
 
-def generate_index_files(d):
+def generate_index_files(d, feedname = None):
     from oe.package_manager.rpm import RpmSubdirIndexer
     from oe.package_manager.ipk import OpkgIndexer
     from oe.package_manager.deb import DpkgIndexer
@@ -541,9 +541,9 @@  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'))
+        "rpm": (RpmSubdirIndexer, d.getVar('DEPLOY_DIR_RPM'), d.expand('${DEPLOY_DIR_FEED_RPM}/%s' % feedname)),
+        "ipk": (OpkgIndexer, d.getVar('DEPLOY_DIR_IPK'), d.expand('${DEPLOY_DIR_FEED_IPK}/%s' % feedname)),
+        "deb": (DpkgIndexer, d.getVar('DEPLOY_DIR_DEB'), d.expand('${DEPLOY_DIR_FEED_DEB}/%s' % feedname))
     }
 
     result = None
@@ -552,8 +552,9 @@  def generate_index_files(d):
         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()
+        feedpath = indexer_map[pkg_class][1] if feedname is None else indexer_map[pkg_class][2]
+        if os.path.exists(feedpath):
+            result = indexer_map[pkg_class][0](d, feedpath).write_index()
 
             if result is not None:
                 bb.fatal(result)