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)
24 absPackageDir, err := filepath.Abs(opts.PackageDir)
26 return fmt.Errorf("error resolving PackageDir %q: %w", opts.PackageDir, err)
29 _, prog := filepath.Split(os.Args[0])
30 tmpdir, err := ioutil.TempDir("", prog+".")
32 return fmt.Errorf("TempDir: %w", err)
34 defer os.RemoveAll(tmpdir)
36 if exists, err := dockerImageExists(ctx, depsImageName); err != nil {
38 } else if !exists || opts.RebuildImage {
39 err = dockerRm(ctx, depsCtrName)
43 defer dockerRm(ctx, depsCtrName)
44 cmd := exec.CommandContext(ctx, "docker", "run",
45 "--name", depsCtrName,
46 "--tmpfs", "/tmp:exec,mode=01777",
47 "-v", absPackageDir+":/pkg:ro",
48 "--env", "DEBIAN_FRONTEND=noninteractive",
52 apt-get --allow-releaseinfo-change update
53 apt-get install -y --no-install-recommends dpkg-dev eatmydata
56 ln -s /pkg/*.deb /tmp/pkg/
57 (cd /tmp/pkg; dpkg-scanpackages --multiversion . | gzip > Packages.gz)
58 echo >/etc/apt/sources.list.d/arvados-local.list "deb [trusted=yes] file:///tmp/pkg ./"
59 apt-get --allow-releaseinfo-change update
61 eatmydata apt-get install -y --no-install-recommends arvados-server-easy postgresql
62 eatmydata apt-get remove -y dpkg-dev
63 SUDO_FORCE_REMOVE=yes apt-get autoremove -y
64 eatmydata apt-get remove -y arvados-server-easy
65 rm /etc/apt/sources.list.d/arvados-local.list
71 return fmt.Errorf("%v: %w", cmd.Args, err)
74 cmd = exec.CommandContext(ctx, "docker", "commit", depsCtrName, depsImageName)
79 return fmt.Errorf("%v: %w", cmd.Args, err)
84 if opts.PackageVersion != "" {
85 versionsuffix = "=" + opts.PackageVersion
87 cmd := exec.CommandContext(ctx, "docker", "run", "--rm",
88 "--tmpfs=/tmp:exec,mode=01777",
89 "--volume="+absPackageDir+":/pkg:ro",
90 "--env=DEBIAN_FRONTEND=noninteractive")
92 cmd.Args = append(cmd.Args,
93 "--env=domain="+opts.Live,
96 "--publish=:4440-4460:4440-4460",
97 "--publish=:9000-9020:9000-9020",
98 "--add-host="+opts.Live+":0.0.0.0",
99 "--volume=/var/lib/acme:/var/lib/acme:ro")
101 cmd.Args = append(cmd.Args,
102 "--env=domain=localhost",
103 "--env=bootargs=-shutdown")
105 cmd.Args = append(cmd.Args,
109 PATH="/var/lib/arvados/bin:$PATH"
110 apt-get --allow-releaseinfo-change update
111 apt-get install -y --no-install-recommends dpkg-dev
113 ln -s /pkg/*.deb /tmp/pkg/
114 (cd /tmp/pkg; dpkg-scanpackages --multiversion . | gzip > Packages.gz)
115 apt-get remove -y dpkg-dev
118 echo >/etc/apt/sources.list.d/arvados-local.list "deb [trusted=yes] file:///tmp/pkg ./"
119 apt-get --allow-releaseinfo-change update
120 eatmydata apt-get install --reinstall -y --no-install-recommends arvados-server-easy`+versionsuffix+`
121 SUDO_FORCE_REMOVE=yes apt-get autoremove -y
123 /etc/init.d/postgresql start
124 arvados-server init -cluster-id x1234 -domain=$domain -login=test -insecure
125 exec arvados-server boot -listen-host=0.0.0.0 -no-workbench2=false $bootargs
131 return fmt.Errorf("%v: %w", cmd.Args, err)
136 func dockerImageExists(ctx context.Context, name string) (bool, error) {
137 cli, err := client.NewClient(client.DefaultDockerHost, "1.21", nil, nil)
141 imgs, err := cli.ImageList(ctx, types.ImageListOptions{All: true})
145 for _, img := range imgs {
146 for _, tag := range img.RepoTags {