package/pkg-generic: tweak only .la files that need it
authorYann E. MORIN <yann.morin.1998@free.fr>
Sun, 10 Feb 2019 21:38:18 +0000 (22:38 +0100)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Sun, 17 Mar 2019 15:39:40 +0000 (16:39 +0100)
Currently, when we tweak the .la files, we do so unconditionally on all
.la files, even those we already fixed in a previous run.

This has the nasty side effect that each .la file will be reported as
being touched by all packages that are installed after the package that
actually installed said .la file.

Since we can't easily know what files were installed by a package (that
is an instrumentation hook, and comes after the mangling), we use a
trick (like is done in libtool?): we do mangle all files, each into a
temporary location; if the result is identical to the input, we remove
the temporary, while if the result differs from the output, we move
the temporary to replace the input.

Reported-by: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
Reported-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Cc: Arnout Vandecappelle <arnout@mind.be>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
package/pkg-generic.mk

index 62c2e221f78c1ebcb21c1d097dac40c11df43ccc..db7f06ddbe3c3c6152b4ad261e73b9b5e9592162 100644 (file)
@@ -294,7 +294,8 @@ $(BUILD_DIR)/%/.stamp_staging_installed:
                                $(addprefix $(STAGING_DIR)/usr/bin/,$($(PKG)_CONFIG_SCRIPTS)) ;\
        fi
        @$(call MESSAGE,"Fixing libtool files")
-       $(Q)find $(STAGING_DIR)/usr/lib* -name "*.la" | xargs --no-run-if-empty \
+       for la in $$(find $(STAGING_DIR)/usr/lib* -name "*.la"); do \
+               cp -a "$${la}" "$${la}.fixed" && \
                $(SED) "s:$(BASE_DIR):@BASE_DIR@:g" \
                        -e "s:$(STAGING_DIR):@STAGING_DIR@:g" \
                        $(if $(TOOLCHAIN_EXTERNAL_INSTALL_DIR),\
@@ -303,7 +304,14 @@ $(BUILD_DIR)/%/.stamp_staging_installed:
                        $(if $(TOOLCHAIN_EXTERNAL_INSTALL_DIR),\
                                -e "s:@TOOLCHAIN_EXTERNAL_INSTALL_DIR@:$(TOOLCHAIN_EXTERNAL_INSTALL_DIR):g") \
                        -e "s:@STAGING_DIR@:$(STAGING_DIR):g" \
-                       -e "s:@BASE_DIR@:$(BASE_DIR):g"
+                       -e "s:@BASE_DIR@:$(BASE_DIR):g" \
+                       "$${la}.fixed" && \
+               if cmp -s "$${la}" "$${la}.fixed"; then \
+                       rm -f "$${la}.fixed"; \
+               else \
+                       mv "$${la}.fixed" "$${la}"; \
+               fi || exit 1; \
+       done
        @$(call step_end,install-staging)
        $(Q)touch $@