mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-07-15 11:57:59 +00:00
New upstream version 1.1.1
This commit is contained in:
+58
-33
@@ -24,12 +24,12 @@ type Package struct {
|
||||
Source string
|
||||
// List of virtual packages this package provides
|
||||
Provides []string
|
||||
// Hash of files section
|
||||
FilesHash uint64
|
||||
// Is this source package
|
||||
IsSource bool
|
||||
// Is this udeb package
|
||||
IsUdeb bool
|
||||
// Hash of files section
|
||||
FilesHash uint64
|
||||
// Is this >= 0.6 package?
|
||||
V06Plus bool
|
||||
// Offload fields
|
||||
@@ -41,6 +41,20 @@ type Package struct {
|
||||
collection *PackageCollection
|
||||
}
|
||||
|
||||
// Package types
|
||||
const (
|
||||
PackageTypeBinary = "deb"
|
||||
PackageTypeUdeb = "udeb"
|
||||
PackageTypeSource = "source"
|
||||
)
|
||||
|
||||
// Special arhictectures
|
||||
const (
|
||||
ArchitectureAll = "all"
|
||||
ArhictectureAny = "any"
|
||||
ArchitectureSource = "source"
|
||||
)
|
||||
|
||||
// Check interface
|
||||
var (
|
||||
_ json.Marshaler = &Package{}
|
||||
@@ -218,12 +232,12 @@ func (p *Package) GetField(name string) string {
|
||||
return p.Architecture
|
||||
case "$PackageType":
|
||||
if p.IsSource {
|
||||
return "source"
|
||||
return PackageTypeSource
|
||||
}
|
||||
if p.IsUdeb {
|
||||
return "udeb"
|
||||
return PackageTypeUdeb
|
||||
}
|
||||
return "deb"
|
||||
return PackageTypeBinary
|
||||
case "Name":
|
||||
return p.Name
|
||||
case "Version":
|
||||
@@ -256,7 +270,7 @@ func (p *Package) GetField(name string) string {
|
||||
|
||||
// MatchesArchitecture checks whether packages matches specified architecture
|
||||
func (p *Package) MatchesArchitecture(arch string) bool {
|
||||
if p.Architecture == "all" && arch != "source" {
|
||||
if p.Architecture == ArchitectureAll && arch != ArchitectureSource {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -344,7 +358,7 @@ func (p *Package) GetDependencies(options int) (dependencies []string) {
|
||||
if source == "" {
|
||||
source = p.Name
|
||||
}
|
||||
if strings.Index(source, ")") != -1 {
|
||||
if strings.Contains(source, ")") {
|
||||
dependencies = append(dependencies, fmt.Sprintf("%s {source}", source))
|
||||
} else {
|
||||
dependencies = append(dependencies, fmt.Sprintf("%s (= %s) {source}", source, p.Version))
|
||||
@@ -403,32 +417,47 @@ 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)
|
||||
poolPath, err := file.GetPoolPath(packagePool)
|
||||
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)
|
||||
reader, err := packagePool.Open(poolPath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
if progress != nil {
|
||||
progress.ColoredPrintf("@y[!]@| @!Failed to open package in pool: @| %s", err)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
defer reader.Close()
|
||||
|
||||
contents, err := GetContentsFromDeb(reader, file.Filename)
|
||||
if err != nil {
|
||||
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
|
||||
@@ -541,7 +570,7 @@ func (p *Package) LinkFromPool(publishedStorage aptly.PublishedStorage, packageP
|
||||
}
|
||||
|
||||
for i, f := range p.Files() {
|
||||
sourcePath, err := packagePool.Path(f.Filename, f.Checksums.MD5)
|
||||
sourcePoolPath, err := f.GetPoolPath(packagePool)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -549,7 +578,7 @@ func (p *Package) LinkFromPool(publishedStorage aptly.PublishedStorage, packageP
|
||||
relPath := filepath.Join("pool", component, poolDir)
|
||||
publishedDirectory := filepath.Join(prefix, relPath)
|
||||
|
||||
err = publishedStorage.LinkFromPool(publishedDirectory, packagePool, sourcePath, f.Checksums.MD5, force)
|
||||
err = publishedStorage.LinkFromPool(publishedDirectory, f.Filename, packagePool, sourcePoolPath, f.Checksums, force)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -590,29 +619,25 @@ func (p *Package) PoolDirectory() (string, error) {
|
||||
|
||||
// PackageDownloadTask is a element of download queue for the package
|
||||
type PackageDownloadTask struct {
|
||||
RepoURI string
|
||||
DestinationPath string
|
||||
Checksums utils.ChecksumInfo
|
||||
File *PackageFile
|
||||
Additional []PackageDownloadTask
|
||||
TempDownPath string
|
||||
}
|
||||
|
||||
// DownloadList returns list of missing package files for download in format
|
||||
// [[srcpath, dstpath]]
|
||||
func (p *Package) DownloadList(packagePool aptly.PackagePool) (result []PackageDownloadTask, err error) {
|
||||
func (p *Package) DownloadList(packagePool aptly.PackagePool, checksumStorage aptly.ChecksumStorage) (result []PackageDownloadTask, err error) {
|
||||
result = make([]PackageDownloadTask, 0, 1)
|
||||
|
||||
for _, f := range p.Files() {
|
||||
poolPath, err := packagePool.Path(f.Filename, f.Checksums.MD5)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
verified, err := f.Verify(packagePool)
|
||||
files := p.Files()
|
||||
for idx := range files {
|
||||
verified, err := files[idx].Verify(packagePool, checksumStorage)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !verified {
|
||||
result = append(result, PackageDownloadTask{RepoURI: f.DownloadURL(), DestinationPath: poolPath, Checksums: f.Checksums})
|
||||
result = append(result, PackageDownloadTask{File: &files[idx]})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -620,11 +645,11 @@ func (p *Package) DownloadList(packagePool aptly.PackagePool) (result []PackageD
|
||||
}
|
||||
|
||||
// VerifyFiles verifies that all package files have neen correctly downloaded
|
||||
func (p *Package) VerifyFiles(packagePool aptly.PackagePool) (result bool, err error) {
|
||||
func (p *Package) VerifyFiles(packagePool aptly.PackagePool, checksumStorage aptly.ChecksumStorage) (result bool, err error) {
|
||||
result = true
|
||||
|
||||
for _, f := range p.Files() {
|
||||
result, err = f.Verify(packagePool)
|
||||
result, err = f.Verify(packagePool, checksumStorage)
|
||||
if err != nil || !result {
|
||||
return
|
||||
}
|
||||
@@ -639,7 +664,7 @@ func (p *Package) FilepathList(packagePool aptly.PackagePool) ([]string, error)
|
||||
result := make([]string, len(p.Files()))
|
||||
|
||||
for i, f := range p.Files() {
|
||||
result[i], err = packagePool.RelativePath(f.Filename, f.Checksums.MD5)
|
||||
result[i], err = f.GetPoolPath(packagePool)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user