in reply to Re: manipulating cpio archive
in thread manipulating cpio archive

Thank you for your reply.
I tried it again, and made better notes. My archive is td.cpio:
$ cpio --list -i <td.cpio . t2 t1 t3 1 block $
My script is
#!/opt/ActivePerl-5.12/bin/perl use Archive::Cpio; my $cpio = Archive::Cpio->new; $cpio->read('td.cpio'); $cpio->remove('t1'); $cpio->write('tdnew.cpio');
The output tdnew.cpio is identical to td.cpio

I think the answer is in the Archive::Cpio code. The entry should be removed in

sub remove { my ($cpio, @filenames) = @_; $cpio->{list} or die "can't remove from nothing\n"; my %filenames = map { $_ => 1 } @filenames; @{$cpio->{list}} = grep { !$filenames{$_} } @{$cpio->{list}}; }
I cannot decipher that last line but I do not like it (I may be completely wrong).

How can I get this right? Thank you.

Replies are listed 'Best First'.
Re^3: manipulating cpio archive
by Corion (Patriarch) on Jan 17, 2011 at 18:39 UTC

    I would now look inside the Archive::Cpio object (using Data::Dumper) to see what it contains, before and after your modification.

      It looks the same to me. The entry I want to skip is there.

        Well, Perl doesn't think so. Maybe it has whitespace at the end of the archive name? Maybe post the actual output of Data::Dumper?

        Interestingly enough, Archive::Cpio contains no call to binmode. I'm not sure whether it will work on Windows at all.