mirror of
https://code.dumpstack.io/tools/appvm.git
synced 2024-11-23 16:41:29 +00:00
parent
959e6e6596
commit
6a54439180
12
appvm.go
12
appvm.go
|
@ -17,6 +17,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
@ -206,12 +207,19 @@ func generateVM(name string, verbose bool) (realpath, reginfo, qcow2 string, err
|
|||
return
|
||||
}
|
||||
|
||||
// TODO: Use go regex
|
||||
reginfo, _, _, err = system.System("sh", "-c", "cat result/bin/run-nixos-vm | grep -o 'regInfo=.*/registration'")
|
||||
bytes, err := ioutil.ReadFile("result/bin/run-nixos-vm")
|
||||
if err != nil {
|
||||
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")
|
||||
|
||||
qcow2 = os.Getenv("HOME") + "/appvm/.fake.qcow2"
|
||||
|
|
Loading…
Reference in a new issue