jRPM status
Paul Nasrat <[email protected]> Mon, 6 Sep 2004 08:27:51 -0400
| Newsgroups | gmane.comp.java.jrpm.devel |
|---|---|
| Message-ID | <[email protected]> |
I've currently been playing a little with jRPM. I probably should start pushing some patches: I've made jRPM work with raw headers (no magic) as this will be necessary for understanding headers from headerUnload (eg yum gzipped hdrs) and from rpmdb. Patch attached. I've got jRPM parsing headers returned from querying the rpmdb using a simple test class using sleepycat db.jar (the JNI implementation) Parsing rpmdb led me to find issues with the CHAR parsing as the only rpm tag that uses that is RPMTAG_FILESTATES that is created on install. Using the INT8 code for char worked, but I need to take a longer look at what is going on here. Paul
jrpm-header-raw.patch
(text/plain, 3.8 KB)
--- src/java/com/jguild/jrpm/io/Header.java 6 May 2004 20:59:22 -0000 1.9
+++ src/java/com/jguild/jrpm/io/Header.java 6 Sep 2004 12:13:11 -0000
@@ -33,48 +33,58 @@
private int version;
private long indexDataSize;
private long indexNumber;
+ private boolean rawHeader = false;
/** The size in bytes of this structure */
protected long size;
/**
- * Construct a header structure for the given input stream.
+ *
+ * Create a header structure from an input stream.
+ *
* The header structure of a signature or a header can be read and
- * also the index entries containig the tags for this rpm section
+ * also the index entries containing the tags for this rpm section
* (signature or header).
- * First a header is read consisting of the following fields:
+ *
+ * Unless we have a raw header from headerUnload or the database,
+ * a header is read consisting of the following fields:
* <code><pre>
* byte magic[3]; (3 byte) (8e ad e8)
* int version; (1 byte)
* byte reserved[4]; (4 byte)
* long num_index; (4 byte)
* long num_data; (4 byte)
- * </pre></code>
- * Afterwareds the index entries are read and then the tags and the
+ * </pre></code>
+ *
+ * Afterwards the index entries are read and then the tags and the
* correspondig data entries are read.
*
* @param inputStream An inputstream containing rpm file informations
+ * @param rawHeader Are we a raw header (from headerUnload or rpmdb)
* @throws IOException if an error occurs on reading informations
* out of the stream
*/
- public Header(DataInputStream inputStream) throws IOException {
+ public Header(DataInputStream inputStream, boolean rawHeader) throws IOException {
if (logger.isDebugEnabled()) {
logger.debug("Start Reading Header");
}
- // Read header
- size = HEADER_LENGTH;
-
- check(inputStream.readUnsignedByte() == 0x8E);
- check(inputStream.readUnsignedByte() == 0xAD);
- check(inputStream.readUnsignedByte() == 0xE8);
- version = inputStream.readUnsignedByte();
-
- if (logger.isDebugEnabled()) {
- logger.debug("version: " + version);
+ if (!rawHeader) {
+ // Read header
+ size = HEADER_LENGTH;
+
+ check(inputStream.readUnsignedByte() == 0x8E);
+ check(inputStream.readUnsignedByte() == 0xAD);
+ check(inputStream.readUnsignedByte() == 0xE8);
+ version = inputStream.readUnsignedByte();
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("version: " + version);
+ }
+
+ // skip reserved bytes
+ inputStream.skipBytes(4);
}
-
- // skip reserved bytes
- inputStream.skipBytes(4);
+
indexNumber = inputStream.readInt();
if (logger.isDebugEnabled()) {
@@ -155,6 +165,15 @@
logger.debug("Finished Reading Header");
}
}
+
+ /**
+ * Construct a header structure for the given input stream.
+ * @param inputStream
+ * @throws IOException
+ */
+ public Header(DataInputStream inputStream) throws IOException {
+ this(inputStream, false);
+ }
/**
* Read all known tag names for this header structure.
--- src/java/com/jguild/jrpm/io/RPMHeader.java 6 May 2004 20:59:23 -0000 1.6
+++ src/java/com/jguild/jrpm/io/RPMHeader.java 6 Sep 2004 12:13:11 -0000
@@ -29,6 +29,11 @@
public RPMHeader(DataInputStream inputStream) throws IOException {
super(inputStream);
}
+
+ public RPMHeader(DataInputStream inputStream, boolean raw) throws IOException {
+ super(inputStream, raw);
+ }
+
/*
* @see com.jguild.jrpm.io.Header#getKnownTagNames()