From 71ea2be6c1e971edec3386ff50a7c53809035b53 Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Thu, 29 May 2014 14:04:06 -0700 Subject: [PATCH 1/3] deb: added Release file to each individual arch dir for d-i. --- deb/publish.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/deb/publish.go b/deb/publish.go index 08a5e80e..b4bda64b 100644 --- a/deb/publish.go +++ b/deb/publish.go @@ -438,6 +438,32 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorage release["SHA256"] += fmt.Sprintf(" %s %8d %s\n", info.SHA256, info.Size, path) } + for _, arch := range p.Architectures { + st := make(Stanza) + st["Archive"] = p.Distribution + st["Architecture"] = arch + + file, err := publishedStorage.CreateFile(filepath.Join(basePath, p.Component, + fmt.Sprintf("binary-%s", arch), "Release")) + if err != nil { + return fmt.Errorf("unable to create Release file: %s", err) + } + + bufWriter := bufio.NewWriter(file) + + err = st.WriteTo(bufWriter) + if err != nil { + return fmt.Errorf("unable to create Release file: %s", err) + } + + err = bufWriter.Flush() + if err != nil { + return fmt.Errorf("unable to create Release file: %s", err) + } + + file.Close() + } + releaseFile, err := publishedStorage.CreateFile(filepath.Join(basePath, "Release"+suffix)) if err != nil { return fmt.Errorf("unable to create Release file: %s", err) From b0f9a4a419bbc6e58742897dc9d22b6f895f4fdd Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Thu, 29 May 2014 22:07:59 -0700 Subject: [PATCH 2/3] Added tests for Release file in distribution directory --- deb/publish_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/deb/publish_test.go b/deb/publish_test.go index 0e49b20a..b2d15b4e 100644 --- a/deb/publish_test.go +++ b/deb/publish_test.go @@ -245,6 +245,16 @@ func (s *PublishedRepoSuite) TestPublish(c *C) { c.Assert(err, IsNil) c.Assert(st, IsNil) + drf, err := os.Open(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/squeeze/main/binary-i386/Release")) + c.Assert(err, IsNil) + + cfr = NewControlFileReader(drf) + st, err = cfr.ReadStanza() + c.Assert(err, IsNil) + + c.Check(st["Archive"], Equals, "squeeze") + c.Check(st["Architecture"], Equals, "i386") + _, err = os.Stat(filepath.Join(s.publishedStorage.PublicPath(), "ppa/pool/main/a/alien-arena/alien-arena-common_7.40-2_i386.deb")) c.Assert(err, IsNil) } @@ -261,6 +271,7 @@ func (s *PublishedRepoSuite) TestPublishLocalRepo(c *C) { 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/binary-i386/Release"), PathExists) } func (s *PublishedRepoSuite) TestString(c *C) { From 9a4543500c720d153cafefe89a1dc1260dfdb1df Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Thu, 29 May 2014 22:24:19 -0700 Subject: [PATCH 3/3] 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")