2016-10-28 05:00:58 +03:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
|
|
|
"path/filepath"
|
|
|
|
"runtime"
|
|
|
|
)
|
|
|
|
|
|
|
|
func VIRTUALBOX_DIR() string {
|
2017-08-21 20:39:31 +03:00
|
|
|
if dir, ok := os.LookupEnv("VIRTUALBOX_DIR"); ok {
|
2016-10-28 05:00:58 +03:00
|
|
|
return filepath.Clean(dir)
|
|
|
|
}
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
return "C:\\Program Files\\Oracle\\VirtualBox"
|
|
|
|
}
|
2017-08-21 20:39:31 +03:00
|
|
|
path, err := exec.LookPath("vboxmanage")
|
2016-10-28 05:00:58 +03:00
|
|
|
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 {
|
2017-08-21 20:39:31 +03:00
|
|
|
if dir, ok := os.LookupEnv("SAILFISH_DIR"); ok {
|
2016-10-28 05:00:58 +03:00
|
|
|
return filepath.Clean(dir)
|
|
|
|
}
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
return "C:\\SailfishOS"
|
|
|
|
}
|
|
|
|
return filepath.Join(os.Getenv("HOME"), "SailfishOS")
|
|
|
|
}
|
2018-03-29 13:09:04 +03:00
|
|
|
|
|
|
|
func QT_SAILFISH() bool {
|
|
|
|
return os.Getenv("QT_SAILFISH") == "true"
|
|
|
|
}
|
|
|
|
|
|
|
|
func QT_SAILFISH_VERSION() string {
|
|
|
|
if ver, ok := os.LookupEnv("QT_SAILFISH_VERSION"); ok {
|
|
|
|
return ver
|
|
|
|
}
|
2018-08-03 21:17:13 +03:00
|
|
|
return "2.2.0.29"
|
2018-03-29 13:09:04 +03:00
|
|
|
}
|