fix build (#865)

This commit is contained in:
Logan Cary
2025-05-28 14:38:17 -04:00
committed by GitHub
parent 8a63cf1336
commit 416f10675f
2 changed files with 13 additions and 2 deletions
+4 -1
View File
@@ -40,7 +40,10 @@ def build_update_image_impl():
# These files will be overwritten, so we should make sure that new build does not have any entities that
# are not in our reference files.
for reference_file, diff in compare_reference_files(cut_nonexistent_user_group_membership=True):
for reference_file, diff in compare_reference_files(
cut_nonexistent_user_group_membership=True,
default_homedir='/var/empty'
):
if any(line.startswith('+') for line in diff):
raise CallError(
f'Reference file {reference_file!r} has new lines in newly installed system.\n'
+9 -1
View File
@@ -6,7 +6,12 @@ from scale_build.exceptions import CallError
from .paths import REFERENCE_FILES_DIR, REFERENCE_FILES, CHROOT_BASEDIR
def compare_reference_files(cut_nonexistent_user_group_membership=False):
def compare_reference_files(cut_nonexistent_user_group_membership: bool = False, default_homedir: str | None = None):
"""Diff /conf/reference-files/etc/group|passwd with the respective files in chroot.
:param cut_nonexistent_user_group_membership:
:param default_homedir: A home directory to replace Debian's default `/nonexistent` before running the diff.
"""
for reference_file in REFERENCE_FILES:
with open(os.path.join(REFERENCE_FILES_DIR, reference_file)) as f:
reference = f.readlines()
@@ -29,6 +34,9 @@ def compare_reference_files(cut_nonexistent_user_group_membership=False):
with open(os.path.join(CHROOT_BASEDIR, reference_file)) as f:
real = f.readlines()
if default_homedir and reference_file == 'etc/passwd':
real = [line.replace('/nonexistent', default_homedir) for line in real]
diff = list(difflib.unified_diff(reference, real))
yield reference_file, diff[3:]