How to read RPM content in java

I am looking for a way to read the contents of an RPM during Java runtime.

Someone suggested using 7zip to unpack and / or extract RPMs at runtime using the system command for 7zip.

This solution has two drawbacks:

  • It depends on the platform (since the commands will be specific to one OS)
  • It uses third-party software.

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 get an exception: java.io.IOException: Unknown magic [???? (Funny characters from the original error message).

+4
source share
2 answers

commons-compress seems to have a cpio package , which may be useful when reading data from RPM files.

0
source

Use the library to unzip LZMA: http://www.7-zip.org/sdk.html

0
source

Source: https://habr.com/ru/post/1382446/


All Articles