All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Barker <paul@paulbarker.me.uk>
To: opkg-devel@googlegroups.com
Cc: brendan.le.foll@intel.com, yocto@yoctoproject.org,
	Thomas Ingleby <thomas.c.ingleby@intel.com>,
	paul.eggleton@linux.intel.com
Subject: Re: [opkg-devel] [opkg-utils PATCH] opkg-build: add detection if using GNU tar.
Date: Mon, 2 Jun 2014 20:48:20 +0000	[thread overview]
Message-ID: <20140602204820.GG7521@gmail.com> (raw)
In-Reply-To: <1401706248-32605-2-git-send-email-tom@ewsting.org>

[-- 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 --]

      reply	other threads:[~2014-06-02 20:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` Paul Barker [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140602204820.GG7521@gmail.com \
    --to=paul@paulbarker.me.uk \
    --cc=brendan.le.foll@intel.com \
    --cc=opkg-devel@googlegroups.com \
    --cc=paul.eggleton@linux.intel.com \
    --cc=thomas.c.ingleby@intel.com \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.