mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-06 22:18:28 +00:00
Skipping contents generation. #142
This commit is contained in:
@@ -43,6 +43,8 @@ type PublishedRepo struct {
|
|||||||
Architectures []string
|
Architectures []string
|
||||||
// SourceKind is "local"/"repo"
|
// SourceKind is "local"/"repo"
|
||||||
SourceKind string
|
SourceKind string
|
||||||
|
// Skip contents generation
|
||||||
|
SkipContents bool
|
||||||
|
|
||||||
// Map of sources by each component: component name -> source UUID
|
// Map of sources by each component: component name -> source UUID
|
||||||
Sources map[string]string
|
Sources map[string]string
|
||||||
@@ -525,6 +527,8 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
|
|||||||
|
|
||||||
list.PrepareIndex()
|
list.PrepareIndex()
|
||||||
|
|
||||||
|
contentIndexes := map[string]*ContentsIndex{}
|
||||||
|
|
||||||
err = list.ForEachIndexed(func(pkg *Package) error {
|
err = list.ForEachIndexed(func(pkg *Package) error {
|
||||||
if progress != nil {
|
if progress != nil {
|
||||||
progress.AddBar(1)
|
progress.AddBar(1)
|
||||||
@@ -550,6 +554,19 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
|
|||||||
if pkg.MatchesArchitecture(arch) {
|
if pkg.MatchesArchitecture(arch) {
|
||||||
var bufWriter *bufio.Writer
|
var bufWriter *bufio.Writer
|
||||||
|
|
||||||
|
if !p.SkipContents {
|
||||||
|
key := fmt.Sprintf("%s-%v", arch, pkg.IsUdeb)
|
||||||
|
|
||||||
|
contentIndex := contentIndexes[key]
|
||||||
|
|
||||||
|
if contentIndex == nil {
|
||||||
|
contentIndex = NewContentsIndex()
|
||||||
|
contentIndexes[key] = contentIndex
|
||||||
|
}
|
||||||
|
|
||||||
|
contentIndex.Push(pkg, packagePool)
|
||||||
|
}
|
||||||
|
|
||||||
bufWriter, err = indexes.PackageIndex(component, arch, pkg.IsUdeb).BufWriter()
|
bufWriter, err = indexes.PackageIndex(component, arch, pkg.IsUdeb).BufWriter()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -569,6 +586,7 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
|
|||||||
pkg.files = nil
|
pkg.files = nil
|
||||||
pkg.deps = nil
|
pkg.deps = nil
|
||||||
pkg.extra = nil
|
pkg.extra = nil
|
||||||
|
pkg.contents = nil
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@@ -577,6 +595,25 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
|
|||||||
return fmt.Errorf("unable to process packages: %s", err)
|
return fmt.Errorf("unable to process packages: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, arch := range p.Architectures {
|
||||||
|
for _, udeb := range []bool{true, false} {
|
||||||
|
index := contentIndexes[fmt.Sprintf("%s-%v", arch, udeb)]
|
||||||
|
if index == nil || index.Empty() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
bufWriter, err := indexes.ContentsIndex(component, arch, udeb).BufWriter()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to generate contents index: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = index.WriteTo(bufWriter)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to generate contents index: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if progress != nil {
|
if progress != nil {
|
||||||
progress.ShutdownBar()
|
progress.ShutdownBar()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,14 +117,19 @@ func (s *PublishedRepoSuite) SetUpTest(c *C) {
|
|||||||
s.packageCollection.Update(s.p3)
|
s.packageCollection.Update(s.p3)
|
||||||
|
|
||||||
s.repo, _ = NewPublishedRepo("", "ppa", "squeeze", nil, []string{"main"}, []interface{}{s.snapshot}, s.factory)
|
s.repo, _ = NewPublishedRepo("", "ppa", "squeeze", nil, []string{"main"}, []interface{}{s.snapshot}, s.factory)
|
||||||
|
s.repo.SkipContents = true
|
||||||
|
|
||||||
s.repo2, _ = NewPublishedRepo("", "ppa", "maverick", nil, []string{"main"}, []interface{}{s.localRepo}, s.factory)
|
s.repo2, _ = NewPublishedRepo("", "ppa", "maverick", nil, []string{"main"}, []interface{}{s.localRepo}, s.factory)
|
||||||
|
s.repo2.SkipContents = true
|
||||||
|
|
||||||
s.repo3, _ = NewPublishedRepo("", "linux", "natty", nil, []string{"main", "contrib"}, []interface{}{s.snapshot, s.snapshot2}, s.factory)
|
s.repo3, _ = NewPublishedRepo("", "linux", "natty", nil, []string{"main", "contrib"}, []interface{}{s.snapshot, s.snapshot2}, s.factory)
|
||||||
|
s.repo3.SkipContents = true
|
||||||
|
|
||||||
s.repo4, _ = NewPublishedRepo("", "ppa", "maverick", []string{"source"}, []string{"main"}, []interface{}{s.localRepo}, s.factory)
|
s.repo4, _ = NewPublishedRepo("", "ppa", "maverick", []string{"source"}, []string{"main"}, []interface{}{s.localRepo}, s.factory)
|
||||||
|
s.repo4.SkipContents = true
|
||||||
|
|
||||||
s.repo5, _ = NewPublishedRepo("files:other", "ppa", "maverick", []string{"source"}, []string{"main"}, []interface{}{s.localRepo}, s.factory)
|
s.repo5, _ = NewPublishedRepo("files:other", "ppa", "maverick", []string{"source"}, []string{"main"}, []interface{}{s.localRepo}, s.factory)
|
||||||
|
s.repo5.SkipContents = true
|
||||||
|
|
||||||
poolPath, _ := s.packagePool.Path(s.p1.Files()[0].Filename, s.p1.Files()[0].Checksums.MD5)
|
poolPath, _ := s.packagePool.Path(s.p1.Files()[0].Filename, s.p1.Files()[0].Checksums.MD5)
|
||||||
err := os.MkdirAll(filepath.Dir(poolPath), 0755)
|
err := os.MkdirAll(filepath.Dir(poolPath), 0755)
|
||||||
|
|||||||
Reference in New Issue
Block a user