LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-25-2011, 01:49 PM   #1
wjtaylor
Member
 
Registered: Feb 2009
Posts: 78

Rep: Reputation: 15
tar and absolute paths


I can't seem to get tar to reference the archived files by absolute path.

I've used both the P and --absolute-names options and still it always shows up without the / (and certainly not absolute from the / directory)

I've used the P option on the tar -xvf foo.tar command as well... still relative paths...

What am I missing?

This is for GNU TAR v1.23 distributed with Debian 6.

Thanks,
WT

Last edited by wjtaylor; 03-25-2011 at 02:15 PM.
 
Old 03-25-2011, 04:12 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,939
Blog Entries: 13

Rep: Reputation: 4981Reputation: 4981Reputation: 4981Reputation: 4981Reputation: 4981Reputation: 4981Reputation: 4981Reputation: 4981Reputation: 4981Reputation: 4981Reputation: 4981
I think there's something wrong with how the file was tarred in the first place.

I personally use tar -cvf to create and tar -xvf to extract and never have any problems.

I also use tar -tvf to get a report on a tar or tar zipped file if I question what's up with it.

Sounds like someone tarred in symbolic links where the targets of the links are not encompassed by the archive scope.

In reading the tar man page, they should have created it using either -h or --dereference to dereference the files that symbolic links point to versus include the symbolic link intact. However if the symbolic link and the target are both encompassed by the archive (for instance if you archived a tree and they are both in that tree) I feel it will work out O.K.

The -P --absolute-names does nothing about this type of problem by the way.
 
Old 03-25-2011, 05:34 PM   #3
wjtaylor
Member
 
Registered: Feb 2009
Posts: 78

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by rtmistler View Post
I think there's something wrong with how the file was tarred in the first place.

I personally use tar -cvf to create and tar -xvf to extract and never have any problems.

I also use tar -tvf to get a report on a tar or tar zipped file if I question what's up with it.

Sounds like someone tarred in symbolic links where the targets of the links are not encompassed by the archive scope.

In reading the tar man page, they should have created it using either -h or --dereference to dereference the files that symbolic links point to versus include the symbolic link intact. However if the symbolic link and the target are both encompassed by the archive (for instance if you archived a tree and they are both in that tree) I feel it will work out O.K.

The -P --absolute-names does nothing about this type of problem by the way.
No, I recreated the tarball with just the standard: tar -cvf foo.tar source/ and there are no absolute paths
I tried again with, tar -cvfP and still nothing...

Tar behaves differently depending on the brand. The tar that comes with Solaris keeps absolute paths by default, I believe. This is for GNU TAR. What brand/version of tar are you using?

You're from Milford? I have some friends from Milford... down the road from EMC. Small world...
 
Old 03-25-2011, 05:58 PM   #4
wjtaylor
Member
 
Registered: Feb 2009
Posts: 78

Original Poster
Rep: Reputation: 15
I think I figured it out... If, when I am creating the archive, I specify the absolute path of the source files then I get them recorded in the tarball; if I use the relative path it only records relative paths in the archive.

Yes, you are right. The P option doesn't control it. It only affects the leading slash.

Thanks,
WT
 
Old 03-28-2011, 09:09 AM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,939
Blog Entries: 13

Rep: Reputation: 4981Reputation: 4981Reputation: 4981Reputation: 4981Reputation: 4981Reputation: 4981Reputation: 4981Reputation: 4981Reputation: 4981Reputation: 4981Reputation: 4981
I work at TechEn off Rt 85 in Milford, small design house for electronics. Got a buddy who works at EMC. Yep, small world, but then again, it's not like there aren't about a zillion engineering people around MA. Glad you figured it out. Yes, depending on the tar flavor, it can be complicated. I hated the old busybox because of that, however they have improved on it somewhat.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
relative/absolute paths? mkohler Linux - Newbie 3 11-13-2010 04:45 AM
Help with cp using absolute paths and globbing. Dru-Jitsu Linux - Newbie 4 06-24-2010 02:03 PM
Help with cp using absolute paths and globbing. Dru-Jitsu Linux - Newbie 1 06-24-2010 12:23 PM
[SOLVED] untar backup into new directory? absolute paths in tar qwertyjjj Linux - Newbie 4 08-19-2009 04:41 PM
Absolute and relative paths Gins Linux - General 6 11-08-2008 09:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 08:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration