diff mbox series

[1/2] opkg-utils: add acl and xattr support

Message ID 20230711231847.2211186-1-p.lobacz@welotec.com
State New
Headers show
Series [1/2] opkg-utils: add acl and xattr support | expand

Commit Message

Piotr Łobacz July 11, 2023, 11:18 p.m. UTC
Add support for tar archives created with --acls and/or --xattrs options,
PAX header format.

GNU tar and libarchive already supports ACLs and extended attributes.
We can now add this support as well to opkg-build script in order to use
fsetattr or setcap inside do_install command and end up with a file in
an image with the relevant ACLs and xattrs.

Signed-off-by: Piotr Łobacz <p.lobacz@welotec.com>
---
 ...kg-build-Add-acls-and-xattrs-support.patch | 70 +++++++++++++++++++
 .../opkg-utils/opkg-utils_0.5.0.bb            |  1 +
 2 files changed, 71 insertions(+)
 create mode 100644 meta/recipes-devtools/opkg-utils/opkg-utils/0002-opkg-build-Add-acls-and-xattrs-support.patch

Comments

Ross Burton July 12, 2023, 10:31 a.m. UTC | #1
On 12 Jul 2023, at 00:18, Piotr Łobacz via lists.openembedded.org <p.lobacz=welotec.com@lists.openembedded.org> wrote:
> +++ b/meta/recipes-devtools/opkg-utils/opkg-utils/0002-opkg-build-Add-acls-and-xattrs-support.patch
> @@ -0,0 +1,70 @@
> +From f177abcba7d72fa1afd0bc23f38beb4fe88fc040 Mon Sep 17 00:00:00 2001
> +From: =?UTF-8?q?Piotr=20=C5=81obacz?= <p.lobacz@welotec.com>
> +Date: Wed, 5 Jul 2023 10:31:13 +0200
> +Subject: [PATCH] opkg-build: add acl and xattr support
> +
> +Add support for tar archives created with --acls and/or --xattrs options,
> +PAX header format.
> +
> +GNU tar and libarchive already supports ACLs and extended attributes.
> +We can now add this support as well to opkg-build script in order to use
> +fsetattr or setcap inside do_install command and end up with a file in
> +an image with the relevant ACLs and xattrs.


This patch needs to have your S-o-b and an Upstream-Status (Submitted, unless it’s already been applied in which case Backport).

Thanks,
Ross
Piotr Łobacz July 12, 2023, 11:23 a.m. UTC | #2
I have added v3 and merged them as one feature/patch change. Additionaly how this Upstream-Status should look like? Could you please give me an example?

Thx
Piotr
Ross Burton July 12, 2023, 11:47 a.m. UTC | #3
On 12 Jul 2023, at 12:23, Piotr Łobacz <p.lobacz@welotec.com> wrote:
> 
> I have added v3 and merged them as one feature/patch change. Additionaly how this Upstream-Status should look like? Could you please give me an example?

https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines#Patch_Header_Recommendations:_Upstream-Status

You can grep oe-core for Upstream-Status and you’ll find hundreds of examples.

Cheers,
Ross
Piotr Łobacz July 12, 2023, 11:50 a.m. UTC | #4
Thx Ross

BR
Piotr
diff mbox series

Patch

diff --git a/meta/recipes-devtools/opkg-utils/opkg-utils/0002-opkg-build-Add-acls-and-xattrs-support.patch b/meta/recipes-devtools/opkg-utils/opkg-utils/0002-opkg-build-Add-acls-and-xattrs-support.patch
new file mode 100644
index 0000000000..08ecf969a8
--- /dev/null
+++ b/meta/recipes-devtools/opkg-utils/opkg-utils/0002-opkg-build-Add-acls-and-xattrs-support.patch
@@ -0,0 +1,70 @@ 
+From f177abcba7d72fa1afd0bc23f38beb4fe88fc040 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Piotr=20=C5=81obacz?= <p.lobacz@welotec.com>
+Date: Wed, 5 Jul 2023 10:31:13 +0200
+Subject: [PATCH] opkg-build: add acl and xattr support
+
+Add support for tar archives created with --acls and/or --xattrs options,
+PAX header format.
+
+GNU tar and libarchive already supports ACLs and extended attributes.
+We can now add this support as well to opkg-build script in order to use
+fsetattr or setcap inside do_install command and end up with a file in
+an image with the relevant ACLs and xattrs.
+---
+ opkg-build | 15 ++++++++++-----
+ 1 file changed, 10 insertions(+), 5 deletions(-)
+
+diff --git a/opkg-build b/opkg-build
+index a9e45d4..8d9bcfa 100755
+--- a/opkg-build
++++ b/opkg-build
+@@ -145,6 +145,7 @@ You probably want to chown these to a system user: " >&2
+ ###
+ # opkg-build "main"
+ ###
++attributesargs=""
+ ogargs=""
+ outer=ar
+ noclean=0
+@@ -166,7 +167,7 @@ compressorargs=""
+ tarformat=""
+ if tar --help 2>&1 | grep -- "--format" > /dev/null;
+ then
+-    tarformat="--format=gnu"
++    tarformat="--format=posix"
+ fi
+ 
+ compressor_ext() {
+@@ -197,13 +198,17 @@ compressor_ext() {
+ : <<=cut
+ =head1 SYNOPSIS
+ 
+-B<opkg-build> [B<-c>] [B<-C>] [B<-Z> I<compressor>] [B<-a>] [B<-O>] [B<-o> I<owner>] [B<-g> I<group>] I<pkg_directory> [I<destination_directory>]
++B<opkg-build> [B<-A>] [B<-X>] [B<-c>] [B<-C>] [B<-Z> I<compressor>] [B<-a>] [B<-O>] [B<-o> I<owner>] [B<-g> I<group>] I<pkg_directory> [I<destination_directory>]
+ 
+ =cut
+ 
+-usage="Usage: $0 [-c] [-C] [-Z compressor] [-a compressor_args] [-O] [-o owner] [-g group] <pkg_directory> [<destination_directory>]"
+-while getopts "a:cCg:ho:vOZ:" opt; do
++usage="Usage: $0 [-A] [-X] [-c] [-C] [-Z compressor] [-a compressor_args] [-O] [-o owner] [-g group] <pkg_directory> [<destination_directory>]"
++while getopts "Aa:cCg:ho:vOXZ:" opt; do
+     case $opt in
++        A ) attributesargs="--acls"
++            ;;
++        X ) attributesargs="$attributesargs --xattrs"
++            ;;
+ 	o ) owner=$OPTARG
+ 	    ogargs="--owner=$owner"
+ 	    ;;
+@@ -314,7 +319,7 @@ export LANG=C
+ export LC_ALL=C
+ ( cd $pkg_dir/$CONTROL && find . -type f | sort > $tmp_dir/control_list )
+ ( cd $pkg_dir && find . -path ./$CONTROL -prune -o -path . -o -print  | sort > $tmp_dir/file_list )
+-( cd $pkg_dir && tar $ogargs $tsortargs --no-recursion $mtime_args -c $tarformat -T $tmp_dir/file_list | $compressor $compressorargs > $tmp_dir/data.tar.$cext )
++( cd $pkg_dir && tar $attributesargs $ogargs $tsortargs --no-recursion $mtime_args -c $tarformat -T $tmp_dir/file_list | $compressor $compressorargs > $tmp_dir/data.tar.$cext )
+ ( cd $pkg_dir/$CONTROL && tar $ogargs $tsortargs --no-recursion --mtime=@$build_date -c $tarformat -T $tmp_dir/control_list | gzip $zipargs > $tmp_dir/control.tar.gz )
+ rm $tmp_dir/file_list
+ rm $tmp_dir/control_list
+-- 
+2.34.1
+
diff --git a/meta/recipes-devtools/opkg-utils/opkg-utils_0.5.0.bb b/meta/recipes-devtools/opkg-utils/opkg-utils_0.5.0.bb
index b27e3ded33..edf730711e 100644
--- a/meta/recipes-devtools/opkg-utils/opkg-utils_0.5.0.bb
+++ b/meta/recipes-devtools/opkg-utils/opkg-utils_0.5.0.bb
@@ -9,6 +9,7 @@  PROVIDES += "${@bb.utils.contains('PACKAGECONFIG', 'update-alternatives', 'virtu
 
 SRC_URI = "git://git.yoctoproject.org/opkg-utils;protocol=https;branch=master \
            file://0001-update-alternatives-correctly-match-priority.patch \
+           file://0002-opkg-build-Add-acls-and-xattrs-support.patch \
            "
 SRCREV = "9239541f14a2529b9d01c0a253ab11afa2822dab"