summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/reproducible_build.bbclass37
1 files changed, 19 insertions, 18 deletions
diff --git a/meta/classes/reproducible_build.bbclass b/meta/classes/reproducible_build.bbclass
index e118cfde01..3f3790dfe3 100644
--- a/meta/classes/reproducible_build.bbclass
+++ b/meta/classes/reproducible_build.bbclass
@@ -49,11 +49,11 @@ 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_from_known_files(d, path): 52def get_source_date_epoch_from_known_files(d, sourcedir):
53 source_date_epoch = None 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(sourcedir, 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
@@ -61,37 +61,38 @@ def get_source_date_epoch_from_known_files(d, path):
61 source_date_epoch = mtime 61 source_date_epoch = mtime
62 return source_date_epoch 62 return source_date_epoch
63 63
64def find_git_folder(path): 64def find_git_folder(workdir):
65 exclude = set(["temp", "license-destdir", "patches", "recipe-sysroot-native", "recipe-sysroot", "pseudo", "build", "image", "sysroot-destdir"]) 65 exclude = set(["temp", "license-destdir", "patches", "recipe-sysroot-native", "recipe-sysroot", "pseudo", "build", "image", "sysroot-destdir"])
66 for root, dirs, files in os.walk(path, topdown=True): 66 for root, dirs, files in os.walk(workdir, topdown=True):
67 dirs[:] = [d for d in dirs if d not in exclude] 67 dirs[:] = [d for d in dirs if d not in exclude]
68 if '.git' in dirs: 68 if '.git' in dirs:
69 return root 69 return root
70 70
71def get_source_date_epoch_from_git(d, path): 71def get_source_date_epoch_from_git(d, sourcedir):
72 source_date_epoch = None 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 workdir = d.getVar('WORKDIR')
75 if gitpath != None: 75 gitpath = find_git_folder(workdir)
76 if gitpath:
76 import subprocess 77 import subprocess
77 if os.path.isdir(os.path.join(gitpath,".git")): 78 if os.path.isdir(os.path.join(gitpath,".git")):
78 try: 79 try:
79 source_date_epoch = int(subprocess.check_output(['git','log','-1','--pretty=%ct'], cwd=path)) 80 source_date_epoch = int(subprocess.check_output(['git','log','-1','--pretty=%ct'], cwd=sourcedir))
80 bb.debug(1, "git repo path:%s sde: %d" % (gitpath,source_date_epoch)) 81 bb.debug(1, "git repo path:%s sde: %d" % (gitpath,source_date_epoch))
81 except subprocess.CalledProcessError as grepexc: 82 except subprocess.CalledProcessError as grepexc:
82 bb.debug(1, "Expected git repository not found, (path: %s) error:%d" % (gitpath, grepexc.returncode)) 83 bb.debug(1, "Expected git repository not found, (path: %s) error:%d" % (gitpath, grepexc.returncode))
83 else: 84 else:
84 bb.warn("Failed to find a git repository for path:%s" % (path)) 85 bb.warn("Failed to find a git repository for path:%s" % workdir)
85 return source_date_epoch 86 return source_date_epoch
86 87
87def get_source_date_epoch_from_youngest_file(d, path): 88def get_source_date_epoch_from_youngest_file(d, sourcedir):
88 # Do it the hard way: check all files and find the youngest one... 89 # Do it the hard way: check all files and find the youngest one...
89 source_date_epoch = None 90 source_date_epoch = None
90 newest_file = None 91 newest_file = None
91 # Just in case S = WORKDIR 92 # Just in case S = WORKDIR
92 exclude = set(["build", "image", "license-destdir", "patches", "pseudo", 93 exclude = set(["build", "image", "license-destdir", "patches", "pseudo",
93 "recipe-sysroot", "recipe-sysroot-native", "sysroot-destdir", "temp"]) 94 "recipe-sysroot", "recipe-sysroot-native", "sysroot-destdir", "temp"])
94 for root, dirs, files in os.walk(path, topdown=True): 95 for root, dirs, files in os.walk(sourcedir, topdown=True):
95 files = [f for f in files if not f[0] == '.'] 96 files = [f for f in files if not f[0] == '.']
96 dirs[:] = [d for d in dirs if d not in exclude] 97 dirs[:] = [d for d in dirs if d not in exclude]
97 98
@@ -110,9 +111,9 @@ def get_source_date_epoch_from_youngest_file(d, path):
110 return source_date_epoch 111 return source_date_epoch
111 112
112python do_create_source_date_epoch_stamp() { 113python do_create_source_date_epoch_stamp() {
113 path = d.getVar('S') 114 sourcedir = d.getVar('S')
114 if not os.path.isdir(path): 115 if not os.path.isdir(sourcedir):
115 bb.warn("Unable to determine source_date_epoch! path:%s" % path) 116 bb.warn("Unable to determine source_date_epoch! path:%s" % sourcedir)
116 return 117 return
117 118
118 epochfile = d.getVar('SDE_FILE') 119 epochfile = d.getVar('SDE_FILE')
@@ -121,16 +122,16 @@ python do_create_source_date_epoch_stamp() {
121 return 122 return
122 123
123 source_date_epoch = ( 124 source_date_epoch = (
124 get_source_date_epoch_from_git(d, path) or 125 get_source_date_epoch_from_git(d, sourcedir) or
125 get_source_date_epoch_from_known_files(d, path) or 126 get_source_date_epoch_from_known_files(d, sourcedir) or
126 get_source_date_epoch_from_youngest_file(d, path) or 127 get_source_date_epoch_from_youngest_file(d, sourcedir) or
127 0 # Last resort 128 0 # Last resort
128 ) 129 )
129 if source_date_epoch == 0: 130 if source_date_epoch == 0:
130 # empty folder, not a single file ... 131 # empty folder, not a single file ...
131 # kernel source do_unpack is special cased 132 # kernel source do_unpack is special cased
132 if not bb.data.inherits_class('kernel', d): 133 if not bb.data.inherits_class('kernel', d):
133 bb.debug(1, "Unable to determine source_date_epoch! path:%s" % path) 134 bb.debug(1, "Unable to determine source_date_epoch! path:%s" % sourcedir)
134 135
135 bb.utils.mkdirhier(d.getVar('SDE_DIR')) 136 bb.utils.mkdirhier(d.getVar('SDE_DIR'))
136 with open(epochfile, 'w') as f: 137 with open(epochfile, 'w') as f: