Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # ex:ts=4:sw=4:sts=4:et |
| 2 | # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- |
| 3 | # |
| 4 | # This bbclass is used for creating archive for: |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 5 | # 1) original (or unpacked) source: ARCHIVER_MODE[src] = "original" |
| 6 | # 2) patched source: ARCHIVER_MODE[src] = "patched" (default) |
| 7 | # 3) configured source: ARCHIVER_MODE[src] = "configured" |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 8 | # 4) source mirror: ARCHIVER_MODE[src] = "mirror" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 9 | # 5) The patches between do_unpack and do_patch: |
| 10 | # ARCHIVER_MODE[diff] = "1" |
| 11 | # And you can set the one that you'd like to exclude from the diff: |
| 12 | # ARCHIVER_MODE[diff-exclude] ?= ".pc autom4te.cache patches" |
| 13 | # 6) The environment data, similar to 'bitbake -e recipe': |
| 14 | # ARCHIVER_MODE[dumpdata] = "1" |
| 15 | # 7) The recipe (.bb and .inc): ARCHIVER_MODE[recipe] = "1" |
| 16 | # 8) Whether output the .src.rpm package: |
| 17 | # ARCHIVER_MODE[srpm] = "1" |
| 18 | # 9) Filter the license, the recipe whose license in |
| 19 | # COPYLEFT_LICENSE_INCLUDE will be included, and in |
| 20 | # COPYLEFT_LICENSE_EXCLUDE will be excluded. |
| 21 | # COPYLEFT_LICENSE_INCLUDE = 'GPL* LGPL*' |
| 22 | # COPYLEFT_LICENSE_EXCLUDE = 'CLOSED Proprietary' |
| 23 | # 10) The recipe type that will be archived: |
| 24 | # COPYLEFT_RECIPE_TYPES = 'target' |
| 25 | # 11) The source mirror mode: |
| 26 | # ARCHIVER_MODE[mirror] = "split" (default): Sources are split into |
| 27 | # per-recipe directories in a similar way to other archiver modes. |
| 28 | # Post-processing may be required to produce a single mirror directory. |
| 29 | # This does however allow inspection of duplicate sources and more |
| 30 | # intelligent handling. |
| 31 | # ARCHIVER_MODE[mirror] = "combined": All sources are placed into a single |
| 32 | # directory suitable for direct use as a mirror. Duplicate sources are |
| 33 | # ignored. |
| 34 | # 12) Source mirror exclusions: |
| 35 | # ARCHIVER_MIRROR_EXCLUDE is a list of prefixes to exclude from the mirror. |
| 36 | # This may be used for sources which you are already publishing yourself |
| 37 | # (e.g. if the URI starts with 'https://mysite.com/' and your mirror is |
| 38 | # going to be published to the same site). It may also be used to exclude |
| 39 | # local files (with the prefix 'file://') if these will be provided as part |
| 40 | # of an archive of the layers themselves. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 41 | # |
| 42 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 43 | # Create archive for all the recipe types |
| 44 | COPYLEFT_RECIPE_TYPES ?= 'target native nativesdk cross crosssdk cross-canadian' |
| 45 | inherit copyleft_filter |
| 46 | |
| 47 | ARCHIVER_MODE[srpm] ?= "0" |
| 48 | ARCHIVER_MODE[src] ?= "patched" |
| 49 | ARCHIVER_MODE[diff] ?= "0" |
| 50 | ARCHIVER_MODE[diff-exclude] ?= ".pc autom4te.cache patches" |
| 51 | ARCHIVER_MODE[dumpdata] ?= "0" |
| 52 | ARCHIVER_MODE[recipe] ?= "0" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 53 | ARCHIVER_MODE[mirror] ?= "split" |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 54 | ARCHIVER_MODE[compression] ?= "xz" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 55 | |
| 56 | DEPLOY_DIR_SRC ?= "${DEPLOY_DIR}/sources" |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 57 | ARCHIVER_TOPDIR ?= "${WORKDIR}/archiver-sources" |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 58 | ARCHIVER_ARCH = "${TARGET_SYS}" |
| 59 | ARCHIVER_OUTDIR = "${ARCHIVER_TOPDIR}/${ARCHIVER_ARCH}/${PF}/" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 60 | ARCHIVER_RPMTOPDIR ?= "${WORKDIR}/deploy-sources-rpm" |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 61 | ARCHIVER_RPMOUTDIR = "${ARCHIVER_RPMTOPDIR}/${ARCHIVER_ARCH}/${PF}/" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 62 | ARCHIVER_WORKDIR = "${WORKDIR}/archiver-work/" |
| 63 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 64 | # When producing a combined mirror directory, allow duplicates for the case |
| 65 | # where multiple recipes use the same SRC_URI. |
| 66 | ARCHIVER_COMBINED_MIRRORDIR = "${ARCHIVER_TOPDIR}/mirror" |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 67 | SSTATE_ALLOW_OVERLAP_FILES += "${DEPLOY_DIR_SRC}/mirror" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 68 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 69 | do_dumpdata[dirs] = "${ARCHIVER_OUTDIR}" |
| 70 | do_ar_recipe[dirs] = "${ARCHIVER_OUTDIR}" |
| 71 | do_ar_original[dirs] = "${ARCHIVER_OUTDIR} ${ARCHIVER_WORKDIR}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 72 | |
| 73 | # This is a convenience for the shell script to use it |
| 74 | |
| 75 | |
| 76 | python () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 77 | pn = d.getVar('PN') |
| 78 | assume_provided = (d.getVar("ASSUME_PROVIDED") or "").split() |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 79 | if pn in assume_provided: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 80 | for p in d.getVar("PROVIDES").split(): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 81 | if p != pn: |
| 82 | pn = p |
| 83 | break |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 84 | |
| 85 | included, reason = copyleft_should_include(d) |
| 86 | if not included: |
| 87 | bb.debug(1, 'archiver: %s is excluded: %s' % (pn, reason)) |
| 88 | return |
| 89 | else: |
| 90 | bb.debug(1, 'archiver: %s is included: %s' % (pn, reason)) |
| 91 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 92 | |
| 93 | # glibc-locale: do_fetch, do_unpack and do_patch tasks have been deleted, |
| 94 | # so avoid archiving source here. |
| 95 | if pn.startswith('glibc-locale'): |
| 96 | return |
| 97 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 98 | # We just archive gcc-source for all the gcc related recipes |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 99 | if d.getVar('BPN') in ['gcc', 'libgcc'] \ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 100 | and not pn.startswith('gcc-source'): |
| 101 | bb.debug(1, 'archiver: %s is excluded, covered by gcc-source' % pn) |
| 102 | return |
| 103 | |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 104 | # TARGET_SYS in ARCHIVER_ARCH will break the stamp for gcc-source in multiconfig |
| 105 | if pn.startswith('gcc-source'): |
| 106 | d.setVar('ARCHIVER_ARCH', "allarch") |
| 107 | |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 108 | def hasTask(task): |
| 109 | return bool(d.getVarFlag(task, "task", False)) and not bool(d.getVarFlag(task, "noexec", False)) |
| 110 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 111 | ar_src = d.getVarFlag('ARCHIVER_MODE', 'src') |
| 112 | ar_dumpdata = d.getVarFlag('ARCHIVER_MODE', 'dumpdata') |
| 113 | ar_recipe = d.getVarFlag('ARCHIVER_MODE', 'recipe') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 114 | |
| 115 | if ar_src == "original": |
| 116 | d.appendVarFlag('do_deploy_archives', 'depends', ' %s:do_ar_original' % pn) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 117 | # 'patched' and 'configured' invoke do_unpack_and_patch because |
| 118 | # do_ar_patched resp. do_ar_configured depend on it, but for 'original' |
| 119 | # we have to add it explicitly. |
| 120 | if d.getVarFlag('ARCHIVER_MODE', 'diff') == '1': |
| 121 | d.appendVarFlag('do_deploy_archives', 'depends', ' %s:do_unpack_and_patch' % pn) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 122 | elif ar_src == "patched": |
| 123 | d.appendVarFlag('do_deploy_archives', 'depends', ' %s:do_ar_patched' % pn) |
| 124 | elif ar_src == "configured": |
| 125 | # We can't use "addtask do_ar_configured after do_configure" since it |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 126 | # will cause the deptask of do_populate_sysroot to run no matter what |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 127 | # archives we need, so we add the depends here. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 128 | |
| 129 | # There is a corner case with "gcc-source-${PV}" recipes, they don't have |
| 130 | # the "do_configure" task, so we need to use "do_preconfigure" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 131 | if hasTask("do_preconfigure"): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 132 | d.appendVarFlag('do_ar_configured', 'depends', ' %s:do_preconfigure' % pn) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 133 | elif hasTask("do_configure"): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 134 | d.appendVarFlag('do_ar_configured', 'depends', ' %s:do_configure' % pn) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 135 | d.appendVarFlag('do_deploy_archives', 'depends', ' %s:do_ar_configured' % pn) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 136 | elif ar_src == "mirror": |
| 137 | d.appendVarFlag('do_deploy_archives', 'depends', '%s:do_ar_mirror' % pn) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 138 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 139 | elif ar_src: |
| 140 | bb.fatal("Invalid ARCHIVER_MODE[src]: %s" % ar_src) |
| 141 | |
| 142 | if ar_dumpdata == "1": |
| 143 | d.appendVarFlag('do_deploy_archives', 'depends', ' %s:do_dumpdata' % pn) |
| 144 | |
| 145 | if ar_recipe == "1": |
| 146 | d.appendVarFlag('do_deploy_archives', 'depends', ' %s:do_ar_recipe' % pn) |
| 147 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 148 | # Output the SRPM package |
| 149 | if d.getVarFlag('ARCHIVER_MODE', 'srpm') == "1" and d.getVar('PACKAGES'): |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 150 | if "package_rpm" not in d.getVar('PACKAGE_CLASSES'): |
| 151 | bb.fatal("ARCHIVER_MODE[srpm] needs package_rpm in PACKAGE_CLASSES") |
| 152 | |
| 153 | # Some recipes do not have any packaging tasks |
| 154 | if hasTask("do_package_write_rpm"): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 155 | d.appendVarFlag('do_deploy_archives', 'depends', ' %s:do_package_write_rpm' % pn) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 156 | d.appendVarFlag('do_package_write_rpm', 'dirs', ' ${ARCHIVER_RPMTOPDIR}') |
| 157 | d.appendVarFlag('do_package_write_rpm', 'sstate-inputdirs', ' ${ARCHIVER_RPMTOPDIR}') |
| 158 | d.appendVarFlag('do_package_write_rpm', 'sstate-outputdirs', ' ${DEPLOY_DIR_SRC}') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 159 | if ar_dumpdata == "1": |
| 160 | d.appendVarFlag('do_package_write_rpm', 'depends', ' %s:do_dumpdata' % pn) |
| 161 | if ar_recipe == "1": |
| 162 | d.appendVarFlag('do_package_write_rpm', 'depends', ' %s:do_ar_recipe' % pn) |
| 163 | if ar_src == "original": |
| 164 | d.appendVarFlag('do_package_write_rpm', 'depends', ' %s:do_ar_original' % pn) |
| 165 | elif ar_src == "patched": |
| 166 | d.appendVarFlag('do_package_write_rpm', 'depends', ' %s:do_ar_patched' % pn) |
| 167 | elif ar_src == "configured": |
| 168 | d.appendVarFlag('do_package_write_rpm', 'depends', ' %s:do_ar_configured' % pn) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 169 | } |
| 170 | |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 171 | # Take all the sources for a recipe and put them in WORKDIR/archiver-work/. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 172 | # Files in SRC_URI are copied directly, anything that's a directory |
| 173 | # (e.g. git repositories) is "unpacked" and then put into a tarball. |
| 174 | python do_ar_original() { |
| 175 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 176 | import shutil, tempfile |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 177 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 178 | if d.getVarFlag('ARCHIVER_MODE', 'src') != "original": |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 179 | return |
| 180 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 181 | ar_outdir = d.getVar('ARCHIVER_OUTDIR') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 182 | bb.note('Archiving the original source...') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 183 | urls = d.getVar("SRC_URI").split() |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 184 | # destsuffix (git fetcher) and subdir (everything else) are allowed to be |
| 185 | # absolute paths (for example, destsuffix=${S}/foobar). |
| 186 | # That messes with unpacking inside our tmpdir below, because the fetchers |
| 187 | # will then unpack in that directory and completely ignore the tmpdir. |
| 188 | # That breaks parallel tasks relying on ${S}, like do_compile. |
| 189 | # |
| 190 | # To solve this, we remove these parameters from all URLs. |
| 191 | # We do this even for relative paths because it makes the content of the |
| 192 | # archives more useful (no extra paths that are only used during |
| 193 | # compilation). |
| 194 | for i, url in enumerate(urls): |
| 195 | decoded = bb.fetch2.decodeurl(url) |
| 196 | for param in ('destsuffix', 'subdir'): |
| 197 | if param in decoded[5]: |
| 198 | del decoded[5][param] |
| 199 | encoded = bb.fetch2.encodeurl(decoded) |
| 200 | urls[i] = encoded |
Andrew Geissler | 1e34c2d | 2020-05-29 16:02:59 -0500 | [diff] [blame] | 201 | |
| 202 | # Cleanup SRC_URI before call bb.fetch2.Fetch() since now SRC_URI is in the |
| 203 | # variable "urls", otherwise there might be errors like: |
| 204 | # The SRCREV_FORMAT variable must be set when multiple SCMs are used |
| 205 | ld = bb.data.createCopy(d) |
| 206 | ld.setVar('SRC_URI', '') |
| 207 | fetch = bb.fetch2.Fetch(urls, ld) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 208 | tarball_suffix = {} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 209 | for url in fetch.urls: |
| 210 | local = fetch.localpath(url).rstrip("/"); |
| 211 | if os.path.isfile(local): |
| 212 | shutil.copy(local, ar_outdir) |
| 213 | elif os.path.isdir(local): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 214 | tmpdir = tempfile.mkdtemp(dir=d.getVar('ARCHIVER_WORKDIR')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 215 | fetch.unpack(tmpdir, (url,)) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 216 | # To handle recipes with more than one source, we add the "name" |
| 217 | # URL parameter as suffix. We treat it as an error when |
| 218 | # there's more than one URL without a name, or a name gets reused. |
| 219 | # This is an additional safety net, in practice the name has |
| 220 | # to be set when using the git fetcher, otherwise SRCREV cannot |
| 221 | # be set separately for each URL. |
| 222 | params = bb.fetch2.decodeurl(url)[5] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 223 | type = bb.fetch2.decodeurl(url)[0] |
| 224 | location = bb.fetch2.decodeurl(url)[2] |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 225 | name = params.get('name', '') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 226 | if type.lower() == 'file': |
| 227 | name_tmp = location.rstrip("*").rstrip("/") |
| 228 | name = os.path.basename(name_tmp) |
| 229 | else: |
| 230 | if name in tarball_suffix: |
| 231 | if not name: |
| 232 | bb.fatal("Cannot determine archive names for original source because 'name' URL parameter is unset in more than one URL. Add it to at least one of these: %s %s" % (tarball_suffix[name], url)) |
| 233 | else: |
| 234 | bb.fatal("Cannot determine archive names for original source because 'name=' URL parameter '%s' is used twice. Make it unique in: %s %s" % (tarball_suffix[name], url)) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 235 | tarball_suffix[name] = url |
| 236 | create_tarball(d, tmpdir + '/.', name, ar_outdir) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 237 | |
| 238 | # Emit patch series files for 'original' |
| 239 | bb.note('Writing patch series files...') |
| 240 | for patch in src_patches(d): |
| 241 | _, _, local, _, _, parm = bb.fetch.decodeurl(patch) |
| 242 | patchdir = parm.get('patchdir') |
| 243 | if patchdir: |
| 244 | series = os.path.join(ar_outdir, 'series.subdir.%s' % patchdir.replace('/', '_')) |
| 245 | else: |
| 246 | series = os.path.join(ar_outdir, 'series') |
| 247 | |
| 248 | with open(series, 'a') as s: |
| 249 | s.write('%s -p%s\n' % (os.path.basename(local), parm['striplevel'])) |
| 250 | } |
| 251 | |
| 252 | python do_ar_patched() { |
| 253 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 254 | if d.getVarFlag('ARCHIVER_MODE', 'src') != 'patched': |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 255 | return |
| 256 | |
| 257 | # Get the ARCHIVER_OUTDIR before we reset the WORKDIR |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 258 | ar_outdir = d.getVar('ARCHIVER_OUTDIR') |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 259 | if not is_work_shared(d): |
| 260 | ar_workdir = d.getVar('ARCHIVER_WORKDIR') |
| 261 | d.setVar('WORKDIR', ar_workdir) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 262 | bb.note('Archiving the patched source...') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 263 | create_tarball(d, d.getVar('S'), 'patched', ar_outdir) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | python do_ar_configured() { |
| 267 | import shutil |
| 268 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 269 | # Forcibly expand the sysroot paths as we're about to change WORKDIR |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 270 | d.setVar('STAGING_DIR_HOST', d.getVar('STAGING_DIR_HOST')) |
| 271 | d.setVar('STAGING_DIR_TARGET', d.getVar('STAGING_DIR_TARGET')) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 272 | d.setVar('RECIPE_SYSROOT', d.getVar('RECIPE_SYSROOT')) |
| 273 | d.setVar('RECIPE_SYSROOT_NATIVE', d.getVar('RECIPE_SYSROOT_NATIVE')) |
| 274 | |
| 275 | ar_outdir = d.getVar('ARCHIVER_OUTDIR') |
| 276 | if d.getVarFlag('ARCHIVER_MODE', 'src') == 'configured': |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 277 | bb.note('Archiving the configured source...') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 278 | pn = d.getVar('PN') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 279 | # "gcc-source-${PV}" recipes don't have "do_configure" |
| 280 | # task, so we need to run "do_preconfigure" instead |
| 281 | if pn.startswith("gcc-source-"): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 282 | d.setVar('WORKDIR', d.getVar('ARCHIVER_WORKDIR')) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 283 | bb.build.exec_func('do_preconfigure', d) |
| 284 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 285 | # The libtool-native's do_configure will remove the |
| 286 | # ${STAGING_DATADIR}/aclocal/libtool.m4, so we can't re-run the |
| 287 | # do_configure, we archive the already configured ${S} to |
| 288 | # instead of. |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 289 | # The kernel class functions require it to be on work-shared, we |
| 290 | # don't unpack, patch, configure again, just archive the already |
| 291 | # configured ${S} |
| 292 | elif not (pn == 'libtool-native' or is_work_shared(d)): |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 293 | def runTask(task): |
| 294 | prefuncs = d.getVarFlag(task, 'prefuncs') or '' |
| 295 | for func in prefuncs.split(): |
| 296 | if func != "sysroot_cleansstate": |
| 297 | bb.build.exec_func(func, d) |
| 298 | bb.build.exec_func(task, d) |
| 299 | postfuncs = d.getVarFlag(task, 'postfuncs') or '' |
| 300 | for func in postfuncs.split(): |
| 301 | if func != 'do_qa_configure': |
| 302 | bb.build.exec_func(func, d) |
| 303 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 304 | # Change the WORKDIR to make do_configure run in another dir. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 305 | d.setVar('WORKDIR', d.getVar('ARCHIVER_WORKDIR')) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 306 | |
| 307 | preceeds = bb.build.preceedtask('do_configure', False, d) |
| 308 | for task in preceeds: |
| 309 | if task != 'do_patch' and task != 'do_prepare_recipe_sysroot': |
| 310 | runTask(task) |
| 311 | runTask('do_configure') |
| 312 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 313 | srcdir = d.getVar('S') |
| 314 | builddir = d.getVar('B') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 315 | if srcdir != builddir: |
| 316 | if os.path.exists(builddir): |
| 317 | oe.path.copytree(builddir, os.path.join(srcdir, \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 318 | 'build.%s.ar_configured' % d.getVar('PF'))) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 319 | create_tarball(d, srcdir, 'configured', ar_outdir) |
| 320 | } |
| 321 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 322 | python do_ar_mirror() { |
| 323 | import subprocess |
| 324 | |
| 325 | src_uri = (d.getVar('SRC_URI') or '').split() |
| 326 | if len(src_uri) == 0: |
| 327 | return |
| 328 | |
| 329 | dl_dir = d.getVar('DL_DIR') |
| 330 | mirror_exclusions = (d.getVar('ARCHIVER_MIRROR_EXCLUDE') or '').split() |
| 331 | mirror_mode = d.getVarFlag('ARCHIVER_MODE', 'mirror') |
| 332 | have_mirror_tarballs = d.getVar('BB_GENERATE_MIRROR_TARBALLS') |
| 333 | |
| 334 | if mirror_mode == 'combined': |
| 335 | destdir = d.getVar('ARCHIVER_COMBINED_MIRRORDIR') |
| 336 | elif mirror_mode == 'split': |
| 337 | destdir = d.getVar('ARCHIVER_OUTDIR') |
| 338 | else: |
| 339 | bb.fatal('Invalid ARCHIVER_MODE[mirror]: %s' % (mirror_mode)) |
| 340 | |
| 341 | if not have_mirror_tarballs: |
| 342 | bb.fatal('Using `ARCHIVER_MODE[src] = "mirror"` depends on setting `BB_GENERATE_MIRROR_TARBALLS = "1"`') |
| 343 | |
| 344 | def is_excluded(url): |
| 345 | for prefix in mirror_exclusions: |
| 346 | if url.startswith(prefix): |
| 347 | return True |
| 348 | return False |
| 349 | |
| 350 | bb.note('Archiving the source as a mirror...') |
| 351 | |
| 352 | bb.utils.mkdirhier(destdir) |
| 353 | |
| 354 | fetcher = bb.fetch2.Fetch(src_uri, d) |
| 355 | |
Andrew Geissler | 5a43b43 | 2020-06-13 10:46:56 -0500 | [diff] [blame] | 356 | for ud in fetcher.expanded_urldata(): |
| 357 | if is_excluded(ud.url): |
| 358 | bb.note('Skipping excluded url: %s' % (ud.url)) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 359 | continue |
| 360 | |
Andrew Geissler | 5a43b43 | 2020-06-13 10:46:56 -0500 | [diff] [blame] | 361 | bb.note('Archiving url: %s' % (ud.url)) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 362 | ud.setup_localpath(d) |
| 363 | localpath = None |
| 364 | |
| 365 | # Check for mirror tarballs first. We will archive the first mirror |
| 366 | # tarball that we find as it's assumed that we just need one. |
| 367 | for mirror_fname in ud.mirrortarballs: |
| 368 | mirror_path = os.path.join(dl_dir, mirror_fname) |
| 369 | if os.path.exists(mirror_path): |
| 370 | bb.note('Found mirror tarball: %s' % (mirror_path)) |
| 371 | localpath = mirror_path |
| 372 | break |
| 373 | |
| 374 | if len(ud.mirrortarballs) and not localpath: |
| 375 | bb.warn('Mirror tarballs are listed for a source but none are present. ' \ |
| 376 | 'Falling back to original download.\n' \ |
Andrew Geissler | 5a43b43 | 2020-06-13 10:46:56 -0500 | [diff] [blame] | 377 | 'SRC_URI = %s' % (ud.url)) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 378 | |
| 379 | # Check original download |
| 380 | if not localpath: |
| 381 | bb.note('Using original download: %s' % (ud.localpath)) |
| 382 | localpath = ud.localpath |
| 383 | |
| 384 | if not localpath or not os.path.exists(localpath): |
| 385 | bb.fatal('Original download is missing for a source.\n' \ |
Andrew Geissler | 5a43b43 | 2020-06-13 10:46:56 -0500 | [diff] [blame] | 386 | 'SRC_URI = %s' % (ud.url)) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 387 | |
| 388 | # We now have an appropriate localpath |
| 389 | bb.note('Copying source mirror') |
| 390 | cmd = 'cp -fpPRH %s %s' % (localpath, destdir) |
| 391 | subprocess.check_call(cmd, shell=True) |
| 392 | } |
| 393 | |
Brad Bishop | c4ea075 | 2018-11-15 14:30:15 -0800 | [diff] [blame] | 394 | def exclude_useless_paths(tarinfo): |
| 395 | if tarinfo.isdir(): |
| 396 | if tarinfo.name.endswith('/temp') or tarinfo.name.endswith('/patches') or tarinfo.name.endswith('/.pc'): |
| 397 | return None |
| 398 | elif tarinfo.name == 'temp' or tarinfo.name == 'patches' or tarinfo.name == '.pc': |
| 399 | return None |
| 400 | return tarinfo |
| 401 | |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 402 | def create_tarball(d, srcdir, suffix, ar_outdir): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 403 | """ |
| 404 | create the tarball from srcdir |
| 405 | """ |
| 406 | import tarfile |
| 407 | |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 408 | # Make sure we are only creating a single tarball for gcc sources |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 409 | if (d.getVar('SRC_URI') == ""): |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 410 | return |
| 411 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 412 | # For the kernel archive, srcdir may just be a link to the |
| 413 | # work-shared location. Use os.path.realpath to make sure |
| 414 | # that we archive the actual directory and not just the link. |
| 415 | srcdir = os.path.realpath(srcdir) |
| 416 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 417 | compression_method = d.getVarFlag('ARCHIVER_MODE', 'compression') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 418 | bb.utils.mkdirhier(ar_outdir) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 419 | if suffix: |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 420 | filename = '%s-%s.tar.%s' % (d.getVar('PF'), suffix, compression_method) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 421 | else: |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 422 | filename = '%s.tar.%s' % (d.getVar('PF'), compression_method) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 423 | tarname = os.path.join(ar_outdir, filename) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 424 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 425 | bb.note('Creating %s' % tarname) |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 426 | tar = tarfile.open(tarname, 'w:%s' % compression_method) |
Brad Bishop | c4ea075 | 2018-11-15 14:30:15 -0800 | [diff] [blame] | 427 | tar.add(srcdir, arcname=os.path.basename(srcdir), filter=exclude_useless_paths) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 428 | tar.close() |
| 429 | |
| 430 | # creating .diff.gz between source.orig and source |
| 431 | def create_diff_gz(d, src_orig, src, ar_outdir): |
| 432 | |
| 433 | import subprocess |
| 434 | |
| 435 | if not os.path.isdir(src) or not os.path.isdir(src_orig): |
| 436 | return |
| 437 | |
| 438 | # The diff --exclude can't exclude the file with path, so we copy |
| 439 | # the patched source, and remove the files that we'd like to |
| 440 | # exclude. |
| 441 | src_patched = src + '.patched' |
| 442 | oe.path.copyhardlinktree(src, src_patched) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 443 | for i in d.getVarFlag('ARCHIVER_MODE', 'diff-exclude').split(): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 444 | bb.utils.remove(os.path.join(src_orig, i), recurse=True) |
| 445 | bb.utils.remove(os.path.join(src_patched, i), recurse=True) |
| 446 | |
| 447 | dirname = os.path.dirname(src) |
| 448 | basename = os.path.basename(src) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 449 | bb.utils.mkdirhier(ar_outdir) |
| 450 | cwd = os.getcwd() |
| 451 | try: |
| 452 | os.chdir(dirname) |
| 453 | out_file = os.path.join(ar_outdir, '%s-diff.gz' % d.getVar('PF')) |
| 454 | diff_cmd = 'diff -Naur %s.orig %s.patched | gzip -c > %s' % (basename, basename, out_file) |
| 455 | subprocess.check_call(diff_cmd, shell=True) |
| 456 | bb.utils.remove(src_patched, recurse=True) |
| 457 | finally: |
| 458 | os.chdir(cwd) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 459 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 460 | def is_work_shared(d): |
| 461 | pn = d.getVar('PN') |
| 462 | return bb.data.inherits_class('kernel', d) or pn.startswith('gcc-source') |
| 463 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 464 | # Run do_unpack and do_patch |
| 465 | python do_unpack_and_patch() { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 466 | if d.getVarFlag('ARCHIVER_MODE', 'src') not in \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 467 | [ 'patched', 'configured'] and \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 468 | d.getVarFlag('ARCHIVER_MODE', 'diff') != '1': |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 469 | return |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 470 | ar_outdir = d.getVar('ARCHIVER_OUTDIR') |
| 471 | ar_workdir = d.getVar('ARCHIVER_WORKDIR') |
| 472 | ar_sysroot_native = d.getVar('STAGING_DIR_NATIVE') |
| 473 | pn = d.getVar('PN') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 474 | |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 475 | # The kernel class functions require it to be on work-shared, so we don't change WORKDIR |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 476 | if not is_work_shared(d): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 477 | # Change the WORKDIR to make do_unpack do_patch run in another dir. |
| 478 | d.setVar('WORKDIR', ar_workdir) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 479 | # Restore the original path to recipe's native sysroot (it's relative to WORKDIR). |
| 480 | d.setVar('STAGING_DIR_NATIVE', ar_sysroot_native) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 481 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 482 | # The changed 'WORKDIR' also caused 'B' changed, create dir 'B' for the |
| 483 | # possibly requiring of the following tasks (such as some recipes's |
| 484 | # do_patch required 'B' existed). |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 485 | bb.utils.mkdirhier(d.getVar('B')) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 486 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 487 | bb.build.exec_func('do_unpack', d) |
| 488 | |
| 489 | # Save the original source for creating the patches |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 490 | if d.getVarFlag('ARCHIVER_MODE', 'diff') == '1': |
| 491 | src = d.getVar('S').rstrip('/') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 492 | src_orig = '%s.orig' % src |
| 493 | oe.path.copytree(src, src_orig) |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 494 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 495 | if bb.data.inherits_class('dos2unix', d): |
| 496 | bb.build.exec_func('do_convert_crlf_to_lf', d) |
| 497 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 498 | # Make sure gcc and kernel sources are patched only once |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 499 | if not (d.getVar('SRC_URI') == "" or is_work_shared(d)): |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 500 | bb.build.exec_func('do_patch', d) |
| 501 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 502 | # Create the patches |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 503 | if d.getVarFlag('ARCHIVER_MODE', 'diff') == '1': |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 504 | bb.note('Creating diff gz...') |
| 505 | create_diff_gz(d, src_orig, src, ar_outdir) |
| 506 | bb.utils.remove(src_orig, recurse=True) |
| 507 | } |
| 508 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 509 | # BBINCLUDED is special (excluded from basehash signature |
| 510 | # calculation). Using it in a task signature can cause "basehash |
| 511 | # changed" errors. |
| 512 | # |
| 513 | # Depending on BBINCLUDED also causes do_ar_recipe to run again |
| 514 | # for unrelated changes, like adding or removing buildhistory.bbclass. |
| 515 | # |
| 516 | # For these reasons we ignore the dependency completely. The versioning |
| 517 | # of the output file ensures that we create it each time the recipe |
| 518 | # gets rebuilt, at least as long as a PR server is used. We also rely |
| 519 | # on that mechanism to catch changes in the file content, because the |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 520 | # file content is not part of the task signature either. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 521 | do_ar_recipe[vardepsexclude] += "BBINCLUDED" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 522 | python do_ar_recipe () { |
| 523 | """ |
| 524 | archive the recipe, including .bb and .inc. |
| 525 | """ |
| 526 | import re |
| 527 | import shutil |
| 528 | |
| 529 | require_re = re.compile( r"require\s+(.+)" ) |
| 530 | include_re = re.compile( r"include\s+(.+)" ) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 531 | bbfile = d.getVar('FILE') |
| 532 | outdir = os.path.join(d.getVar('WORKDIR'), \ |
| 533 | '%s-recipe' % d.getVar('PF')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 534 | bb.utils.mkdirhier(outdir) |
| 535 | shutil.copy(bbfile, outdir) |
| 536 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 537 | pn = d.getVar('PN') |
| 538 | bbappend_files = d.getVar('BBINCLUDED').split() |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 539 | # If recipe name is aa, we need to match files like aa.bbappend and aa_1.1.bbappend |
| 540 | # Files like aa1.bbappend or aa1_1.1.bbappend must be excluded. |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 541 | bbappend_re = re.compile( r".*/%s_[^/]*\.bbappend$" % re.escape(pn)) |
| 542 | bbappend_re1 = re.compile( r".*/%s\.bbappend$" % re.escape(pn)) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 543 | for file in bbappend_files: |
| 544 | if bbappend_re.match(file) or bbappend_re1.match(file): |
| 545 | shutil.copy(file, outdir) |
| 546 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 547 | dirname = os.path.dirname(bbfile) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 548 | bbpath = '%s:%s' % (dirname, d.getVar('BBPATH')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 549 | f = open(bbfile, 'r') |
| 550 | for line in f.readlines(): |
| 551 | incfile = None |
| 552 | if require_re.match(line): |
| 553 | incfile = require_re.match(line).group(1) |
| 554 | elif include_re.match(line): |
| 555 | incfile = include_re.match(line).group(1) |
| 556 | if incfile: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 557 | incfile = d.expand(incfile) |
Brad Bishop | 1d80a2e | 2019-11-15 16:35:03 -0500 | [diff] [blame] | 558 | if incfile: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 559 | incfile = bb.utils.which(bbpath, incfile) |
Brad Bishop | 1d80a2e | 2019-11-15 16:35:03 -0500 | [diff] [blame] | 560 | if incfile: |
| 561 | shutil.copy(incfile, outdir) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 562 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 563 | create_tarball(d, outdir, 'recipe', d.getVar('ARCHIVER_OUTDIR')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 564 | bb.utils.remove(outdir, recurse=True) |
| 565 | } |
| 566 | |
| 567 | python do_dumpdata () { |
| 568 | """ |
| 569 | dump environment data to ${PF}-showdata.dump |
| 570 | """ |
| 571 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 572 | dumpfile = os.path.join(d.getVar('ARCHIVER_OUTDIR'), \ |
| 573 | '%s-showdata.dump' % d.getVar('PF')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 574 | bb.note('Dumping metadata into %s' % dumpfile) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 575 | with open(dumpfile, "w") as f: |
| 576 | # emit variables and shell functions |
| 577 | bb.data.emit_env(f, d, True) |
| 578 | # emit the metadata which isn't valid shell |
| 579 | for e in d.keys(): |
| 580 | if d.getVarFlag(e, "python", False): |
| 581 | f.write("\npython %s () {\n%s}\n" % (e, d.getVar(e, False))) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 582 | } |
| 583 | |
| 584 | SSTATETASKS += "do_deploy_archives" |
| 585 | do_deploy_archives () { |
Andrew Geissler | 78b7279 | 2022-06-14 06:47:25 -0500 | [diff] [blame] | 586 | bbnote "Deploying source archive files from ${ARCHIVER_TOPDIR} to ${DEPLOY_DIR_SRC}." |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 587 | } |
| 588 | python do_deploy_archives_setscene () { |
| 589 | sstate_setscene(d) |
| 590 | } |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 591 | do_deploy_archives[dirs] = "${ARCHIVER_TOPDIR}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 592 | do_deploy_archives[sstate-inputdirs] = "${ARCHIVER_TOPDIR}" |
| 593 | do_deploy_archives[sstate-outputdirs] = "${DEPLOY_DIR_SRC}" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 594 | addtask do_deploy_archives_setscene |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 595 | |
| 596 | addtask do_ar_original after do_unpack |
Andrew Geissler | 475cb72 | 2020-07-10 16:00:51 -0500 | [diff] [blame] | 597 | addtask do_unpack_and_patch after do_patch do_preconfigure |
| 598 | addtask do_ar_patched after do_unpack_and_patch |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 599 | addtask do_ar_configured after do_unpack_and_patch |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 600 | addtask do_ar_mirror after do_fetch |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 601 | addtask do_dumpdata |
| 602 | addtask do_ar_recipe |
Andrew Geissler | 1e34c2d | 2020-05-29 16:02:59 -0500 | [diff] [blame] | 603 | addtask do_deploy_archives |
| 604 | do_build[recrdeptask] += "do_deploy_archives" |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 605 | do_rootfs[recrdeptask] += "do_deploy_archives" |
Andrew Geissler | 1e34c2d | 2020-05-29 16:02:59 -0500 | [diff] [blame] | 606 | do_populate_sdk[recrdeptask] += "do_deploy_archives" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 607 | |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 608 | python () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 609 | # Add tasks in the correct order, specifically for linux-yocto to avoid race condition. |
| 610 | # sstatesig.py:sstate_rundepfilter has special support that excludes this dependency |
| 611 | # so that do_kernel_configme does not need to run again when do_unpack_and_patch |
| 612 | # gets added or removed (by adding or removing archiver.bbclass). |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 613 | if bb.data.inherits_class('kernel-yocto', d): |
| 614 | bb.build.addtask('do_kernel_configme', 'do_configure', 'do_unpack_and_patch', d) |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 615 | } |