summaryrefslogtreecommitdiffstats
path: root/meta/classes/sstate.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/sstate.bbclass')
-rw-r--r--meta/classes/sstate.bbclass118
1 files changed, 81 insertions, 37 deletions
diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
index 8643f3d247..78ceaf835a 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -97,7 +97,7 @@ python () {
# These classes encode staging paths into their scripts data so can only be
# reused if we manipulate the paths
if bb.data.inherits_class('native', d) or bb.data.inherits_class('cross', d) or bb.data.inherits_class('sdk', d) or bb.data.inherits_class('crosssdk', d):
- scan_cmd = "grep -Irl ${STAGING_DIR} ${SSTATE_BUILDDIR}"
+ scan_cmd = "grep -Irl -e ${RECIPE_SYSROOT} -e ${RECIPE_SYSROOT_NATIVE} ${SSTATE_BUILDDIR}"
d.setVar('SSTATE_SCAN_CMD', scan_cmd)
unique_tasks = sorted(set((d.getVar('SSTATETASKS', True) or "").split()))
@@ -131,6 +131,7 @@ def sstate_state_fromvars(d, task = None):
lockfiles = (d.getVarFlag("do_" + task, 'sstate-lockfile', True) or "").split()
lockfilesshared = (d.getVarFlag("do_" + task, 'sstate-lockfile-shared', True) or "").split()
interceptfuncs = (d.getVarFlag("do_" + task, 'sstate-interceptfuncs', True) or "").split()
+ fixmedir = d.getVarFlag("do_" + task, 'sstate-fixmedir', True) or ""
if not task or len(inputs) != len(outputs):
bb.fatal("sstate variables not setup correctly?!")
@@ -146,6 +147,7 @@ def sstate_state_fromvars(d, task = None):
ss['lockfiles-shared'] = lockfilesshared
ss['plaindirs'] = plaindirs
ss['interceptfuncs'] = interceptfuncs
+ ss['fixmedir'] = fixmedir
return ss
def sstate_add(ss, source, dest, d):
@@ -195,6 +197,9 @@ def sstate_install(ss, d):
srcdir = os.path.join(walkroot, dir)
dstdir = srcdir.replace(state[1], state[2])
#bb.debug(2, "Staging %s to %s" % (srcdir, dstdir))
+ if os.path.islink(srcdir):
+ sharedfiles.append(dstdir)
+ continue
if not dstdir.endswith("/"):
dstdir = dstdir + "/"
shareddirs.append(dstdir)
@@ -203,7 +208,7 @@ def sstate_install(ss, d):
whitelist = (d.getVar("SSTATE_DUPWHITELIST", True) or "").split()
match = []
for f in sharedfiles:
- if os.path.exists(f):
+ if os.path.exists(f) and not os.path.islink(f):
f = os.path.normpath(f)
realmatch = True
for w in whitelist:
@@ -242,6 +247,10 @@ def sstate_install(ss, d):
(d.getVar('PN', True), "\n ".join(match)))
bb.fatal("If the above message is too much, the simpler version is you're advised to wipe out tmp and rebuild (reusing sstate is fine). That will likely fix things in most (but not all) cases.")
+ if ss['fixmedir'] and os.path.exists(ss['fixmedir'] + "/fixmepath.cmd"):
+ sharedfiles.append(ss['fixmedir'] + "/fixmepath.cmd")
+ sharedfiles.append(ss['fixmedir'] + "/fixmepath")
+
# Write out the manifest
f = open(manifest, "w")
for file in sharedfiles:
@@ -286,17 +295,8 @@ sstate_install[vardepsexclude] += "SSTATE_DUPWHITELIST STATE_MANMACH SSTATE_MANF
sstate_install[vardeps] += "${SSTATEPOSTINSTFUNCS}"
def sstate_installpkg(ss, d):
- import oe.path
- import subprocess
from oe.gpg_sign import get_signer
- def prepdir(dir):
- # remove dir if it exists, ensure any parent directories do exist
- if os.path.exists(dir):
- oe.path.remove(dir)
- bb.utils.mkdirhier(dir)
- oe.path.remove(dir)
-
sstateinst = d.expand("${WORKDIR}/sstate-install-%s/" % ss['task'])
sstatefetch = d.getVar('SSTATE_PKGNAME', True) + '_' + ss['task'] + ".tgz"
sstatepkg = d.getVar('SSTATE_PKG', True) + '_' + ss['task'] + ".tgz"
@@ -318,11 +318,36 @@ def sstate_installpkg(ss, d):
if not signer.verify(sstatepkg + '.sig'):
bb.warn("Cannot verify signature on sstate package %s" % sstatepkg)
- for f in (d.getVar('SSTATEPREINSTFUNCS', True) or '').split() + ['sstate_unpack_package'] + (d.getVar('SSTATEPOSTUNPACKFUNCS', True) or '').split():
+ sstateinst = d.getVar("SSTATE_INSTDIR", True)
+ d.setVar('SSTATE_FIXMEDIR', ss['fixmedir'])
+
+ for f in (d.getVar('SSTATEPREINSTFUNCS', True) or '').split() + ['sstate_unpack_package']:
# All hooks should run in the SSTATE_INSTDIR
bb.build.exec_func(f, d, (sstateinst,))
+ return sstate_installpkgdir(ss, d)
+
+def sstate_installpkgdir(ss, d):
+ import oe.path
+ import subprocess
+
+ sstateinst = d.getVar("SSTATE_INSTDIR", True)
+ d.setVar('SSTATE_FIXMEDIR', ss['fixmedir'])
+
+ for f in (d.getVar('SSTATEPOSTUNPACKFUNCS', True) or '').split():
+ # All hooks should run in the SSTATE_INSTDIR
+ bb.build.exec_func(f, d, (sstateinst,))
+
+ def prepdir(dir):
+ # remove dir if it exists, ensure any parent directories do exist
+ if os.path.exists(dir):
+ oe.path.remove(dir)
+ bb.utils.mkdirhier(dir)
+ oe.path.remove(dir)
+
for state in ss['dirs']:
+ if d.getVar('SSTATE_SKIP_CREATION', True) == '1':
+ continue
prepdir(state[1])
os.rename(sstateinst + state[0], state[1])
sstate_install(ss, d)
@@ -345,18 +370,18 @@ python sstate_hardcode_path_unpack () {
import subprocess
sstateinst = d.getVar('SSTATE_INSTDIR', True)
- fixmefn = sstateinst + "fixmepath"
+ sstatefixmedir = d.getVar('SSTATE_FIXMEDIR', True)
+ fixmefn = sstateinst + "fixmepath"
if os.path.isfile(fixmefn):
- staging = d.getVar('STAGING_DIR', True)
- staging_target = d.getVar('STAGING_DIR_TARGET', True)
- staging_host = d.getVar('STAGING_DIR_HOST', True)
+ staging_target = d.getVar('RECIPE_SYSROOT', True)
+ staging_host = d.getVar('RECIPE_SYSROOT_NATIVE', True)
if bb.data.inherits_class('native', d) or bb.data.inherits_class('nativesdk', d) or bb.data.inherits_class('crosssdk', d) or bb.data.inherits_class('cross-canadian', d):
- sstate_sed_cmd = "sed -i -e 's:FIXMESTAGINGDIR:%s:g'" % (staging)
+ sstate_sed_cmd = "sed -i -e 's:FIXMESTAGINGDIRHOST:%s:g'" % (staging_host)
elif bb.data.inherits_class('cross', d):
- sstate_sed_cmd = "sed -i -e 's:FIXMESTAGINGDIRTARGET:%s:g; s:FIXMESTAGINGDIR:%s:g'" % (staging_target, staging)
+ sstate_sed_cmd = "sed -i -e 's:FIXMESTAGINGDIRTARGET:%s:g; s:FIXMESTAGINGDIRHOST:%s:g'" % (staging_target, staging_host)
else:
- sstate_sed_cmd = "sed -i -e 's:FIXMESTAGINGDIRHOST:%s:g'" % (staging_host)
+ sstate_sed_cmd = "sed -i -e 's:FIXMESTAGINGDIRTARGET:%s:g'" % (staging_target)
extra_staging_fixmes = d.getVar('EXTRA_STAGING_FIXMES', True) or ''
for fixmevar in extra_staging_fixmes.split():
@@ -366,6 +391,18 @@ python sstate_hardcode_path_unpack () {
# Add sstateinst to each filename in fixmepath, use xargs to efficiently call sed
sstate_hardcode_cmd = "sed -e 's:^:%s:g' %s | xargs %s" % (sstateinst, fixmefn, sstate_sed_cmd)
+ # Defer do_populate_sysroot relocation command
+ if sstatefixmedir:
+ bb.utils.mkdirhier(sstatefixmedir)
+ with open(sstatefixmedir + "/fixmepath.cmd", "w") as f:
+ sstate_hardcode_cmd = sstate_hardcode_cmd.replace(fixmefn, sstatefixmedir + "/fixmepath")
+ sstate_hardcode_cmd = sstate_hardcode_cmd.replace(sstateinst, "FIXMEFINALSSTATEINST")
+ sstate_hardcode_cmd = sstate_hardcode_cmd.replace(staging_host, "FIXMEFINALSSTATEHOST")
+ sstate_hardcode_cmd = sstate_hardcode_cmd.replace(staging_target, "FIXMEFINALSSTATETARGET")
+ f.write(sstate_hardcode_cmd)
+ bb.utils.copyfile(fixmefn, sstatefixmedir + "/fixmepath")
+ return
+
bb.note("Replacing fixme paths in sstate package: %s" % (sstate_hardcode_cmd))
subprocess.call(sstate_hardcode_cmd, shell=True)
@@ -497,20 +534,19 @@ python sstate_hardcode_path () {
# Note: the logic in this function needs to match the reverse logic
# in sstate_installpkg(ss, d)
- staging = d.getVar('STAGING_DIR', True)
- staging_target = d.getVar('STAGING_DIR_TARGET', True)
- staging_host = d.getVar('STAGING_DIR_HOST', True)
+ staging_target = d.getVar('RECIPE_SYSROOT', True)
+ staging_host = d.getVar('RECIPE_SYSROOT_NATIVE', True)
sstate_builddir = d.getVar('SSTATE_BUILDDIR', True)
if bb.data.inherits_class('native', d) or bb.data.inherits_class('nativesdk', d) or bb.data.inherits_class('crosssdk', d) or bb.data.inherits_class('cross-canadian', d):
- sstate_grep_cmd = "grep -l -e '%s'" % (staging)
- sstate_sed_cmd = "sed -i -e 's:%s:FIXMESTAGINGDIR:g'" % (staging)
- elif bb.data.inherits_class('cross', d):
- sstate_grep_cmd = "grep -l -e '%s' -e '%s'" % (staging_target, staging)
- sstate_sed_cmd = "sed -i -e 's:%s:FIXMESTAGINGDIRTARGET:g; s:%s:FIXMESTAGINGDIR:g'" % (staging_target, staging)
- else:
sstate_grep_cmd = "grep -l -e '%s'" % (staging_host)
sstate_sed_cmd = "sed -i -e 's:%s:FIXMESTAGINGDIRHOST:g'" % (staging_host)
+ elif bb.data.inherits_class('cross', d):
+ sstate_grep_cmd = "grep -l -e '%s' -e '%s'" % (staging_target, staging_host)
+ sstate_sed_cmd = "sed -i -e 's:%s:FIXMESTAGINGDIRTARGET:g; s:%s:FIXMESTAGINGDIRHOST:g'" % (staging_target, staging_host)
+ else:
+ sstate_grep_cmd = "grep -l -e '%s'" % (staging_target)
+ sstate_sed_cmd = "sed -i -e 's:%s:FIXMESTAGINGDIRTARGET:g'" % (staging_target)
extra_staging_fixmes = d.getVar('EXTRA_STAGING_FIXMES', True) or ''
for fixmevar in extra_staging_fixmes.split():
@@ -534,14 +570,14 @@ python sstate_hardcode_path () {
sstate_hardcode_cmd = "%s | xargs %s | %s | xargs %s %s" % (sstate_scan_cmd, sstate_grep_cmd, sstate_filelist_cmd, xargs_no_empty_run_cmd, sstate_sed_cmd)
bb.note("Removing hardcoded paths from sstate package: '%s'" % (sstate_hardcode_cmd))
- subprocess.call(sstate_hardcode_cmd, shell=True)
+ subprocess.check_call(sstate_hardcode_cmd, shell=True, cwd=sstate_builddir)
# If the fixmefn is empty, remove it..
if os.stat(fixmefn).st_size == 0:
os.remove(fixmefn)
else:
bb.note("Replacing absolute paths in fixmepath file: '%s'" % (sstate_filelist_relative_cmd))
- subprocess.call(sstate_filelist_relative_cmd, shell=True)
+ subprocess.check_call(sstate_filelist_relative_cmd, shell=True)
}
def sstate_package(ss, d):
@@ -557,6 +593,8 @@ def sstate_package(ss, d):
if not link.startswith(tmpdir):
return
+ #base = os.path.relpath(link, os.path.dirname(path))
+
depth = outputpath.rpartition(tmpdir)[2].count('/')
base = link.partition(tmpdir)[2].strip()
while depth > 1:
@@ -591,14 +629,14 @@ def sstate_package(ss, d):
dstpath = srcpath.replace(state[1], state[2])
make_relative_symlink(srcpath, dstpath, d)
bb.debug(2, "Preparing tree %s for packaging at %s" % (state[1], sstatebuild + state[0]))
- oe.path.copyhardlinktree(state[1], sstatebuild + state[0])
+ os.rename(state[1], sstatebuild + state[0])
workdir = d.getVar('WORKDIR', True)
for plain in ss['plaindirs']:
pdir = plain.replace(workdir, sstatebuild)
bb.utils.mkdirhier(plain)
bb.utils.mkdirhier(pdir)
- oe.path.copyhardlinktree(plain, pdir)
+ os.rename(plain, pdir)
d.setVar('SSTATE_BUILDDIR', sstatebuild)
d.setVar('SSTATE_PKG', sstatepkg)
@@ -611,6 +649,8 @@ def sstate_package(ss, d):
bb.siggen.dump_this_task(sstatepkg + ".siginfo", d)
+ d.setVar('SSTATE_INSTDIR', sstatebuild)
+
return
def pstaging_fetch(sstatefetch, sstatepkg, d):
@@ -669,14 +709,21 @@ sstate_task_prefunc[dirs] = "${WORKDIR}"
python sstate_task_postfunc () {
shared_state = sstate_state_fromvars(d)
- sstate_install(shared_state, d)
for intercept in shared_state['interceptfuncs']:
bb.build.exec_func(intercept, d, (d.getVar("WORKDIR", True),))
+
omask = os.umask(0o002)
if omask != 0o002:
bb.note("Using umask 0o002 (not %0o) for sstate packaging" % omask)
sstate_package(shared_state, d)
os.umask(omask)
+
+ sstateinst = d.getVar("SSTATE_INSTDIR", True)
+ d.setVar('SSTATE_FIXMEDIR', shared_state['fixmedir'])
+
+ sstate_installpkgdir(shared_state, d)
+
+ bb.utils.remove(d.getVar("SSTATE_BUILDDIR", True), recurse=True)
}
sstate_task_postfunc[dirs] = "${WORKDIR}"
@@ -701,9 +748,6 @@ sstate_create_package () {
fi
chmod 0664 $TFILE
mv -f $TFILE ${SSTATE_PKG}
-
- cd ${WORKDIR}
- rm -rf ${SSTATE_BUILDDIR}
}
python sstate_sign_package () {
@@ -895,7 +939,7 @@ def setscene_depvalid(task, taskdependees, notneeded, d):
bb.debug(2, "Considering setscene task: %s" % (str(taskdependees[task])))
def isNativeCross(x):
- return x.endswith("-native") or "-cross-" in x or "-crosssdk" in x
+ return x.endswith("-native") or "-cross-" in x or "-crosssdk" in x or x.endswith("-cross")
def isPostInstDep(x):
if x in ["qemu-native", "gdk-pixbuf-native", "qemuwrapper-cross", "depmodwrapper-cross", "systemd-systemctl-native", "gtk-icon-utils-native", "ca-certificates-native"]: