diff mbox series

[v13,3/8] package.bbclass: add support for ACLs and xattr

Message ID 20230817124612.1043464-3-p.lobacz@welotec.com
State New
Headers show
Series [v13,1/8] path.py: add support for ACLs and all additional attributes | expand

Commit Message

Piotr Łobacz Aug. 17, 2023, 12:46 p.m. UTC
Extend `tar` command, with additional parameters, depending
on choosen package class and target distro features, in order
to support ACLs and xattr.

Currently only `package_ipk` supports fully ACLs and xattr.

Signed-off-by: Piotr Łobacz <p.lobacz@welotec.com>
---
 meta/classes-global/package.bbclass | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/meta/classes-global/package.bbclass b/meta/classes-global/package.bbclass
index e8055a9cdc..6b65641aea 100644
--- a/meta/classes-global/package.bbclass
+++ b/meta/classes-global/package.bbclass
@@ -342,8 +342,13 @@  python perform_packagecopy () {
 
     # Start by package population by taking a copy of the installed
     # files to operate on
-    # Preserve sparse files and hard links
-    cmd = 'tar --exclude=./sysroot-only -cf - -C %s -p -S . | tar -xf - -C %s' % (dest, dvar)
+    # Preserve sparse files, hard links, ACLs and extended attributes
+    # TODO: for the moment only ipk packages are supporting ACLs and extended attributes
+    # we need to add support for other package systems as well, but that doesn't bother
+    # tar from creating archives with acl and/or xattr support
+    acl = bb.utils.contains('DISTRO_FEATURES', 'acl', '--acls', '', d)
+    xattr = bb.utils.contains('DISTRO_FEATURES', 'xattr', '--xattrs', '', d)
+    cmd = f'tar --format=posix {acl} {xattr} --numeric-owner --exclude=./sysroot-only -cf - -C {dest} -p -S . | tar --format=posix {acl} {xattr} -xf - -C {dvar}'
     subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
 
     # replace RPATHs for the nativesdk binaries, to make them relocatable