You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

46 lines
1.2 KiB

package config
import (
"gerrit.wikimedia.org/r/blubber/build"
)
// AptConfig represents configuration pertaining to package installation from
// existing APT sources.
//
type AptConfig struct {
Packages []string `json:"packages" validate:"dive,debianpackage"`
}
// Merge takes another AptConfig and combines the packages declared within
// with the packages of this AptConfig.
//
func (apt *AptConfig) Merge(apt2 AptConfig) {
apt.Packages = append(apt.Packages, apt2.Packages...)
}
// InstructionsForPhase injects build instructions that will install the
// declared packages during the privileged phase.
//
// PhasePrivileged
//
// Updates the APT cache, installs configured packages, and cleans up.
//
func (apt AptConfig) InstructionsForPhase(phase build.Phase) []build.Instruction {
if len(apt.Packages) > 0 {
switch phase {
case build.PhasePrivileged:
return []build.Instruction{
build.Env{map[string]string{
"DEBIAN_FRONTEND": "noninteractive",
}},
build.RunAll{[]build.Run{
{"apt-get update", []string{}},
{"apt-get install -y", apt.Packages},
{"rm -rf /var/lib/apt/lists/*", []string{}},
}},
}
}
}
return []build.Instruction{}
}