On Mon, Jun 02, 2014 at 11:50:48AM +0100, t...@ewsting.org wrote: > From: Thomas Ingleby <thomas.c.ingl...@intel.com> > > * Some options of GNU tar do not exist on other implementations > > Signed-off-by: Thomas Ingleby <thomas.c.ingl...@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+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- Paul Barker Email: p...@paulbarker.me.uk http://www.paulbarker.me.uk
pgpBBgEKXe_1j.pgp
Description: PGP signature
-- _______________________________________________ yocto mailing list yocto@yoctoproject.org https://lists.yoctoproject.org/listinfo/yocto