(ctx context.Context, pkg *packageFS)
| 278 | } |
| 279 | |
| 280 | func (d *DerivationBuilder) findRemovedRefs(ctx context.Context, pkg *packageFS) ([]fileSlice, error) { |
| 281 | var refs []fileSlice |
| 282 | matches, err := fs.Glob(pkg, "lib/python*/_sysconfigdata_*.py") |
| 283 | if err != nil { |
| 284 | return nil, err |
| 285 | } |
| 286 | for _, name := range matches { |
| 287 | if ctx.Err() != nil { |
| 288 | return nil, ctx.Err() |
| 289 | } |
| 290 | matches, err := searchFile(pkg, name, reRemovedRefs) |
| 291 | if err != nil { |
| 292 | return nil, err |
| 293 | } |
| 294 | refs = append(refs, matches...) |
| 295 | } |
| 296 | |
| 297 | pkgNameToHash := make(map[string]string, len(refs)) |
| 298 | for _, ref := range refs { |
| 299 | if ctx.Err() != nil { |
| 300 | return nil, ctx.Err() |
| 301 | } |
| 302 | |
| 303 | name := string(ref.data[33:]) |
| 304 | if hash, ok := pkgNameToHash[name]; ok { |
| 305 | copy(ref.data, hash) |
| 306 | continue |
| 307 | } |
| 308 | |
| 309 | re, err := regexp.Compile(`[0123456789abcdfghijklmnpqrsvwxyz]{32}-` + regexp.QuoteMeta(name) + `([$"'{}/[\] \t\r\n]|$)`) |
| 310 | if err != nil { |
| 311 | return nil, err |
| 312 | } |
| 313 | match := searchEnv(re) |
| 314 | if match == "" { |
| 315 | return nil, fmt.Errorf("can't find hash to restore store path reference %q in %q: regexp %q returned 0 matches", ref.data, ref.path, re) |
| 316 | } |
| 317 | hash := match[:32] |
| 318 | pkgNameToHash[name] = hash |
| 319 | copy(ref.data, hash) |
| 320 | slog.DebugContext(ctx, "restored store ref", "ref", ref) |
| 321 | } |
| 322 | return refs, nil |
| 323 | } |
| 324 | |
| 325 | func (d *DerivationBuilder) findCUDA(ctx context.Context, out *packageFS) error { |
| 326 | if d.src == nil { |
no test coverage detected