Expose some CPIO related helpers
This change is derived from some pieces of https://github.com/sassoftware/go-rpmutils/pull/17 by refining the interface based on the comments and removing the tar implementation.
@mtharp can you take a look?
Hi,
Could you please elaborate on what your goal is? I am mostly trying to get away from directly surfacing the cpio implementation in the API, as using it correctly requires metadata from the RPM headers as well. If there is something you are trying to do that cannot be done through PayloadReaderExtended then I'd like to address it there, if possible.
Hm, I have to check to remember, but I think I could not access all the attributes or streams in a way which allowed an easy translation from cpio to tar.
@mtharp just played a little bit again with it. One reason is for instance that the header info exposed by the extended reader is completely different. Mapping the cpio header is very simple:
tarHeader := &tar.Header{
Name: entry.Header.Filename(),
Size: entry.Header.Filesize64(),
Mode: int64(entry.Header.Mode()),
Uid: entry.Header.Uid(),
Gid: entry.Header.Gid(),
ModTime: time.Unix(int64(entry.Header.Mtime()), 0),
Devmajor: int64(entry.Header.Devmajor()),
Devminor: int64(entry.Header.Devminor()),
PAXRecords: pax,
}
The FileInfo is different. It does for instance collaps device major/minor, I don't know how to figure out if something is a hard link, ...
Remember more now. The RPM header is different than the cpio header. I am not sure it has all info needed for a clean transformation. Like I don't see UID/GID and e.g. link types mentioned there ...