Documentation
¶
Index ¶
- Constants
- Variables
- type DebPackage
- func (dp *DebPackage) CalcSize()
- func (dp *DebPackage) CalculateAllHashes() error
- func (dp DebPackage) GetAptTag(field interface{}) string
- func (dp *DebPackage) HasFilename() bool
- func (dp *DebPackage) MD5sum() string
- func (dp *DebPackage) SHA1sum() string
- func (dp *DebPackage) SHA256sum() string
- func (dp *DebPackage) ShortDescription() string
- type Dpkg
- func (dp *Dpkg) CompareVersions(v1, v2 string) int
- func (d *Dpkg) Info(debFile string) (*DebPackage, error)
- func (d *Dpkg) IsDebFile(debFile string) bool
- func (d *Dpkg) List() ([]DebPackage, error)
- func (d *Dpkg) ListGrep(pkgName string) ([]DebPackage, error)
- func (d *Dpkg) ScanPackages(dir string) ([]byte, error)
- type PackagesScanner
Constants ¶
const (
DPKG_DATABASE = "/var/lib/dpkg/status"
)
Variables ¶
var ( ErrDebHeader = errors.New("go-apt/dpkg: invalid debian package (ar magic header not matched)") ErrNoControlFile = errors.New("go-apt/dpkg: failed to find control.tar file") ErrNoDpkgStatusFile = errors.New("go-apt/dpkg: failed to read " + DPKG_DATABASE + " file") ErrNoFilenameAvailable = errors.New("go-apt/dpkg: no Filename available for this package") )
Functions ¶
This section is empty.
Types ¶
type DebPackage ¶
type DebPackage struct {
Package string `apt:"Package"`
Version string `apt:"Version"`
Architecture string `apt:"Architecture"`
Maintainer string `apt:"Maintainer"`
Essential string `apt:"Essential"`
Protected string `apt:"Protected"`
Status string `apt:"Status"`
Priority string `apt:"Priority"`
Section string `apt:"Section"`
InstalledSize string `apt:"Installed-Size"`
Origin string `apt:"Origin"`
MultiArch string `apt:"Multi-Arch"`
Source string `apt:"Source"`
Replaces []string `apt:"Replaces"`
Provides []string `apt:"Provides"`
Depends []string `apt:"Depends"`
PreDepends []string `apt:"Pre-Depends"`
Recommends []string `apt:"Recommends"`
Suggests []string `apt:"Suggests"`
Breaks []string `apt:"Breaks"`
Conflicts []string `apt:"Conflicts"`
Enhances []string `apt:"Enhances"`
Conffiles string `apt:"Conffiles"`
Filename string `apt:"Filename"`
Size int64 `apt:"Size"`
Description string `apt:"Description"`
Homepage string `apt:"Homepage"`
MD5Hash string `apt:"MD5sum"`
SHA1Hash string `apt:"SHA1"`
SHA256Hash string `apt:"SHA256"`
}
DebPackage represents the metadata of a Debian package https://salsa.debian.org/dpkg-team/dpkg/-/blob/main/lib/dpkg/parse.c?ref_type=heads#L53
func (*DebPackage) CalcSize ¶ added in v0.0.3
func (dp *DebPackage) CalcSize()
CalcSize calculates the size of the package file
func (*DebPackage) CalculateAllHashes ¶ added in v0.0.3
func (dp *DebPackage) CalculateAllHashes() error
CalculateAllHashes calculates the MD5, SHA1, and SHA256 hashes of the package content
func (DebPackage) GetAptTag ¶ added in v0.0.3
func (dp DebPackage) GetAptTag(field interface{}) string
GetAptTag retrieves the 'apt' tag value for a given field name in the DebPackage struct
func (*DebPackage) HasFilename ¶ added in v0.0.3
func (dp *DebPackage) HasFilename() bool
HasFilename checks if the DebPackage has a filename
func (*DebPackage) MD5sum ¶ added in v0.0.2
func (dp *DebPackage) MD5sum() string
MD5sum returns the MD5 hash of the package content
func (*DebPackage) SHA1sum ¶ added in v0.0.3
func (dp *DebPackage) SHA1sum() string
SHA1sum returns the SHA1 hash of the package content
func (*DebPackage) SHA256sum ¶ added in v0.0.3
func (dp *DebPackage) SHA256sum() string
SHA256sum returns the SHA256 hash of the package content
func (*DebPackage) ShortDescription ¶
func (dp *DebPackage) ShortDescription() string
ShortDescription returns the short description of the package
type Dpkg ¶
type Dpkg struct {
StatusFileLocation string
}
Dpkg represents a Debian package manager
func (*Dpkg) CompareVersions ¶ added in v0.0.3
CompareVersions compares Debian package versions based on https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-version
func (*Dpkg) Info ¶
func (d *Dpkg) Info(debFile string) (*DebPackage, error)
Info retrieves the metadata of a Debian package
func (*Dpkg) IsDebFile ¶
IsDebFile checks if the file is a valid .deb package https://manpages.debian.org/buster/dpkg-dev/deb.5.en.html#FORMAT
func (*Dpkg) List ¶
func (d *Dpkg) List() ([]DebPackage, error)
List lists packages from the default dpkg database
type PackagesScanner ¶ added in v0.0.3
type PackagesScanner struct {
RootDir string
Arch string
Type string
Hashes []string
Multiversion bool
}
PackagesScanner represents a scanner for Debian packages
func NewPackagesScanner ¶ added in v0.0.3
func NewPackagesScanner(dir string) *PackagesScanner
NewPackagesScanner creates a new instance of PackagesScanner
func (*PackagesScanner) ScanPackages ¶ added in v0.0.3
func (ps *PackagesScanner) ScanPackages() ([]byte, error)
ScanPackages scans the directory for packages matching the criteria