kola/docker: update test image creation
The previous tar script both printed a warning and was subtly wrong.
Using `docker build` is a much saner way to create this image.
More importantly, the previous method broke when run as a non-root user
due to crazy reasons.
@@ -66,9 +66,12 @@ func init() {
// make a docker container out of binaries on the host
func genDockerContainer(m platform.Machine, name string, binnames []string) error {
- genScript := "b=$(which %s) ; tar -hc $b $(ldd $b | grep -o /lib'[^ ]*' | sort -u) | docker import - %s"
+ cmd := `tmpdir=$(mktemp -d); cd $tmpdir; echo -e "FROM scratch\nCOPY . /" > Dockerfile;
+ b=$(which %s); libs=$(ldd $b | grep -o /lib'[^ ]*' | sort -u);
+ rsync -av --relative --copy-links $b $libs ./;
+ docker build -t %s .`
- if output, err := m.SSH(fmt.Sprintf(genScript, strings.Join(binnames, " "), name)); err != nil {
+ if output, err := m.SSH(fmt.Sprintf(cmd, strings.Join(binnames, " "), name)); err != nil {
return fmt.Errorf("failed to make %s container: output: %q status: %q", name, output, err)
}
