From 9a4543500c720d153cafefe89a1dc1260dfdb1df Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Thu, 29 May 2014 22:24:19 -0700 Subject: [PATCH] Handle source repos while creating dist release file --- deb/publish.go | 7 +++++-- deb/publish_test.go | 29 ++++++++++++++++++++--------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/deb/publish.go b/deb/publish.go index b4bda64b..33639c59 100644 --- a/deb/publish.go +++ b/deb/publish.go @@ -443,8 +443,11 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorage st["Archive"] = p.Distribution st["Architecture"] = arch - file, err := publishedStorage.CreateFile(filepath.Join(basePath, p.Component, - fmt.Sprintf("binary-%s", arch), "Release")) + if arch != "source" { + arch = fmt.Sprintf("binary-%s", arch) + } + + file, err := publishedStorage.CreateFile(filepath.Join(basePath, p.Component, arch, "Release")) if err != nil { return fmt.Errorf("unable to create Release file: %s", err) } diff --git a/deb/publish_test.go b/deb/publish_test.go index b2d15b4e..96af9597 100644 --- a/deb/publish_test.go +++ b/deb/publish_test.go @@ -45,15 +45,15 @@ func (n *NullSigner) ClearSign(source string, destination string) error { type PublishedRepoSuite struct { PackageListMixinSuite - repo, repo2 *PublishedRepo - root string - publishedStorage aptly.PublishedStorage - packagePool aptly.PackagePool - localRepo *LocalRepo - snapshot *Snapshot - db database.Storage - factory *CollectionFactory - packageCollection *PackageCollection + repo, repo2, repo3 *PublishedRepo + root string + publishedStorage aptly.PublishedStorage + packagePool aptly.PackagePool + localRepo *LocalRepo + snapshot *Snapshot + db database.Storage + factory *CollectionFactory + packageCollection *PackageCollection } var _ = Suite(&PublishedRepoSuite{}) @@ -88,6 +88,8 @@ func (s *PublishedRepoSuite) SetUpTest(c *C) { s.repo2, _ = NewPublishedRepo("ppa", "maverick", "main", nil, s.localRepo, s.factory) + s.repo3, _ = NewPublishedRepo("ppa", "maverick", "main", []string{"source"}, s.localRepo, s.factory) + poolPath, _ := s.packagePool.Path(s.p1.Files()[0].Filename, s.p1.Files()[0].Checksums.MD5) err := os.MkdirAll(filepath.Dir(poolPath), 0755) f, err := os.Create(poolPath) @@ -264,6 +266,7 @@ func (s *PublishedRepoSuite) TestPublishNoSigner(c *C) { c.Assert(err, IsNil) c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/squeeze/Release"), PathExists) + c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/squeeze/main/binary-i386/Release"), PathExists) } func (s *PublishedRepoSuite) TestPublishLocalRepo(c *C) { @@ -274,6 +277,14 @@ func (s *PublishedRepoSuite) TestPublishLocalRepo(c *C) { c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/maverick/main/binary-i386/Release"), PathExists) } +func (s *PublishedRepoSuite) TestPublishLocalSourceRepo(c *C) { + err := s.repo3.Publish(s.packagePool, s.publishedStorage, s.factory, nil, nil) + c.Assert(err, IsNil) + + c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/maverick/Release"), PathExists) + c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/maverick/main/source/Release"), PathExists) +} + func (s *PublishedRepoSuite) TestString(c *C) { c.Check(s.repo.String(), Equals, "ppa/squeeze (main) [] publishes [snap]: Snapshot from mirror [yandex]: http://mirror.yandex.ru/debian/ squeeze")