2016-10-28 05:00:58 +03:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
|
|
|
"path/filepath"
|
|
|
|
"runtime"
|
|
|
|
)
|
|
|
|
|
|
|
|
func VIRTUALBOX_DIR() string {
|
|
|
|
if dir := os.Getenv("VIRTUALBOX_DIR"); dir != "" {
|
|
|
|
return filepath.Clean(dir)
|
|
|
|
}
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
return "C:\\Program Files\\Oracle\\VirtualBox"
|
|
|
|
}
|
|
|
|
var path, err = exec.LookPath("vboxmanage")
|
|
|
|
if err != nil {
|
|
|
|
Log.WithError(err).Error("failed to find vboxmanage in your PATH")
|
|
|
|
}
|
2017-03-11 00:54:09 +03:00
|
|
|
path = filepath.Dir(path)
|
|
|
|
if !filepath.IsAbs(path) {
|
|
|
|
path, err = filepath.Abs(path)
|
|
|
|
if err != nil {
|
|
|
|
Log.WithError(err).WithField("path", path).Fatal("can't resolve absolute path")
|
|
|
|
}
|
|
|
|
}
|
2016-10-28 05:00:58 +03:00
|
|
|
return path
|
|
|
|
}
|
|
|
|
|
|
|
|
func SAILFISH_DIR() string {
|
|
|
|
if dir := os.Getenv("SAILFISH_DIR"); dir != "" {
|
|
|
|
return filepath.Clean(dir)
|
|
|
|
}
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
return "C:\\SailfishOS"
|
|
|
|
}
|
|
|
|
return filepath.Join(os.Getenv("HOME"), "SailfishOS")
|
|
|
|
}
|