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,
95 "--publish=:4430-4450:4430-4450",
96 "--add-host="+opts.Live+":0.0.0.0",
97 "--volume=/var/lib/acme:/var/lib/acme:ro")
99 cmd.Args = append(cmd.Args,
100 "--env=domain=localhost",
101 "--env=bootargs=-shutdown")
103 cmd.Args = append(cmd.Args,
107 PATH="/var/lib/arvados/bin:$PATH"
108 apt-get --allow-releaseinfo-change update
109 apt-get install -y --no-install-recommends dpkg-dev
111 ln -s /pkg/*.deb /tmp/pkg/
112 (cd /tmp/pkg; dpkg-scanpackages --multiversion . | gzip > Packages.gz)
113 apt-get remove -y dpkg-dev
116 echo >/etc/apt/sources.list.d/arvados-local.list "deb [trusted=yes] file:///tmp/pkg ./"
117 apt-get --allow-releaseinfo-change update
118 eatmydata apt-get install --reinstall -y --no-install-recommends arvados-server-easy`+versionsuffix+`
119 SUDO_FORCE_REMOVE=yes apt-get autoremove -y
121 /etc/init.d/postgresql start
122 arvados-server init -cluster-id x1234 -domain=$domain -login=test -insecure
123 exec arvados-server boot -listen-host=0.0.0.0 -no-workbench2=false $bootargs
129 return fmt.Errorf("%v: %w", cmd.Args, err)
134 func dockerImageExists(ctx context.Context, name string) (bool, error) {
135 cli, err := client.NewEnvClient()
139 imgs, err := cli.ImageList(ctx, types.ImageListOptions{All: true})
143 for _, img := range imgs {
144 for _, tag := range img.RepoTags {