summaryrefslogtreecommitdiffstats
path: root/meta/classes/reproducible_build.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/reproducible_build.bbclass')
-rw-r--r--meta/classes/reproducible_build.bbclass35
1 files changed, 23 insertions, 12 deletions
diff --git a/meta/classes/reproducible_build.bbclass b/meta/classes/reproducible_build.bbclass
index 3f3790dfe3..42cb37b042 100644
--- a/meta/classes/reproducible_build.bbclass
+++ b/meta/classes/reproducible_build.bbclass
@@ -61,28 +61,39 @@ def get_source_date_epoch_from_known_files(d, sourcedir):
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(workdir): 64def find_git_folder(d, sourcedir):
65 exclude = set(["temp", "license-destdir", "patches", "recipe-sysroot-native", "recipe-sysroot", "pseudo", "build", "image", "sysroot-destdir"]) 65 # First guess: WORKDIR/git
66 # This is the default git fetcher unpack path
67 workdir = d.getVar('WORKDIR')
68 gitpath = os.path.join(workdir, "git/.git")
69 if os.path.isdir(gitpath):
70 return gitpath
71
72 # Second guess: ${S}
73 gitpath = os.path.join(sourcedir, ".git")
74 if os.path.isdir(gitpath):
75 return gitpath
76
77 # Perhaps there was a subpath or destsuffix specified.
78 # Go looking in the WORKDIR
79 exclude = set(["build", "image", "license-destdir", "patches", "pseudo",
80 "recipe-sysroot", "recipe-sysroot-native", "sysroot-destdir", "temp"])
66 for root, dirs, files in os.walk(workdir, topdown=True): 81 for root, dirs, files in os.walk(workdir, topdown=True):
67 dirs[:] = [d for d in dirs if d not in exclude] 82 dirs[:] = [d for d in dirs if d not in exclude]
68 if '.git' in dirs: 83 if '.git' in dirs:
69 return root 84 return root
70 85
86 bb.warn("Failed to find a git repository in WORKDIR: %s" % workdir)
87 return None
88
71def get_source_date_epoch_from_git(d, sourcedir): 89def get_source_date_epoch_from_git(d, sourcedir):
72 source_date_epoch = None 90 source_date_epoch = None
73 if "git://" in d.getVar('SRC_URI'): 91 if "git://" in d.getVar('SRC_URI'):
74 workdir = d.getVar('WORKDIR') 92 gitpath = find_git_folder(d, sourcedir)
75 gitpath = find_git_folder(workdir)
76 if gitpath: 93 if gitpath:
77 import subprocess 94 import subprocess
78 if os.path.isdir(os.path.join(gitpath,".git")): 95 source_date_epoch = int(subprocess.check_output(['git','log','-1','--pretty=%ct'], cwd=gitpath))
79 try: 96 bb.debug(1, "git repo path: %s sde: %d" % (gitpath, source_date_epoch))
80 source_date_epoch = int(subprocess.check_output(['git','log','-1','--pretty=%ct'], cwd=sourcedir))
81 bb.debug(1, "git repo path:%s sde: %d" % (gitpath,source_date_epoch))
82 except subprocess.CalledProcessError as grepexc:
83 bb.debug(1, "Expected git repository not found, (path: %s) error:%d" % (gitpath, grepexc.returncode))
84 else:
85 bb.warn("Failed to find a git repository for path:%s" % workdir)
86 return source_date_epoch 97 return source_date_epoch
87 98
88def get_source_date_epoch_from_youngest_file(d, sourcedir): 99def get_source_date_epoch_from_youngest_file(d, sourcedir):