Author: jhuntwork
Date: 2005-06-16 11:26:14 -0600 (Thu, 16 Jun 2005)
New Revision: 228

Modified:
   trunk/scripts/unpack
Log:
Updated unpack script to use modern tar features, if available

Modified: trunk/scripts/unpack
===================================================================
--- trunk/scripts/unpack        2005-06-15 04:55:53 UTC (rev 227)
+++ trunk/scripts/unpack        2005-06-16 17:26:14 UTC (rev 228)
@@ -1,6 +1,7 @@
 #!/bin/bash
 
-TAR=`which tar`
+TAR=`which tar` || echo "Error: Cannot find tar on your system" && exit 1
+VRS=`$TAR --version | head -n 1 | awk '{print $4}' | cut -f2 -d'.'`
 
 if [ -z $1 ] ; then
        echo "Error: No file specified."
@@ -12,12 +13,18 @@
        exit 1
 fi
 
-if echo $1 | grep -q "tar.gz" || echo $1 | grep -q ".tgz" ; then
-       $TAR -xzf $1 || echo "Error: Unpacking of \"$1\" failed."
-elif echo $1 | grep -q "tar.bz2" ; then
-       $TAR -xjf $1 || echo "Error: Unpacking of \"$1\" failed."
-elif [ `expr "$1" : '.*\(...\)'` = "tar" ] ; then
+if [ $VRS -lt 15 ] ; then # This version of tar doesn't support the automatic 
discovery of
+                         # compression type.
+
+       if echo $1 | grep -q "tar.gz" || echo $1 | grep -q ".tgz" ; then
+               $TAR -xzf $1 || echo "Error: Unpacking of \"$1\" failed."
+       elif echo $1 | grep -q "tar.bz2" ; then
+               $TAR -xjf $1 || echo "Error: Unpacking of \"$1\" failed."
+       elif [ `expr "$1" : '.*\(...\)'` = "tar" ] ; then
+               $TAR -xf $1 || echo "Error: Unpacking of \"$1\" failed."
+       else
+               echo "Error: Bad format or unknown compression type"
+       fi
+else
        $TAR -xf $1 || echo "Error: Unpacking of \"$1\" failed."
-else
-       echo "Error: Bad format or unknown compression type"
-fi     
+fi

-- 
http://linuxfromscratch.org/mailman/listinfo/livecd
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to