package/pkg-utils: teach per-package-rsync to copy or hardlink dest
commit21d52e52d8
(package/pkg-utils.mk: break hardlinks in global {TARGET, HOST}_DIR on per-package build) was recently reverted, so we are back to a situation where it is possible for packages and post-build scripts to modify files in-place, and thus impact files in any arbitrary per-package directory, which may break things on rebuild for example.21d52e52d8
was too big a hammer, but we can still apply the reasoning from it, to the aggregation of the final target and host directories. This solves the case for post-build scripts at least. We leave the case of inter-package modification aside, as it is a bigger issue that will need more than just copying files around. We use --hard-links, so that hard-links in the source (the PPD), are kept as new hard-links (i.e. "copy" of hard-links) in the destination. This contributes to limiting the size of target/. Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr> Cc: Herve Codina <herve.codina@bootlin.com> Cc: Peter Korsgaard <peter@korsgaard.com> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Reviewed-by: Herve Codina <herve.codina@bootlin.com>
This commit is contained in:
parent
8f1487d6fa
commit
23edf9837c
4
Makefile
4
Makefile
@ -717,7 +717,7 @@ STAGING_DIR_FILES_LISTS = $(sort $(wildcard $(BUILD_DIR)/*/.files-list-staging.t
|
||||
.PHONY: host-finalize
|
||||
host-finalize: $(PACKAGES) $(HOST_DIR) $(HOST_DIR_SYMLINK)
|
||||
@$(call MESSAGE,"Finalizing host directory")
|
||||
$(call per-package-rsync,$(sort $(PACKAGES)),host,$(HOST_DIR))
|
||||
$(call per-package-rsync,$(sort $(PACKAGES)),host,$(HOST_DIR),copy)
|
||||
|
||||
.PHONY: staging-finalize
|
||||
staging-finalize: $(STAGING_DIR_SYMLINK)
|
||||
@ -725,7 +725,7 @@ staging-finalize: $(STAGING_DIR_SYMLINK)
|
||||
.PHONY: target-finalize
|
||||
target-finalize: $(PACKAGES) $(TARGET_DIR) host-finalize
|
||||
@$(call MESSAGE,"Finalizing target directory")
|
||||
$(call per-package-rsync,$(sort $(PACKAGES)),target,$(TARGET_DIR))
|
||||
$(call per-package-rsync,$(sort $(PACKAGES)),target,$(TARGET_DIR),copy)
|
||||
$(foreach hook,$(TARGET_FINALIZE_HOOKS),$($(hook))$(sep))
|
||||
rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
|
||||
$(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig \
|
||||
|
@ -214,10 +214,19 @@ ifeq ($(BR2_PER_PACKAGE_DIRECTORIES),y)
|
||||
# $1: space-separated list of packages to rsync from
|
||||
# $2: 'host' or 'target'
|
||||
# $3: destination directory
|
||||
# $4: literal "copy" or "hardlink" to copy or hardlink files from src to dest
|
||||
define per-package-rsync
|
||||
mkdir -p $(3)
|
||||
$(foreach pkg,$(1),\
|
||||
rsync -a --link-dest=$(PER_PACKAGE_DIR)/$(pkg)/$(2)/ \
|
||||
rsync -a \
|
||||
--hard-links \
|
||||
$(if $(filter hardlink,$(4)), \
|
||||
--link-dest=$(PER_PACKAGE_DIR)/$(pkg)/$(2)/, \
|
||||
$(if $(filter copy,$(4)), \
|
||||
$(empty), \
|
||||
$(error per-package-rsync can only "copy" or "hardlink", not "$(4)") \
|
||||
) \
|
||||
) \
|
||||
$(PER_PACKAGE_DIR)/$(pkg)/$(2)/ \
|
||||
$(3)$(sep))
|
||||
endef
|
||||
@ -230,8 +239,8 @@ endef
|
||||
#
|
||||
# $1: space-separated list of packages to rsync from
|
||||
define prepare-per-package-directory
|
||||
$(call per-package-rsync,$(1),host,$(HOST_DIR))
|
||||
$(call per-package-rsync,$(1),target,$(TARGET_DIR))
|
||||
$(call per-package-rsync,$(1),host,$(HOST_DIR),hardlink)
|
||||
$(call per-package-rsync,$(1),target,$(TARGET_DIR),hardlink)
|
||||
endef
|
||||
|
||||
# Ensure files like .la, .pc, .pri, .cmake, and so on, point to the
|
||||
|
Loading…
Reference in New Issue
Block a user