diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-05-09 17:01:27 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-05-22 22:26:29 +0100 |
| commit | d24a7d0fb16457e10e7a216d4c9ae3fb265113d1 (patch) | |
| tree | 2635c8c0faf8a1f0036966ba7be7fbcbee9856c5 /meta/classes-global/base.bbclass | |
| parent | 94168037a1abab550e8e76ac33295a899eb4015f (diff) | |
| download | poky-d24a7d0fb16457e10e7a216d4c9ae3fb265113d1.tar.gz | |
base: Switch UNPACKDIR to a subdir of WORKDIR
Change do_unpack to unpack files to a subdirectory of WORKDIR instead of WORKDIR
itself. There are several good reasons for this but it is mainly about being able
to isolate the output of the unpack task and tell the files apart from other things
which are created in workdir (logs, sysroots, temp dirs and more).
This means that when the do_unpack task reruns, we can clean UNPACKDIR and know
we have a standard point to start builds from.
It also makes code in tools like devtool and recipetool easier.
To reduce the impact to users, if a subdirectory under UNPACKDIR matches
the first subdirectory under WORKDIR of S, that directory is moved into position
inside WORKDIR. This preserves the behaviour of S = "${WORKDIR}/git",
S = "${WORKDIR}/${BPN}" and other commonly used source directory setups.
The directory is moved since sadly many autotools based projects can't cope with
symlinks in their paths.
The patch also updates reproducible and SOURCE_DATE_EPOCH handling to
match the new potential source locations. We can get rid of the horrible
list of hardcoded directories in WORKDIR to ignore from that code.
(From OE-Core rev: b84eec5c4cbf4b39d6712800dd0d2fe5337721cb)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-global/base.bbclass')
| -rw-r--r-- | meta/classes-global/base.bbclass | 28 |
1 files changed, 23 insertions, 5 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" |
