diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-08-11 13:52:59 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-08-24 16:50:24 +0100 |
commit | 62afa02d01794376efab75623f42e7e08af08526 (patch) | |
tree | e713e2ad86aeb3daa677dc62d47b5e9d9402c957 /meta/classes-global/base.bbclass | |
parent | 871a4ac6e7e814242db4f90fc4d8ae92d72d7460 (diff) | |
download | poky-62afa02d01794376efab75623f42e7e08af08526.tar.gz |
base/package: Move source revision information from PV to PKGV
Source control information being present in PV used to be a hard requirement
for bitbake to operate correctly. Now that hashes are a required part of task
stamps, this requirement no longer exists.
This means we can defer the hash pieces to PKGV and simplify PV.
Use new bitbake fetcher API to inject the source revisions directly into the hash
allowing removal of some horrible code from base.bbclass and avoiding any hardcoding
about how SRCREV may or may not be used.
Use that API to object the string to append to PKGV and append that directly.
The user visible effect of this change is that PV will no longer have revision
information in it and this will now be appended to PV through PKGV when the
packages are written. Since PV is used in STAMP and WORKDIR, users will see
small directory naming and stamp naming changes.
This will mean that sstate reuse through hash equivalence where the source
revision changes but the output does not will become possible as the sstate
naming will become less specific and no longer contain the revision.
The SRCPV variable will no longer be needed in PV and is effectively now just
a null operation. Usage can be removed over time.
(From OE-Core rev: a8e7b0f932b9ea69b3a218fca18041676c65aba0)
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 | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/meta/classes-global/base.bbclass b/meta/classes-global/base.bbclass index cbda8d12f0..7c774d250f 100644 --- a/meta/classes-global/base.bbclass +++ b/meta/classes-global/base.bbclass | |||
@@ -126,11 +126,18 @@ def setup_hosttools_dir(dest, toolsvar, d, fatal=True): | |||
126 | if notfound and fatal: | 126 | if notfound and fatal: |
127 | bb.fatal("The following required tools (as specified by HOSTTOOLS) appear to be unavailable in PATH, please install them in order to proceed:\n %s" % " ".join(notfound)) | 127 | bb.fatal("The following required tools (as specified by HOSTTOOLS) appear to be unavailable in PATH, please install them in order to proceed:\n %s" % " ".join(notfound)) |
128 | 128 | ||
129 | # We can't use vardepvalue against do_fetch directly since that would overwrite | ||
130 | # the other task dependencies so we use an indirect function. | ||
131 | python fetcher_hashes_dummyfunc() { | ||
132 | return | ||
133 | } | ||
134 | fetcher_hashes_dummyfunc[vardepvalue] = "${@bb.fetch.get_hashvalue(d)}" | ||
135 | |||
129 | addtask fetch | 136 | addtask fetch |
130 | do_fetch[dirs] = "${DL_DIR}" | 137 | do_fetch[dirs] = "${DL_DIR}" |
131 | do_fetch[file-checksums] = "${@bb.fetch.get_checksum_file_list(d)}" | 138 | do_fetch[file-checksums] = "${@bb.fetch.get_checksum_file_list(d)}" |
132 | do_fetch[file-checksums] += " ${@get_lic_checksum_file_list(d)}" | 139 | do_fetch[file-checksums] += " ${@get_lic_checksum_file_list(d)}" |
133 | do_fetch[vardeps] += "SRCREV" | 140 | do_fetch[prefuncs] += "fetcher_hashes_dummyfunc" |
134 | do_fetch[network] = "1" | 141 | do_fetch[network] = "1" |
135 | python base_do_fetch() { | 142 | python base_do_fetch() { |
136 | 143 | ||
@@ -606,7 +613,6 @@ python () { | |||
606 | bb.debug(1, "Skipping recipe %s because of incompatible license(s): %s" % (pn, ' '.join(incompatible_lic))) | 613 | bb.debug(1, "Skipping recipe %s because of incompatible license(s): %s" % (pn, ' '.join(incompatible_lic))) |
607 | raise bb.parse.SkipRecipe("it has incompatible license(s): %s" % ' '.join(incompatible_lic)) | 614 | raise bb.parse.SkipRecipe("it has incompatible license(s): %s" % ' '.join(incompatible_lic)) |
608 | 615 | ||
609 | needsrcrev = False | ||
610 | srcuri = d.getVar('SRC_URI') | 616 | srcuri = d.getVar('SRC_URI') |
611 | for uri_string in srcuri.split(): | 617 | for uri_string in srcuri.split(): |
612 | uri = bb.fetch.URI(uri_string) | 618 | uri = bb.fetch.URI(uri_string) |
@@ -619,24 +625,17 @@ python () { | |||
619 | 625 | ||
620 | # Svn packages should DEPEND on subversion-native | 626 | # Svn packages should DEPEND on subversion-native |
621 | if uri.scheme == "svn": | 627 | if uri.scheme == "svn": |
622 | needsrcrev = True | ||
623 | d.appendVarFlag('do_fetch', 'depends', ' subversion-native:do_populate_sysroot') | 628 | d.appendVarFlag('do_fetch', 'depends', ' subversion-native:do_populate_sysroot') |
624 | 629 | ||
625 | # Git packages should DEPEND on git-native | 630 | # Git packages should DEPEND on git-native |
626 | elif uri.scheme in ("git", "gitsm"): | 631 | elif uri.scheme in ("git", "gitsm"): |
627 | needsrcrev = True | ||
628 | d.appendVarFlag('do_fetch', 'depends', ' git-native:do_populate_sysroot') | 632 | d.appendVarFlag('do_fetch', 'depends', ' git-native:do_populate_sysroot') |
629 | 633 | ||
630 | # Mercurial packages should DEPEND on mercurial-native | 634 | # Mercurial packages should DEPEND on mercurial-native |
631 | elif uri.scheme == "hg": | 635 | elif uri.scheme == "hg": |
632 | needsrcrev = True | ||
633 | d.appendVar("EXTRANATIVEPATH", ' python3-native ') | 636 | d.appendVar("EXTRANATIVEPATH", ' python3-native ') |
634 | d.appendVarFlag('do_fetch', 'depends', ' mercurial-native:do_populate_sysroot') | 637 | d.appendVarFlag('do_fetch', 'depends', ' mercurial-native:do_populate_sysroot') |
635 | 638 | ||
636 | # Perforce packages support SRCREV = "${AUTOREV}" | ||
637 | elif uri.scheme == "p4": | ||
638 | needsrcrev = True | ||
639 | |||
640 | # OSC packages should DEPEND on osc-native | 639 | # OSC packages should DEPEND on osc-native |
641 | elif uri.scheme == "osc": | 640 | elif uri.scheme == "osc": |
642 | d.appendVarFlag('do_fetch', 'depends', ' osc-native:do_populate_sysroot') | 641 | d.appendVarFlag('do_fetch', 'depends', ' osc-native:do_populate_sysroot') |
@@ -645,7 +644,6 @@ python () { | |||
645 | d.appendVarFlag('do_fetch', 'depends', ' nodejs-native:do_populate_sysroot') | 644 | d.appendVarFlag('do_fetch', 'depends', ' nodejs-native:do_populate_sysroot') |
646 | 645 | ||
647 | elif uri.scheme == "repo": | 646 | elif uri.scheme == "repo": |
648 | needsrcrev = True | ||
649 | d.appendVarFlag('do_fetch', 'depends', ' repo-native:do_populate_sysroot') | 647 | d.appendVarFlag('do_fetch', 'depends', ' repo-native:do_populate_sysroot') |
650 | 648 | ||
651 | # *.lz4 should DEPEND on lz4-native for unpacking | 649 | # *.lz4 should DEPEND on lz4-native for unpacking |
@@ -676,21 +674,6 @@ python () { | |||
676 | elif path.endswith('.deb'): | 674 | elif path.endswith('.deb'): |
677 | d.appendVarFlag('do_unpack', 'depends', ' xz-native:do_populate_sysroot') | 675 | d.appendVarFlag('do_unpack', 'depends', ' xz-native:do_populate_sysroot') |
678 | 676 | ||
679 | if needsrcrev: | ||
680 | d.setVar("SRCPV", "${@bb.fetch2.get_srcrev(d)}") | ||
681 | |||
682 | # Gather all named SRCREVs to add to the sstate hash calculation | ||
683 | # This anonymous python snippet is called multiple times so we | ||
684 | # need to be careful to not double up the appends here and cause | ||
685 | # the base hash to mismatch the task hash | ||
686 | for uri in srcuri.split(): | ||
687 | parm = bb.fetch.decodeurl(uri)[5] | ||
688 | uri_names = parm.get("name", "").split(",") | ||
689 | for uri_name in filter(None, uri_names): | ||
690 | srcrev_name = "SRCREV_{}".format(uri_name) | ||
691 | if srcrev_name not in (d.getVarFlag("do_fetch", "vardeps") or "").split(): | ||
692 | d.appendVarFlag("do_fetch", "vardeps", " {}".format(srcrev_name)) | ||
693 | |||
694 | set_packagetriplet(d) | 677 | set_packagetriplet(d) |
695 | 678 | ||
696 | # 'multimachine' handling | 679 | # 'multimachine' handling |