Automatically install dependencies with local packages

This commit is contained in:
Ciprian Hacman 2019-11-27 17:12:38 +02:00
parent 501baf7e56
commit d66dfc1ac1
2 changed files with 25 additions and 7 deletions

View File

@ -878,7 +878,7 @@ var dockerVersions = []dockerVersion{
Hash: "7de4211fa0dfd240d8827b93763e1eb5f0d56411",
},
},
Dependencies: []string{"libtool-ltdl", "libseccomp", "libcgroup", "policycoreutils-python"},
Dependencies: []string{"libtool-ltdl"},
},
// 18.09.9 - CentOS / Rhel8
@ -902,7 +902,7 @@ var dockerVersions = []dockerVersion{
Hash: "f6447e84479df3a58ce04a3da87ccc384663493b",
},
},
Dependencies: []string{"container-selinux", "libtool-ltdl", "libseccomp", "libcgroup", "policycoreutils-python-utils", "python3-policycoreutils"},
Dependencies: []string{"libtool-ltdl"},
},
// 19.03.4 - k8s 1.17 - https://github.com/kubernetes/kubernetes/pull/84476
@ -1005,7 +1005,7 @@ var dockerVersions = []dockerVersion{
Hash: "7de4211fa0dfd240d8827b93763e1eb5f0d56411",
},
},
Dependencies: []string{"libtool-ltdl", "libseccomp", "libcgroup", "policycoreutils-python"},
Dependencies: []string{"libtool-ltdl"},
},
// 19.03.4 - CentOS / Rhel8
@ -1029,7 +1029,7 @@ var dockerVersions = []dockerVersion{
Hash: "f6447e84479df3a58ce04a3da87ccc384663493b",
},
},
Dependencies: []string{"container-selinux", "libtool-ltdl", "libseccomp", "libcgroup", "policycoreutils-python-utils", "python3-policycoreutils"},
Dependencies: []string{"libtool-ltdl"},
},
// TIP: When adding the next version, copy the previous

View File

@ -273,10 +273,18 @@ func (_ *Package) RenderLocal(t *local.LocalTarget, a, e, changes *Package) erro
return fmt.Errorf("error creating directories %q: %v", localPackageDir, err)
}
// Append file extension for local files
var ext string
if t.HasTag(tags.TagOSFamilyDebian) {
ext = ".deb"
} else {
ext = ".rpm"
}
// Download all the debs/rpms.
localPkgs := make([]string, 1+len(e.Deps))
for i, pkg := range append([]*Package{e}, e.Deps...) {
local := path.Join(localPackageDir, pkg.Name)
local := path.Join(localPackageDir, pkg.Name+ext)
localPkgs[i] = local
var hash *hashing.Hash
if fi.StringValue(pkg.Hash) != "" {
@ -293,16 +301,26 @@ func (_ *Package) RenderLocal(t *local.LocalTarget, a, e, changes *Package) erro
}
var args []string
env := os.Environ()
if t.HasTag(tags.TagOSFamilyDebian) {
args = []string{"dpkg", "-i"}
// Only Debian releases newer than Jessie can install .deb via apt-get
// TODO: Refactor this function when Jessie support is dropped (duplicated code)
if t.HasTag("_jessie") {
args = []string{"dpkg", "-i"}
} else {
args = []string{"apt-get", "install", "--yes"}
env = append(env, "DEBIAN_FRONTEND=noninteractive")
}
} else if t.HasTag(tags.TagOSFamilyRHEL) {
args = []string{"/usr/bin/rpm", "-i"}
args = []string{"/usr/bin/yum", "install", "-y"}
} else {
return fmt.Errorf("unsupported package system")
}
args = append(args, localPkgs...)
klog.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))