MCPcopy Index your code
hub / github.com/jetify-com/devbox / build

Method build

internal/patchpkg/builder.go:105–152  ·  view source on GitHub ↗
(ctx context.Context, pkg, out *packageFS)

Source from the content-addressed store, hash-verified

103}
104
105func (d *DerivationBuilder) build(ctx context.Context, pkg, out *packageFS) error {
106 // Create the derivation's $out directory.
107 if err := d.copyDir(out, "."); err != nil {
108 return err
109 }
110
111 if d.RestoreRefs {
112 if err := d.restoreMissingRefs(ctx, pkg); err != nil {
113 // Don't break the flake build if we're unable to
114 // restore some of the refs. Having some is still an
115 // improvement.
116 slog.ErrorContext(ctx, "unable to restore all removed refs", "err", err)
117 }
118 }
119 if err := d.findCUDA(ctx, out); err != nil {
120 slog.ErrorContext(ctx, "unable to patch CUDA libraries", "err", err)
121 }
122
123 var err error
124 for path, entry := range allFiles(pkg, ".") {
125 if ctx.Err() != nil {
126 return ctx.Err()
127 }
128 if path == "." {
129 // Skip the $out directory - we already created it.
130 continue
131 }
132
133 switch {
134 case entry.IsDir():
135 err = d.copyDir(out, path)
136 case isSymlink(entry.Type()):
137 err = d.copySymlink(pkg, out, path)
138 default:
139 err = d.copyFile(ctx, pkg, out, path)
140 }
141
142 if err != nil {
143 return err
144 }
145 }
146
147 cmd := exec.CommandContext(ctx, lookPath("bash"), "-s")
148 cmd.Stdin = bytes.NewReader(glibcPatchScript)
149 cmd.Stdout = os.Stdout
150 cmd.Stderr = os.Stderr
151 return cmd.Run()
152}
153
154func (d *DerivationBuilder) restoreMissingRefs(ctx context.Context, pkg *packageFS) error {
155 // Find store path references to build inputs that were removed

Callers 1

BuildMethod · 0.95

Calls 10

copyDirMethod · 0.95
restoreMissingRefsMethod · 0.95
findCUDAMethod · 0.95
copySymlinkMethod · 0.95
copyFileMethod · 0.95
allFilesFunction · 0.85
isSymlinkFunction · 0.85
lookPathFunction · 0.85
TypeMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected