[oe-commits] Richard Purdie : package.bbclass/module-strip.bbclass: Various strip fixes

git version control git at git.openembedded.org
Tue Nov 24 12:52:30 UTC 2009


Module: openembedded.git
Branch: likewise/nios2
Commit: 18a377dcf50c5c10ebc73a36963a6e83d1bbad5d
URL:    http://gitweb.openembedded.net/?p=openembedded.git&a=commit;h=18a377dcf50c5c10ebc73a36963a6e83d1bbad5d

Author: Richard Purdie <rpurdie at linux.intel.com>
Date:   Mon Nov 23 01:20:04 2009 +0000

package.bbclass/module-strip.bbclass: Various strip fixes

* Turn striping functionality into functions and call in the appropriate place
* Removing various races and ordering issues
* Should mean kernel modules are correctly stripped (and stripping can be disabled)
* Addresses bug 1182
* kernel module stripping applied to ${PKGD} (the correct place)

Signed-off-by: Richard Purdie <rpurdie at linux.intel.com>

---

 classes/module_strip.bbclass |   36 +++++++++++++++---------------------
 classes/package.bbclass      |   37 ++++++++++++++++++++++++-------------
 2 files changed, 39 insertions(+), 34 deletions(-)

diff --git a/classes/module_strip.bbclass b/classes/module_strip.bbclass
index 1740919..ce36e21 100644
--- a/classes/module_strip.bbclass
+++ b/classes/module_strip.bbclass
@@ -1,26 +1,20 @@
-#DEPENDS_append = " module-strip"
+PACKAGESTRIPFUNCS += "do_strip_modules"
 
 do_strip_modules () {
-	for p in ${PACKAGES}; do
-		if test -e ${PKGDEST}/$p/lib/modules; then
-			if [ "${KERNEL_MAJOR_VERSION}" == "2.6" ]; then
-				modules="`find ${PKGDEST}/${p}/lib/modules -name \*.ko`"
-			else
-				modules="`find ${PKGDEST}/${p}/lib/modules -name \*.o`"
-			fi
-			if [ -n "$modules" ]; then
-				for module in $modules ; do
-					if ! [ -d "$module"  ] ; then
-						${STRIP} -v -g $module
-					fi
-				done	
-#				NM="${CROSS_DIR}/bin/${HOST_PREFIX}nm" OBJCOPY="${CROSS_DIR}/bin/${HOST_PREFIX}objcopy" strip_module $modules
-			fi
+	if test -e ${PKGDEST}/lib/modules; then
+		if [ "${KERNEL_MAJOR_VERSION}" == "2.6" ]; then
+			modules="`find ${PKGD}/lib/modules -name \*.ko`"
+		else
+			modules="`find ${PKGD}/lib/modules -name \*.o`"
 		fi
-	done
+		if [ -n "$modules" ]; then
+			for module in $modules ; do
+				if ! [ -d "$module"  ] ; then
+					${STRIP} -v -g $module
+				fi
+			done	
+		fi
+	fi
 }
 
-python do_package_append () {
-	if (bb.data.getVar('INHIBIT_PACKAGE_STRIP', d, 1) != '1'):
-		bb.build.exec_func('do_strip_modules', d)
-}
+
diff --git a/classes/package.bbclass b/classes/package.bbclass
index 8892fa9..4196135 100644
--- a/classes/package.bbclass
+++ b/classes/package.bbclass
@@ -201,6 +201,26 @@ def runstrip(file, d):
 
     return 1
 
+PACKAGESTRIPFUNCS += "do_runstrip"
+python do_runstrip() {
+	import stat
+
+	dvar = bb.data.getVar('PKGD', d, True)
+	def isexec(path):
+		try:
+			s = os.stat(path)
+		except (os.error, AttributeError):
+			return 0
+		return (s[stat.ST_MODE] & stat.S_IEXEC)
+
+	for root, dirs, files in os.walk(dvar):
+		for f in files:
+			file = os.path.join(root, f)
+			if not os.path.islink(file) and not os.path.isdir(file) and isexec(file):
+				runstrip(file, d)
+}
+
+
 def write_package_md5sums (root, outfile, ignorepaths):
     # For each regular file under root, writes an md5sum to outfile.
     # With thanks to patch.bbclass.
@@ -339,7 +359,7 @@ python perform_packagecopy () {
 }
 
 python populate_packages () {
-	import glob, stat, errno, re,os
+	import glob, errno, re,os
 
 	workdir = bb.data.getVar('WORKDIR', d, True)
 	outdir = bb.data.getVar('DEPLOY_DIR', d, True)
@@ -350,13 +370,6 @@ python populate_packages () {
 	bb.mkdirhier(outdir)
 	os.chdir(dvar)
 
-	def isexec(path):
-		try:
-			s = os.stat(path)
-		except (os.error, AttributeError):
-			return 0
-		return (s[stat.ST_MODE] & stat.S_IEXEC)
-
 	# Sanity check PACKAGES for duplicates - should be moved to 
 	# sanity.bbclass once we have the infrastucture
 	package_list = []
@@ -369,12 +382,10 @@ python populate_packages () {
 		else:
 			package_list.append(pkg)
 
+
 	if (bb.data.getVar('INHIBIT_PACKAGE_STRIP', d, True) != '1'):
-		for root, dirs, files in os.walk(dvar):
-			for f in files:
-				file = os.path.join(root, f)
-				if not os.path.islink(file) and not os.path.isdir(file) and isexec(file):
-					runstrip(file, d)
+		for f in (bb.data.getVar('PACKAGESTRIPFUNCS', d, True) or '').split():
+			bb.build.exec_func(f, d)
 
 	pkgdest = bb.data.getVar('PKGDEST', d, True)
 	os.system('rm -rf %s' % pkgdest)





More information about the Openembedded-commits mailing list