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.lo...@welotec.com>
---
opkg-build | 54 ++++++++++++++++++++++++++++++++++--------------------
1 file changed, 34 insertions(+), 20 deletions(-)
diff --git a/opkg-build b/opkg-build
index a9e45d4..8e327f5 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
@@ -153,22 +154,6 @@ compressor=gzip
zipargs="-9n"
compressorargs=""
-# Determine if tar supports the --format argument by checking the help output.
-#
-# This is needed because:
-# - Busybox tar doesn't support '--format'
-# - On some Linux distros, tar now defaults to posix format if '--format'
-# isn't explicitly specified
-# - Opkg doesn't currently support posix format archives
-#
-# It's easier to check for mention of the '--format' option than to detect the
-# tar implementation and maintain a list of which support '--format'.
-tarformat=""
-if tar --help 2>&1 | grep -- "--format" > /dev/null;
-then
- tarformat="--format=gnu"
-fi
-
compressor_ext() {
case $1 in
gzip|pigz)
@@ -197,13 +182,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"
;;
@@ -232,6 +221,31 @@ while getopts "a:cCg:ho:vOZ:" opt; do
esac
done
+# Determine if tar supports the --format argument by checking the help output.
+#
+# This is needed because:
+# - Busybox tar doesn't support '--format'
+# - On some Linux distros, tar now defaults to posix format if '--format'
+# isn't explicitly specified
+# - Opkg doesn't currently support posix format archives
+#
+# It's easier to check for mention of the '--format' option than to detect the
+# tar implementation and maintain a list of which support '--format'.
+tarformat=""
+if tar --help 2>&1 | grep -- "--format" > /dev/null;
+then
+ # For ACLs or xattr support, gnu format will not work
+ # we need to set posix format instead
+ if [ ! -z "$attributesargs" ] ; then
+ tarformat="--format=posix"
+ else
+ tarformat="--format=gnu"
+ fi
+elif [ ! -z "$attributesargs" ] ; then
+ echo "*** Error: Attributes: $attributesargs, doesn't' work, without posix format, which is not supported by tar command." >&2
+ exit 1
+fi
+
cext=$(compressor_ext $compressor)
# pgzip requires -T to avoid timestamps on the gzip archive
@@ -314,7 +328,7 @@ export LANG=C