diff options
Diffstat (limited to 'meta/classes/staging.bbclass')
-rw-r--r-- | meta/classes/staging.bbclass | 150 |
1 files changed, 105 insertions, 45 deletions
diff --git a/meta/classes/staging.bbclass b/meta/classes/staging.bbclass index 84e13bab59..ab827766be 100644 --- a/meta/classes/staging.bbclass +++ b/meta/classes/staging.bbclass @@ -5,6 +5,7 @@ SYSROOT_DIRS = " \ ${base_libdir} \ ${nonarch_base_libdir} \ ${datadir} \ + /sysroot-only \ " # These directories are also staged in the sysroot when they contain files that @@ -18,20 +19,25 @@ SYSROOT_DIRS_NATIVE = " \ ${sysconfdir} \ ${localstatedir} \ " -SYSROOT_DIRS_append_class-native = " ${SYSROOT_DIRS_NATIVE}" -SYSROOT_DIRS_append_class-cross = " ${SYSROOT_DIRS_NATIVE}" -SYSROOT_DIRS_append_class-crosssdk = " ${SYSROOT_DIRS_NATIVE}" +SYSROOT_DIRS:append:class-native = " ${SYSROOT_DIRS_NATIVE}" +SYSROOT_DIRS:append:class-cross = " ${SYSROOT_DIRS_NATIVE}" +SYSROOT_DIRS:append:class-crosssdk = " ${SYSROOT_DIRS_NATIVE}" # These directories will not be staged in the sysroot -SYSROOT_DIRS_BLACKLIST = " \ +SYSROOT_DIRS_IGNORE = " \ ${mandir} \ ${docdir} \ ${infodir} \ - ${datadir}/locale \ + ${datadir}/X11/locale \ ${datadir}/applications \ + ${datadir}/bash-completion \ ${datadir}/fonts \ + ${datadir}/gtk-doc/html \ + ${datadir}/installed-tests \ + ${datadir}/locale \ ${datadir}/pixmaps \ - ${libdir}/${PN}/ptest \ + ${datadir}/terminfo \ + ${libdir}/${BPN}/ptest \ " sysroot_stage_dir() { @@ -43,9 +49,10 @@ sysroot_stage_dir() { fi mkdir -p "$dest" + rdest=$(realpath --relative-to="$src" "$dest") ( cd $src - find . -print0 | cpio --null -pdlu $dest + find . -print0 | cpio --null -pdlu $rdest ) } @@ -58,7 +65,7 @@ sysroot_stage_dirs() { done # Remove directories we do not care about - for dir in ${SYSROOT_DIRS_BLACKLIST}; do + for dir in ${SYSROOT_DIRS_IGNORE}; do rm -rf "$to$dir" done } @@ -74,9 +81,9 @@ python sysroot_strip () { dstdir = d.getVar('SYSROOT_DESTDIR') pn = d.getVar('PN') - libdir = os.path.abspath(dstdir + os.sep + d.getVar("libdir")) - base_libdir = os.path.abspath(dstdir + os.sep + d.getVar("base_libdir")) - qa_already_stripped = 'already-stripped' in (d.getVar('INSANE_SKIP_' + pn) or "").split() + libdir = d.getVar("libdir") + base_libdir = d.getVar("base_libdir") + qa_already_stripped = 'already-stripped' in (d.getVar('INSANE_SKIP:' + pn) or "").split() strip_cmd = d.getVar("STRIP") oe.package.strip_execs(pn, dstdir, strip_cmd, libdir, base_libdir, d, @@ -84,7 +91,6 @@ python sysroot_strip () { } do_populate_sysroot[dirs] = "${SYSROOT_DESTDIR}" -do_populate_sysroot[umask] = "022" addtask populate_sysroot after do_install @@ -92,12 +98,13 @@ SYSROOT_PREPROCESS_FUNCS ?= "" SYSROOT_DESTDIR = "${WORKDIR}/sysroot-destdir" python do_populate_sysroot () { + # SYSROOT 'version' 2 bb.build.exec_func("sysroot_stage_all", d) bb.build.exec_func("sysroot_strip", d) for f in (d.getVar('SYSROOT_PREPROCESS_FUNCS') or '').split(): bb.build.exec_func(f, d) pn = d.getVar("PN") - multiprov = d.getVar("MULTI_PROVIDER_WHITELIST").split() + multiprov = d.getVar("BB_MULTI_PROVIDER_ALLOWED").split() provdir = d.expand("${SYSROOT_DESTDIR}${base_prefix}/sysroot-providers/") bb.utils.mkdirhier(provdir) for p in d.getVar("PROVIDES").split(): @@ -109,11 +116,11 @@ python do_populate_sysroot () { } do_populate_sysroot[vardeps] += "${SYSROOT_PREPROCESS_FUNCS}" -do_populate_sysroot[vardepsexclude] += "MULTI_PROVIDER_WHITELIST" +do_populate_sysroot[vardepsexclude] += "BB_MULTI_PROVIDER_ALLOWED" POPULATESYSROOTDEPS = "" -POPULATESYSROOTDEPS_class-target = "virtual/${MLPREFIX}${TARGET_PREFIX}binutils:do_populate_sysroot" -POPULATESYSROOTDEPS_class-nativesdk = "virtual/${TARGET_PREFIX}binutils-crosssdk:do_populate_sysroot" +POPULATESYSROOTDEPS:class-target = "virtual/${MLPREFIX}${HOST_PREFIX}binutils:do_populate_sysroot" +POPULATESYSROOTDEPS:class-nativesdk = "virtual/${HOST_PREFIX}binutils-crosssdk:do_populate_sysroot" do_populate_sysroot[depends] += "${POPULATESYSROOTDEPS}" SSTATETASKS += "do_populate_sysroot" @@ -167,7 +174,7 @@ def staging_processfixme(fixme, target, recipesysroot, recipesysrootnative, d): if not fixme: return cmd = "sed -e 's:^[^/]*/:%s/:g' %s | xargs sed -i -e 's:FIXMESTAGINGDIRTARGET:%s:g; s:FIXMESTAGINGDIRHOST:%s:g'" % (target, " ".join(fixme), recipesysroot, recipesysrootnative) - for fixmevar in ['COMPONENTS_DIR', 'HOSTTOOLS_DIR', 'PKGDATA_DIR', 'PSEUDO_LOCALSTATEDIR', 'LOGFIFO']: + for fixmevar in ['PSEUDO_SYSROOT', 'HOSTTOOLS_DIR', 'PKGDATA_DIR', 'PSEUDO_LOCALSTATEDIR', 'LOGFIFO']: fixme_path = d.getVar(fixmevar) cmd += " -e 's:FIXME_%s:%s:g'" % (fixmevar, fixme_path) bb.debug(2, cmd) @@ -196,7 +203,11 @@ def staging_populate_sysroot_dir(targetsysroot, nativesysroot, native, d): for pkgarch in pkgarchs: for manifest in glob.glob(d.expand("${SSTATE_MANIFESTS}/manifest-%s-*.populate_sysroot" % pkgarch)): if manifest.endswith("-initial.populate_sysroot"): - # skip glibc-initial and libgcc-initial due to file overlap + # skip libgcc-initial due to file overlap + continue + if not native and (manifest.endswith("-native.populate_sysroot") or "nativesdk-" in manifest): + continue + if native and not (manifest.endswith("-native.populate_sysroot") or manifest.endswith("-cross.populate_sysroot") or "-cross-" in manifest): continue tmanifest = targetdir + "/" + os.path.basename(manifest) if os.path.exists(tmanifest): @@ -256,12 +267,10 @@ python extend_recipe_sysroot() { workdir = d.getVar("WORKDIR") #bb.warn(str(taskdepdata)) pn = d.getVar("PN") - mc = d.getVar("BB_CURRENT_MC") stagingdir = d.getVar("STAGING_DIR") sharedmanifests = d.getVar("COMPONENTS_DIR") + "/manifests" recipesysroot = d.getVar("RECIPE_SYSROOT") recipesysrootnative = d.getVar("RECIPE_SYSROOT_NATIVE") - current_variant = d.getVar("BBEXTENDVARIANT") # Detect bitbake -b usage nodeps = d.getVar("BB_LIMITEDDEPS") or False @@ -274,11 +283,13 @@ python extend_recipe_sysroot() { start = None configuredeps = [] + owntaskdeps = [] for dep in taskdepdata: data = taskdepdata[dep] if data[1] == mytaskname and data[0] == pn: start = dep - break + elif data[0] == pn: + owntaskdeps.append(data[1]) if start is None: bb.fatal("Couldn't find ourself in BB_TASKDEPDATA?") @@ -296,6 +307,7 @@ python extend_recipe_sysroot() { sstatetasks = d.getVar("SSTATETASKS").split() # Add recipe specific tasks referenced by setscene_depvalid() sstatetasks.append("do_stash_locale") + sstatetasks.append("do_deploy") def print_dep_tree(deptree): data = "" @@ -399,7 +411,7 @@ python extend_recipe_sysroot() { if os.path.islink(f) and not os.path.exists(f): bb.note("%s no longer exists, removing from sysroot" % f) lnk = os.readlink(f.replace(".complete", "")) - sstate_clean_manifest(depdir + "/" + lnk, d, workdir) + sstate_clean_manifest(depdir + "/" + lnk, d, canrace=True, prefix=workdir) os.unlink(f) os.unlink(f.replace(".complete", "")) @@ -424,7 +436,7 @@ python extend_recipe_sysroot() { # Was likely already uninstalled continue potential.append(l) - # We need to ensure not other task needs this dependency. We hold the sysroot + # We need to ensure no other task needs this dependency. We hold the sysroot # lock so we ca search the indexes to check if potential: for i in glob.glob(depdir + "/index.*"): @@ -432,6 +444,11 @@ python extend_recipe_sysroot() { continue with open(i, "r") as f: for l in f: + if l.startswith("TaskDeps:"): + prevtasks = l.split()[1:] + if mytaskname in prevtasks: + # We're a dependency of this task so we can clear items out the sysroot + break l = l.strip() if l in potential: potential.remove(l) @@ -439,19 +456,15 @@ python extend_recipe_sysroot() { fl = depdir + "/" + l bb.note("Task %s no longer depends on %s, removing from sysroot" % (mytaskname, l)) lnk = os.readlink(fl) - sstate_clean_manifest(depdir + "/" + lnk, d, workdir) + sstate_clean_manifest(depdir + "/" + lnk, d, canrace=True, prefix=workdir) os.unlink(fl) os.unlink(fl + ".complete") msg_exists = [] msg_adding = [] + # Handle all removals first since files may move between recipes for dep in configuredeps: - if mc != 'default': - # We should not care about other multiconfigs - depmc = dep.split(':')[1] - if depmc != mc: - continue c = setscenedeps[dep][0] if c not in installed: continue @@ -461,17 +474,31 @@ python extend_recipe_sysroot() { if os.path.exists(depdir + "/" + c): lnk = os.readlink(depdir + "/" + c) if lnk == c + "." + taskhash and os.path.exists(depdir + "/" + c + ".complete"): - msg_exists.append(c) continue else: bb.note("%s exists in sysroot, but is stale (%s vs. %s), removing." % (c, lnk, c + "." + taskhash)) - sstate_clean_manifest(depdir + "/" + lnk, d, workdir) + sstate_clean_manifest(depdir + "/" + lnk, d, canrace=True, prefix=workdir) os.unlink(depdir + "/" + c) if os.path.lexists(depdir + "/" + c + ".complete"): os.unlink(depdir + "/" + c + ".complete") elif os.path.lexists(depdir + "/" + c): os.unlink(depdir + "/" + c) + binfiles = {} + # Now handle installs + for dep in configuredeps: + c = setscenedeps[dep][0] + if c not in installed: + continue + taskhash = setscenedeps[dep][5] + taskmanifest = depdir + "/" + c + "." + taskhash + + if os.path.exists(depdir + "/" + c): + lnk = os.readlink(depdir + "/" + c) + if lnk == c + "." + taskhash and os.path.exists(depdir + "/" + c + ".complete"): + msg_exists.append(c) + continue + msg_adding.append(c) os.symlink(c + "." + taskhash, depdir + "/" + c) @@ -550,7 +577,16 @@ python extend_recipe_sysroot() { if l.endswith("/"): staging_copydir(l, targetdir, dest, seendirs) continue - staging_copyfile(l, targetdir, dest, postinsts, seendirs) + if "/bin/" in l or "/sbin/" in l: + # defer /*bin/* files until last in case they need libs + binfiles[l] = (targetdir, dest) + else: + staging_copyfile(l, targetdir, dest, postinsts, seendirs) + + # Handle deferred binfiles + for l in binfiles: + (targetdir, dest) = binfiles[l] + staging_copyfile(l, targetdir, dest, postinsts, seendirs) bb.note("Installed into sysroot: %s" % str(msg_adding)) bb.note("Skipping as already exists in sysroot: %s" % str(msg_exists)) @@ -566,6 +602,7 @@ python extend_recipe_sysroot() { os.symlink(manifests[dep], depdir + "/" + c + ".complete") with open(taskindex, "w") as f: + f.write("TaskDeps: " + " ".join(owntaskdeps) + "\n") for l in sorted(installed): f.write(l + "\n") @@ -573,28 +610,51 @@ python extend_recipe_sysroot() { } extend_recipe_sysroot[vardepsexclude] += "MACHINE_ARCH PACKAGE_EXTRA_ARCHS SDK_ARCH BUILD_ARCH SDK_OS BB_TASKDEPDATA" +do_prepare_recipe_sysroot[deptask] = "do_populate_sysroot" python do_prepare_recipe_sysroot () { bb.build.exec_func("extend_recipe_sysroot", d) } addtask do_prepare_recipe_sysroot before do_configure after do_fetch -# Clean out the recipe specific sysroots before do_fetch -# (use a prefunc so we can order before extend_recipe_sysroot if it gets added) -python clean_recipe_sysroot() { - # We remove these stamps since we're removing any content they'd have added with - # cleandirs. This removes the sigdata too, likely not a big deal, - oe.path.remove(d.getVar("STAMP") + "*addto_recipe_sysroot*") - return -} -clean_recipe_sysroot[cleandirs] += "${RECIPE_SYSROOT} ${RECIPE_SYSROOT_NATIVE}" -do_fetch[prefuncs] += "clean_recipe_sysroot" - python staging_taskhandler() { bbtasks = e.tasklist for task in bbtasks: deps = d.getVarFlag(task, "depends") - if deps and "populate_sysroot" in deps: - d.appendVarFlag(task, "prefuncs", " extend_recipe_sysroot") + if task == "do_configure" or (deps and "populate_sysroot" in deps): + d.prependVarFlag(task, "prefuncs", "extend_recipe_sysroot ") } staging_taskhandler[eventmask] = "bb.event.RecipeTaskPreProcess" addhandler staging_taskhandler + + +# +# Target build output, stored in do_populate_sysroot or do_package can depend +# not only upon direct dependencies but also indirect ones. A good example is +# linux-libc-headers. The toolchain depends on this but most target recipes do +# not. There are some headers which are not used by the toolchain build and do +# not change the toolchain task output, hence the task hashes can change without +# changing the sysroot output of that recipe yet they can influence others. +# +# A specific example is rtc.h which can change rtcwake.c in util-linux but is not +# used in the glibc or gcc build. To account for this, we need to account for the +# populate_sysroot hashes in the task output hashes. +# +python target_add_sysroot_deps () { + current_task = "do_" + d.getVar("BB_CURRENTTASK") + if current_task not in ["do_populate_sysroot", "do_package"]: + return + + pn = d.getVar("PN") + if pn.endswith("-native"): + return + + taskdepdata = d.getVar("BB_TASKDEPDATA", False) + deps = {} + for dep in taskdepdata.values(): + if dep[1] == "do_populate_sysroot" and not dep[0].endswith(("-native", "-initial")) and "-cross-" not in dep[0]: + deps[dep[0]] = dep[6] + + d.setVar("HASHEQUIV_EXTRA_SIGDATA", "\n".join("%s: %s" % (k, deps[k]) for k in sorted(deps.keys()))) +} +SSTATECREATEFUNCS += "target_add_sysroot_deps" + |