1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
17 "github.com/docker/docker/api/types"
18 "github.com/docker/docker/client"
21 func testinstall(ctx context.Context, opts opts, stdin io.Reader, stdout, stderr io.Writer) error {
22 depsImageName := "arvados-package-deps-" + opts.TargetOS
23 depsCtrName := strings.Replace(depsImageName, ":", "-", -1)
25 _, prog := filepath.Split(os.Args[0])
26 tmpdir, err := ioutil.TempDir("", prog+".")
28 return fmt.Errorf("TempDir: %w", err)
30 defer os.RemoveAll(tmpdir)
32 if exists, err := dockerImageExists(ctx, depsImageName); err != nil {
34 } else if !exists || opts.RebuildImage {
35 err = dockerRm(ctx, depsCtrName)
39 defer dockerRm(ctx, depsCtrName)
40 cmd := exec.CommandContext(ctx, "docker", "run",
41 "--name", depsCtrName,
42 "--tmpfs", "/tmp:exec,mode=01777",
43 "-v", opts.PackageDir+":/pkg:ro",
44 "--env", "DEBIAN_FRONTEND=noninteractive",
49 apt-get install -y --no-install-recommends dpkg-dev eatmydata
52 ln -s /pkg/*.deb /tmp/pkg/
53 (cd /tmp/pkg; dpkg-scanpackages --multiversion . | gzip > Packages.gz)
54 echo >/etc/apt/sources.list.d/arvados-local.list "deb [trusted=yes] file:///tmp/pkg ./"
57 eatmydata apt-get install -y --no-install-recommends arvados-server-easy postgresql
58 eatmydata apt-get remove -y dpkg-dev
59 SUDO_FORCE_REMOVE=yes apt-get autoremove -y
60 eatmydata apt-get remove -y arvados-server-easy
61 rm /etc/apt/sources.list.d/arvados-local.list
67 return fmt.Errorf("docker run: %w", err)
70 cmd = exec.CommandContext(ctx, "docker", "commit", depsCtrName, depsImageName)
75 return fmt.Errorf("docker commit: %w", err)
80 if opts.PackageVersion != "" {
81 versionsuffix = "=" + opts.PackageVersion
83 cmd := exec.CommandContext(ctx, "docker", "run", "--rm",
84 "--tmpfs", "/tmp:exec,mode=01777",
85 "-v", opts.PackageDir+":/pkg:ro",
86 "--env", "DEBIAN_FRONTEND=noninteractive",
90 PATH="/var/lib/arvados/bin:$PATH"
92 apt-get install -y --no-install-recommends dpkg-dev
94 ln -s /pkg/*.deb /tmp/pkg/
95 (cd /tmp/pkg; dpkg-scanpackages --multiversion . | gzip > Packages.gz)
96 apt-get remove -y dpkg-dev
99 echo >/etc/apt/sources.list.d/arvados-local.list "deb [trusted=yes] file:///tmp/pkg ./"
101 eatmydata apt-get install --reinstall -y --no-install-recommends arvados-server-easy`+versionsuffix+`
102 SUDO_FORCE_REMOVE=yes apt-get autoremove -y
104 /etc/init.d/postgresql start
105 arvados-server init -cluster-id x1234
106 exec arvados-server boot -listen-host 0.0.0.0 -shutdown
112 return fmt.Errorf("docker run: %w", err)
117 func dockerImageExists(ctx context.Context, name string) (bool, error) {
118 cli, err := client.NewEnvClient()
122 imgs, err := cli.ImageList(ctx, types.ImageListOptions{All: true})
126 for _, img := range imgs {
127 for _, tag := range img.RepoTags {