MCPcopy
hub / github.com/perkeep/perkeep / verifyPerkeepRoot

Function verifyPerkeepRoot

make.go:294–314  ·  view source on GitHub ↗

verifyPerkeepRoot sets pkRoot and crashes if dir isn't the Perkeep root directory.

()

Source from the content-addressed store, hash-verified

292
293// verifyPerkeepRoot sets pkRoot and crashes if dir isn't the Perkeep root directory.
294func verifyPerkeepRoot() {
295 var err error
296 pkRoot, err = os.Getwd()
297 if err != nil {
298 log.Fatalf("Failed to get current directory: %v", err)
299 }
300 testFile := filepath.Join(pkRoot, "pkg", "blob", "ref.go")
301 if _, err := os.Stat(testFile); err != nil {
302 log.Fatalf("make.go must be run from the Perkeep src root directory (where make.go is). Current working directory is %s", pkRoot)
303 }
304
305 // we can't rely on perkeep.org/cmd/pk with modules on as we have no assurance
306 // the current dir is $GOPATH/src/perkeep.org, so we use ./cmd/pk instead.
307 cmd := exec.Command("go", "list", "-f", "{{.Target}}", "perkeep.org/cmd/pk")
308 cmd.Stderr = os.Stderr
309 out, err := cmd.Output()
310 if err != nil {
311 log.Fatalf("Could not run go list to find install dir: %v, %s", err, out)
312 }
313 binDir = filepath.Dir(strings.TrimSpace(string(out)))
314}
315
316const (
317 goVersionMinor = 21

Callers 1

mainFunction · 0.85

Calls 3

FatalfMethod · 0.65
StatMethod · 0.65
CommandMethod · 0.65

Tested by

no test coverage detected