summaryrefslogtreecommitdiff
path: root/import-layers/yocto-poky/meta/classes/staging.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'import-layers/yocto-poky/meta/classes/staging.bbclass')
-rw-r--r--import-layers/yocto-poky/meta/classes/staging.bbclass136
1 files changed, 39 insertions, 97 deletions
diff --git a/import-layers/yocto-poky/meta/classes/staging.bbclass b/import-layers/yocto-poky/meta/classes/staging.bbclass
index 984051d6aa..c479bd93ea 100644
--- a/import-layers/yocto-poky/meta/classes/staging.bbclass
+++ b/import-layers/yocto-poky/meta/classes/staging.bbclass
@@ -68,101 +68,19 @@ sysroot_stage_all() {
}
python sysroot_strip () {
- import stat, errno
+ inhibit_sysroot = d.getVar('INHIBIT_SYSROOT_STRIP')
+ if inhibit_sysroot and oe.types.boolean(inhibit_sysroot):
+ return 0
- dvar = d.getVar('SYSROOT_DESTDIR')
+ 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()
+ strip_cmd = d.getVar("STRIP")
- os.chdir(dvar)
-
- # Return type (bits):
- # 0 - not elf
- # 1 - ELF
- # 2 - stripped
- # 4 - executable
- # 8 - shared library
- # 16 - kernel module
- def isELF(path):
- type = 0
- ret, result = oe.utils.getstatusoutput("file \"%s\"" % path.replace("\"", "\\\""))
-
- if ret:
- bb.error("split_and_strip_files: 'file %s' failed" % path)
- return type
-
- # Not stripped
- if "ELF" in result:
- type |= 1
- if "not stripped" not in result:
- type |= 2
- if "executable" in result:
- type |= 4
- if "shared" in result:
- type |= 8
- return type
-
-
- elffiles = {}
- inodes = {}
- libdir = os.path.abspath(dvar + os.sep + d.getVar("libdir"))
- baselibdir = os.path.abspath(dvar + os.sep + d.getVar("base_libdir"))
- if (d.getVar('INHIBIT_SYSROOT_STRIP') != '1'):
- #
- # First lets figure out all of the files we may have to process
- #
- for root, dirs, files in os.walk(dvar):
- for f in files:
- file = os.path.join(root, f)
-
- try:
- ltarget = oe.path.realpath(file, dvar, False)
- s = os.lstat(ltarget)
- except OSError as e:
- (err, strerror) = e.args
- if err != errno.ENOENT:
- raise
- # Skip broken symlinks
- continue
- if not s:
- continue
- # Check its an excutable
- if (s[stat.ST_MODE] & stat.S_IXUSR) or (s[stat.ST_MODE] & stat.S_IXGRP) or (s[stat.ST_MODE] & stat.S_IXOTH) \
- or ((file.startswith(libdir) or file.startswith(baselibdir)) and ".so" in f):
- # If it's a symlink, and points to an ELF file, we capture the readlink target
- if os.path.islink(file):
- continue
-
- # It's a file (or hardlink), not a link
- # ...but is it ELF, and is it already stripped?
- elf_file = isELF(file)
- if elf_file & 1:
- if elf_file & 2:
- if 'already-stripped' in (d.getVar('INSANE_SKIP_' + pn) or "").split():
- bb.note("Skipping file %s from %s for already-stripped QA test" % (file[len(dvar):], pn))
- else:
- bb.warn("File '%s' from %s was already stripped, this will prevent future debugging!" % (file[len(dvar):], pn))
- continue
-
- if s.st_ino in inodes:
- os.unlink(file)
- os.link(inodes[s.st_ino], file)
- else:
- inodes[s.st_ino] = file
- # break hardlink
- bb.utils.copyfile(file, file)
- elffiles[file] = elf_file
-
- #
- # Now strip them (in parallel)
- #
- strip = d.getVar("STRIP")
- sfiles = []
- for file in elffiles:
- elf_file = int(elffiles[file])
- #bb.note("Strip %s" % file)
- sfiles.append((file, elf_file, strip))
-
- oe.utils.multiprocess_exec(sfiles, oe.package.runstrip)
+ oe.package.strip_execs(pn, dstdir, strip_cmd, libdir, base_libdir,
+ qa_already_stripped=qa_already_stripped)
}
do_populate_sysroot[dirs] = "${SYSROOT_DESTDIR}"
@@ -259,6 +177,7 @@ def staging_processfixme(fixme, target, recipesysroot, recipesysrootnative, d):
def staging_populate_sysroot_dir(targetsysroot, nativesysroot, native, d):
import glob
import subprocess
+ import errno
fixme = []
postinsts = []
@@ -454,7 +373,8 @@ python extend_recipe_sysroot() {
msgbuf.append("Following dependency on %s" % setscenedeps[datadep][0])
next = new
- bb.note("\n".join(msgbuf))
+ # This logging is too verbose for day to day use sadly
+ #bb.debug(2, "\n".join(msgbuf))
depdir = recipesysrootnative + "/installeddeps"
bb.utils.mkdirhier(depdir)
@@ -469,6 +389,8 @@ python extend_recipe_sysroot() {
postinsts = []
multilibs = {}
manifests = {}
+ # All files that we're going to be installing, to find conflicts.
+ fileset = {}
for f in os.listdir(depdir):
if not f.endswith(".complete"):
@@ -521,6 +443,8 @@ python extend_recipe_sysroot() {
os.unlink(fl)
os.unlink(fl + ".complete")
+ msg_exists = []
+ msg_adding = []
for dep in configuredeps:
c = setscenedeps[dep][0]
if c not in installed:
@@ -531,7 +455,7 @@ 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"):
- bb.note("%s exists in sysroot, skipping" % c)
+ msg_exists.append(c)
continue
else:
bb.note("%s exists in sysroot, but is stale (%s vs. %s), removing." % (c, lnk, c + "." + taskhash))
@@ -542,6 +466,8 @@ python extend_recipe_sysroot() {
elif os.path.lexists(depdir + "/" + c):
os.unlink(depdir + "/" + c)
+ msg_adding.append(c)
+
os.symlink(c + "." + taskhash, depdir + "/" + c)
d2 = d
@@ -595,8 +521,19 @@ python extend_recipe_sysroot() {
if l.endswith("/fixmepath.cmd"):
continue
dest = l.replace(stagingdir, "")
- dest = targetdir + "/" + "/".join(dest.split("/")[3:])
- newmanifest[l] = dest
+ dest = "/" + "/".join(dest.split("/")[3:])
+ newmanifest[l] = targetdir + dest
+
+ # Check if files have already been installed by another
+ # recipe and abort if they have, explaining what recipes are
+ # conflicting.
+ hashname = targetdir + dest
+ if not hashname.endswith("/"):
+ if hashname in fileset:
+ bb.fatal("The file %s is installed by both %s and %s, aborting" % (dest, c, fileset[hashname]))
+ else:
+ fileset[hashname] = c
+
# Having multiple identical manifests in each sysroot eats diskspace so
# create a shared pool of them and hardlink if we can.
# We create the manifest in advance so that if something fails during installation,
@@ -627,6 +564,9 @@ python extend_recipe_sysroot() {
continue
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))
+
for f in fixme:
if f == '':
staging_processfixme(fixme[f], recipesysroot, recipesysroot, recipesysrootnative, d)
@@ -658,6 +598,9 @@ 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}"
@@ -672,4 +615,3 @@ python staging_taskhandler() {
}
staging_taskhandler[eventmask] = "bb.event.RecipeTaskPreProcess"
addhandler staging_taskhandler
-