All of lore.kernel.org
 help / color / mirror / Atom feed
* [opkg-utils PATCH] detect ability to use --format=gnu with tar
@ 2014-06-02 10:50 tom
  2014-06-02 10:50 ` [opkg-utils PATCH] opkg-build: add detection if using GNU tar tom
  0 siblings, 1 reply; 3+ messages in thread
From: tom @ 2014-06-02 10:50 UTC (permalink / raw)
  To: opkg-devel, yocto; +Cc: brendan.le.foll, paul.eggleton, Thomas Ingleby

From: Thomas Ingleby <thomas.c.ingleby@intel.com>

If opkg-build is being used on a platform not using GNU tar, format=gnu will necessarily work.

Thomas Ingleby (1):
  opkg-build: add detection if using GNU tar.

 opkg-build | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

-- 
1.9.2



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [opkg-utils PATCH] opkg-build: add detection if using GNU tar.
  2014-06-02 10:50 [opkg-utils PATCH] detect ability to use --format=gnu with tar tom
@ 2014-06-02 10:50 ` tom
  2014-06-02 20:48   ` [opkg-devel] " Paul Barker
  0 siblings, 1 reply; 3+ messages in thread
From: tom @ 2014-06-02 10:50 UTC (permalink / raw)
  To: opkg-devel, yocto; +Cc: brendan.le.foll, paul.eggleton, Thomas Ingleby

From: Thomas Ingleby <thomas.c.ingleby@intel.com>

* Some options of GNU tar do not exist on other implementations

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
---
 opkg-build | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/opkg-build b/opkg-build
index e314712..8abc14d 100755
--- a/opkg-build
+++ b/opkg-build
@@ -159,6 +159,17 @@ ogargs=""
 outer=ar
 noclean=0
 opkext=0
+
+tarformat=""
+#Probably not the best way to detect if running on a system without full GNU tar
+set +e
+tar --help | grep "format" &> /dev/null
+if [ $? -eq 0 ]
+then
+    tarformat="--format=gnu"
+fi
+set -e
+
 usage="Usage: $0 [-c] [-C] [-O] [-o owner] [-g group] <pkg_directory> [<destination_directory>]"
 while getopts "cCg:ho:vO" opt; do
     case $opt in
@@ -233,8 +244,8 @@ tmp_dir=$dest_dir/IPKG_BUILD.$$
 mkdir $tmp_dir
 
 echo $CONTROL > $tmp_dir/tarX
-( cd $pkg_dir && tar $ogargs -X $tmp_dir/tarX -cz --format=gnu -f $tmp_dir/data.tar.gz . )
-( cd $pkg_dir/$CONTROL && tar $ogargs -cz --format=gnu -f $tmp_dir/control.tar.gz . )
+( cd $pkg_dir && tar $ogargs -X $tmp_dir/tarX -cz $tarformat -f $tmp_dir/data.tar.gz . )
+( cd $pkg_dir/$CONTROL && tar $ogargs -cz $tarformat -f $tmp_dir/control.tar.gz . )
 rm $tmp_dir/tarX
 
 echo "2.0" > $tmp_dir/debian-binary
@@ -249,7 +260,7 @@ rm -f $pkg_file
 if [ "$outer" = "ar" ] ; then
   ( cd $tmp_dir && ar -crf $pkg_file ./debian-binary ./control.tar.gz ./data.tar.gz )
 else
-  ( cd $tmp_dir && tar -cz --format=gnu -f $pkg_file ./debian-binary ./control.tar.gz ./data.tar.gz )
+  ( cd $tmp_dir && tar -cz $tarformat -f $pkg_file ./debian-binary ./control.tar.gz ./data.tar.gz )
 fi
 
 rm $tmp_dir/debian-binary $tmp_dir/data.tar.gz $tmp_dir/control.tar.gz
-- 
1.9.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [opkg-devel] [opkg-utils PATCH] opkg-build: add detection if using GNU tar.
  2014-06-02 10:50 ` [opkg-utils PATCH] opkg-build: add detection if using GNU tar tom
@ 2014-06-02 20:48   ` Paul Barker
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Barker @ 2014-06-02 20:48 UTC (permalink / raw)
  To: opkg-devel; +Cc: brendan.le.foll, yocto, Thomas Ingleby, paul.eggleton

[-- Attachment #1: Type: text/plain, Size: 2986 bytes --]

On Mon, Jun 02, 2014 at 11:50:48AM +0100, tom@ewsting.org wrote:
> From: Thomas Ingleby <thomas.c.ingleby@intel.com>
> 
> * Some options of GNU tar do not exist on other implementations
> 
> Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
> ---
>  opkg-build | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/opkg-build b/opkg-build
> index e314712..8abc14d 100755
> --- a/opkg-build
> +++ b/opkg-build
> @@ -159,6 +159,17 @@ ogargs=""
>  outer=ar
>  noclean=0
>  opkext=0
> +
> +tarformat=""
> +#Probably not the best way to detect if running on a system without full GNU tar
> +set +e
> +tar --help | grep "format" &> /dev/null
> +if [ $? -eq 0 ]
> +then
> +    tarformat="--format=gnu"
> +fi
> +set -e
> +

I wouldn't trust that the word 'format' won't occur in some other context within
the help output of tar. I'd search for '--format' instead, both bsdtar and gnu
tar include that in the help output but busybox tar does not. The output of
busybox tar also seems to be printed on stderr, so I'd include '2>&1' before the
pipe.

You also shouldn't need the 'set +e' magic, if you move the command which could
fail into the if statement then an error should not cause the script to abort.
Maybe try something like:
    if tar --help 2>&1 | grep -- --format > /dev/null; then ...

The rest of this looks good to me.

>  usage="Usage: $0 [-c] [-C] [-O] [-o owner] [-g group] <pkg_directory> [<destination_directory>]"
>  while getopts "cCg:ho:vO" opt; do
>      case $opt in
> @@ -233,8 +244,8 @@ tmp_dir=$dest_dir/IPKG_BUILD.$$
>  mkdir $tmp_dir
>  
>  echo $CONTROL > $tmp_dir/tarX
> -( cd $pkg_dir && tar $ogargs -X $tmp_dir/tarX -cz --format=gnu -f $tmp_dir/data.tar.gz . )
> -( cd $pkg_dir/$CONTROL && tar $ogargs -cz --format=gnu -f $tmp_dir/control.tar.gz . )
> +( cd $pkg_dir && tar $ogargs -X $tmp_dir/tarX -cz $tarformat -f $tmp_dir/data.tar.gz . )
> +( cd $pkg_dir/$CONTROL && tar $ogargs -cz $tarformat -f $tmp_dir/control.tar.gz . )
>  rm $tmp_dir/tarX
>  
>  echo "2.0" > $tmp_dir/debian-binary
> @@ -249,7 +260,7 @@ rm -f $pkg_file
>  if [ "$outer" = "ar" ] ; then
>    ( cd $tmp_dir && ar -crf $pkg_file ./debian-binary ./control.tar.gz ./data.tar.gz )
>  else
> -  ( cd $tmp_dir && tar -cz --format=gnu -f $pkg_file ./debian-binary ./control.tar.gz ./data.tar.gz )
> +  ( cd $tmp_dir && tar -cz $tarformat -f $pkg_file ./debian-binary ./control.tar.gz ./data.tar.gz )
>  fi
>  
>  rm $tmp_dir/debian-binary $tmp_dir/data.tar.gz $tmp_dir/control.tar.gz
> -- 
> 1.9.2
> 
> -- 
> You received this message because you are subscribed to the Google Groups "opkg-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to opkg-devel+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
Paul Barker

Email: paul@paulbarker.me.uk
http://www.paulbarker.me.uk

[-- Attachment #2: Type: application/pgp-signature, Size: 501 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-06-02 20:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-02 10:50 [opkg-utils PATCH] detect ability to use --format=gnu with tar tom
2014-06-02 10:50 ` [opkg-utils PATCH] opkg-build: add detection if using GNU tar tom
2014-06-02 20:48   ` [opkg-devel] " Paul Barker

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.