Skip to content

Commit

Permalink
Added support for openSUSE MicroOS (#5998)
Browse files Browse the repository at this point in the history
* fix(zypper): Added condition to check for transactional-update binary to support microos

closes #5615

* style(changelog): Made zypper-change uppercase

Co-authored-by: Felix Fontein <felix@fontein.de>

* fix(zypper): Removed check for /var/lib/misc/transactional-update.state

* feat(zypper): Aligned transactional-update checks with zypper's

* refactor(zypper): Removed dependency to psutil and made use of parsing /proc/mount

* refactor(zypper): Removed need for regex, plus small refactoring

---------

Co-authored-by: André Dörscheln <ad@itesign.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 2c762c4)
  • Loading branch information
andre161292 authored and patchback[bot] committed Feb 25, 2023
1 parent 470f4e8 commit ef4b913
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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)."
15 changes: 14 additions & 1 deletion plugins/modules/zypper.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,21 @@ def repo_refresh(m):
return retvals


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, 'ro' in opts.split(',')
return None


def transactional_updates():
return os.path.exists('/var/lib/misc/transactional-update.state')
return os.path.exists('/usr/sbin/transactional-update') and get_fs_type_and_readonly_state('/') == ('btrfs', True)


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

0 comments on commit ef4b913

Please sign in to comment.