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

Method setGlibc

internal/patchpkg/patch.go:30–66  ·  view source on GitHub ↗

setGlibc configures the patcher to use the dynamic linker and libc libraries in pkg.

(pkg *packageFS)

Source from the content-addressed store, hash-verified

28// setGlibc configures the patcher to use the dynamic linker and libc libraries
29// in pkg.
30func (p *libPatcher) setGlibc(pkg *packageFS) error {
31 // Verify that we can find a directory with libc in it.
32 glob := "lib*/libc.so*"
33 matches, _ := fs.Glob(pkg, glob)
34 if len(matches) == 0 {
35 return fmt.Errorf("cannot find libc.so file matching %q", glob)
36 }
37 for i := range matches {
38 matches[i] = path.Dir(matches[i])
39 }
40 // Pick the shortest name: lib < lib32 < lib64 < libx32
41 //
42 // - lib is usually a symlink to the correct arch (e.g., lib -> lib64)
43 // - *.so is usually a symlink to the correct version (e.g., foo.so -> foo.so.2)
44 slices.Sort(matches)
45
46 lib, err := pkg.OSPath(matches[0])
47 if err != nil {
48 return err
49 }
50 p.rpath = append(p.rpath, lib)
51 slog.Debug("found new libc directory", "path", lib)
52
53 // Verify that we can find the new dynamic linker.
54 glob = "lib*/ld-linux*.so*"
55 matches, _ = fs.Glob(pkg, glob)
56 if len(matches) == 0 {
57 return fmt.Errorf("cannot find ld.so file matching %q", glob)
58 }
59 slices.Sort(matches)
60 p.ld, err = pkg.OSPath(matches[0])
61 if err != nil {
62 return err
63 }
64 slog.Debug("found new dynamic linker", "path", p.ld)
65 return nil
66}
67
68// setGlibc configures the patcher to use the standard C++ and gcc libraries in
69// pkg.

Callers 1

initMethod · 0.80

Calls 1

OSPathMethod · 0.80

Tested by

no test coverage detected