Make relative tar path absolute at extraction

Make relative tar path absolute at extraction

Post by greyf.. » Thu, 05 Feb 2004 05:45:39



Is there any way that I can tar, for example, /tmp/usr/local/apache2
and when it is extracted, force it to /usr/local/apache2? I know I can
cd to /tmp and cvf on usr/local/apache2 from there, but that requires
being in / when extracting the tar later. The people who extract these
tars are often in their own home directory, so the files don't go
where they need to. Is there anything I can do when I make a
relative-pathed tar to make the extraction location absolute?
 
 
 

Make relative tar path absolute at extraction

Post by Kevin Rodger » Thu, 05 Feb 2004 07:47:39



> Is there any way that I can tar, for example, /tmp/usr/local/apache2
> and when it is extracted, force it to /usr/local/apache2?

ln -s /usr/local/apache2 /tmp/usr/local/apache2

Quote:> I know I can
> cd to /tmp and cvf on usr/local/apache2 from there, but that requires
> being in / when extracting the tar later. The people who extract these
> tars are often in their own home directory, so the files don't go
> where they need to.

They get what they deserve.  Why can't they follow directions to cd to
the correct directory?

Quote:> Is there anything I can do when I make a
> relative-pathed tar to make the extraction location absolute?

Not that I'm aware of.  But you could distribute an install script

along with the tar file, and tell them to run that instead of extracting
directly from the tar file.

--
Kevin Rodgers

 
 
 

Make relative tar path absolute at extraction

Post by Carlos J. G. Duart » Thu, 05 Feb 2004 09:42:52



> Is there any way that I can tar, for example, /tmp/usr/local/apache2
> and when it is extracted, force it to /usr/local/apache2? I know I can
> cd to /tmp and cvf on usr/local/apache2 from there, but that requires
> being in / when extracting the tar later. The people who extract these
> tars are often in their own home directory, so the files don't go
> where they need to. Is there anything I can do when I make a
> relative-pathed tar to make the extraction location absolute?

Well.
Grab the wonderful star command here:
http://www.fokus.gmd.de/research/cc/glone/employees/joerg.schilling/p...

and create the tarball like this:
star -c -f foo.tar  /tmp/usr/local/apache2 -s ,/tmp,,

then your users can use their normal tar and just do a :
tar xf foo.tar

WARNING: most tar's seems to automatically remove the leading /, so
check that out.

Another option is to use CPIO to produce the archive instead, but I
don't do much cpio ...

--
carlos ** http://cgd.sdf-eu.org

 
 
 

Make relative tar path absolute at extraction

Post by Sven Maschec » Thu, 05 Feb 2004 21:53:19




> > Is there any way that I can tar, for example, /tmp/usr/local/apache2
> > and when it is extracted, force it to /usr/local/apache2?
> Grab the wonderful star command [...]
> and create the tarball like this: [...]

Speaking of other utilities than tar:

You can use _existing_ tar archives with pax(1)
(if you had used a reasonable tar format w/o * options, etc.)

$ pax -r  -s ,^/tmp,, < $TARFILE

(See also the flag 'i' to even interact for each archive member.)

Commercial unix systems traditionally come with pax(1).
Unfortunately, the GNU tar people don't want to promote a GNU pax
(and AFAIK the last maintainer who wanted to isn't maintainer anymore...).
But there's a BSD pax; i just also tried the debian package.

 
 
 

1. tarring absolute paths for relative untar

I have a command which outputs to STDOUT a bunch of absolute paths to
some files of interest:

/tmp/x
/tmp/y/z/g/x.txt
/tmp/er/wsdf/sddd.doc

I would like to tar all of these files up, but have them untar in
relative fashion. ie,

tmp/x
tmp/y/z/g/x.txt
tmp/er/wsdf/sddd.doc

I am using Solaris tar

--
Terrence Brannon

2. Logging in to an NT domain from Linux?

3. Relative path to Absolute path

4. Read text fileson DOS partition?

5. Relative path to Absolute Path

6. retrieving machine status under linux !!

7. Symbolic Links - Absolute Paths to Relative Paths

8. how do i use Xauthority files?

9. C: get absolute path to a file from relative path

10. Add an absolute path prefix only to relative paths

11. How to convert a relative path into an absolute one?

12. finding absolute or relative path?

13. Relative / absolute paths and symlinks