mirror of
https://code.dumpstack.io/tools/appvm.git
synced 2024-11-27 10:31:31 +00:00
parent
959e6e6596
commit
6a54439180
12
appvm.go
12
appvm.go
|
@ -17,6 +17,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
@ -206,12 +207,19 @@ func generateVM(name string, verbose bool) (realpath, reginfo, qcow2 string, err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Use go regex
|
bytes, err := ioutil.ReadFile("result/bin/run-nixos-vm")
|
||||||
reginfo, _, _, err = system.System("sh", "-c", "cat result/bin/run-nixos-vm | grep -o 'regInfo=.*/registration'")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match := regexp.MustCompile("regInfo=.*/registration").FindSubmatch(bytes)
|
||||||
|
if len(match) != 1 {
|
||||||
|
err = errors.New("should be one reginfo")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
reginfo = string(match[0])
|
||||||
|
|
||||||
syscall.Unlink("result")
|
syscall.Unlink("result")
|
||||||
|
|
||||||
qcow2 = os.Getenv("HOME") + "/appvm/.fake.qcow2"
|
qcow2 = os.Getenv("HOME") + "/appvm/.fake.qcow2"
|
||||||
|
|
Loading…
Reference in a new issue