Skip Menu |

This queue is for tickets about the Archive-Tar-Wrapper CPAN distribution.

Report information
The Basics
Id: 75770
Status: resolved
Priority: 0/
Queue: Archive-Tar-Wrapper

People
Owner: Nobody in particular
Requestors: brian [...] lanierfamily.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Issue with adding directories to a tar file not maintaining original permissions
Date: Wed, 14 Mar 2012 10:42:06 -0700
To: bug-Archive-Tar-Wrapper [...] rt.cpan.org
From: Brian Lanier <brian [...] lanierfamily.net>
Running Archive::Tar::Wrapper version "0.15" via CPAN Centos 5.8 Perl Version 5.8.8 I am using this module to archive up directories and compress them. Everything works great, however, directory permissions are not preserved. File permissions are great. I also notice you cannot pass in directories to the add method due to the use of the copy statement. Directories get created fine by the mkpath call however, they don't get sent to the permissions functions because they are made as a parent of the file getting added. I needed to be able to create an array of files and directories and loop through the array, adding them to a tar archive. Currently, unless you skip the directories, the add method will choke and die due to the copy. The fix below allows you to send a directory to the add method. It is minimal and I don't think it changes the method any other way. There is probably a better way, but this works for me. I had to add in the second mkpath call because it kept tripping up when the directory was added before a file within the directory: primarily the top level directory. Was trying to avoid unnecessary logic changes for now. In my case, I am calling the method in the following way: $tar = Archive::Tar::Wrapper->new(); find (sub { push @TAR_DIR_LIST, $File::Find::name }, $dir); foreach $tar_element (@TAR_DIR_LIST) { $tar->add($tar_element,$tar_element); } $logger->error("Error: Problem writing TAR FILE") unless $tar->write($dir.$SUFFIX,$COMPRESS); where $dir contains a path to the directory I want to archive. If I am totally missing the point of the module, please let me know. Advanced Novice with Perl, so there is always a better way. Thanks Brian ---- /admin/changes/Archive.Tar.Wrapper.orig.pm 2012-03-13 14:42:32.000000000 -0700 +++ /usr/lib/perl5/site_perl/5.8.8/Archive/Tar/Wrapper.pm 2012-03-14 10:35:28.000000000 -0700 @@ -178,8 +178,13 @@ print FILE $$path_or_stringref; close FILE; } else { - copy $path_or_stringref, $target or - LOGDIE "Can't copy $path_or_stringref to $target ($!)"; + if ( -d $path_or_stringref) { + mkpath($target, 0, 0755) unless -d $target; + + } else { + copy $path_or_stringref, $target or + LOGDIE "Can't copy $path_or_stringref to $target ($!)"; + } } if(defined $uid) {
Thanks for your patch, upon playing with it some more, I came up with a slightly different route: https://github.com/mschilli/archive-tar-wrapper- perl/commit/ac6bc87cfca3c3dd5d9ff1620576a7caec4799dd Let me know if this works for you. A tar ball is available at https://github.com/mschilli/archive-tar-wrapper-perl/tarball/rel_016 for testing. Hope that helps! -- Mike
Subject: Re: [rt.cpan.org #75770] Issue with adding directories to a tar file not maintaining original permissions
Date: Tue, 20 Mar 2012 10:58:14 -0700
To: bug-Archive-Tar-Wrapper [...] rt.cpan.org
From: Brian Lanier <brian [...] lanierfamily.net>
Hi Mike, That seemed to work fine. I applied your change as a patch to a copy of the original file. From my perspective it does the same thing as my patch only better. I figured there was probably a better way. Thanks for your quick attention to this. I wasn't really expecting a response so soon. Have a great day! Brian On 3/19/2012 8:10 PM, Michael_Schilli via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=75770> > > Thanks for your patch, upon playing with it some more, I came up with a slightly different > route: > > https://github.com/mschilli/archive-tar-wrapper- > perl/commit/ac6bc87cfca3c3dd5d9ff1620576a7caec4799dd > > Let me know if this works for you. A tar ball is available at > > https://github.com/mschilli/archive-tar-wrapper-perl/tarball/rel_016 > > for testing. > > Hope that helps! -- Mike
Sweet, thanks for the note, I'm glad it's working for you. Closing bug.