Download this file
| 1 | package thin |
| 2 | |
| 3 | import ( |
| 4 | "path/filepath" |
| 5 | "strings" |
| 6 | |
| 7 | "amadan.net/oficina/equipo/internal/runner" |
| 8 | ) |
| 9 | |
| 10 | // A Mac's tool sockets (Mac runners spec §8.2). Linux binds a step's tool |
| 11 | // socket through its directory's descriptor, so the path's length never |
| 12 | // matters there. A Mac has no /proc/self/fd: the CLI's tool endpoint |
| 13 | // dials the socket by its path, which must fit sun_path |
| 14 | // (provider.MaxDarwinSocketPath). The state directory with Linux's names |
| 15 | // does not fit a long home, so a Mac's go under the scratch root's short |
| 16 | // t/, each in a directory named only by MkdirTemp's random number (at |
| 17 | // most 10 digits), as s. |
| 18 | const ( |
| 19 | macToolDirPrefix = "" |
| 20 | macToolSocketName = "s" |
| 21 | // macToolHomeName is the longest runner user name whose sockets fit, |
| 22 | // for install_mac.go's roots (~/.local/share/equipo-runner/scratch): |
| 23 | // /Users/<name>/.local/share/equipo-runner/scratch/t/<10 digits>/s. |
| 24 | macToolHomeName = 46 |
| 25 | ) |
| 26 | |
| 27 | // macToolRoot is the directory a Mac's tool sockets go under. |
| 28 | func macToolRoot(c runner.Config) string { return filepath.Join(c.ScratchRoot, "t") } |
| 29 | |
| 30 | // macToolSocketLongest is the longest tool socket path a Mac makes under |
| 31 | // root. |
| 32 | func macToolSocketLongest(root string) string { |
| 33 | return filepath.Join(root, macToolDirPrefix+strings.Repeat("9", 10), macToolSocketName) |
| 34 | } |
| 35 | |