From 1081a2d74f66f79f402cba5dc5d2d260bd86e347 Mon Sep 17 00:00:00 2001 From: Luca Toniolo <10792599+grandixximo@users.noreply.github.com> Date: Sun, 9 Aug 2026 14:54:47 +0800 Subject: [PATCH] docs(build): stage translated images atomically to fix a -j race .adoc-images-stamp and the per-file TRANSLATED_IMAGE_RULE both stage the same translated images, and under parallel make two cp -f calls on the same destination intermittently fail with "cannot create regular file: File exists". Seen in CI package-indep on PR #4367 (de/drivers/images/GM_ENDSWpinout.png). Stage via mktemp + mv -f instead: the rename is atomic so concurrent stagers can no longer produce EEXIST, and chmod 644 restores the permissions plain cp used to give the new file (mktemp makes 600). --- docs/src/Submakefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/src/Submakefile b/docs/src/Submakefile index 62567b56916..51637a6c4f3 100644 --- a/docs/src/Submakefile +++ b/docs/src/Submakefile @@ -1222,7 +1222,9 @@ endif mkdir -p $(DOC_OUT_ADOC)/$$ADOC_DIR/$$IMAGE_DIR; \ if [ ! -e $$TIMAGE_PATH ] ; then \ echo "Generating $$TIMAGE_PATH for $$ADOC_FILE"; \ - cp -f $$IMAGE_PATH $$TIMAGE_PATH; \ + TIMAGE_TMP=$$(mktemp $$TIMAGE_PATH.tmp.XXXXXX) && \ + cp $$IMAGE_PATH $$TIMAGE_TMP && mv -f $$TIMAGE_TMP $$TIMAGE_PATH && \ + chmod 644 $$TIMAGE_PATH; \ fi ; \ done; \ done > $@.new && mv $@.new $@ @@ -1238,7 +1240,7 @@ $(DOC_OUT_ADOC)/$(1)/%.$(2): | $(DOC_DIR)/.translateddocs-stamp @mkdir -p $$(@D) $$(Q)S=$(DOC_SRCDIR)/$$*.$(2); \ [ -e "$$$$S" ] || S=$(DOC_OUT_ADOC)/en/$$*.$(2); \ - cp -f "$$$$S" $$@ + T=$$$$(mktemp "$$@.tmp.XXXXXX") && cp "$$$$S" "$$$$T" && mv -f "$$$$T" $$@ && chmod 644 $$@ endef $(foreach L,$(LANGUAGES), \ $(foreach E,png jpg jpeg gif svg, \