Skip to content

Commit 9931946

Browse files
committed
improve check_in_file and warning for empty initramfs fstab
the warning was confusing, this also ensures that the fstab is double checked, in case a module clobbers it Signed-off-by: Zen <[email protected]>
1 parent a2740d5 commit 9931946

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/ugrd/base/checks.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.4.1"
1+
__version__ = "0.4.2"
22

33
from pathlib import Path
44

@@ -31,8 +31,11 @@ def _check_in_file(self, file, lines):
3131
with open(file, "r") as f:
3232
file_lines = f.readlines()
3333

34+
stripped_lines = [line.strip() for line in file_lines]
35+
3436
for check_line in lines:
35-
if check_line not in file_lines:
37+
if check_line not in file_lines and check_line not in stripped_lines:
38+
self.logger.info(f"File lines: {file_lines}")
3639
raise ValueError("Failed to find line '%s' in file '%s'" % (check_line, file))
3740

3841

src/ugrd/fs/mounts.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = "desultory"
2-
__version__ = "7.1.1"
2+
__version__ = "7.1.2"
33

44
from pathlib import Path
55
from re import search
@@ -294,7 +294,9 @@ def _to_fstab_entry(self, mount: dict) -> str:
294294

295295

296296
def generate_fstab(self, mount_class="mounts", filename="/etc/fstab") -> None:
297-
"""Generates the fstab from the specified mounts."""
297+
"""Generates the fstab from the specified mounts.
298+
Adds fstab entries to the check_in_file, to ensure they exist in the final image.
299+
"""
298300
fstab_info = [f"# UGRD Filesystem module v{__version__}"]
299301

300302
for mount_name, mount_info in self[mount_class].items():
@@ -308,6 +310,7 @@ def generate_fstab(self, mount_class="mounts", filename="/etc/fstab") -> None:
308310

309311
if len(fstab_info) > 1:
310312
self._write(filename, fstab_info)
313+
self["check_in_file"][filename] = fstab_info
311314
else:
312315
self.logger.debug(
313316
"[%s] No fstab entries generated for mounts: %s" % (mount_class, ", ".join(self[mount_class].keys()))
@@ -865,7 +868,7 @@ def mount_fstab(self) -> list[str]:
865868
mount_retries sets the number of times to retry the mount, infinite otherwise.
866869
"""
867870
if not self._get_build_path("/etc/fstab").exists():
868-
return self.logger.warning("No initramfs fstab found, skipping mount_fstab.")
871+
return self.logger.info("No initramfs fstab found, skipping mount_fstab. If non-root storage devices are not needed at boot, this is fine.")
869872

870873
out = [
871874
'einfo "Attempting to mount all filesystems."',

0 commit comments

Comments
 (0)