Enable xattr in created images
authorKévin THIERRY <kevin.thierry@open.eurogiciel.org>
Tue, 22 Apr 2014 15:18:20 +0000 (17:18 +0200)
committerKévin THIERRY <kevin.thierry@open.eurogiciel.org>
Tue, 22 Apr 2014 15:27:14 +0000 (17:27 +0200)
Adding the xattr in the rootfs before creating the image doesn't work
(xattr are not copied by "mkfs.ext3). The solution is to mount the
image after its creeation and then, set the xattr.

Note that it seems that adding the xattr in the rootfs before creating
the image seems to be needed. Without this step the xattr are not set,
even after setting them with this solution. I don't know why...

Signed-off-by: Kévin THIERRY <kevin.thierry@open.eurogiciel.org>
classes/image.bbclass
lib/oe/smack.py

index acffe0d..54b3971 100644 (file)
@@ -241,6 +241,7 @@ fakeroot python do_rootfs () {
     from oe.image import create_image
     from oe.manifest import create_manifest
     from oe.smack import create_smackrules
+    from oe.smack import apply_smackrules
 
     # generate the initial manifest
     create_manifest(d)
@@ -253,6 +254,9 @@ fakeroot python do_rootfs () {
 
     # generate final images
     create_image(d)
+
+    # apply smackrules
+    apply_smackrules(d)
 }
 
 insert_feed_uris () {
index d8311af..e6c4f61 100644 (file)
@@ -3,16 +3,19 @@ import subprocess as sub
 import tempfile
 import stat
 import os
+import sys
 
 import logging
 logger = logging.getLogger('BitBake.OE.Terminal')
 
 
-
-
 def create_smackrules(d):
 
+  logger.debug(1, '*** Enter create_smackrules() ***')
+
   D=d.expand('${WORKDIR}/rootfs')
+  logger.debug(1, 'D = %s' % D)
+
   command="#!/bin/bash\n"
   command+="export D=%s\n" %  D
   command+="chmod a+x %s/etc/smack/init_attr\n" %  D
@@ -28,4 +31,46 @@ def create_smackrules(d):
 
   p = sub.Popen(splitted_command,stdout=sub.PIPE,stderr=sub.PIPE)
   out, err = p.communicate()
-  os.unlink(f.name)
\ No newline at end of file
+  logger.debug(1, 'p.communicate returned:\nout =\n"%s"\nerr =\n"%s"' % (out, err))
+  os.unlink(f.name)
+
+  logger.debug(1, '*** Leave create_smackrules() ***')
+
+
+def apply_smackrules(d):
+
+  logger.debug(1, '*** Enter apply_smackrules() ***')
+
+  D=d.expand('${T}/mountdir')
+  DEPLOY_DIR_IMAGE=d.expand('${DEPLOY_DIR_IMAGE}')
+  IMAGE_NAME=d.expand('${IMAGE_NAME}')
+  
+  logger.debug(1, 'D = %s' % D)
+  logger.debug(1, 'IMAGE_NAME = %s.rootfs.ext3' % IMAGE_NAME)
+  logger.debug(1, 'DEPLOY_DIR_IMAGE = %s' % DEPLOY_DIR_IMAGE)
+
+  command="#!/bin/bash\n"
+  command+="export D=%s\n" %  D
+  command+="mkdir -p $D\n"
+  command+="sudo mount %s/%s.rootfs.ext3 $D\n" % (DEPLOY_DIR_IMAGE, IMAGE_NAME)
+  command+="chmod a+x %s/etc/smack/init_attr\n" %  D
+  command+="sudo -E $D/etc/smack/init_attr\n"
+  command+="sudo umount $D\n"
+  command+="rm -rf $D\n"
+
+  f = tempfile.NamedTemporaryFile(delete=False)
+  f.write(command)
+  os.chmod(f.name, 0777)
+  f.close()
+
+  splitted_command = shlex.split( str( f.name ) )
+  bb.note("RLM run command:%s" % splitted_command)
+
+  p = sub.Popen(splitted_command,stdout=sub.PIPE,stderr=sub.PIPE)
+  out, err = p.communicate()
+  logger.debug(1, 'p.communicate returned:\nout =\n"%s"\nerr =\n"%s"' % (out, err))
+  os.unlink(f.name)
+
+  logger.debug(1, '*** Leave apply_smackrules() ***')