Page 1 of 1

Need help extracting deb (ar) archive

Posted: Tue Apr 28, 2009 6:51 pm
by mrlanrat
Hello, I am somewhat new to php but am trying to learn as much as I can.

A project I am currently working on will need to extract a file from a .deb file which is an ar archive. Unlike tar or zip php does not seem to have any sort of built in function for doing so.

After doing much searching all I found in the way of extraction an ar archive in php was http://poocl.la-grotte.org/ This seems to have he ability. But I only want to have a single function for extracting an ar archive and not the rest.
Can anyone help me figure out how to do this? What I really want is the control file located in file.deb/control.tar.gz/control But I know how to extract the tar.gz, unless there is some way to do it all at once.

Even though I do not want to include the dependency of the File_Archive software I linked to above I gave it a try following an example on their website. (which required php-pear to be installed, another dependency I would prefer to do without) Using the following code:

Code: Select all

<?php
require_once "File/Archive.php";
 
//Note as the archives appear as folders
File_Archive::extract(
//    $src = "archive.tar/inner.tgz/file.txt",
//    File_Archive::toOutput()
    $src = "./file.deb/control.tar.gz/control",
    $conout = "./out.txt"
);
?>
I get the following error:

Code: Select all

Warning: require_once(MIME/Type.php) [function.require-once]: failed to open stream: No such file or directory in /data/web/test/File/Archive/Reader/File.php on line 33
 
Fatal error: require_once() [function.require]: Failed opening required 'MIME/Type.php' (include_path='.:/usr/share/php:/usr/share/pear') in /data/web/test/File/Archive/Reader/File.php on line 33
So, if there is no simple way to extract the ar, or just use the ar code from this project. How can I get the above test to work?


Thanks in advance!

Re: Need help extracting deb (ar) archive

Posted: Tue Apr 28, 2009 7:12 pm
by mrlanrat
I was playing with it a bit more and came across this http://poocl.la-grotte.org/phorum/read.php?3,21

I didn't know that File_Archive need to be installed. I just copied over the files to the working directory. Now when I run the script I get no errors, but It does not seem to extract the file I want. So, How can I get it to do that?

And I would still like to have this script to be independent from pear, so any alternatives would be great!

Thanks.