apt-get: specify unattended installation

Otherwise we risk getting stuck on a prompt
This commit is contained in:
Justin Santa Barbara 2017-12-15 01:06:32 -05:00
parent 3a10a8c7cb
commit 78b84d6c2c
1 changed files with 3 additions and 1 deletions

View File

@ -296,9 +296,10 @@ func (_ *Package) RenderLocal(t *local.LocalTarget, a, e, changes *Package) erro
}
} else {
var args []string
env := os.Environ()
if t.HasTag(tags.TagOSFamilyDebian) {
args = []string{"apt-get", "install", "--yes", e.Name}
env = append(env, "DEBIAN_FRONTEND=noninteractive")
} else if t.HasTag(tags.TagOSFamilyRHEL) {
args = []string{"/usr/bin/yum", "install", "-y", e.Name}
} else {
@ -307,6 +308,7 @@ func (_ *Package) RenderLocal(t *local.LocalTarget, a, e, changes *Package) erro
glog.Infof("running command %s", args)
cmd := exec.Command(args[0], args[1:]...)
cmd.Env = env
output, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("error installing package %q: %v: %s", e.Name, err, string(output))