Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cpio/cpio.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ type countingReader struct {
curPos int64
}

func (ce *CpioEntry) ReadAll() ([]byte, error) {
return io.ReadAll(ce.payload)
}

func (ce *CpioEntry) Copy(dst io.Writer) (written int64, err error) {
return io.Copy(dst, ce.payload)
}

func (ce *CpioEntry) HasPayload() bool {
return ce.payload != nil
}

// NewCpioStream starts reading files from a cpio archive
func NewCpioStream(stream io.Reader) *CpioStream {
return &CpioStream{
Expand Down
10 changes: 10 additions & 0 deletions rpmutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ func (rpm *Rpm) PayloadReaderExtended() (PayloadReader, error) {
return newPayloadReader(pld, files), nil
}

// CpioStream returns a cpio stream for the RPM payload
func (rpm *Rpm) CpioStream() (*cpio.CpioStream, error) {
pld, err := uncompressRpmPayloadReader(rpm.f, rpm.Header)
if err != nil {
return nil, err
}

return cpio.NewCpioStream(pld), nil
}

// ReadHeader reads the signature and general headers from a RPM.
//
// The stream is positioned for reading the compressed payload following the headers.
Expand Down