1
0
Fork 0

Use go regex

Resolves #9
master
dump_stack() 2019-12-29 07:24:59 +00:00
parent 959e6e6596
commit 6a54439180
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC
1 changed files with 10 additions and 2 deletions

View File

@ -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"