mirror of
https://code.dumpstack.io/tools/appvm.git
synced 2024-11-25 21:53:01 +00:00
Avoid of changing current work directory
This commit is contained in:
parent
1fbbdee76a
commit
2146397906
11
appvm.go
11
appvm.go
@ -106,10 +106,10 @@ func streamStdOutErr(command *cmd.Cmd) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateVM(name string, verbose bool) (realpath, reginfo, qcow2 string, err error) {
|
func generateVM(path, name string, verbose bool) (realpath, reginfo, qcow2 string, err error) {
|
||||||
command := cmd.NewCmdOptions(cmd.Options{Buffered: false, Streaming: true},
|
command := cmd.NewCmdOptions(cmd.Options{Buffered: false, Streaming: true},
|
||||||
"nix-build", "<nixpkgs/nixos>", "-A", "config.system.build.vm",
|
"nix-build", "<nixpkgs/nixos>", "-A", "config.system.build.vm",
|
||||||
"-I", "nixos-config=nix/"+name+".nix", "-I", ".")
|
"-I", "nixos-config="+path+"/nix/"+name+".nix", "-I", path)
|
||||||
|
|
||||||
if verbose {
|
if verbose {
|
||||||
go streamStdOutErr(command)
|
go streamStdOutErr(command)
|
||||||
@ -170,12 +170,7 @@ func generateAppVM(l *libvirt.Libvirt,
|
|||||||
nixName, vmName, appvmPath, sharedDir string,
|
nixName, vmName, appvmPath, sharedDir string,
|
||||||
verbose, online bool) (err error) {
|
verbose, online bool) (err error) {
|
||||||
|
|
||||||
err = os.Chdir(appvmPath)
|
realpath, reginfo, qcow2, err := generateVM(appvmPath, nixName, verbose)
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
realpath, reginfo, qcow2, err := generateVM(nixName, verbose)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -190,15 +190,10 @@ func generate(pkg, bin, vmname string, build bool) (err error) {
|
|||||||
log.Println("Configuration file is saved to", appFilename)
|
log.Println("Configuration file is saved to", appFilename)
|
||||||
|
|
||||||
if build {
|
if build {
|
||||||
err = os.Chdir(configDir)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if vmname != "" {
|
if vmname != "" {
|
||||||
_, _, _, err = generateVM(vmname, true)
|
_, _, _, err = generateVM(configDir, vmname, true)
|
||||||
} else {
|
} else {
|
||||||
_, _, _, err = generateVM(name, true)
|
_, _, _, err = generateVM(configDir, name, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user