Skip to content

Commit 416f106

Browse files
authored
fix build (#865)
1 parent 8a63cf1 commit 416f106

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

scale_build/update_image.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ def build_update_image_impl():
4040

4141
# These files will be overwritten, so we should make sure that new build does not have any entities that
4242
# are not in our reference files.
43-
for reference_file, diff in compare_reference_files(cut_nonexistent_user_group_membership=True):
43+
for reference_file, diff in compare_reference_files(
44+
cut_nonexistent_user_group_membership=True,
45+
default_homedir='/var/empty'
46+
):
4447
if any(line.startswith('+') for line in diff):
4548
raise CallError(
4649
f'Reference file {reference_file!r} has new lines in newly installed system.\n'

scale_build/utils/reference_files.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
from .paths import REFERENCE_FILES_DIR, REFERENCE_FILES, CHROOT_BASEDIR
77

88

9-
def compare_reference_files(cut_nonexistent_user_group_membership=False):
9+
def compare_reference_files(cut_nonexistent_user_group_membership: bool = False, default_homedir: str | None = None):
10+
"""Diff /conf/reference-files/etc/group|passwd with the respective files in chroot.
11+
12+
:param cut_nonexistent_user_group_membership:
13+
:param default_homedir: A home directory to replace Debian's default `/nonexistent` before running the diff.
14+
"""
1015
for reference_file in REFERENCE_FILES:
1116
with open(os.path.join(REFERENCE_FILES_DIR, reference_file)) as f:
1217
reference = f.readlines()
@@ -29,6 +34,9 @@ def compare_reference_files(cut_nonexistent_user_group_membership=False):
2934
with open(os.path.join(CHROOT_BASEDIR, reference_file)) as f:
3035
real = f.readlines()
3136

37+
if default_homedir and reference_file == 'etc/passwd':
38+
real = [line.replace('/nonexistent', default_homedir) for line in real]
39+
3240
diff = list(difflib.unified_diff(reference, real))
3341

3442
yield reference_file, diff[3:]

0 commit comments

Comments
 (0)