[openwrt/openwrt] build: find_md5 list with mod time and sorted

LEDE Commits lede-commits at lists.infradead.org
Mon Dec 7 15:56:41 EST 2020


aparcar pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/36e0268aa67bb757d7b9b39cbe1e7f89332f6746

commit 36e0268aa67bb757d7b9b39cbe1e7f89332f6746
Author: John Beckett <john.beckett at net2edge.com>
AuthorDate: Mon Sep 21 13:34:17 2020 +0100

    build: find_md5 list with mod time and sorted
    
    It was observed that the MD5 would not change after source files had been
    modified, looking deeper into the build process it was discovered that
    find_md5 build function makes a list of the files being built and then
    passes the list to a summing utility on stdin.  The resultant MD5 is of
    the file list, not the contents of the files.
    
    The MD5 would change if the ordering of the list changed, or items were
    removed or deleted.
    
    The proposed fix is to add the modification time after the filename and
    then sort the list to prevent find returning files in a different order
    falsely re-triggering a rebuild. The MD5 will now change when a file is
    modified or files are added/removed from the list.
    
    Using 'T@' to show time in epoch for timezone independent behaviour.
    
    Signed-off-by: John Beckett <john.beckett at net2edge.com>
---
 include/depends.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/depends.mk b/include/depends.mk
index 3df51adae3..ace7139000 100644
--- a/include/depends.mk
+++ b/include/depends.mk
@@ -13,7 +13,7 @@
 
 DEP_FINDPARAMS := -x "*/.svn*" -x ".*" -x "*:*" -x "*\!*" -x "* *" -x "*\\\#*" -x "*/.*_check" -x "*/.*.swp" -x "*/.pkgdir*"
 
-find_md5=find $(wildcard $(1)) -type f $(patsubst -x,-and -not -path,$(DEP_FINDPARAMS) $(2)) | mkhash md5
+find_md5=find $(wildcard $(1)) -type f $(patsubst -x,-and -not -path,$(DEP_FINDPARAMS) $(2)) -printf "%p%T@\n" | sort | mkhash md5
 
 define rdep
   .PRECIOUS: $(2)



More information about the lede-commits mailing list