diff --git a/deb/contents.go b/deb/contents.go index e3dc8eb7..b13a8343 100644 --- a/deb/contents.go +++ b/deb/contents.go @@ -26,8 +26,8 @@ func NewContentsIndex(db database.Storage) *ContentsIndex { } // Push adds package to contents index, calculating package contents as required -func (index *ContentsIndex) Push(p *Package, packagePool aptly.PackagePool) error { - contents := p.Contents(packagePool) +func (index *ContentsIndex) Push(p *Package, packagePool aptly.PackagePool, progress aptly.Progress) error { + contents := p.Contents(packagePool, progress) qualifiedName := []byte(p.QualifiedName()) for _, path := range contents { diff --git a/deb/package.go b/deb/package.go index c8b8ef63..764ddb71 100644 --- a/deb/package.go +++ b/deb/package.go @@ -403,32 +403,38 @@ func (p *Package) Files() PackageFiles { } // Contents returns cached package contents -func (p *Package) Contents(packagePool aptly.PackagePool) []string { +func (p *Package) Contents(packagePool aptly.PackagePool, progress aptly.Progress) []string { if p.IsSource { return nil } - return p.collection.loadContents(p, packagePool) + return p.collection.loadContents(p, packagePool, progress) } // CalculateContents looks up contents in package file -func (p *Package) CalculateContents(packagePool aptly.PackagePool) []string { +func (p *Package) CalculateContents(packagePool aptly.PackagePool, progress aptly.Progress) ([]string, error) { if p.IsSource { - return nil + return nil, nil } file := p.Files()[0] path, err := packagePool.Path(file.Filename, file.Checksums.MD5) if err != nil { - panic(err) + if progress != nil { + progress.ColoredPrintf("@y[!]@| @!Failed to build pool path: @| %s", err) + } + return nil, err } contents, err := GetContentsFromDeb(path) if err != nil { - panic(err) + if progress != nil { + progress.ColoredPrintf("@y[!]@| @!Failed to generate package contents: @| %s", err) + } + return nil, err } - return contents + return contents, nil } // UpdateFiles saves new state of files diff --git a/deb/package_collection.go b/deb/package_collection.go index abc45452..3f282ac5 100644 --- a/deb/package_collection.go +++ b/deb/package_collection.go @@ -163,7 +163,7 @@ func (collection *PackageCollection) loadFiles(p *Package) *PackageFiles { } // loadContents loads or calculates and saves package contents -func (collection *PackageCollection) loadContents(p *Package, packagePool aptly.PackagePool) []string { +func (collection *PackageCollection) loadContents(p *Package, packagePool aptly.PackagePool, progress aptly.Progress) []string { encoded, err := collection.db.Get(p.Key("xC")) if err == nil { contents := []string{} @@ -181,7 +181,11 @@ func (collection *PackageCollection) loadContents(p *Package, packagePool aptly. panic("unable to load contents") } - contents := p.CalculateContents(packagePool) + contents, err := p.CalculateContents(packagePool, progress) + if err != nil { + // failed to acquire contents, don't persist it + return contents + } var buf bytes.Buffer err = codec.NewEncoder(&buf, collection.codecHandle).Encode(contents) diff --git a/deb/publish.go b/deb/publish.go index df043fde..2f9b516f 100644 --- a/deb/publish.go +++ b/deb/publish.go @@ -574,7 +574,7 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP contentIndexes[key] = contentIndex } - contentIndex.Push(pkg, packagePool) + contentIndex.Push(pkg, packagePool, progress) } bufWriter, err = indexes.PackageIndex(component, arch, pkg.IsUdeb).BufWriter() diff --git a/system/t06_publish/PublishRepo29Test/libboost-broken-program-options-dev_1.49.0.1_i386.deb b/system/t06_publish/PublishRepo29Test/libboost-broken-program-options-dev_1.49.0.1_i386.deb new file mode 100644 index 00000000..9ac6e0d6 Binary files /dev/null and b/system/t06_publish/PublishRepo29Test/libboost-broken-program-options-dev_1.49.0.1_i386.deb differ diff --git a/system/t06_publish/PublishRepo29Test_gold b/system/t06_publish/PublishRepo29Test_gold new file mode 100644 index 00000000..505fe84a --- /dev/null +++ b/system/t06_publish/PublishRepo29Test_gold @@ -0,0 +1,14 @@ +Loading packages... +Generating metadata files and linking package files... +[!] Failed to generate package contents: unable to read .tar archive from ${HOME}/.aptly/pool/3a/0a/libboost-broken-program-options-dev_1.49.0.1_i386.deb: unexpected EOF +Finalizing metadata files... +Signing file 'Release' with gpg, please enter your passphrase when prompted: +Clearsigning file 'Release' with gpg, please enter your passphrase when prompted: + +Local repo local-repo has been successfully published. +Please setup your webserver to serve directory '${HOME}/.aptly/public' with autoindexing. +Now you can add following line to apt sources: + deb http://your-server/ maverick main +Don't forget to add your GPG key to apt with apt-key. + +You can also use `aptly serve` to publish your repositories over HTTP quickly. diff --git a/system/t06_publish/repo.py b/system/t06_publish/repo.py index 0a26ccfb..36ad902a 100644 --- a/system/t06_publish/repo.py +++ b/system/t06_publish/repo.py @@ -694,3 +694,15 @@ class PublishRepo28Test(BaseTest): self.check_not_exists('public/dists/maverick/main/Contents-i386.gz') self.check_exists('public/dists/maverick/main/debian-installer/binary-i386/Release') self.check_not_exists('public/dists/maverick/main/Contents-udeb-i386.gz') + + +class PublishRepo29Test(BaseTest): + """ + publish repo: broken .deb file for contents + """ + fixtureCmds = [ + "aptly repo create local-repo", + "aptly repo add local-repo ${testfiles}", + ] + runCmd = "aptly publish repo -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick local-repo" + gold_processor = BaseTest.expand_environ