List of architectures now includes optionally "source" virtual arch.

This commit is contained in:
Andrey Smirnov
2014-02-16 21:36:25 +04:00
parent 5e8b6da1db
commit ce793c6dae
4 changed files with 19 additions and 12 deletions
+2 -2
View File
@@ -179,7 +179,7 @@ func aptlySnapshotVerify(cmd *commander.Command, args []string) error {
if len(context.architecturesList) > 0 {
architecturesList = context.architecturesList
} else {
architecturesList = packageList.Architectures()
architecturesList = packageList.Architectures(true)
}
if len(architecturesList) == 0 {
@@ -271,7 +271,7 @@ func aptlySnapshotPull(cmd *commander.Command, args []string) error {
if len(context.architecturesList) > 0 {
architecturesList = context.architecturesList
} else {
architecturesList = packageList.Architectures()
architecturesList = packageList.Architectures(false)
}
if len(architecturesList) == 0 {
+5 -3
View File
@@ -158,11 +158,13 @@ func (l *PackageList) Remove(p *Package) {
}
}
// Architectures returns list of architectures present in packages
func (l *PackageList) Architectures() (result []string) {
// Architectures returns list of architectures present in packages and flag if source packages are present.
//
// If includeSource is true, meta-architecture "source" would be present in the list
func (l *PackageList) Architectures(includeSource bool) (result []string) {
result = make([]string, 0, 10)
for _, pkg := range l.packages {
if pkg.Architecture != "all" && !utils.StrSliceHasItem(result, pkg.Architecture) {
if pkg.Architecture != "all" && (pkg.Architecture != "source" || includeSource) && !utils.StrSliceHasItem(result, pkg.Architecture) {
result = append(result, pkg.Architecture)
}
}
+11 -6
View File
@@ -51,6 +51,7 @@ func (s *PackageListSuite) SetUpTest(c *C) {
&Package{Name: "dpkg", Version: "1.6.1-3", Architecture: "amd64", Provides: []string{"package-installer"}},
&Package{Name: "libx", Version: "1.5", Architecture: "arm", PreDepends: []string{"dpkg (>= 1.6)"}},
&Package{Name: "dpkg", Version: "1.6.1-3", Architecture: "arm", Provides: []string{"package-installer"}},
&Package{Name: "dpkg", Version: "1.6.1-3", Architecture: "source", SourceArchitecture: "any"},
}
for _, p := range s.packages {
s.il.Add(p)
@@ -110,14 +111,14 @@ func (s *PackageListSuite) TestRemoveWhenIndexed(c *C) {
for i, p := range s.il.packagesIndex {
names[i] = p.Name
}
c.Check(names, DeepEquals, []string{"aa", "app", "app", "app", "app", "data", "dpkg", "dpkg", "dpkg", "libx", "mailer"})
c.Check(names, DeepEquals, []string{"aa", "app", "app", "app", "app", "data", "dpkg", "dpkg", "dpkg", "dpkg", "libx", "mailer"})
s.il.Remove(s.packages[4])
names = make([]string, s.il.Len())
for i, p := range s.il.packagesIndex {
names[i] = p.Name
}
c.Check(names, DeepEquals, []string{"aa", "app", "app", "app", "app", "data", "dpkg", "dpkg", "dpkg", "libx"})
c.Check(names, DeepEquals, []string{"aa", "app", "app", "app", "app", "data", "dpkg", "dpkg", "dpkg", "dpkg", "libx"})
c.Check(s.il.providesIndex["mail-agent"], DeepEquals, []*Package{})
s.il.Remove(s.packages[9])
@@ -125,7 +126,7 @@ func (s *PackageListSuite) TestRemoveWhenIndexed(c *C) {
for i, p := range s.il.packagesIndex {
names[i] = p.Name
}
c.Check(names, DeepEquals, []string{"aa", "app", "app", "app", "app", "data", "dpkg", "dpkg", "libx"})
c.Check(names, DeepEquals, []string{"aa", "app", "app", "app", "app", "data", "dpkg", "dpkg", "dpkg", "libx"})
c.Check(s.il.providesIndex["package-installer"], HasLen, 2)
s.il.Remove(s.packages[1])
@@ -133,7 +134,7 @@ func (s *PackageListSuite) TestRemoveWhenIndexed(c *C) {
for i, p := range s.il.packagesIndex {
names[i] = p.Name
}
c.Check(names, DeepEquals, []string{"aa", "app", "app", "app", "app", "data", "dpkg", "libx"})
c.Check(names, DeepEquals, []string{"aa", "app", "app", "app", "app", "data", "dpkg", "dpkg", "libx"})
c.Check(s.il.providesIndex["package-installer"], DeepEquals, []*Package{s.packages[11]})
}
@@ -173,7 +174,7 @@ func (s *PackageListSuite) TestAppend(c *C) {
err := s.list.Append(s.il)
c.Check(err, IsNil)
c.Check(s.list.Len(), Equals, 14)
c.Check(s.list.Len(), Equals, 15)
list := NewPackageList()
list.Add(s.p4)
@@ -238,7 +239,11 @@ func (s *PackageListSuite) TestVerifyDependencies(c *C) {
}
func (s *PackageListSuite) TestArchitectures(c *C) {
archs := s.il.Architectures()
archs := s.il.Architectures(true)
sort.Strings(archs)
c.Check(archs, DeepEquals, []string{"amd64", "arm", "i386", "s390", "source"})
archs = s.il.Architectures(false)
sort.Strings(archs)
c.Check(archs, DeepEquals, []string{"amd64", "arm", "i386", "s390"})
}
+1 -1
View File
@@ -113,7 +113,7 @@ func (p *PublishedRepo) Publish(repo *Repository, packageCollection *PackageColl
}
if len(p.Architectures) == 0 {
p.Architectures = list.Architectures()
p.Architectures = list.Architectures(true)
}
if len(p.Architectures) == 0 {