Bug #337180 - Add a --unmatched-removal option for stricter checking
authorZac Medico <zmedico@gentoo.org>
Wed, 15 Sep 2010 07:27:09 +0000 (00:27 -0700)
committerZac Medico <zmedico@gentoo.org>
Wed, 15 Sep 2010 07:27:09 +0000 (00:27 -0700)
of package.mask and package.unmask files for unmatched removal atoms.

bin/repoman
man/repoman.1
pym/portage/package/ebuild/_config/MaskManager.py
pym/portage/package/ebuild/config.py

index 70e7cdaf24acec3243ebe68e22f18a29d7f94b3b..1f7b21bce165eb468a4cff50c4339b39d2e8dbaf 100755 (executable)
@@ -216,6 +216,9 @@ def ParseArgs(argv, qahelp):
        parser.add_option('-d', '--include-dev', dest='include_dev', action='store_true',
                default=False, help='include dev profiles in dependency checks')
 
+       parser.add_option('--unmatched-removal', dest='unmatched_removal', action='store_true',
+               default=False, help='enable strict checking of package.mask and package.unmask files for unmatched removal atoms')
+
        parser.add_option('--without-mask', dest='without_mask', action='store_true',
                default=False, help='behave as if no package.mask entries exist (not allowed with commit mode)')
 
@@ -1818,6 +1821,7 @@ for x in scanlist:
                                                config_profile_path=prof.abs_path,
                                                config_incrementals=repoman_incrementals,
                                                local_config=False,
+                                               _unmatched_removal=options.unmatched_removal,
                                                env=env)
                                        if options.without_mask:
                                                dep_settings._mask_manager = \
index 2e0e5a540bd9c556d1038c91bc250aeeab2a417b..e7234b0a0d75c8a60e61d52cbbe791f8762aabe3 100644 (file)
@@ -50,6 +50,10 @@ Ignore masked packages (not allowed with commit mode)
 \fB\-d\fR, \fB\-\-include\-dev\fR
 Include dev profiles in dependency checks.
 .TP
+\fB\-\-unmatched\-removal\fR
+Enable strict checking of package.mask and package.unmask files for
+unmatched removal atoms.
+.TP
 \fB\-\-without\-mask\fR
 Behave as if no package.mask entries exist (not allowed with commit mode)
 .TP
index 34cc6ec26be0b58b2897e8a6714f5500c830f272..f5b240a4743b52949793d04960878cdc2696226a 100644 (file)
@@ -13,7 +13,8 @@ from portage.versions import cpv_getkey
 
 class MaskManager(object):
 
-       def __init__(self, pmask_locations, abs_user_config, user_config=True):
+       def __init__(self, pmask_locations, abs_user_config,
+               user_config=True, strict_umatched_removal=False):
                self._punmaskdict = ExtendedAtomDict(list)
                self._pmaskdict = ExtendedAtomDict(list)
 
@@ -26,10 +27,14 @@ class MaskManager(object):
                for x in repo_profiles:
                        repo_pkgmasklines.append(stack_lists([grabfile_package(
                                os.path.join(x, "package.mask"), recursive=1, remember_source_file=True, verify_eapi=True)], \
-                                       incremental=1, remember_source_file=True, warn_for_unmatched_removal=True))
+                                       incremental=1, remember_source_file=True,
+                                       warn_for_unmatched_removal=True,
+                                       strict_warn_for_unmatched_removal=strict_umatched_removal))
                        repo_pkgunmasklines.append(stack_lists([grabfile_package(
                                os.path.join(x, "package.unmask"), recursive=1, remember_source_file=True, verify_eapi=True)], \
-                               incremental=1, remember_source_file=True, warn_for_unmatched_removal=True))
+                               incremental=1, remember_source_file=True,
+                               warn_for_unmatched_removal=True,
+                               strict_warn_for_unmatched_removal=strict_umatched_removal))
                repo_pkgmasklines = list(chain.from_iterable(repo_pkgmasklines))
                repo_pkgunmasklines = list(chain.from_iterable(repo_pkgunmasklines))
 
@@ -43,9 +48,11 @@ class MaskManager(object):
                        profile_pkgunmasklines.append(grabfile_package(
                                os.path.join(x, "package.unmask"), recursive=1, remember_source_file=True, verify_eapi=True))
                profile_pkgmasklines = stack_lists(profile_pkgmasklines, incremental=1, \
-                       remember_source_file=True, warn_for_unmatched_removal=True)
+                       remember_source_file=True, warn_for_unmatched_removal=True,
+                       strict_warn_for_unmatched_removal=strict_umatched_removal)
                profile_pkgunmasklines = stack_lists(profile_pkgunmasklines, incremental=1, \
-                       remember_source_file=True, warn_for_unmatched_removal=True)
+                       remember_source_file=True, warn_for_unmatched_removal=True,
+                       strict_warn_for_unmatched_removal=strict_umatched_removal)
 
                #Read /etc/portage/package.mask. Don't stack it to allow the user to
                #remove mask atoms from everywhere with -atoms.
index 733d36cfc2eac2e514d0d536e7a1b6b52cda03cb..8ee93005ae856e5fe515a037a5e6a59f0c9b7409 100644 (file)
@@ -157,7 +157,7 @@ class config(object):
 
        def __init__(self, clone=None, mycpv=None, config_profile_path=None,
                config_incrementals=None, config_root=None, target_root=None,
-               _eprefix=None, local_config=True, env=None):
+               _eprefix=None, local_config=True, env=None, _unmatched_removal=False):
                """
                @param clone: If provided, init will use deepcopy to copy by value the instance.
                @type clone: Instance of config class.
@@ -181,6 +181,9 @@ class config(object):
                @param env: The calling environment which is used to override settings.
                        Defaults to os.environ if unspecified.
                @type env: dict
+               @param _unmatched_removal: Enabled by repoman when the
+                       --unmatched-removal option is given.
+               @type _unmatched_removal: Boolean
                """
 
                # rename local _eprefix variable for convenience
@@ -542,7 +545,9 @@ class config(object):
                                        self.configdict["conf"].get("ACCEPT_LICENSE", ""))
 
                        #Read package.mask and package.unmask from profiles and optionally from user config
-                       self._mask_manager = MaskManager(locations_manager.pmask_locations, abs_user_config, user_config=local_config)
+                       self._mask_manager = MaskManager(locations_manager.pmask_locations,
+                               abs_user_config, user_config=local_config,
+                               strict_umatched_removal=_unmatched_removal)
 
                        self._virtuals_manager = VirtualsManager(self.profiles)