diff --git a/cmd_snapshot.go b/cmd_snapshot.go index cd1d49c3..8da6dae2 100644 --- a/cmd_snapshot.go +++ b/cmd_snapshot.go @@ -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 { diff --git a/debian/list.go b/debian/list.go index bf978df4..d2b80892 100644 --- a/debian/list.go +++ b/debian/list.go @@ -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) } } diff --git a/debian/list_test.go b/debian/list_test.go index 8d7f7664..186eaad2 100644 --- a/debian/list_test.go +++ b/debian/list_test.go @@ -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"}) } diff --git a/debian/publish.go b/debian/publish.go index 13d9f4ba..734f6f57 100644 --- a/debian/publish.go +++ b/debian/publish.go @@ -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 {