Version: v0.9.7 Latest Latest

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

Go to latest
Published: Apr 18, 2016 License: MIT Imports: 17 Imported by: 0



Package utils collects various services: simple operations, compression, etc.



This section is empty.


View Source
var Config = ConfigStructure{
	RootDir:                filepath.Join(os.Getenv("HOME"), ".aptly"),
	DownloadConcurrency:    4,
	DownloadLimit:          0,
	Architectures:          []string{},
	DepFollowSuggests:      false,
	DepFollowRecommends:    false,
	DepFollowAllVariants:   false,
	DepFollowSource:        false,
	GpgDisableSign:         false,
	GpgDisableVerify:       false,
	DownloadSourcePackages: false,
	PpaDistributorID:       "ubuntu",
	PpaCodename:            "",
	S3PublishRoots:         map[string]S3PublishRoot{},
	SwiftPublishRoots:      map[string]SwiftPublishRoot{},

Config is configuration for aptly, shared by all modules


func CompressFile

func CompressFile(source *os.File) error

CompressFile compresses file specified by source to .gz & .bz2

It uses internal gzip and external bzip2, see: https://code.google.com/p/go/issues/detail?id=4828

func CopyFile added in v0.9.6

func CopyFile(src, dst string) error

CopyFile copeis file from src to dst, not preserving attributes

func HumanBytes added in v0.5.1

func HumanBytes(i int64) (result string)

HumanBytes converts bytes to human readable string

func LoadConfig

func LoadConfig(filename string, config *ConfigStructure) error

LoadConfig loads configuration from json file

func SaveConfig

func SaveConfig(filename string, config *ConfigStructure) error

SaveConfig write configuration to json file

func StrMapSortedKeys

func StrMapSortedKeys(m map[string]string) []string

StrMapSortedKeys returns keys of map[string]string sorted

func StrMapsEqual

func StrMapsEqual(m1, m2 map[string]string) bool

StrMapsEqual compares two map[string]string

func StrSliceDeduplicate

func StrSliceDeduplicate(s []string) []string

StrSliceDeduplicate removes dups in slice

func StrSliceHasItem

func StrSliceHasItem(s []string, item string) bool

StrSliceHasItem checks item for presence in slice

func StrSlicesEqual

func StrSlicesEqual(s1, s2 []string) bool

StrSlicesEqual compares two slices for equality

func StrSlicesSubstract

func StrSlicesSubstract(l, r []string) []string

StrSlicesSubstract finds all the strings which are in l but not in r, both slices shoult be sorted

func StringsIsSubset

func StringsIsSubset(subset, full []string, errorFmt string) error

StringsIsSubset checks that subset is strict subset of full, and returns error formatted with errorFmt otherwise


type ChecksumInfo

type ChecksumInfo struct {
	Size   int64
	MD5    string
	SHA1   string
	SHA256 string
	SHA512 string

ChecksumInfo represents checksums for a single file

func ChecksumsForFile

func ChecksumsForFile(path string) (ChecksumInfo, error)

ChecksumsForFile generates size, MD5, SHA1 & SHA256 checksums for given file

type ChecksumWriter

type ChecksumWriter struct {
	// contains filtered or unexported fields

ChecksumWriter is a writer that does checksum calculation on the fly passing data to real writer

func NewChecksumWriter

func NewChecksumWriter() *ChecksumWriter

NewChecksumWriter creates checksum calculator for given writer w

func (*ChecksumWriter) Sum

func (c *ChecksumWriter) Sum() ChecksumInfo

Sum returns caculated ChecksumInfo

func (*ChecksumWriter) Write

func (c *ChecksumWriter) Write(p []byte) (n int, err error)

Write implememnts pass-through writing with checksum calculation on the fly

type ConfigStructure

type ConfigStructure struct {
	RootDir                string                      `json:"rootDir"`
	DownloadConcurrency    int                         `json:"downloadConcurrency"`
	DownloadLimit          int64                       `json:"downloadSpeedLimit"`
	Architectures          []string                    `json:"architectures"`
	DepFollowSuggests      bool                        `json:"dependencyFollowSuggests"`
	DepFollowRecommends    bool                        `json:"dependencyFollowRecommends"`
	DepFollowAllVariants   bool                        `json:"dependencyFollowAllVariants"`
	DepFollowSource        bool                        `json:"dependencyFollowSource"`
	GpgDisableSign         bool                        `json:"gpgDisableSign"`
	GpgDisableVerify       bool                        `json:"gpgDisableVerify"`
	DownloadSourcePackages bool                        `json:"downloadSourcePackages"`
	PpaDistributorID       string                      `json:"ppaDistributorID"`
	PpaCodename            string                      `json:"ppaCodename"`
	SkipContentsPublishing bool                        `json:"skipContentsPublishing"`
	S3PublishRoots         map[string]S3PublishRoot    `json:"S3PublishEndpoints"`
	SwiftPublishRoots      map[string]SwiftPublishRoot `json:"SwiftPublishEndpoints"`

ConfigStructure is structure of main configuration

type GpgKey added in v0.9.6

type GpgKey string

GpgKey is key in GPG representation

func (GpgKey) Matches added in v0.9.6

func (key1 GpgKey) Matches(key2 GpgKey) bool

Matches checks two keys for equality

type GpgKeyInfo added in v0.9.6

type GpgKeyInfo struct {
	GoodKeys    []GpgKey
	MissingKeys []GpgKey

GpgKeyInfo is response from signature verification

type GpgSigner

type GpgSigner struct {
	// contains filtered or unexported fields

GpgSigner is implementation of Signer interface using gpg

func (*GpgSigner) ClearSign

func (g *GpgSigner) ClearSign(source string, destination string) error

ClearSign clear-signs the file

func (*GpgSigner) DetachedSign

func (g *GpgSigner) DetachedSign(source string, destination string) error

DetachedSign signs file with detached signature in ASCII format

func (*GpgSigner) Init

func (g *GpgSigner) Init() error

Init verifies availability of gpg & presence of keys

func (*GpgSigner) SetBatch added in v0.9.1

func (g *GpgSigner) SetBatch(batch bool)

SetBatch control --no-tty flag to gpg

func (*GpgSigner) SetKey

func (g *GpgSigner) SetKey(keyRef string)

SetKey sets key ID to use when signing files

func (*GpgSigner) SetKeyRing

func (g *GpgSigner) SetKeyRing(keyring, secretKeyring string)

SetKeyRing allows to set custom keyring and secretkeyring

func (*GpgSigner) SetPassphrase added in v0.9.1

func (g *GpgSigner) SetPassphrase(passphrase, passphraseFile string)

SetPassphrase sets passhprase params

type GpgVerifier

type GpgVerifier struct {
	// contains filtered or unexported fields

GpgVerifier is implementation of Verifier interface using gpgv

func (*GpgVerifier) AddKeyring

func (g *GpgVerifier) AddKeyring(keyring string)

AddKeyring adds custom keyring to GPG parameters

func (*GpgVerifier) ExtractClearsigned

func (g *GpgVerifier) ExtractClearsigned(clearsigned io.Reader) (text *os.File, err error)

ExtractClearsigned extracts cleartext from clearsigned file WITHOUT signature verification

func (*GpgVerifier) InitKeyring

func (g *GpgVerifier) InitKeyring() error

InitKeyring verifies that gpg is installed and some keys are trusted

func (*GpgVerifier) IsClearSigned added in v0.9.6

func (g *GpgVerifier) IsClearSigned(clearsigned io.Reader) (bool, error)

IsClearSigned returns true if file contains signature

func (*GpgVerifier) VerifyClearsigned

func (g *GpgVerifier) VerifyClearsigned(clearsigned io.Reader, showKeyTip bool) (*GpgKeyInfo, error)

VerifyClearsigned verifies clearsigned file using gpgv

func (*GpgVerifier) VerifyDetachedSignature

func (g *GpgVerifier) VerifyDetachedSignature(signature, cleartext io.Reader) error

VerifyDetachedSignature verifies combination of signature and cleartext using gpgv

type S3PublishRoot added in v0.7.1

type S3PublishRoot struct {
	Region           string `json:"region"`
	Bucket           string `json:"bucket"`
	Endpoint         string `json:"endpoint"`
	AccessKeyID      string `json:"awsAccessKeyID"`
	SecretAccessKey  string `json:"awsSecretAccessKey"`
	SessionToken     string `json:"awsSessionToken"`
	Prefix           string `json:"prefix"`
	ACL              string `json:"acl"`
	StorageClass     string `json:"storageClass"`
	EncryptionMethod string `json:"encryptionMethod"`
	PlusWorkaround   bool   `json:"plusWorkaround"`
	DisableMultiDel  bool   `json:"disableMultiDel"`
	ForceSigV2       bool   `json:"forceSigV2"`
	Debug            bool   `json:"debug"`

S3PublishRoot describes single S3 publishing entry point

type Signer

type Signer interface {
	Init() error
	SetKey(keyRef string)
	SetKeyRing(keyring, secretKeyring string)
	SetPassphrase(passphrase, passphraseFile string)
	SetBatch(batch bool)
	DetachedSign(source string, destination string) error
	ClearSign(source string, destination string) error

Signer interface describes facility implementing signing of files

type SwiftPublishRoot added in v0.9.1

type SwiftPublishRoot struct {
	UserName  string `json:"osname"`
	Password  string `json:"password"`
	AuthURL   string `json:"authurl"`
	Tenant    string `json:"tenant"`
	TenantID  string `json:"tenantid"`
	Prefix    string `json:"prefix"`
	Container string `json:"container"`

SwiftPublishRoot describes single OpenStack Swift publishing entry point

type Verifier

type Verifier interface {
	InitKeyring() error
	AddKeyring(keyring string)
	VerifyDetachedSignature(signature, cleartext io.Reader) error
	IsClearSigned(clearsigned io.Reader) (bool, error)
	VerifyClearsigned(clearsigned io.Reader, showKeyTip bool) (*GpgKeyInfo, error)
	ExtractClearsigned(clearsigned io.Reader) (text *os.File, err error)

Verifier interface describes signature verification factility

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL