Skip to content
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

Added support for openSUSE MicroOS #5998

Merged
merged 6 commits into from
Feb 25, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/5615-zypper-transactional-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "zypper - make package managing work on readonly filesystem of openSUSE MicroOS (https://github.com/ansible-collections/community.general/pull/5615)."
19 changes: 18 additions & 1 deletion plugins/modules/zypper.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,25 @@ def repo_refresh(m):
return retvals


def contains_readonly_opt(opts):
return re.match('^ro,|,ro,|,ro$|^ro$', opts) is not None


def get_fs_type_and_readonly_state(mount_point):
with open('/proc/mounts', 'r') as file:
for line in file.readlines():
fields = line.split()
path = fields[1]
if path == mount_point:
fs = fields[2]
opts = fields[3]
return fs, contains_readonly_opt(opts)
andre161292 marked this conversation as resolved.
Show resolved Hide resolved
return None


def transactional_updates():
return os.path.exists('/var/lib/misc/transactional-update.state')
return get_fs_type_and_readonly_state('/') == ('btrfs', True) and os.path.exists('/usr/sbin/transactional-update')
andre161292 marked this conversation as resolved.
Show resolved Hide resolved


# ===========================================
# Main control flow
Expand Down