|
29 | 29 | from collections.abc import Sequence
|
30 | 30 | except ImportError:
|
31 | 31 | from collections import Sequence
|
| 32 | +from collections import defaultdict |
32 | 33 | import datetime
|
33 | 34 | import logging
|
34 | 35 | import operator
|
@@ -245,6 +246,24 @@ def do_transaction(self, display=()):
|
245 | 246 | "Keep in mind that changes to /etc and /var will still persist, and packages "
|
246 | 247 | "commonly modify these directories."))
|
247 | 248 | self._persistence = libdnf.transaction.TransactionPersistence_TRANSIENT
|
| 249 | + |
| 250 | + # Check whether the transaction modifies usr_drift_protected_paths |
| 251 | + transaction_protected_paths = defaultdict(list) |
| 252 | + for pkg in trans: |
| 253 | + for pkg_file_path in sorted(pkg.files): |
| 254 | + for protected_path in self.conf.usr_drift_protected_paths: |
| 255 | + if pkg_file_path.startswith("%s/" % protected_path) or pkg_file_path == protected_path: |
| 256 | + transaction_protected_paths[pkg.nevra].append(pkg_file_path) |
| 257 | + if transaction_protected_paths: |
| 258 | + logger.info(_('This operation would modify the following paths, possibly introducing ' |
| 259 | + 'inconsistencies when the transient overlay on /usr is discarded. See the ' |
| 260 | + 'usr_drift_protected_paths configuration option for more information.')) |
| 261 | + for nevra, protected_paths in transaction_protected_paths.items(): |
| 262 | + logger.info(nevra) |
| 263 | + for protected_path in protected_paths: |
| 264 | + logger.info(" %s" % protected_path) |
| 265 | + raise CliError(_("Operation aborted.")) |
| 266 | + |
248 | 267 | else:
|
249 | 268 | # Not a bootc transaction.
|
250 | 269 | if self.conf.persistence == "transient":
|
|
0 commit comments