From 65b2e63bb956940b89e0397d10540df0c3e846b2 Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Fri, 3 Nov 2017 16:52:12 +0100 Subject: [PATCH] Ensure stable sorting order in tools This eliminates certain surprises with port contents and depot hashes. --- tool/builddir/build.mk | 3 +++ tool/depot/mk/common.inc | 3 +++ tool/depot/mk/extract.inc | 2 +- tool/ports/mk/common.inc | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tool/builddir/build.mk b/tool/builddir/build.mk index 3a89fede1..e9a3a917f 100644 --- a/tool/builddir/build.mk +++ b/tool/builddir/build.mk @@ -56,6 +56,9 @@ export LIB_DEP_FILE ?= var/libdeps export ECHO ?= echo -e export CONTRIB_DIR +# Force stable sorting order +export LC_COLLATE=C + # # Convert user-defined directories to absolute directories # diff --git a/tool/depot/mk/common.inc b/tool/depot/mk/common.inc index 9b1c38ffc..71b3b4171 100644 --- a/tool/depot/mk/common.inc +++ b/tool/depot/mk/common.inc @@ -30,3 +30,6 @@ EMPTY := # is not empty. # file_content = $(if $(wildcard $1),$(shell cat $1),) + +# Force stable sorting order +export LC_COLLATE=C diff --git a/tool/depot/mk/extract.inc b/tool/depot/mk/extract.inc index 36251e56a..1ab5d9e5e 100644 --- a/tool/depot/mk/extract.inc +++ b/tool/depot/mk/extract.inc @@ -198,7 +198,7 @@ _check_hash: $(DEPOT_ARCHIVE_DIR).hash checked_recipe_hash_value_exists # would otherwise prompt 'cat' to block for standard input. # HASH_CMD := cd $(DEPOT_ARCHIVE_DIR); \ - echo | cat `find . -type f | LC_COLLATE=C sort` | $(HASHSUM) | sed "s/ .*//" \ + echo | cat `find . -type f | sort` | $(HASHSUM) | sed "s/ .*//" \ # # Generate the hash from the archive content diff --git a/tool/ports/mk/common.inc b/tool/ports/mk/common.inc index 5a65fcbcd..ebe59f0e9 100644 --- a/tool/ports/mk/common.inc +++ b/tool/ports/mk/common.inc @@ -23,3 +23,5 @@ MSG_GENERATE := $(MSG_PREFIX)"generate " MSG_EXTRACT := $(MSG_PREFIX)"extract " MSG_GIT := $(MSG_PREFIX_TXT)git +# Force stable sorting order +export LC_COLLATE=C