1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

[PR #5998/2c762c47 backport][stable-5] Added support for openSUSE MicroOS (#6077)

Added support for openSUSE MicroOS (#5998)

* 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 2c762c4753)

Co-authored-by: andre161292 <andre161292@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2023-02-25 11:23:20 +01:00 committed by GitHub
parent 04df03f365
commit 170a099101
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View file

@ -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)."

View file

@ -511,8 +511,21 @@ def repo_refresh(m):
return retvals 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(): 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 # Main control flow