Do not preserve ownership or xattrs on copied files

As noticed in https://bugzilla.redhat.com/show_bug.cgi?id=2239008#c16, when
compiling a kernel as a user and doing 'sudo make install', and when using a
non-vfat fs for the install destination, the file would end up owned by the
user. This is not useful at all, so let's only preserve the timestamps on the
copied file, no other attributes.

Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2023-09-28 12:05:19 +02:00 committed by Nicolas Frayer
parent af4f1536b6
commit 8800efcb0b

View file

@ -56,7 +56,7 @@ case "$COMMAND" in
if [[ "${KERNEL_DIR}" != "/boot" ]]; then
# rename to match the name used in the pseudo-BLS snippet above
rm -f "/boot/vmlinuz-${KERNEL_VERSION}"
cp -aT "${KERNEL_IMAGE}" "/boot/vmlinuz-${KERNEL_VERSION}"
cp --preserve=timestamps -T "${KERNEL_IMAGE}" "/boot/vmlinuz-${KERNEL_VERSION}"
command -v restorecon &>/dev/null && \
restorecon -R "/boot/vmlinuz-${KERNEL_VERSION}"
@ -68,7 +68,7 @@ case "$COMMAND" in
do
[[ -e "$i" ]] || continue
rm -f "/boot/${i##*/}-${KERNEL_VERSION}"
cp -aT "$i" "/boot/${i##*/}-${KERNEL_VERSION}"
cp --preserve=timestamps -T "$i" "/boot/${i##*/}-${KERNEL_VERSION}"
command -v restorecon &>/dev/null && \
restorecon -R "/boot/${i##*/}-${KERNEL_VERSION}"
done
@ -76,7 +76,7 @@ case "$COMMAND" in
i="$KERNEL_DIR/.${KERNEL_IMAGE##*/}.hmac"
if [[ -e "$i" ]]; then
rm -f "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
cp -a "$i" "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
cp --preserve=timestamps "$i" "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
command -v restorecon &>/dev/null && \
restorecon "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
fi
@ -158,7 +158,7 @@ case "$COMMAND" in
if [ "x$GRUB_LINUX_MAKE_DEBUG" = "xtrue" ]; then
BLS_DEBUG="$(echo ${BLS_TARGET} | sed -e "s/${KERNEL_VERSION}/${KERNEL_VERSION}~debug/")"
cp -aT "${BLS_TARGET}" "${BLS_DEBUG}"
cp --preserve=timestamps -T "${BLS_TARGET}" "${BLS_DEBUG}"
TITLE="$(grep '^title[ \t]' "${BLS_DEBUG}" | sed -e 's/^title[ \t]*//')"
OPTIONS="$(echo "${BOOT_OPTIONS[*]} ${GRUB_CMDLINE_LINUX_DEBUG}" | sed -e 's/\//\\\//g')"
sed -i -e "s/^title.*/title ${TITLE}${GRUB_LINUX_DEBUG_TITLE_POSTFIX}/" "${BLS_DEBUG}"