package.bbclass/module-strip.bbclass: Various strip fixes
authorRichard Purdie <rpurdie@linux.intel.com>
Mon, 23 Nov 2009 01:20:04 +0000 (01:20 +0000)
committerRichard Purdie <rpurdie@linux.intel.com>
Mon, 23 Nov 2009 01:20:04 +0000 (01:20 +0000)
* 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@linux.intel.com>
classes/module_strip.bbclass
classes/package.bbclass

index 1740919..ce36e21 100644 (file)
@@ -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)
-}
+
index 8892fa9..4196135 100644 (file)
@@ -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)