deb

package module
v0.0.0-...-4bb66f3 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2021 License: MIT Imports: 24 Imported by: 1

README

go-deb

A native implementation of the Debian specification in Go, which is very much inspired by go-rpm. The go-deb is trying to replicate go-rpm as close as possible in order to provide more or less common API. The difference between RPM and Dpkg, however, inevitable.

$ go get github.com/isbm/go-deb

Same as go-rpm, go-deb package aims to enable cross-platform tooling for dpkg written in Go.

Initial goals include like-for-like implementation of existing Dpkg ecosystem features such as:

  • Reading of modern and legacy Debian package file formats
  • Reading, creating and updating modern and legacy Dpkg repository metadata
package main

import (
	"fmt"
	"github.com/isbm/go-deb"
)

func main() {
	// Set options manually or use deb.DefaultPackageOptions instance
	options := &deb.PackageOptions{
		Hash: deb.HASH_SHA1,
		RecalculateChecksums: true,
		MetaOnly: false,
	}

	p, err := deb.OpenPackageFile("golang_1.12~1_amd64.deb", options)
	if err != nil {
		panic(err)
	}

	fmt.Printf("Loaded package: %v - %s\n", p, p.Summary())
}

Documentation

Index

Constants

View Source
const (
	HASH_MD5 = iota
	HASH_SHA1
	HASH_SHA256
)

Variables

View Source
var DefaultPackageOptions = &PackageOptions{
	MetaOnly:             false,
	Hash:                 HASH_MD5,
	RecalculateChecksums: true,
}

Functions

This section is empty.

Types

type CfgFilesFile

type CfgFilesFile struct {
	// contains filtered or unexported fields
}

func NewCfgFilesFiles

func NewCfgFilesFiles() *CfgFilesFile

func (*CfgFilesFile) Names

func (cfg *CfgFilesFile) Names() []string

type Checksum

type Checksum struct {
	// contains filtered or unexported fields
}

Checksum object computes and returns the SHA256, SHA1 and MD5 checksums encoded in hexadecimal) of the package file.

Checksum reopens the package using the file path that was given via OpenPackageFile.

func NewBytesChecksum

func NewBytesChecksum(data []byte) *Checksum

func NewChecksum

func NewChecksum(path string) *Checksum

Constructor

func (*Checksum) MD5

func (cs *Checksum) MD5() string

MD5 checksum

func (*Checksum) SHA1

func (cs *Checksum) SHA1() string

SHA1 checksum

func (*Checksum) SHA256

func (cs *Checksum) SHA256() string

SHA256 checksum

func (*Checksum) SetHash

func (cs *Checksum) SetHash(hash int) *Checksum

func (*Checksum) Sum

func (cs *Checksum) Sum() string

type ControlFile

type ControlFile struct {
	// contains filtered or unexported fields
}

Control file

func NewControlFile

func NewControlFile() *ControlFile

func (*ControlFile) Architecture

func (cf *ControlFile) Architecture() string

func (*ControlFile) Breaks

func (cf *ControlFile) Breaks() []string

func (*ControlFile) Conflicts

func (cf *ControlFile) Conflicts() []string

func (*ControlFile) Depends

func (cf *ControlFile) Depends() []string

func (*ControlFile) Description

func (cf *ControlFile) Description() string

func (*ControlFile) Enhances

func (cf *ControlFile) Enhances() []string

func (*ControlFile) InstalledSize

func (cf *ControlFile) InstalledSize() int

func (*ControlFile) Licence

func (cf *ControlFile) Licence() string

Licence of the package

func (*ControlFile) Maintainer

func (cf *ControlFile) Maintainer() string

func (*ControlFile) MultiArch

func (cf *ControlFile) MultiArch() string

func (*ControlFile) OE

func (cf *ControlFile) OE() string

func (*ControlFile) OriginalMaintainer

func (cf *ControlFile) OriginalMaintainer() string

func (*ControlFile) Package

func (cf *ControlFile) Package() string

func (*ControlFile) Predepends

func (cf *ControlFile) Predepends() []string

func (*ControlFile) Priority

func (cf *ControlFile) Priority() string

func (*ControlFile) Provides

func (cf *ControlFile) Provides() []string

func (*ControlFile) Recommends

func (cf *ControlFile) Recommends() []string

func (*ControlFile) Replaces

func (cf *ControlFile) Replaces() []string

func (*ControlFile) Section

func (cf *ControlFile) Section() string

func (*ControlFile) Source

func (cf *ControlFile) Source() string

Source

func (*ControlFile) Suggests

func (cf *ControlFile) Suggests() []string

func (*ControlFile) Summary

func (cf *ControlFile) Summary() string

Summary returns a first line of Description

func (*ControlFile) Version

func (cf *ControlFile) Version() string

type FileInfo

type FileInfo struct {
	// contains filtered or unexported fields
}

A FileInfo describes a file in a Deb package and is returned by packagefile.Files.

FileInfo implements the os.FileInfo interface.

func (*FileInfo) Digest

func (f *FileInfo) Digest() string

Digest is the md5sum of a file in a Deb package

func (*FileInfo) Group

func (f *FileInfo) Group() string

Group is the name of the owner group of a file in a Deb package

func (*FileInfo) IsDir

func (f *FileInfo) IsDir() bool

IsDir returns true if a file is a directory in a Deb package

func (*FileInfo) Linkname

func (f *FileInfo) Linkname() string

Linkname is the link target of a link file in a Deb package

func (*FileInfo) ModTime

func (f *FileInfo) ModTime() time.Time

ModTime is the modification time of a file in a Deb package

func (*FileInfo) Mode

func (f *FileInfo) Mode() os.FileMode

Mode is the file mode in bits of a file in a Deb package

func (*FileInfo) Name

func (f *FileInfo) Name() string

Name is the full path of a file in a Deb package

func (*FileInfo) Owner

func (f *FileInfo) Owner() string

Owner is the name of the owner of a file in a Deb package

func (*FileInfo) Size

func (f *FileInfo) Size() int64

Size is the size in bytes of a file in a Deb package

func (*FileInfo) String

func (f *FileInfo) String() string

func (*FileInfo) Sys

func (f *FileInfo) Sys() interface{}

Sys is required to implement os.FileInfo and always returns nil

type PackageFile

type PackageFile struct {
	// contains filtered or unexported fields
}

PackageFile object

func NewPackageFile

func NewPackageFile() *PackageFile

Constructor

func OpenPackageFile

func OpenPackageFile(uri string, opts *PackageOptions) (*PackageFile, error)

OpenPackageFile from URI string.

func (*PackageFile) ConffilesFile

func (c *PackageFile) ConffilesFile() *CfgFilesFile

ConffilesFile returns parsed triggers file data.

func (*PackageFile) ControlFile

func (c *PackageFile) ControlFile() *ControlFile

ControlFile returns parsed data of the package's control file

func (*PackageFile) DebVersion

func (c *PackageFile) DebVersion() string

DpkgVersion returns the version of the format of the .deb file

func (*PackageFile) FileSize

func (c *PackageFile) FileSize() uint64

FileSize returns the size of the package file in bytes if it was opened with OpenPackageFile.

func (*PackageFile) FileTime

func (c *PackageFile) FileTime() time.Time

FileTime returns the time at which the Debian package file was last modified if it was opened with OpenPackageFile.

func (*PackageFile) Files

func (c *PackageFile) Files() []FileInfo

Return meta-content of the package

func (*PackageFile) GetCalculatedChecksum

func (c *PackageFile) GetCalculatedChecksum(path string) string

func (*PackageFile) GetFileChecksum

func (c *PackageFile) GetFileChecksum(path string) string

GetFileChecksum returns file checksum by relative path

func (*PackageFile) GetFileMd5Sums

func (c *PackageFile) GetFileMd5Sums(path string) string

GetFileMd5Sums returns file checksum by relative path from the md5sums file. NOTE: md5sums file omits configuration files.

func (*PackageFile) GetPackageChecksum

func (c *PackageFile) GetPackageChecksum() *Checksum

GetPackageChecksum returns checksum of the package itself

func (*PackageFile) Path

func (c *PackageFile) Path() string

Path returns the path which was given to open a package file if it was opened with OpenPackageFile.

func (*PackageFile) PostInstallScript

func (c *PackageFile) PostInstallScript() string

func (*PackageFile) PostUninstallScript

func (c *PackageFile) PostUninstallScript() string

func (*PackageFile) PreInstallScript

func (c *PackageFile) PreInstallScript() string

func (*PackageFile) PreUninstallScript

func (c *PackageFile) PreUninstallScript() string

func (*PackageFile) SetCalculatedChecksum

func (c *PackageFile) SetCalculatedChecksum(path, sum string) *PackageFile

SetCalculatedChecksum sets pre-calculated checksum out of the package directly. Dpkg has only md5sums and often these are neglected or incorrect (e.g. no configuration files). Sometimes md5sums is not even shipped (rare cases). In this case there is no way to get all the information out of a .deb package into a some sort of database and then later on find out if a particular file has been changed on the disk.

func (*PackageFile) SharedLibsFile

func (c *PackageFile) SharedLibsFile() *SharedLibsFile

SharedLibsFile returns parsed shlibs file data (an alternative system to symbols)

func (*PackageFile) SymbolsFile

func (c *PackageFile) SymbolsFile() *SymbolsFile

SymbolsFile returns parsed symbols file data

func (*PackageFile) TriggersFile

func (c *PackageFile) TriggersFile() *TriggerFile

TriggersFile returns parsed triggers file data.

type PackageFileReader

type PackageFileReader struct {
	// contains filtered or unexported fields
}

PackageFileReader object

func NewPackageFileReader

func NewPackageFileReader(reader io.Reader) *PackageFileReader

PackageFileReader constructor

func (*PackageFileReader) Read

func (pfr *PackageFileReader) Read() (*PackageFile, error)

Read Debian package data from the stream

func (*PackageFileReader) SetHash

func (pfr *PackageFileReader) SetHash(hash int) *PackageFileReader

SetHash of the pre-calculated checksum

func (*PackageFileReader) SetMetaonly

func (pfr *PackageFileReader) SetMetaonly(metaonly bool) *PackageFileReader

type PackageOptions

type PackageOptions struct {
	// Do not process actual files in "data" archive, only read the headers.
	// This is useful for quick scans.
	MetaOnly bool

	// Set a hash type, one of HASH_MD5, HASH_SHA1 or HASH_SHA256.
	// Default is HASH_MD5
	Hash int

	// Recalculate checksums, because dpkg is quite lousy here.
	// Usually it is a very good idea to do so, but not needed if the package
	// information is not intended to be used for system verification.
	RecalculateChecksums bool
}

type SharedLibrary

type SharedLibrary struct {
	// contains filtered or unexported fields
}

func NewSharedLibrary

func NewSharedLibrary() *SharedLibrary

func (*SharedLibrary) Dependencies

func (shl *SharedLibrary) Dependencies() []string

Dependencies returns the list of dependencies of the shared library.

func (*SharedLibrary) Name

func (shl *SharedLibrary) Name() string

Name returns the name of the shared library.

func (*SharedLibrary) Tag

func (shl *SharedLibrary) Tag() string

Tag returns possible shared library tag. Usually it is an empty string.

func (*SharedLibrary) Version

func (shl *SharedLibrary) Version() string

Version returns the version of the shared library.

type SharedLibsFile

type SharedLibsFile struct {
	// contains filtered or unexported fields
}

func NewSharedLibsFile

func NewSharedLibsFile() *SharedLibsFile

func (*SharedLibsFile) Libraries

func (shl *SharedLibsFile) Libraries() []SharedLibrary

Libraries returns shared libraries

type SymbolElement

type SymbolElement struct {
	// contains filtered or unexported fields
}

Basic symbol description. It is not parsed "to the ground" at the moment. It has only a symbol itself and the version of it.

func NewSymbolElement

func NewSymbolElement() *SymbolElement

NewSymbolElement constuctor.

func (*SymbolElement) Base

func (se *SymbolElement) Base() string

Returns the entire symbol in one row This does not parses (yet?) things like: (arch-bits=32|arch-endian=little)32bit_le_symbol@Base etc.

func (*SymbolElement) Version

func (se *SymbolElement) Version() string

Returns version of the symbol

type SymbolsFile

type SymbolsFile struct {
	// contains filtered or unexported fields
}

part of the shlibdeps

func NewSymbolsFile

func NewSymbolsFile() *SymbolsFile

func (*SymbolsFile) GetSymbols

func (smb *SymbolsFile) GetSymbols() []SymbolElement

GetSymbols returns parsed symbols file data

type Trigger

type Trigger struct {
	// contains filtered or unexported fields
}

func NewTrigger

func NewTrigger() *Trigger

func (*Trigger) Directive

func (t *Trigger) Directive() string

func (*Trigger) Name

func (t *Trigger) Name() string

type TriggerFile

type TriggerFile struct {
	// contains filtered or unexported fields
}

func NewTriggerFile

func NewTriggerFile() *TriggerFile

func (TriggerFile) Triggers

func (tf TriggerFile) Triggers() []Trigger

Triggers return known parsed triggers

Jump to

Keyboard shortcuts

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