-
Notifications
You must be signed in to change notification settings - Fork 134
Add checks for atomic update compatibility #1396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
danigm
merged 1 commit into
rpm-software-management:main
from
mtravitzky:atomic-update-file-check
Oct 30, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| from rpmlint.checks.AbstractCheck import AbstractCheck | ||
|
|
||
|
|
||
| class AtomicUpdateCheck(AbstractCheck): | ||
|
|
||
| """ | ||
| Requirements for atomic updates: | ||
| * All files must be stored inside the snapshot, which is in our case /etc and /usr, not /var, | ||
| /opt, /srv, /usr/local or anything else. | ||
| * (Re)starting daemons is not possible. | ||
| * Modifying files outside of /usr and /etc is not possible. | ||
| * Modifications outside the snapshot have to be done via systemd-tmpfiles and systemd services. | ||
| This check currently only implements checking for files at illegal paths. | ||
| """ | ||
|
|
||
| def __init__(self, config, output): | ||
| super().__init__(config, output) | ||
| self.check_ghosts = self.config.configuration['AtomicCheckGhosts'] | ||
| self.allowed_dirs = self.config.configuration['AtomicAllowedDirs'] | ||
| self.disallowed_subdirs = self.config.configuration['AtomicDisallowedSubdirs'] | ||
|
|
||
| def check(self, pkg): | ||
| if pkg.is_source: | ||
| return | ||
|
|
||
| # Check for files stored outside the snapshot | ||
| self._check_paths(pkg, self.check_ghosts) | ||
|
|
||
| def _check_paths(self, pkg, check_ghosts=False): | ||
| for file in pkg.files.keys(): | ||
| if file in pkg.ghost_files: | ||
| continue # Ghosts are only handled if explicitly desired | ||
| if not (self._check_single_path(file)): | ||
| self.output.add_info('E', pkg, 'dir-or-file-outside-snapshot', file) | ||
| if check_ghosts: | ||
| for ghost in pkg.ghost_files: | ||
| if not (self._check_single_path(ghost)): | ||
| self.output.add_info('W', pkg, 'ghost-outside-snapshot', ghost) | ||
|
|
||
| def _check_single_path(self, file): | ||
| return ( | ||
| file.startswith(tuple(self.allowed_dirs)) and | ||
| not file.startswith(tuple(self.disallowed_subdirs)) | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| dir-or-file-outside-snapshot=""" | ||
| The package contains files outside the snapshot, e.g. outside /etc and /usr | ||
| or inside /usr/local. | ||
| """ | ||
| ghost-outside-snapshot=""" | ||
| The package contains ghosts outside the snapshot, e.g. outside /etc and /usr | ||
| or inside /usr/local. This might become an issue upon removal of this | ||
| package, but not during installation. | ||
| """ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.