From d36368c4df17cca23b4d6063767a39d1269d62c7 Mon Sep 17 00:00:00 2001 From: brent s Date: Fri, 1 Nov 2019 03:43:14 -0400 Subject: [PATCH] some more groundwork --- aif.xsd | 2 +- aif/config/__init__.py | 2 ++ aif/{config.py => config/parser.py} | 0 aif/constants.py | 1 + aif/disk/block_fallback.py | 3 --- aif/disk/filesystem_fallback.py | 32 ++++++++++++++++------------- 6 files changed, 22 insertions(+), 18 deletions(-) create mode 100644 aif/config/__init__.py rename aif/{config.py => config/parser.py} (100%) diff --git a/aif.xsd b/aif.xsd index 2d4d287..e959ea5 100644 --- a/aif.xsd +++ b/aif.xsd @@ -810,7 +810,7 @@ - + \ No newline at end of file diff --git a/aif/config/__init__.py b/aif/config/__init__.py new file mode 100644 index 0000000..5644bdc --- /dev/null +++ b/aif/config/__init__.py @@ -0,0 +1,2 @@ +from . import parser +# from . import generator # pending API diff --git a/aif/config.py b/aif/config/parser.py similarity index 100% rename from aif/config.py rename to aif/config/parser.py diff --git a/aif/constants.py b/aif/constants.py index 12a38f4..084c045 100644 --- a/aif/constants.py +++ b/aif/constants.py @@ -1,3 +1,4 @@ +arch_releng_key = '4AA4767BBC9C4B1D18AE28B77F2D434B9741E8AC' version = '0.2.0' external_deps = ['blkinfo', 'gpg', diff --git a/aif/disk/block_fallback.py b/aif/disk/block_fallback.py index fb04e92..cf795a2 100644 --- a/aif/disk/block_fallback.py +++ b/aif/disk/block_fallback.py @@ -3,9 +3,7 @@ # https://github.com/dcantrell/pyparted/blob/master/examples/query_device_capacity.py # TODO: Remember to replicate genfstab behaviour. -import os import re -import subprocess try: # https://stackoverflow.com/a/34812552/733214 # https://github.com/karelzak/util-linux/blob/master/libmount/python/test_mount_context.py#L6 @@ -14,7 +12,6 @@ except ImportError: # We should never get here. util-linux is part of core (base) in Arch and uses "libmount". import pylibmount as mount ## -# import blkinfo import parted # https://www.gnu.org/software/parted/api/index.html import psutil ## diff --git a/aif/disk/filesystem_fallback.py b/aif/disk/filesystem_fallback.py index 7fb8b47..06127c9 100644 --- a/aif/disk/filesystem_fallback.py +++ b/aif/disk/filesystem_fallback.py @@ -25,20 +25,24 @@ _mod_dir = os.path.join('/lib/modules', os.uname().release, 'kernel/fs') _strip_mod_suffix = re.compile(r'(?P)\.ko(\.(x|g)?z)?$', re.IGNORECASE) -for i in os.listdir(_mod_dir): - path = os.path.join(_mod_dir, i) - fs_name = None - if os.path.isdir(path): - fs_name = i - elif os.path.isfile(path): - mod_name = _strip_mod_suffix.search(i) - fs_name = mod_name.group('fsname') - if fs_name: - # The kernel *probably* has autoloading enabled, but in case it doesn't... - # TODO: logging! - if os.getuid() == 0: - subprocess.run(['modprobe', fs_name]) - FS_FSTYPES.append(fs_name) +try: + for i in os.listdir(_mod_dir): + path = os.path.join(_mod_dir, i) + fs_name = None + if os.path.isdir(path): + fs_name = i + elif os.path.isfile(path): + mod_name = _strip_mod_suffix.search(i) + fs_name = mod_name.group('fsname') + if fs_name: + # The kernel *probably* has autoloading enabled, but in case it doesn't... + # TODO: logging! + if os.getuid() == 0: + subprocess.run(['modprobe', fs_name]) + FS_FSTYPES.append(fs_name) +except FileNotFoundError: + # We're running on a kernel that doesn't have modules + pass class FS(object):