FW: Unpacking script

Jason Gurtz jason at tommyk.com
Thu Feb 22 12:21:39 PST 2001


Hey all,

Could the following be used somehow to alleviate the .gz vs. .bz2 issues in
profiles?

~jason

--
+------------------+
| Jason at tommyk.com |
+------------------+

(from lfs-apps)

>
> I use the following "unpack" script, which takes care of several types of
> archived/zipped files:
>
> #!/bin/sh
> # Fri Jan  5 14:57:59 EST 2001
> # /usr/local/bin/scripts/unpack-sh
> # linked to /usr/local/bin/unpack
> # Copyright 2001, Chris F.A. Johnson
> # Released under the terms of the GNU General Public License
>
> for file in "$@"
> do
>     case $file in
>
> 	*.zip)
> 	    unzip $file
> 	    ;;
>
> 	*.tar)
> 	    tar xvpf $file
> 	    ;;
>
> 	*.tgz|*tar.gz|*.tar.Z)
> 	    tar xvzpf $file
> 	    ;;
>
> 	*tar.bz2|*.tbz2)
> 	## Requires a patch to GNU tar (see below)
> 	## Debian GNU/Linux distros include it (I think);
> 	## I don't know about other distros.
> 	## I haven't seen any files with the .tbz2 extension (yet).
> 	    tar xvypf $file
> 	    ;;
>
> 	## gzipped and bzip2ed files are uncompressed to the current
> 	## directory, leaving the original files in place
> 	*.gz)
> 	    gunzip -c $file > `basename $file .gz`
> 	    ;;
>
> 	*.Z)
> 	    gunzip -c $file > `basename $file .Z`
> 	    ;;
>
> 	*.bz2)
> 	    bunzip2  -c $file > `basename $file .bz2`
> 	    ;;
>     esac
> done
> ############## end of unpack-sh ###################
>
> The following patch to tar enables the use of the 'y' option:
>
> ############## start of gnutarpatch.txt #######################
> *** tar.c.orig	Mon Jul 12 16:58:10 1999
> --- tar.c	Mon Jul 12 17:02:27 1999
> ***************
> *** 16,21 ****
> --- 16,23 ----
>      with this program; if not, write to the Free Software
> Foundation, Inc.,
>      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
>
> + /* Patched to integrate bzip2 as compression filter (option -y)  */
> +
>   #include "system.h"
>
>   #include <getopt.h>
> ***************
> *** 164,169 ****
> --- 166,173 ----
>     {"block-number", no_argument, NULL, 'R'},
>     {"block-size", required_argument, NULL, OBSOLETE_BLOCKING_FACTOR},
>     {"blocking-factor", required_argument, NULL, 'b'},
> +   {"bunzip2", required_argument, NULL, 'y'},
> +   {"bzip2", required_argument, NULL, 'y'},
>     {"catenate", no_argument, NULL, 'A'},
>     {"checkpoint", no_argument, &checkpoint_option, 1},
>     {"compare", no_argument, NULL, 'd'},
> ***************
> *** 340,345 ****
> --- 344,350 ----
>                 PATTERN                at list/extract time, a
> globbing PATTERN\n\
>     -o, --old-archive, --portability   write a V7 format archive\n\
>         --posix                        write a POSIX conformant archive\n\
> +   -y, --bzip2, --bunzip2             filter the archive through bzip2\n\
>     -z, --gzip, --ungzip               filter the archive through gzip\n\
>     -Z, --compress, --uncompress       filter the archive through
> compress\n\
>         --use-compress-program=PROG    filter through PROG (must
> accept -d)\n"),
> ***************
> *** 416,422 ****
>      Y  per-block gzip compression */
>
>   #define OPTION_STRING \
> !   "-01234567ABC:F:GK:L:MN:OPRST:UV:WX:Zb:cdf:g:hiklmoprstuvwxz"
>
>   static void
>   set_subcommand_option (enum subcommand subcommand)
> --- 421,427 ----
>      Y  per-block gzip compression */
>
>   #define OPTION_STRING \
> !   "-01234567ABC:F:GK:L:MN:OPRST:UV:WX:Zb:cdf:g:hiklmoprstuvwxyz"
>
>   static void
>   set_subcommand_option (enum subcommand subcommand)
> ***************
> *** 786,791 ****
> --- 791,800 ----
>         case 'X':
>   	if (add_exclude_file (excluded, optarg, '\n') != 0)
>   	  FATAL_ERROR ((0, errno, "%s", optarg));
> + 	break;
> +
> +       case 'y':
> + 	set_use_compress_program_option ("bzip2");
>   	break;
>
>         case 'z':
> ############## end of gnutarpatch.txt #######################
>
>
>
>
> ~--
> 	Chris F.A. Johnson	    bq933 at torfree.net
> 	=================================================================
> 	c.f.a.johnson at home.com	    http://cfaj.freeshell.org
> 	cfaj at freeshell.org	    http://members.home.net/c.f.a.johnson


-- 
Unsubscribe: send email to alfs-discuss-request at linuxfromscratch.org
and put unsubscribe in the subject header of the message




More information about the alfs-discuss mailing list