From b51fda22c164b35b7fe171f7e1a4c14c2fe63e6b Mon Sep 17 00:00:00 2001 From: Daniel Pineda Date: Tue, 21 Feb 2023 14:15:25 -0600 Subject: [PATCH] Makefile: add --remove-destination to cp calls. This avoids overwriting the busybox binary (and bricking the system) by following a symlink when busybox and other module both provide a command with the same filename. Signed-off-by: Daniel Pineda --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 0ca170dd..a79e608b 100644 --- a/Makefile +++ b/Makefile @@ -234,7 +234,7 @@ define do-copy = if cmp --quiet "$1" "$2" ; then \ echo "$(DATE) UNCHANGED $(1:$(pwd)/%=%)" ; \ fi ; \ - cp -a "$1" "$2" ; \ + cp -a --remove-destination "$1" "$2" ; \ ) @sha256sum "$(2:$(pwd)/%=%)" endef @@ -415,7 +415,7 @@ $(call map, define_module, $(modules-y)) # define install = @-mkdir -p "$(dir $2)" - $(call do,INSTALL,$2,cp -a "$1" "$2") + $(call do,INSTALL,$2,cp -a --remove-destination "$1" "$2") endef # @@ -424,7 +424,7 @@ endef # define initrd_bin_add = $(initrd_bin_dir)/$(notdir $1): $1 - $(call do,INSTALL-BIN,$$(<:$(pwd)/%=%),cp -a "$$<" "$$@") + $(call do,INSTALL-BIN,$$(<:$(pwd)/%=%),cp -a --remove-destination "$$<" "$$@") @$(CROSS)strip --preserve-dates "$$@" 2>&-; true initrd_bins += $(initrd_bin_dir)/$(notdir $1) endef