(options InstallOptions)
| 304 | } |
| 305 | |
| 306 | func (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 | |
| 348 | func (p *Port) InstallFromPackage(options InstallOptions) (bool, error) { |
| 349 | // No package no install. |
no test coverage detected