Improve strategy for the copying of /etc into the factory

Use rsync with --exclude instead of copying everything and then removing
it.

I was having problems copying resolv.conf because it was owned by
"nobody".
This commit is contained in:
Aleix Pol i Gonzalez
2026-05-28 18:42:57 +02:00
parent e4ed69b939
commit cd69c73b24
2 changed files with 16 additions and 30 deletions

View File

@@ -93,8 +93,6 @@ BST="bst"
rm -rf "$BUILDSTREAM_ROOTFS" "$BUILDSTREAM_BOOTFS" "$BUILDSTREAM_TOOLFS" "$BUILDSTREAM_EFI"
$BST build os/filesystem.bst
$BST artifact checkout os/filesystem.bst --directory $BUILDSTREAM_ROOTFS
[ -d "$BUILDSTREAM_ROOTFS/etc" ] || mkdir -p "$BUILDSTREAM_ROOTFS/etc"
: > "$BUILDSTREAM_ROOTFS/etc/resolv.conf"
$BST build components/calamares.bst \
os/initrd.bst \
freedesktop-sdk.bst:components/ovmf-maybe.bst \

View File

@@ -23,32 +23,20 @@ echo "deny = 12" >> /etc/security/faillock.conf
rm --recursive --force /usr/share/factory/etc/pam.d
# Copy all of etc into factory dir for tmpfiles.d (see tmpfiles.d docs).
# Exclude the content that we absolutely do not want because it is machine/installation dependent.
[ -d /usr/share/factory ] || mkdir /usr/share/factory
find /etc -mindepth 1 ! -path /etc/resolv.conf -exec cp --archive --parents --target-directory=/usr/share/factory/ {} +
# Clean up factory content that we absolutely do not want because it is machine/installation dependent.
cd /usr/share/factory/etc
rm --force \
.pwd.lock \
passwd \
passwd- \
shadow \
shadow- \
gshadow \
gshadow- \
group \
group- \
localtime \
machine-id \
crypttab \
resolv.conf \
vconsole.conf \
hostname \
locale.conf
# These are actually needed and must be copied from the factory onto the host. If they are missing useradd will
# not configure subuids, breaking podman for instance.
# subuid \
# subgid- \
# subgid \
# subgid- \
cd /etc
rsync --archive --update \
--exclude='.pwd.lock' \
--exclude='passwd*' \
--exclude='shadow*' \
--exclude='gshadow*' \
--exclude='group*' \
--exclude='localtime' \
--exclude='machine-id' \
--exclude='crypttab' \
--exclude='resolv.conf' \
--exclude='vconsole.conf' \
--exclude='hostname' \
--exclude='locale.conf' \
/etc/ /usr/share/factory/etc/