diff options
| -rw-r--r-- | meta/classes-global/base.bbclass | 28 | ||||
| -rw-r--r-- | meta/conf/bitbake.conf | 2 | ||||
| -rw-r--r-- | meta/lib/oe/reproducible.py | 19 |
3 files changed, 34 insertions, 15 deletions
diff --git a/meta/classes-global/base.bbclass b/meta/classes-global/base.bbclass index 066f3848f7..13e91b24a3 100644 --- a/meta/classes-global/base.bbclass +++ b/meta/classes-global/base.bbclass | |||
| @@ -153,20 +153,38 @@ python base_do_fetch() { | |||
| 153 | } | 153 | } |
| 154 | 154 | ||
| 155 | addtask unpack after do_fetch | 155 | addtask unpack after do_fetch |
| 156 | do_unpack[dirs] = "${UNPACKDIR}" | 156 | do_unpack[cleandirs] = "${UNPACKDIR}" |
| 157 | |||
| 158 | do_unpack[cleandirs] = "${@d.getVar('S') if os.path.normpath(d.getVar('S')) != os.path.normpath(d.getVar('WORKDIR')) else os.path.join('${S}', 'patches')}" | ||
| 159 | 157 | ||
| 160 | python base_do_unpack() { | 158 | python base_do_unpack() { |
| 159 | import shutil | ||
| 160 | |||
| 161 | sourcedir = d.getVar('S') | ||
| 162 | # Intentionally keep SOURCE_BASEDIR internal to the task just for SDE | ||
| 163 | d.setVar("SOURCE_BASEDIR", sourcedir) | ||
| 164 | |||
| 161 | src_uri = (d.getVar('SRC_URI') or "").split() | 165 | src_uri = (d.getVar('SRC_URI') or "").split() |
| 162 | if not src_uri: | 166 | if not src_uri: |
| 163 | return | 167 | return |
| 164 | 168 | ||
| 169 | basedir = None | ||
| 170 | unpackdir = d.getVar('UNPACKDIR') | ||
| 171 | workdir = d.getVar('WORKDIR') | ||
| 172 | if sourcedir.startswith(workdir) and not sourcedir.startswith(unpackdir): | ||
| 173 | basedir = sourcedir.replace(workdir, '').strip("/").split('/')[0] | ||
| 174 | if basedir: | ||
| 175 | bb.utils.remove(workdir + '/' + basedir, True) | ||
| 176 | d.setVar("SOURCE_BASEDIR", workdir + '/' + basedir) | ||
| 177 | |||
| 165 | try: | 178 | try: |
| 166 | fetcher = bb.fetch2.Fetch(src_uri, d) | 179 | fetcher = bb.fetch2.Fetch(src_uri, d) |
| 167 | fetcher.unpack(d.getVar('UNPACKDIR')) | 180 | fetcher.unpack(d.getVar('UNPACKDIR')) |
| 168 | except bb.fetch2.BBFetchException as e: | 181 | except bb.fetch2.BBFetchException as e: |
| 169 | bb.fatal("Bitbake Fetcher Error: " + repr(e)) | 182 | bb.fatal("Bitbake Fetcher Error: " + repr(e)) |
| 183 | |||
| 184 | if basedir and os.path.exists(unpackdir + '/' + basedir): | ||
| 185 | # Compatibility magic to ensure ${WORKDIR}/git and ${WORKDIR}/${BP} | ||
| 186 | # as often used in S work as expected. | ||
| 187 | shutil.move(unpackdir + '/' + basedir, workdir + '/' + basedir) | ||
| 170 | } | 188 | } |
| 171 | 189 | ||
| 172 | SSTATETASKS += "do_deploy_source_date_epoch" | 190 | SSTATETASKS += "do_deploy_source_date_epoch" |
| @@ -199,8 +217,8 @@ addtask do_deploy_source_date_epoch_setscene | |||
| 199 | addtask do_deploy_source_date_epoch before do_configure after do_patch | 217 | addtask do_deploy_source_date_epoch before do_configure after do_patch |
| 200 | 218 | ||
| 201 | python create_source_date_epoch_stamp() { | 219 | python create_source_date_epoch_stamp() { |
| 202 | # Version: 1 | 220 | # Version: 2 |
| 203 | source_date_epoch = oe.reproducible.get_source_date_epoch(d, d.getVar('S')) | 221 | source_date_epoch = oe.reproducible.get_source_date_epoch(d, d.getVar('SOURCE_BASEDIR') or d.getVar('S')) |
| 204 | oe.reproducible.epochfile_write(source_date_epoch, d.getVar('SDE_FILE'), d) | 222 | oe.reproducible.epochfile_write(source_date_epoch, d.getVar('SDE_FILE'), d) |
| 205 | } | 223 | } |
| 206 | do_unpack[postfuncs] += "create_source_date_epoch_stamp" | 224 | do_unpack[postfuncs] += "create_source_date_epoch_stamp" |
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf index b2c500d873..75c850760f 100644 --- a/meta/conf/bitbake.conf +++ b/meta/conf/bitbake.conf | |||
| @@ -405,7 +405,7 @@ STAMP = "${STAMPS_DIR}/${MULTIMACH_TARGET_SYS}/${PN}/${PV}" | |||
| 405 | STAMPCLEAN = "${STAMPS_DIR}/${MULTIMACH_TARGET_SYS}/${PN}/*-*" | 405 | STAMPCLEAN = "${STAMPS_DIR}/${MULTIMACH_TARGET_SYS}/${PN}/*-*" |
| 406 | BASE_WORKDIR ?= "${TMPDIR}/work" | 406 | BASE_WORKDIR ?= "${TMPDIR}/work" |
| 407 | WORKDIR = "${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}/${PN}/${PV}" | 407 | WORKDIR = "${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}/${PN}/${PV}" |
| 408 | UNPACKDIR ??= "${WORKDIR}" | 408 | UNPACKDIR ??= "${WORKDIR}/sources-unpack" |
| 409 | T = "${WORKDIR}/temp" | 409 | T = "${WORKDIR}/temp" |
| 410 | D = "${WORKDIR}/image" | 410 | D = "${WORKDIR}/image" |
| 411 | S = "${WORKDIR}/${BP}" | 411 | S = "${WORKDIR}/${BP}" |
diff --git a/meta/lib/oe/reproducible.py b/meta/lib/oe/reproducible.py index a9f717159e..1957c97434 100644 --- a/meta/lib/oe/reproducible.py +++ b/meta/lib/oe/reproducible.py | |||
| @@ -75,10 +75,10 @@ def get_source_date_epoch_from_known_files(d, sourcedir): | |||
| 75 | return source_date_epoch | 75 | return source_date_epoch |
| 76 | 76 | ||
| 77 | def find_git_folder(d, sourcedir): | 77 | def find_git_folder(d, sourcedir): |
| 78 | # First guess: WORKDIR/git | 78 | # First guess: UNPACKDIR/git |
| 79 | # This is the default git fetcher unpack path | 79 | # This is the default git fetcher unpack path |
| 80 | workdir = d.getVar('WORKDIR') | 80 | unpackdir = d.getVar('UNPACKDIR') |
| 81 | gitpath = os.path.join(workdir, "git/.git") | 81 | gitpath = os.path.join(unpackdir, "git/.git") |
| 82 | if os.path.isdir(gitpath): | 82 | if os.path.isdir(gitpath): |
| 83 | return gitpath | 83 | return gitpath |
| 84 | 84 | ||
| @@ -88,15 +88,16 @@ def find_git_folder(d, sourcedir): | |||
| 88 | return gitpath | 88 | return gitpath |
| 89 | 89 | ||
| 90 | # Perhaps there was a subpath or destsuffix specified. | 90 | # Perhaps there was a subpath or destsuffix specified. |
| 91 | # Go looking in the WORKDIR | 91 | # Go looking in the UNPACKDIR |
| 92 | exclude = set(["build", "image", "license-destdir", "patches", "pseudo", | 92 | for root, dirs, files in os.walk(unpackdir, topdown=True): |
| 93 | "recipe-sysroot", "recipe-sysroot-native", "sysroot-destdir", "temp"]) | ||
| 94 | for root, dirs, files in os.walk(workdir, topdown=True): | ||
| 95 | dirs[:] = [d for d in dirs if d not in exclude] | ||
| 96 | if '.git' in dirs: | 93 | if '.git' in dirs: |
| 97 | return os.path.join(root, ".git") | 94 | return os.path.join(root, ".git") |
| 98 | 95 | ||
| 99 | bb.warn("Failed to find a git repository in WORKDIR: %s" % workdir) | 96 | for root, dirs, files in os.walk(sourcedir, topdown=True): |
| 97 | if '.git' in dirs: | ||
| 98 | return os.path.join(root, ".git") | ||
| 99 | |||
| 100 | bb.warn("Failed to find a git repository in UNPACKDIR: %s" % unpackdir) | ||
| 100 | return None | 101 | return None |
| 101 | 102 | ||
| 102 | def get_source_date_epoch_from_git(d, sourcedir): | 103 | def get_source_date_epoch_from_git(d, sourcedir): |
