Patchwork [5/7] sstate.bbclass: improve performance of sstate package creation

login
register
mail settings
Submitter Martin Jansa
Date Feb. 24, 2012, 5:06 p.m.
Message ID <141f227e9201766a9657a41a92a5d5485adcd513.1330102968.git.Martin.Jansa@gmail.com>
Download mbox | patch
Permalink /patch/21947/
State Accepted
Commit 94c52d68fc2ce258bcc5b0978ac73413480a1a93
Headers show

Comments

Martin Jansa - Feb. 24, 2012, 5:06 p.m.
* also fixes replacing paths for perl where cmd line was probably
  too long for os.system(cmd) (it had 560410 characters because a lot of
  files from sstate_scan_cmd).
* also print those 2 commands so we can find them in log.do_package

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 meta/classes/sstate.bbclass |   39 ++++++++++++++++-----------------------
 1 files changed, 16 insertions(+), 23 deletions(-)

Patch

diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
index ee9bf05..d20b62a 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -304,38 +304,31 @@  python sstate_cleanall() {
 def sstate_hardcode_path(d):
 	# Need to remove hardcoded paths and fix these when we install the
 	# staging packages.
-	sstate_scan_cmd = d.getVar('SSTATE_SCAN_CMD', True)
-	p = os.popen("%s" % sstate_scan_cmd)
-	file_list = p.read()
-
-	if file_list == "":
-		p.close()
-		return
 
 	staging = d.getVar('STAGING_DIR', True)
 	staging_target = d.getVar('STAGING_DIR_TARGET', True)
 	staging_host = d.getVar('STAGING_DIR_HOST', True)
 	sstate_builddir = d.getVar('SSTATE_BUILDDIR', True)
 
-	files = " ".join(file_list.split('\n'))
-
 	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):
-		cmd = "sed -i -e s:%s:FIXMESTAGINGDIR:g %s" % (staging, files)
+		sstate_sed_cmd = "sed -i -e 's:%s:FIXMESTAGINGDIR:g'" % (staging)
 	elif bb.data.inherits_class('cross', d):
-		cmd = "sed -i -e s:%s:FIXMESTAGINGDIRTARGET:g %s \
-			sed -i -e s:%s:FIXMESTAGINGDIR:g %s" % (staging_target, files, staging, files)
+		sstate_sed_cmd = "sed -i -e 's:%s:FIXMESTAGINGDIRTARGET:g; s:%s:FIXMESTAGINGDIR:g'" % (staging_target, staging)
 	else:
-		cmd = "sed -i -e s:%s:FIXMESTAGINGDIRHOST:g %s" % (staging_host, files)
-
-	if files:
-		os.system(cmd)
-		fix = open("%sfixmepath" % (sstate_builddir), "w")
-		fixme = []
-		for f in file_list.split('\n'):
-			fixme.append(f.replace(sstate_builddir, ""))
-		fix.write("\n".join(fixme))
-		fix.close()
-	p.close()
+		sstate_sed_cmd = "sed -i -e 's:%s:FIXMESTAGINGDIRHOST:g'" % (staging_host)
+	
+	sstate_scan_cmd = d.getVar('SSTATE_SCAN_CMD', True)
+	sstate_filelist_cmd = "tee %sfixmepath" % (sstate_builddir)
+
+	# fixmepath file needs relative paths, drop sstate_builddir prefix
+	sstate_filelist_relative_cmd = "sed -i -e 's:^%s::g' %sfixmepath" % (sstate_builddir, sstate_builddir)
+
+	sstate_hardcode_cmd = "%s | %s | xargs %s" % (sstate_scan_cmd, sstate_filelist_cmd, sstate_sed_cmd)
+
+	print "Removing hardcoded paths from sstate package: '%s'" % (sstate_hardcode_cmd)
+	os.system(sstate_hardcode_cmd)
+	print "Replacing absolute paths in fixmepath file: '%s'" % (sstate_filelist_relative_cmd)
+	os.system(sstate_filelist_relative_cmd)
 
 def sstate_package(ss, d):
     import oe.path