summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes/reproducible_build.bbclass73
1 files changed, 40 insertions, 33 deletions
diff --git a/meta/classes/reproducible_build.bbclass b/meta/classes/reproducible_build.bbclass
index 4e8850fb83..e118cfde01 100644
--- a/meta/classes/reproducible_build.bbclass
+++ b/meta/classes/reproducible_build.bbclass
@@ -49,15 +49,15 @@ do_deploy_source_date_epoch[sstate-plaindirs] = "${SDE_DIR}"
49addtask do_deploy_source_date_epoch_setscene 49addtask do_deploy_source_date_epoch_setscene
50addtask do_deploy_source_date_epoch before do_configure after do_patch 50addtask do_deploy_source_date_epoch before do_configure after do_patch
51 51
52def get_source_date_epoch_known_files(d, path): 52def get_source_date_epoch_from_known_files(d, path):
53 source_date_epoch = 0 53 source_date_epoch = None
54 known_files = set(["NEWS", "ChangeLog", "Changelog", "CHANGES"]) 54 known_files = set(["NEWS", "ChangeLog", "Changelog", "CHANGES"])
55 for file in known_files: 55 for file in known_files:
56 filepath = os.path.join(path,file) 56 filepath = os.path.join(path,file)
57 if os.path.isfile(filepath): 57 if os.path.isfile(filepath):
58 mtime = int(os.lstat(filepath).st_mtime) 58 mtime = int(os.lstat(filepath).st_mtime)
59 # There may be more than one "known_file" present, if so, use the youngest one 59 # There may be more than one "known_file" present, if so, use the youngest one
60 if mtime > source_date_epoch: 60 if not source_date_epoch or mtime > source_date_epoch:
61 source_date_epoch = mtime 61 source_date_epoch = mtime
62 return source_date_epoch 62 return source_date_epoch
63 63
@@ -68,8 +68,8 @@ def find_git_folder(path):
68 if '.git' in dirs: 68 if '.git' in dirs:
69 return root 69 return root
70 70
71def get_source_date_epoch_git(d, path): 71def get_source_date_epoch_from_git(d, path):
72 source_date_epoch = 0 72 source_date_epoch = None
73 if "git://" in d.getVar('SRC_URI'): 73 if "git://" in d.getVar('SRC_URI'):
74 gitpath = find_git_folder(d.getVar('WORKDIR')) 74 gitpath = find_git_folder(d.getVar('WORKDIR'))
75 if gitpath != None: 75 if gitpath != None:
@@ -84,6 +84,31 @@ def get_source_date_epoch_git(d, path):
84 bb.warn("Failed to find a git repository for path:%s" % (path)) 84 bb.warn("Failed to find a git repository for path:%s" % (path))
85 return source_date_epoch 85 return source_date_epoch
86 86
87def get_source_date_epoch_from_youngest_file(d, path):
88 # Do it the hard way: check all files and find the youngest one...
89 source_date_epoch = None
90 newest_file = None
91 # Just in case S = WORKDIR
92 exclude = set(["build", "image", "license-destdir", "patches", "pseudo",
93 "recipe-sysroot", "recipe-sysroot-native", "sysroot-destdir", "temp"])
94 for root, dirs, files in os.walk(path, topdown=True):
95 files = [f for f in files if not f[0] == '.']
96 dirs[:] = [d for d in dirs if d not in exclude]
97
98 for fname in files:
99 filename = os.path.join(root, fname)
100 try:
101 mtime = int(os.lstat(filename).st_mtime)
102 except ValueError:
103 mtime = 0
104 if not source_date_epoch or mtime > source_date_epoch:
105 source_date_epoch = mtime
106 newest_file = filename
107
108 if newest_file != None:
109 bb.debug(1," SOURCE_DATE_EPOCH %d derived from: %s" % (source_date_epoch, newest_file))
110 return source_date_epoch
111
87python do_create_source_date_epoch_stamp() { 112python do_create_source_date_epoch_stamp() {
88 path = d.getVar('S') 113 path = d.getVar('S')
89 if not os.path.isdir(path): 114 if not os.path.isdir(path):
@@ -95,35 +120,17 @@ python do_create_source_date_epoch_stamp() {
95 bb.debug(1, " path: %s reusing __source_date_epoch.txt" % epochfile) 120 bb.debug(1, " path: %s reusing __source_date_epoch.txt" % epochfile)
96 return 121 return
97 122
98 source_date_epoch = get_source_date_epoch_git(d, path) 123 source_date_epoch = (
124 get_source_date_epoch_from_git(d, path) or
125 get_source_date_epoch_from_known_files(d, path) or
126 get_source_date_epoch_from_youngest_file(d, path) or
127 0 # Last resort
128 )
99 if source_date_epoch == 0: 129 if source_date_epoch == 0:
100 source_date_epoch = get_source_date_epoch_known_files(d, path) 130 # empty folder, not a single file ...
101 if source_date_epoch == 0: 131 # kernel source do_unpack is special cased
102 # Do it the hard way: check all files and find the youngest one... 132 if not bb.data.inherits_class('kernel', d):
103 filename_dbg = None 133 bb.debug(1, "Unable to determine source_date_epoch! path:%s" % path)
104 exclude = set(["temp", "license-destdir", "patches", "recipe-sysroot-native", "recipe-sysroot", "pseudo", "build", "image", "sysroot-destdir"])
105 for root, dirs, files in os.walk(path, topdown=True):
106 files = [f for f in files if not f[0] == '.']
107 dirs[:] = [d for d in dirs if d not in exclude]
108
109 for fname in files:
110 filename = os.path.join(root, fname)
111 try:
112 mtime = int(os.lstat(filename).st_mtime)
113 except ValueError:
114 mtime = 0
115 if mtime > source_date_epoch:
116 source_date_epoch = mtime
117 filename_dbg = filename
118
119 if filename_dbg != None:
120 bb.debug(1," SOURCE_DATE_EPOCH %d derived from: %s" % (source_date_epoch, filename_dbg))
121
122 if source_date_epoch == 0:
123 # empty folder, not a single file ...
124 # kernel source do_unpack is special cased
125 if not bb.data.inherits_class('kernel', d):
126 bb.debug(1, "Unable to determine source_date_epoch! path:%s" % path)
127 134
128 bb.utils.mkdirhier(d.getVar('SDE_DIR')) 135 bb.utils.mkdirhier(d.getVar('SDE_DIR'))
129 with open(epochfile, 'w') as f: 136 with open(epochfile, 'w') as f: