Documentation
¶
Index ¶
Constants ¶
const DefaultMaxControlSize int64 = 10 << 20
DefaultMaxControlSize is the default maximum decompressed size for control sections (10 MB).
const DefaultMaxDataSize int64 = 16 << 30
DefaultMaxDataSize is the default maximum decompressed size for data sections (~17 GB).
Variables ¶
This section is empty.
Functions ¶
func Split ¶
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
SignatureHash []byte
ControlSize int64
PackageSize int64
SignatureSize int64
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 ¶
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 ExpandApkWithOptions ¶ added in v1.1.0
func ExpandApkWithOptions(ctx context.Context, source io.Reader, cacheDir string, opts ...Option) (*APKExpanded, error)
ExpandApkWithOptions is like ExpandApk but accepts functional options to configure size limits for APK sections.
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) IsValid ¶ added in v0.30.35
func (a *APKExpanded) IsValid() bool
IsValid checks that the expanded APK is still valid by verifying that the underlying files exist and that the file handles match the expected files. Since this structure is heavily cached, this is useful to verify that the cached data is still valid.
func (*APKExpanded) PackageData ¶
func (a *APKExpanded) PackageData() (*os.File, error)
func (*APKExpanded) PkgInfo ¶ added in v1.0.2
func (a *APKExpanded) PkgInfo() (*types.PackageInfo, error)
PkgInfo parses and returns the .PKGINFO file.
type Option ¶ added in v1.1.0
Option is a functional option for configuring Options.
func WithMaxControlSize ¶ added in v1.1.0
WithMaxControlSize sets the maximum decompressed size for signature and control sections.
func WithMaxDataSize ¶ added in v1.1.0
WithMaxDataSize sets the maximum decompressed size for the data section.
type Options ¶ added in v1.1.0
type Options struct {
// MaxControlSize is the maximum decompressed size for signature and control sections.
// Use -1 for unlimited.
MaxControlSize int64
// MaxDataSize is the maximum decompressed size for the data section.
// Use -1 for unlimited.
MaxDataSize int64
}
Options configures the behavior of APK expansion operations.
func DefaultOptions ¶ added in v1.1.0
func DefaultOptions() *Options
DefaultOptions returns Options with default size limits.