MCPcopy Create free account
hub / github.com/celer-pkg/celer / doInstallFromPkgCache

Method doInstallFromPkgCache

configs/port_install.go:306–346  ·  view source on GitHub ↗
(options InstallOptions)

Source from the content-addressed store, hash-verified

304}
305
306func (p Port) doInstallFromPkgCache(options InstallOptions) (bool, error) {
307 // Try to install dependencies first.
308 for _, nameVersion := range p.MatchedConfig.Dependencies {
309 // Skip Init() for already-processed ports.
310 key := expr.If(p.DevDep || p.HostDep, nameVersion+"[dev]", nameVersion)
311 if visitedPorts[key] {
312 continue
313 }
314
315 var port Port
316 port.DevDep = false
317 port.HostDep = p.HostDep
318 port.Parent = p.NameVersion()
319 port.installReport = p.installReport
320 if err := port.Init(p.ctx, nameVersion); err != nil {
321 return false, err
322 }
323 if _, err := port.Install(options); err != nil {
324 return false, err
325 }
326 visitedPorts[key] = true
327 }
328
329 // Calculate buildhash.
330 buildhash, err := p.buildhash()
331 if err != nil {
332 return false, fmt.Errorf("failed to calculate buildhash -> %w", err)
333 }
334
335 // Read cache file and extract them to package dir.
336 artifactCache := p.ctx.PkgCacheConfig().GetArtifactCache()
337 if artifactCache != nil {
338 if fromWhere, err := artifactCache.Restore(p.NameVersion(), buildhash, p.PackageDir); err != nil {
339 return false, fmt.Errorf("read cache with buildhash: %s", err)
340 } else if fromWhere != "" {
341 return true, nil
342 }
343 }
344
345 return false, nil
346}
347
348func (p *Port) InstallFromPackage(options InstallOptions) (bool, error) {
349 // No package no install.

Callers 1

InstallFromPkgCacheMethod · 0.95

Calls 8

NameVersionMethod · 0.95
InitMethod · 0.95
InstallMethod · 0.95
buildhashMethod · 0.95
IfFunction · 0.92
GetArtifactCacheMethod · 0.65
PkgCacheConfigMethod · 0.65
RestoreMethod · 0.65

Tested by

no test coverage detected