expandapk

package
v0.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 19 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Split

func Split(source io.Reader) ([]io.Reader, error)

Split takes an APK reader and splits it into its constituent parts.

If the length of the returned slice is 3, the first part is the signature section. If the length of the returned slice is 2, the first part is the control section. The last part is the data section.

These values are the compressed gzip streams, and should be decompressed before use.

The signature and control sections are buffered in memory, while the data section is streamed from the input reader.

Types

type APKExpanded

type APKExpanded struct {
	// The size in bytes of the entire apk (sum of all tar.gz file sizes)
	Size int64

	// Whether or not the apk contains a signature
	// Note: currently unused
	Signed bool

	// The package signature filename (a.k.a. ".SIGN...") in tar.gz format
	SignatureFile string

	// The control data filename (a.k.a. ".PKGINFO") in tar.gz format
	ControlFile string

	// The package data filename in .tar.gz format
	PackageFile string

	// The package data filename in .tar format.
	TarFile string

	// Expose ControlFile as an indexed FS implementation.
	ControlFS *tarfs.FS

	// Exposes TarFile as an indexed FS implementation.
	TarFS *tarfs.FS

	ControlHash []byte
	PackageHash []byte

	sync.Mutex
	// contains filtered or unexported fields
}

APKExpanded contains information about and reference to an expanded APK package. Close() deletes all temporary files and directories created during the expansion process.

func ExpandApk

func ExpandApk(ctx context.Context, source io.Reader, cacheDir string) (*APKExpanded, error)

ExpandAPK given a ready to an apk stream, normally a tar stream with gzip compression, expand it into its components.

An apk is split into either 2 or 3 file streams (2 for unsigned packages, 3 for signed).

For more info, see https://wiki.alpinelinux.org/wiki/Apk_spec:

"APK v2 packages contain two tar segments followed by a tarball each in their
own gzip stream (3 streams total). These streams contain the package signature,
control data, and package data"

Returns an APKExpanded struct containing references to the file. You *must* call APKExpanded.Close() when finished to clean up the various files.

func (*APKExpanded) APK

func (a *APKExpanded) APK() (io.ReadCloser, error)

func (*APKExpanded) Close

func (a *APKExpanded) Close() error

func (*APKExpanded) ControlData

func (a *APKExpanded) ControlData() ([]byte, error)

func (*APKExpanded) PackageData

func (a *APKExpanded) PackageData() (*os.File, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL