rpmtest

package
v1.4.11 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IgnoreGPGPubkey = cmpopts.IgnoreSliceElements(func(p *claircore.Package) bool {
		return p.Name == `gpg-pubkey`
	})
	SortPackages = cmpopts.SortSlices(func(a, b *claircore.Package) bool {
		return a.Name < b.Name
	})
	IgnorePackageDB = cmpopts.IgnoreFields(claircore.Package{}, ".PackageDB")
)

Does what it says on the tin.

View Source
var EpochCompare = cmp.FilterPath(
	func(p cmp.Path) bool { return p.Last().String() == ".Version" },
	cmp.Comparer(func(a, b string) bool {
		evr, vr := a, b
		if len(b) > len(a) {
			evr = b
			vr = a
		}
		return strings.Contains(evr, vr)
	}),
)

RPM Manifest doesn't have package epoch information. This checks if the VR string is contained in the EVR string.

View Source
var HintCompare = cmp.FilterPath(
	func(p cmp.Path) bool { return p.Last().String() == ".RepositoryHint" },
	cmp.Comparer(func(a, b string) bool {
		am, bm := make(map[string]string), make(map[string]string)
		for _, s := range strings.Split(a, "|") {
			if s == "" {
				continue
			}
			kv := strings.SplitN(s, ":", 2)
			if len(kv) != 2 {
				println(s)
			}
			am[kv[0]] = kv[1]
		}
		delete(am, "hash")
		for _, s := range strings.Split(b, "|") {
			if s == "" {
				continue
			}
			kv := strings.SplitN(s, ":", 2)
			bm[kv[0]] = kv[1]
		}
		delete(bm, "hash")
		return cmp.Equal(am, bm)
	}),
)

RPM Manifest doesn't have checksum information. It does have keyid information, so cook up a comparison function that understands the rpm package's packed format.

Functions

func PackagesFromRPMManifest

func PackagesFromRPMManifest(t *testing.T, r io.Reader) []*claircore.Package

Types

type Manifest

type Manifest struct {
	RPM []ManifestRPM `json:"rpms"`
}

type ManifestRPM

type ManifestRPM struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	Release string `json:"release"`
	Arch    string `json:"architecture"`
	Source  string `json:"srpm_nevra"`
	GPG     string `json:"gpg"`
}

Jump to

Keyboard shortcuts

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