I'm looking for a way to read an RPM's content in java runtime.
Someone has suggested using 7zip to unpack and/or extract the RPM in runtime, using system command for 7zip.
that solution has two cons:
any ideas?
EDIT :
I'm trying to go down Robert's road. Here is my code:
String file = "MyRpm.rpm";
CpioArchiveInputStream cpioIn =
new CpioArchiveInputStream( new FileInputStream(new File(file)) );
CpioArchiveEntry cpioEntry;
while ((cpioEntry = cpioIn.getNextEntry()) != null)
{
System.out.println(cpioEntry.getName());
int tmp;
StringBuffer buf = new StringBuffer();
while ((tmp = cpioIn.read()) != -1)
{
buf.append((char) tmp);
}
System.out.println(buf.toString());
}
cpioIn.close();
I'm getting an exception: java.io.IOException: Unknown magic [????
(The funny characters are from the original error message).
Examples – Extract files from rpm In this example, output of the rpm2cpio command piped to the cpio command with the following options: i : Restore archive. d : Create leading directories where needed. m : Retain previous file modification times when creating files.
It seems that commons-compress
has a cpio package which you might find useful in reading the data from RPM files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With