[CentOS] tar and gunzip help

Fri Aug 21 21:13:31 UTC 2009
Robert Heller <heller at deepsoft.com>

At Fri, 21 Aug 2009 12:16:41 -0700 CentOS mailing list <centos at centos.org> wrote:

> 
> HI All,
> 
> I have a directory tree that when the user un-gzips/untars it does  
> into /opt by default.
> 
> The directory tree is like:
> 
> ugui
> |
> |-- <misc files>
> |-- source
> |-----framework
> |------ <misc files>
> 
> so when unzipped I want to end it with /opt/ugui and all the stuff  
> below it.
> 
> How do I do this? Can I also issue one command that will unzip and  
> untar the archive at the same time? (I know I can, I just cant get it  
> right)

Assuming you did:

tar czvf ugui-package.tar.gz ugui

Then you would do:

tar xzvf ugui-package.tar.gz -C /opt

The 'z' option implies piping the output (c) or input (x or t) though
gzip. Using 'j' instead of 'z' implies bzip2 instead.

The -C option implies a cd to the directoriy specified.

I don't believe tar itself can have an absolute directory embedded.  GNU
Tar *always* strips off a leading '/' in archives (but see the -P
option).

Just using tar, I don't think you can *force* a user to unpack under a
specific directory tree.  You might want to consider using the rpm
system, which can in fact enforce where a package is unpacked into.

> 
> Thanks!
> -ML
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos
> 
>                     

-- 
Robert Heller             -- 978-544-6933
Deepwoods Software        -- Download the Model Railroad System
http://www.deepsoft.com/  -- Binaries for Linux and MS-Windows
heller at deepsoft.com       -- http://www.deepsoft.com/ModelRailroadSystem/