mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-07-15 11:57:59 +00:00
New upstream version 1.4.0+ds1
This commit is contained in:
+49
-9
@@ -1,6 +1,7 @@
|
||||
package deb
|
||||
|
||||
import (
|
||||
gocontext "context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
@@ -26,6 +27,8 @@ type Package struct {
|
||||
Provides []string
|
||||
// Hash of files section
|
||||
FilesHash uint64
|
||||
// Is this package a dummy installer package
|
||||
IsInstaller bool
|
||||
// Is this source package
|
||||
IsSource bool
|
||||
// Is this udeb package
|
||||
@@ -43,9 +46,10 @@ type Package struct {
|
||||
|
||||
// Package types
|
||||
const (
|
||||
PackageTypeBinary = "deb"
|
||||
PackageTypeUdeb = "udeb"
|
||||
PackageTypeSource = "source"
|
||||
PackageTypeBinary = "deb"
|
||||
PackageTypeUdeb = "udeb"
|
||||
PackageTypeSource = "source"
|
||||
PackageTypeInstaller = "installer"
|
||||
)
|
||||
|
||||
// Special arhictectures
|
||||
@@ -168,6 +172,41 @@ func NewUdebPackageFromControlFile(input Stanza) *Package {
|
||||
return p
|
||||
}
|
||||
|
||||
// NewInstallerPackageFromControlFile creates a dummy installer Package from parsed hash sum file
|
||||
func NewInstallerPackageFromControlFile(input Stanza, repo *RemoteRepo, component, architecture string, d aptly.Downloader) (*Package, error) {
|
||||
p := &Package{
|
||||
Name: "installer",
|
||||
Architecture: architecture,
|
||||
IsInstaller: true,
|
||||
V06Plus: true,
|
||||
extra: &Stanza{},
|
||||
deps: &PackageDependencies{},
|
||||
}
|
||||
|
||||
files := make(PackageFiles, 0)
|
||||
files, err := files.ParseSumField(input[""], func(sum *utils.ChecksumInfo, data string) { sum.SHA256 = data }, false, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
relPath := filepath.Join("dists", repo.Distribution, component, fmt.Sprintf("%s-%s", p.Name, architecture), "current", "images")
|
||||
for i := range files {
|
||||
files[i].downloadPath = relPath
|
||||
|
||||
url := repo.PackageURL(files[i].DownloadURL()).String()
|
||||
var size int64
|
||||
size, err = d.GetLength(gocontext.TODO(), url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
files[i].Checksums.Size = size
|
||||
}
|
||||
|
||||
p.UpdateFiles(files)
|
||||
return p, nil
|
||||
}
|
||||
|
||||
// Key returns unique key identifying package
|
||||
func (p *Package) Key(prefix string) []byte {
|
||||
if p.V06Plus {
|
||||
@@ -509,6 +548,12 @@ func (p *Package) Stanza() (result Stanza) {
|
||||
if len(sha512) > 0 {
|
||||
result["Checksums-Sha512"] = strings.Join(sha512, "")
|
||||
}
|
||||
} else if p.IsInstaller {
|
||||
sha256 := []string{}
|
||||
for _, f := range p.Files() {
|
||||
sha256 = append(sha256, fmt.Sprintf("%s %s", f.Checksums.SHA256, f.Filename))
|
||||
}
|
||||
result[""] = strings.Join(sha256, "\n")
|
||||
} else {
|
||||
f := p.Files()[0]
|
||||
result["Filename"] = f.DownloadURL()
|
||||
@@ -563,11 +608,7 @@ func (p *Package) Equals(p2 *Package) bool {
|
||||
|
||||
// LinkFromPool links package file from pool to dist's pool location
|
||||
func (p *Package) LinkFromPool(publishedStorage aptly.PublishedStorage, packagePool aptly.PackagePool,
|
||||
prefix, component string, force bool) error {
|
||||
poolDir, err := p.PoolDirectory()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
prefix, relPath string, force bool) error {
|
||||
|
||||
for i, f := range p.Files() {
|
||||
sourcePoolPath, err := f.GetPoolPath(packagePool)
|
||||
@@ -575,7 +616,6 @@ func (p *Package) LinkFromPool(publishedStorage aptly.PublishedStorage, packageP
|
||||
return err
|
||||
}
|
||||
|
||||
relPath := filepath.Join("pool", component, poolDir)
|
||||
publishedDirectory := filepath.Join(prefix, relPath)
|
||||
|
||||
err = publishedStorage.LinkFromPool(publishedDirectory, f.Filename, packagePool, sourcePoolPath, f.Checksums, force)
|
||||
|
||||
Reference in New Issue
Block a user