#1161 gather: Don't trim prepopulate package
Opened 2 years ago by lsedlar. Modified 2 years ago
lsedlar/pungi no-remove-prepopulate  into  master

@@ -293,9 +293,20 @@ 

              pkg_path = pkg["path"]

              if not pkg_path:

                  continue

+ 

              nvra = parse_nvra(pkg_path)

              key = ((nvra["name"], nvra["arch"]))

  

+             if "prepopulate" in pkg["flags"]:

+                 # Don't trim prepopulate packages. If we did, it could cause

+                 # packages to disappear from optional variants because the

+                 # package is pulled in as a dependency to an addon. Ultimately

+                 # that could even break dependencies for users with access to

+                 # optional but not the addon.

+                 new_pkgs.append(pkg)

+                 addon_pkgs[pkg_type].add(nvra["name"])

+                 continue

+ 

              if nvra["name"] in remove_pkgs.get(pkg_type, set()):

                  # TODO: make an option to turn this off

                  if variant.type == "layered-product" and pkg_type in ("srpm", "debuginfo"):

@@ -375,6 +375,20 @@ 

          self.assertEqual(moved_to_parent, _mk_pkg_map())

          self.assertEqual(pkg_map, _mk_pkg_map([to_keep]))

  

+     def test_dont_remove_prepopulate_package(self):

+         prep_pkg = {

+             "path": "/build/required-1.0.0-1.x86_64.rpm",

+             "flags": ["input", "prepopulate"],

+         }

+         pkg_map = _mk_pkg_map([prep_pkg])

+         addon_pkgs, moved_to_parent, removed_pkgs = gather.trim_packages(

+             self.compose, 'x86_64', self.addon, pkg_map, remove_pkgs={'rpm': ['required']})

+ 

+         self.assertEqual(removed_pkgs, _mk_pkg_map())

+         self.assertEqual(addon_pkgs, _mk_pkg_map(set(["required"]), iterable_class=set))

+         self.assertEqual(moved_to_parent, _mk_pkg_map())

+         self.assertEqual(pkg_map, _mk_pkg_map([prep_pkg]))

+ 

      def test_remove_package_present_in_parent(self):

          # packages present in parent will be removed from addon

          parent_pkgs = {

If a package is listed in prepopulate file, it should not be removed from the variant during trimming.

Example situation:

  1. Initial release ships package in Server-optional.
  2. In next release prepopulate is used to keep packages in the same locations.
  3. An addon starts pulling in the package. Trimming removes it from the original location.

This results in consumers being surprised about packages going missing. Just because a package is available in an addon is not an excuse for it to disappear (and possibly break dependencies).

The solution is to not trim anything pulled in due to prepopulate. As an end result, the same package may be included in multiple variants.

Yes, that should work.

rebased onto cd957a7

2 years ago