From dc50e85ff1ceb2ffae2634a001f524a84a1b40e7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20=C5=81obacz?=
Date: Mon, 10 Jul 2023 11:03:12 +0200
Subject: [PATCH] opkg-build: Add acls and xattrs support
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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
Signed-off-by: Alex Stewart
---
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 [B<-c>] [B<-C>] [B<-Z> I] [B<-a>] [B<-O>] [B<-o> I] [B<-g> I] I [I]
+B [B<-A>] [B<-X>] [B<-c>] [B<-C>] [B<-Z> I] [B<-a>] [B<-O>] [B<-o> I] [B<-g> I] I [I]
=cut
-usage="Usage: $0 [-c] [-C] [-Z compressor] [-a compressor_args] [-O] [-o owner] [-g group] []"
-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] []"
+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