MCPcopy
hub / github.com/aptly-dev/aptly / NewInstallerPackageFromControlFile

Function NewInstallerPackageFromControlFile

deb/package.go:177–214  ·  view source on GitHub ↗

NewInstallerPackageFromControlFile creates a dummy installer Package from parsed hash sum file

(input Stanza, repo *RemoteRepo, component, architecture string, d aptly.Downloader)

Source from the content-addressed store, hash-verified

175
176// NewInstallerPackageFromControlFile creates a dummy installer Package from parsed hash sum file
177func NewInstallerPackageFromControlFile(input Stanza, repo *RemoteRepo, component, architecture string, d aptly.Downloader) (*Package, error) {
178 p := &Package{
179 Name: "installer",
180 Architecture: architecture,
181 IsInstaller: true,
182 V06Plus: true,
183 extra: &Stanza{},
184 deps: &PackageDependencies{},
185 }
186
187 files := make(PackageFiles, 0)
188 files, err := files.ParseSumField(input[""], func(sum *utils.ChecksumInfo, data string) { sum.SHA256 = data }, false, false)
189 if err != nil {
190 return nil, err
191 }
192
193 var relPath string
194 if repo.Distribution == aptly.DistributionFocal {
195 relPath = filepath.Join("dists", repo.Distribution, component, fmt.Sprintf("%s-%s", p.Name, architecture), "current", "legacy-images")
196 } else {
197 relPath = filepath.Join("dists", repo.Distribution, component, fmt.Sprintf("%s-%s", p.Name, architecture), "current", "images")
198 }
199 for i := range files {
200 files[i].downloadPath = relPath
201
202 url := repo.PackageURL(files[i].DownloadURL()).String()
203 var size int64
204 size, err = d.GetLength(gocontext.TODO(), url)
205 if err != nil {
206 return nil, err
207 }
208
209 files[i].Checksums.Size = size
210 }
211
212 p.UpdateFiles(files)
213 return p, nil
214}
215
216// Key returns unique key identifying package
217func (p *Package) Key(prefix string) []byte {

Callers 2

Calls 6

UpdateFilesMethod · 0.95
ParseSumFieldMethod · 0.80
PackageURLMethod · 0.80
DownloadURLMethod · 0.80
StringMethod · 0.65
GetLengthMethod · 0.65

Tested by 1