go-rpmutils icon indicating copy to clipboard operation
go-rpmutils copied to clipboard

Expose some CPIO related helpers

Open kellyma2 opened this issue 1 year ago • 5 comments

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.

kellyma2 avatar Nov 14 '24 00:11 kellyma2

@mtharp can you take a look?

kellyma2 avatar Nov 14 '24 00:11 kellyma2

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.

mtharp avatar Mar 18 '25 16:03 mtharp

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.

rmohr avatar Jun 05 '25 18:06 rmohr

@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, ...

rmohr avatar Jun 05 '25 19:06 rmohr

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 ...

rmohr avatar Jun 05 '25 20:06 rmohr