mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-12 03:21:33 +00:00
Push not finished file to fix build.
This commit is contained in:
111
debian/list.go
vendored
111
debian/list.go
vendored
@@ -51,15 +51,124 @@ func (l *PackageList) Len() int {
|
||||
return len(l.packages)
|
||||
}
|
||||
|
||||
// Dependency options
|
||||
const (
|
||||
// DepFollowSource pulls source packages when required
|
||||
DepFollowSource = 1 << iota
|
||||
// DepFollowSuggests pulls from suggests
|
||||
DepFollowSuggests
|
||||
// DepFollowRecommends pulls from recommends
|
||||
DepFollowRecommends
|
||||
// DepFollowAllVariants follows all variants if depends on "a | b"
|
||||
DepFollowAllVariants
|
||||
)
|
||||
|
||||
// VerifyDependencies looks for missing dependencies in package list.
|
||||
//
|
||||
// Analysis would be peformed for each architecture
|
||||
func (l *PackageList) VerifyDependencies(options int, architectures []string, sources *PackageIndexedList) ([]string, error) {
|
||||
missing := make([]string, 0, 100)
|
||||
|
||||
for _, arch := range architectures {
|
||||
for _, p := range l.packages {
|
||||
if !p.MatchesArchitecture(arch) {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, dep := range p.GetDependencies(options) {
|
||||
pkg, relation, version, err := parseDependency(dep)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to process pkg %s: %s", p, err)
|
||||
}
|
||||
|
||||
if sources.Search(arch, pkg, relation, version) != nil {
|
||||
missing = append(missing, fmt.Sprintf("%s [%s]", formatDependency(pkg, relation, version), arch))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return missing, nil
|
||||
}
|
||||
|
||||
// PackageIndexedList is a list of packages optimized for satisfying searches
|
||||
type PackageIndexedList struct {
|
||||
// List of packages, sorted by name internally
|
||||
packages []*Package
|
||||
// Map of packages for each virtual package
|
||||
providesList map[string][]*Package
|
||||
}
|
||||
|
||||
// Verify interface
|
||||
var (
|
||||
_ sort.Interface = &PackageIndexedList{}
|
||||
)
|
||||
|
||||
// NewPackageIndexedList creates empty PackageIndexedList
|
||||
func NewPackageIndexedList() *PackageIndexedList {
|
||||
return &PackageIndexedList{
|
||||
packages: make([]*Package, 0, 1024),
|
||||
}
|
||||
}
|
||||
|
||||
// Len returns number of refs
|
||||
func (l *PackageIndexedList) Len() int {
|
||||
return len(l.packages)
|
||||
}
|
||||
|
||||
// Swap swaps two refs
|
||||
func (l *PackageIndexedList) Swap(i, j int) {
|
||||
l.packages[i], l.packages[j] = l.packages[j], l.packages[i]
|
||||
}
|
||||
|
||||
// Compare compares two refs in lexographical order
|
||||
func (l *PackageIndexedList) Less(i, j int) bool {
|
||||
return l.packages[i].Name < l.packages[j].Name
|
||||
}
|
||||
|
||||
// PrepareIndex prepares list for indexing
|
||||
func (l *PackageIndexedList) PrepareIndex() {
|
||||
sort.Sort(l)
|
||||
|
||||
l.providesList = make(map[string][]*Package, 128)
|
||||
for _, p := range l.packages {
|
||||
if p.Provides != "" {
|
||||
l.providesList[p.Provides] = append(l.providesList[p.Provides], p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Append adds more packages to the index
|
||||
func (l *PackageIndexedList) Append(pl *PackageList) {
|
||||
pp := make([]*Package, pl.Len())
|
||||
i := 0
|
||||
for _, p := range pl.packages {
|
||||
pp[i] = p
|
||||
i++
|
||||
}
|
||||
|
||||
l.packages = append(l.packages, pp...)
|
||||
}
|
||||
|
||||
// Search searches package index for specified package
|
||||
func (l *PackageIndexedList) Search(arch string, pkg string, relation int, version string) *Package {
|
||||
return nil
|
||||
}
|
||||
|
||||
// PackageRefList is a list of keys of packages, this is basis for snapshot
|
||||
// and similar stuff
|
||||
//
|
||||
// Refs are sorted in lexographical order
|
||||
// Refs are sorted in lexicographical order
|
||||
type PackageRefList struct {
|
||||
// List of package keys
|
||||
Refs [][]byte
|
||||
}
|
||||
|
||||
// Verify interface
|
||||
var (
|
||||
_ sort.Interface = &PackageRefList{}
|
||||
)
|
||||
|
||||
// NewPackageRefListFromPackageList creates PackageRefList from PackageList
|
||||
func NewPackageRefListFromPackageList(list *PackageList) *PackageRefList {
|
||||
reflist := &PackageRefList{}
|
||||
|
||||
Reference in New Issue
Block a user