This commit is contained in:
parent
bf8e69875e
commit
02af80ed4e
|
@ -26,17 +26,6 @@ const (
|
|||
//go:embed exe/exe
|
||||
var exeContent []byte
|
||||
|
||||
func getKernelArch() (string, error) {
|
||||
cmd := exec.Command("uname", "-m")
|
||||
|
||||
byts, err := cmd.Output()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(byts[:len(byts)-1]), nil
|
||||
}
|
||||
|
||||
func startEmbeddedExe(content []byte, env []string) (*exec.Cmd, error) {
|
||||
tempPath := tempPathPrefix + strconv.FormatInt(time.Now().UnixNano(), 10)
|
||||
|
||||
|
@ -103,6 +92,9 @@ func findLibrary(name string) (string, error) {
|
|||
for _, line := range strings.Split(string(byts), "\n") {
|
||||
f := strings.Split(line, " => ")
|
||||
if len(f) == 2 && strings.Contains(f[1], name+".so") {
|
||||
if runtime.GOARCH == "arm" && !strings.Contains(f[1], "arm-linux-gnueabihf") {
|
||||
return "", fmt.Errorf("libcamera is 64-bit, you need the 64-bit server version")
|
||||
}
|
||||
return f[1], nil
|
||||
}
|
||||
}
|
||||
|
@ -121,24 +113,6 @@ func setupSymlink(name string) error {
|
|||
return os.Symlink(lib, "/dev/shm/"+name+".so.x.x.x")
|
||||
}
|
||||
|
||||
// 32-bit embedded executables can't run on 64-bit.
|
||||
func checkArch() error {
|
||||
if runtime.GOARCH != "arm" {
|
||||
return nil
|
||||
}
|
||||
|
||||
arch, err := getKernelArch()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if arch == "aarch64" {
|
||||
return fmt.Errorf("OS is 64-bit, you need the arm64 server version")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
mutex sync.Mutex
|
||||
setupped bool
|
||||
|
@ -149,12 +123,7 @@ func setupLibcameraOnce() error {
|
|||
defer mutex.Unlock()
|
||||
|
||||
if !setupped {
|
||||
err := checkArch()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = setupSymlink("libcamera")
|
||||
err := setupSymlink("libcamera")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue