diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-09-29 15:02:08 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-10-04 15:03:53 +0100 |
commit | 86c7d3e0310f1602327365a360199efe5ea05fc8 (patch) | |
tree | 6ca83ac3466048b8b915a522f327c25810f2d7fe /meta | |
parent | 0b4198eeac06d40861256496169a2e6bb275916c (diff) | |
download | poky-86c7d3e0310f1602327365a360199efe5ea05fc8.tar.gz |
sstatesig: Add processing for full build paths in sysroot files
Some files in the populate_sysroot tasks have hardcoded paths in them,
particularly if they are postinst-useradd- files or crossscripts.
Add some filtering logic to remove these paths.
This means that the hashequiv "outhash" matches correcting in more
cases allowing for better build artefact reuse.
To make this work a new variable is added SSTATE_HASHEQUIV_FILEMAP
which maps file globbing to replacement patterns (paths or regex)
on a per sstate task basis. It is hoped this shouldn't be needed
in many cases. We are in the process to developing QA tests which
will better detect issues in this area to allow optimal sstate
reuse.
(From OE-Core rev: d9852ffbbe728dac33dc081538a08af98f52fd4a)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/classes/sstate.bbclass | 7 | ||||
-rw-r--r-- | meta/lib/oe/sstatesig.py | 39 | ||||
-rw-r--r-- | meta/recipes-devtools/perl/perl_5.34.0.bb | 7 | ||||
-rw-r--r-- | meta/recipes-devtools/python/python3_3.9.6.bb | 8 | ||||
-rw-r--r-- | meta/recipes-devtools/qemu/qemuwrapper-cross_1.0.bb | 1 | ||||
-rw-r--r-- | meta/recipes-devtools/rpm/rpm_4.16.1.3.bb | 5 |
6 files changed, 64 insertions, 3 deletions
diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass index 92a73114bb..89e9f56178 100644 --- a/meta/classes/sstate.bbclass +++ b/meta/classes/sstate.bbclass | |||
@@ -67,6 +67,13 @@ SSTATE_DUPWHITELIST += "${DEPLOY_DIR_IMAGE}/microcode" | |||
67 | SSTATE_SCAN_FILES ?= "*.la *-config *_config postinst-*" | 67 | SSTATE_SCAN_FILES ?= "*.la *-config *_config postinst-*" |
68 | SSTATE_SCAN_CMD ??= 'find ${SSTATE_BUILDDIR} \( -name "${@"\" -o -name \"".join(d.getVar("SSTATE_SCAN_FILES").split())}" \) -type f' | 68 | SSTATE_SCAN_CMD ??= 'find ${SSTATE_BUILDDIR} \( -name "${@"\" -o -name \"".join(d.getVar("SSTATE_SCAN_FILES").split())}" \) -type f' |
69 | SSTATE_SCAN_CMD_NATIVE ??= 'grep -Irl -e ${RECIPE_SYSROOT} -e ${RECIPE_SYSROOT_NATIVE} -e ${HOSTTOOLS_DIR} ${SSTATE_BUILDDIR}' | 69 | SSTATE_SCAN_CMD_NATIVE ??= 'grep -Irl -e ${RECIPE_SYSROOT} -e ${RECIPE_SYSROOT_NATIVE} -e ${HOSTTOOLS_DIR} ${SSTATE_BUILDDIR}' |
70 | SSTATE_HASHEQUIV_FILEMAP ?= " \ | ||
71 | populate_sysroot:*/postinst-useradd-*:${TMPDIR} \ | ||
72 | populate_sysroot:*/postinst-useradd-*:${COREBASE} \ | ||
73 | populate_sysroot:*/postinst-useradd-*:regex-\s(PATH|PSEUDO_IGNORE_PATHS|HOME|LOGNAME|OMP_NUM_THREADS|USER)=.*\s \ | ||
74 | populate_sysroot:*/crossscripts/*:${TMPDIR} \ | ||
75 | populate_sysroot:*/crossscripts/*:${COREBASE} \ | ||
76 | " | ||
70 | 77 | ||
71 | BB_HASHFILENAME = "False ${SSTATE_PKGSPEC} ${SSTATE_SWSPEC}" | 78 | BB_HASHFILENAME = "False ${SSTATE_PKGSPEC} ${SSTATE_SWSPEC}" |
72 | 79 | ||
diff --git a/meta/lib/oe/sstatesig.py b/meta/lib/oe/sstatesig.py index 24577249ff..0c3b4589c5 100644 --- a/meta/lib/oe/sstatesig.py +++ b/meta/lib/oe/sstatesig.py | |||
@@ -470,6 +470,8 @@ def OEOuthashBasic(path, sigfile, task, d): | |||
470 | import stat | 470 | import stat |
471 | import pwd | 471 | import pwd |
472 | import grp | 472 | import grp |
473 | import re | ||
474 | import fnmatch | ||
473 | 475 | ||
474 | def update_hash(s): | 476 | def update_hash(s): |
475 | s = s.encode('utf-8') | 477 | s = s.encode('utf-8') |
@@ -479,6 +481,8 @@ def OEOuthashBasic(path, sigfile, task, d): | |||
479 | 481 | ||
480 | h = hashlib.sha256() | 482 | h = hashlib.sha256() |
481 | prev_dir = os.getcwd() | 483 | prev_dir = os.getcwd() |
484 | corebase = d.getVar("COREBASE") | ||
485 | tmpdir = d.getVar("TMPDIR") | ||
482 | include_owners = os.environ.get('PSEUDO_DISABLED') == '0' | 486 | include_owners = os.environ.get('PSEUDO_DISABLED') == '0' |
483 | if "package_write_" in task or task == "package_qa": | 487 | if "package_write_" in task or task == "package_qa": |
484 | include_owners = False | 488 | include_owners = False |
@@ -489,8 +493,17 @@ def OEOuthashBasic(path, sigfile, task, d): | |||
489 | include_root = False | 493 | include_root = False |
490 | extra_content = d.getVar('HASHEQUIV_HASH_VERSION') | 494 | extra_content = d.getVar('HASHEQUIV_HASH_VERSION') |
491 | 495 | ||
496 | filemaps = {} | ||
497 | for m in (d.getVar('SSTATE_HASHEQUIV_FILEMAP') or '').split(): | ||
498 | entry = m.split(":") | ||
499 | if len(entry) != 3 or entry[0] != task: | ||
500 | continue | ||
501 | filemaps.setdefault(entry[1], []) | ||
502 | filemaps[entry[1]].append(entry[2]) | ||
503 | |||
492 | try: | 504 | try: |
493 | os.chdir(path) | 505 | os.chdir(path) |
506 | basepath = os.path.normpath(path) | ||
494 | 507 | ||
495 | update_hash("OEOuthashBasic\n") | 508 | update_hash("OEOuthashBasic\n") |
496 | if extra_content: | 509 | if extra_content: |
@@ -572,8 +585,13 @@ def OEOuthashBasic(path, sigfile, task, d): | |||
572 | else: | 585 | else: |
573 | update_hash(" " * 9) | 586 | update_hash(" " * 9) |
574 | 587 | ||
588 | filterfile = False | ||
589 | for entry in filemaps: | ||
590 | if fnmatch.fnmatch(path, entry): | ||
591 | filterfile = True | ||
592 | |||
575 | update_hash(" ") | 593 | update_hash(" ") |
576 | if stat.S_ISREG(s.st_mode): | 594 | if stat.S_ISREG(s.st_mode) and not filterfile: |
577 | update_hash("%10d" % s.st_size) | 595 | update_hash("%10d" % s.st_size) |
578 | else: | 596 | else: |
579 | update_hash(" " * 10) | 597 | update_hash(" " * 10) |
@@ -582,9 +600,24 @@ def OEOuthashBasic(path, sigfile, task, d): | |||
582 | fh = hashlib.sha256() | 600 | fh = hashlib.sha256() |
583 | if stat.S_ISREG(s.st_mode): | 601 | if stat.S_ISREG(s.st_mode): |
584 | # Hash file contents | 602 | # Hash file contents |
585 | with open(path, 'rb') as d: | 603 | if filterfile: |
586 | for chunk in iter(lambda: d.read(4096), b""): | 604 | # Need to ignore paths in crossscripts and postinst-useradd files. |
605 | with open(path, 'rb') as d: | ||
606 | chunk = d.read() | ||
607 | chunk = chunk.replace(bytes(basepath, encoding='utf8'), b'') | ||
608 | for entry in filemaps: | ||
609 | if not fnmatch.fnmatch(path, entry): | ||
610 | continue | ||
611 | for r in filemaps[entry]: | ||
612 | if r.startswith("regex-"): | ||
613 | chunk = re.sub(bytes(r[6:], encoding='utf8'), b'', chunk) | ||
614 | else: | ||
615 | chunk = chunk.replace(bytes(r, encoding='utf8'), b'') | ||
587 | fh.update(chunk) | 616 | fh.update(chunk) |
617 | else: | ||
618 | with open(path, 'rb') as d: | ||
619 | for chunk in iter(lambda: d.read(4096), b""): | ||
620 | fh.update(chunk) | ||
588 | update_hash(fh.hexdigest()) | 621 | update_hash(fh.hexdigest()) |
589 | else: | 622 | else: |
590 | update_hash(" " * len(fh.hexdigest())) | 623 | update_hash(" " * len(fh.hexdigest())) |
diff --git a/meta/recipes-devtools/perl/perl_5.34.0.bb b/meta/recipes-devtools/perl/perl_5.34.0.bb index 0e0fe7f985..175db4ee31 100644 --- a/meta/recipes-devtools/perl/perl_5.34.0.bb +++ b/meta/recipes-devtools/perl/perl_5.34.0.bb | |||
@@ -385,3 +385,10 @@ EOF | |||
385 | chmod 0755 ${SYSROOT_DESTDIR}${bindir}/nativeperl | 385 | chmod 0755 ${SYSROOT_DESTDIR}${bindir}/nativeperl |
386 | cat ${SYSROOT_DESTDIR}${bindir}/nativeperl | 386 | cat ${SYSROOT_DESTDIR}${bindir}/nativeperl |
387 | } | 387 | } |
388 | |||
389 | SSTATE_HASHEQUIV_FILEMAP = " \ | ||
390 | populate_sysroot:*/lib*/perl5/*/*/Config_heavy.pl:${TMPDIR} \ | ||
391 | populate_sysroot:*/lib*/perl5/*/*/Config_heavy.pl:${COREBASE} \ | ||
392 | populate_sysroot:*/lib*/perl5/config.sh:${TMPDIR} \ | ||
393 | populate_sysroot:*/lib*/perl5/config.sh:${COREBASE} \ | ||
394 | " | ||
diff --git a/meta/recipes-devtools/python/python3_3.9.6.bb b/meta/recipes-devtools/python/python3_3.9.6.bb index aae7837180..d09943f891 100644 --- a/meta/recipes-devtools/python/python3_3.9.6.bb +++ b/meta/recipes-devtools/python/python3_3.9.6.bb | |||
@@ -195,6 +195,14 @@ do_install:append:class-nativesdk () { | |||
195 | } | 195 | } |
196 | 196 | ||
197 | SSTATE_SCAN_FILES += "Makefile _sysconfigdata.py" | 197 | SSTATE_SCAN_FILES += "Makefile _sysconfigdata.py" |
198 | SSTATE_HASHEQUIV_FILEMAP = " \ | ||
199 | populate_sysroot:*/lib*/python3*/_sysconfigdata*.py:${TMPDIR} \ | ||
200 | populate_sysroot:*/lib*/python3*/_sysconfigdata*.py:${COREBASE} \ | ||
201 | populate_sysroot:*/lib*/python3*/config-*/Makefile:${TMPDIR} \ | ||
202 | populate_sysroot:*/lib*/python3*/config-*/Makefile:${COREBASE} \ | ||
203 | populate_sysroot:*/lib*/python-sysconfigdata/_sysconfigdata.py:${TMPDIR} \ | ||
204 | populate_sysroot:*/lib*/python-sysconfigdata/_sysconfigdata.py:${COREBASE} \ | ||
205 | " | ||
198 | PACKAGE_PREPROCESS_FUNCS += "py_package_preprocess" | 206 | PACKAGE_PREPROCESS_FUNCS += "py_package_preprocess" |
199 | 207 | ||
200 | py_package_preprocess () { | 208 | py_package_preprocess () { |
diff --git a/meta/recipes-devtools/qemu/qemuwrapper-cross_1.0.bb b/meta/recipes-devtools/qemu/qemuwrapper-cross_1.0.bb index a0448a1803..97b44ad2e5 100644 --- a/meta/recipes-devtools/qemu/qemuwrapper-cross_1.0.bb +++ b/meta/recipes-devtools/qemu/qemuwrapper-cross_1.0.bb | |||
@@ -18,6 +18,7 @@ do_install () { | |||
18 | 18 | ||
19 | cat >> ${D}${bindir_crossscripts}/${MLPREFIX}qemuwrapper << EOF | 19 | cat >> ${D}${bindir_crossscripts}/${MLPREFIX}qemuwrapper << EOF |
20 | #!/bin/sh | 20 | #!/bin/sh |
21 | # Wrapper script to run binaries under qemu user-mode emulation | ||
21 | set -x | 22 | set -x |
22 | 23 | ||
23 | if [ ${@bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'True', 'False', d)} = False -a "${PN}" != "nativesdk-qemuwrapper-cross" ]; then | 24 | if [ ${@bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'True', 'False', d)} = False -a "${PN}" != "nativesdk-qemuwrapper-cross" ]; then |
diff --git a/meta/recipes-devtools/rpm/rpm_4.16.1.3.bb b/meta/recipes-devtools/rpm/rpm_4.16.1.3.bb index 60181f26c7..2ff9c2b112 100644 --- a/meta/recipes-devtools/rpm/rpm_4.16.1.3.bb +++ b/meta/recipes-devtools/rpm/rpm_4.16.1.3.bb | |||
@@ -195,3 +195,8 @@ rpm_package_preprocess () { | |||
195 | sed -i -e 's:--sysroot[^ ]*::g' \ | 195 | sed -i -e 's:--sysroot[^ ]*::g' \ |
196 | ${PKGD}/${libdir}/rpm/macros | 196 | ${PKGD}/${libdir}/rpm/macros |
197 | } | 197 | } |
198 | |||
199 | SSTATE_HASHEQUIV_FILEMAP = " \ | ||
200 | populate_sysroot:*/rpm/macros:${TMPDIR} \ | ||
201 | populate_sysroot:*/rpm/macros:${COREBASE} \ | ||
202 | " | ||