X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8257b9e9049a2592c9858941775a11b5a98ec1f7..3325e3c0aca3dcf51dfc72b63c7d077c6b6e5017:/lib/install/deps.go diff --git a/lib/install/deps.go b/lib/install/deps.go index 6090a51a7f..11ce0f188f 100644 --- a/lib/install/deps.go +++ b/lib/install/deps.go @@ -8,6 +8,7 @@ import ( "bufio" "bytes" "context" + _ "embed" "errors" "flag" "fmt" @@ -32,15 +33,19 @@ const goversion = "1.17.7" const ( rubyversion = "2.7.5" - singularityversion = "3.7.4" + bundlerversion = "2.2.19" + singularityversion = "3.9.9" pjsversion = "1.9.8" geckoversion = "0.24.0" gradleversion = "5.3.1" - nodejsversion = "v12.22.2" + nodejsversion = "v12.22.11" devtestDatabasePassword = "insecure_arvados_test" - workbench2version = "cfa81dfc3041cb459c8a0918a2732dfcf3a11d40" + workbench2version = "2454ac35292a79594c32a80430740317ed5005cf" ) +//go:embed arvados.service +var arvadosServiceFile []byte + type installCommand struct { ClusterType string SourcePath string @@ -133,7 +138,6 @@ func (inst *installCommand) RunCommand(prog string, args []string, stdin io.Read pkgs = append(pkgs, "dpkg-dev", "eatmydata", // install it for later steps, even if we're not using it now - "rsync", ) } @@ -167,7 +171,6 @@ func (inst *installCommand) RunCommand(prog string, args []string, stdin io.Read "make", "net-tools", "pandoc", - "perl-modules", "pkg-config", "postgresql", "postgresql-contrib", @@ -181,6 +184,7 @@ func (inst *installCommand) RunCommand(prog string, args []string, stdin io.Read "r-cran-markdown", "r-cran-roxygen2", "r-cran-xml", + "rsync", "sudo", "uuid-dev", "wget", @@ -195,12 +199,15 @@ func (inst *installCommand) RunCommand(prog string, args []string, stdin io.Read } if dev || test { pkgs = append(pkgs, "squashfs-tools") // for singularity + pkgs = append(pkgs, "gnupg") // for docker install recipe } switch { + case osv.Debian && osv.Major >= 11: + pkgs = append(pkgs, "libcurl4", "perl-modules-5.32") case osv.Debian && osv.Major >= 10: - pkgs = append(pkgs, "libcurl4") + pkgs = append(pkgs, "libcurl4", "perl-modules") default: - pkgs = append(pkgs, "libcurl3") + pkgs = append(pkgs, "libcurl3", "perl-modules") } cmd := exec.CommandContext(ctx, "apt-get") if inst.EatMyData { @@ -217,6 +224,37 @@ func (inst *installCommand) RunCommand(prog string, args []string, stdin io.Read } } + if dev || test { + if havedockerversion, err := exec.Command("docker", "--version").CombinedOutput(); err == nil { + logger.Printf("%s installed, assuming that version is ok", bytes.TrimSuffix(havedockerversion, []byte("\n"))) + } else if osv.Debian { + var codename string + switch osv.Major { + case 10: + codename = "buster" + case 11: + codename = "bullseye" + default: + err = fmt.Errorf("don't know how to install docker-ce for debian %d", osv.Major) + return 1 + } + err = inst.runBash(` +rm -f /usr/share/keyrings/docker-archive-keyring.gpg +curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg +echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian/ `+codename+` stable' | \ + tee /etc/apt/sources.list.d/docker.list +apt-get update +DEBIAN_FRONTEND=noninteractive apt-get --yes --no-install-recommends install docker-ce +`, stdout, stderr) + if err != nil { + return 1 + } + } else { + err = fmt.Errorf("don't know how to install docker for osversion %v", osv) + return 1 + } + } + os.Mkdir("/var/lib/arvados", 0755) os.Mkdir("/var/lib/arvados/tmp", 0700) if prod || pkg { @@ -332,6 +370,14 @@ make -C ./builddir install } } + err = inst.runBash(` +install /usr/bin/nsenter /var/lib/arvados/bin/nsenter +setcap "cap_sys_admin+pei cap_sys_chroot+pei" /var/lib/arvados/bin/nsenter +`, stdout, stderr) + if err != nil { + return 1 + } + // The entry in /etc/locale.gen is "en_US.UTF-8"; once // it's installed, locale -a reports it as // "en_US.utf8". @@ -493,6 +539,7 @@ else cd arvados-workbench2 if ! git checkout $V; then git fetch + git checkout yarn.lock git checkout $V fi fi @@ -512,12 +559,30 @@ yarn install } if prod || pkg { - // Install workbench2 app to /var/lib/arvados/workbench2/ - if err = inst.runBash(` -cd /var/lib/arvados/arvados-workbench2 -VERSION="`+inst.PackageVersion+`" BUILD_NUMBER=1 GIT_COMMIT="`+workbench2version+`" yarn build -rsync -a --delete-after build/ /var/lib/arvados/workbench2/ -`, stdout, stderr); err != nil { + // Install Go programs to /var/lib/arvados/bin/ + for _, srcdir := range []string{ + "cmd/arvados-client", + "cmd/arvados-server", + } { + fmt.Fprintf(stderr, "building %s...\n", srcdir) + cmd := exec.Command("go", "install", "-ldflags", "-X git.arvados.org/arvados.git/lib/cmd.version="+inst.PackageVersion+" -X main.version="+inst.PackageVersion+" -s -w") + cmd.Env = append(cmd.Env, os.Environ()...) + cmd.Env = append(cmd.Env, "GOBIN=/var/lib/arvados/bin") + cmd.Dir = filepath.Join(inst.SourcePath, srcdir) + cmd.Stdout = stdout + cmd.Stderr = stderr + err = cmd.Run() + if err != nil { + return 1 + } + } + + // Copy assets from source tree to /var/lib/arvados/share + cmd := exec.Command("install", "-v", "-t", "/var/lib/arvados/share", filepath.Join(inst.SourcePath, "sdk/python/tests/nginx.conf")) + cmd.Stdout = stdout + cmd.Stderr = stderr + err = cmd.Run() + if err != nil { return 1 } @@ -531,7 +596,9 @@ rsync -a --delete-after build/ /var/lib/arvados/workbench2/ "-a", "--no-owner", "--no-group", "--delete-after", "--delete-excluded", "--exclude", "/coverage", "--exclude", "/log", + "--exclude", "/node_modules", "--exclude", "/tmp", + "--exclude", "/public/assets", "--exclude", "/vendor", "--exclude", "/config/environments", "./", "/var/lib/arvados/"+dstdir+"/") @@ -543,14 +610,28 @@ rsync -a --delete-after build/ /var/lib/arvados/workbench2/ return 1 } for _, cmdline := range [][]string{ - {"mkdir", "-p", "log", "tmp", ".bundle", "/var/www/.gem", "/var/www/.bundle", "/var/www/.passenger"}, + {"mkdir", "-p", "log", "public/assets", "tmp", "vendor", ".bundle", "/var/www/.bundle", "/var/www/.gem", "/var/www/.npm", "/var/www/.passenger"}, {"touch", "log/production.log"}, - {"chown", "-R", "--from=root", "www-data:www-data", "/var/www/.gem", "/var/www/.bundle", "/var/www/.passenger", "log", "tmp", ".bundle", "Gemfile.lock", "config.ru", "config/environment.rb"}, - {"sudo", "-u", "www-data", "/var/lib/arvados/bin/gem", "install", "--user", "--conservative", "--no-document", "bundler:2.2.19"}, - {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "install", "--deployment", "--jobs", "8", "--path", "/var/www/.gem"}, + {"chown", "-R", "--from=root", "www-data:www-data", "/var/www/.bundle", "/var/www/.gem", "/var/www/.npm", "/var/www/.passenger", "log", "tmp", "vendor", ".bundle", "Gemfile.lock", "config.ru", "config/environment.rb"}, + {"sudo", "-u", "www-data", "/var/lib/arvados/bin/gem", "install", "--user", "--conservative", "--no-document", "bundler:" + bundlerversion}, + {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "config", "set", "--local", "deployment", "true"}, + {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "config", "set", "--local", "path", "/var/www/.gem"}, + {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "config", "set", "--local", "without", "development test diagnostics performance"}, + {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "install", "--jobs", "8"}, + + {"chown", "www-data:www-data", ".", "public/assets"}, + // {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "config", "set", "--local", "system", "true"}, + {"sudo", "-u", "www-data", "ARVADOS_CONFIG=none", "RAILS_GROUPS=assets", "RAILS_ENV=production", "/var/lib/arvados/bin/bundle", "exec", "rake", "npm:install"}, + {"sudo", "-u", "www-data", "ARVADOS_CONFIG=none", "RAILS_GROUPS=assets", "RAILS_ENV=production", "/var/lib/arvados/bin/bundle", "exec", "rake", "assets:precompile"}, + {"chown", "root:root", "."}, + {"chown", "-R", "root:root", "public/assets", "vendor"}, + {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "exec", "passenger-config", "build-native-support"}, {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "exec", "passenger-config", "install-standalone-runtime"}, } { + if cmdline[len(cmdline)-2] == "rake" && dstdir != "workbench1" { + continue + } cmd = exec.Command(cmdline[0], cmdline[1:]...) cmd.Dir = "/var/lib/arvados/" + dstdir cmd.Stdout = stdout @@ -575,41 +656,52 @@ rsync -a --delete-after build/ /var/lib/arvados/workbench2/ } } - // Install Go programs to /var/lib/arvados/bin/ - for _, srcdir := range []string{ - "cmd/arvados-client", - "cmd/arvados-server", - "services/arv-git-httpd", - "services/crunch-dispatch-local", - "services/crunch-dispatch-slurm", - "services/health", - "services/keep-balance", - "services/keep-web", - "services/keepproxy", - "services/keepstore", - "services/ws", - } { - fmt.Fprintf(stderr, "building %s...\n", srcdir) - cmd := exec.Command("go", "install", "-ldflags", "-X git.arvados.org/arvados.git/lib/cmd.version="+inst.PackageVersion+" -X main.version="+inst.PackageVersion) - cmd.Env = append(cmd.Env, os.Environ()...) - cmd.Env = append(cmd.Env, "GOBIN=/var/lib/arvados/bin") - cmd.Dir = filepath.Join(inst.SourcePath, srcdir) - cmd.Stdout = stdout - cmd.Stderr = stderr - err = cmd.Run() - if err != nil { - return 1 - } + // Install workbench2 app to /var/lib/arvados/workbench2/ + if err = inst.runBash(` +cd /var/lib/arvados/arvados-workbench2 +VERSION="`+inst.PackageVersion+`" BUILD_NUMBER=1 GIT_COMMIT="`+workbench2version[:9]+`" yarn build +rsync -a --delete-after build/ /var/lib/arvados/workbench2/ +`, stdout, stderr); err != nil { + return 1 } - // Copy assets from source tree to /var/lib/arvados/share - cmd := exec.Command("install", "-v", "-t", "/var/lib/arvados/share", filepath.Join(inst.SourcePath, "sdk/python/tests/nginx.conf")) - cmd.Stdout = stdout - cmd.Stderr = stderr - err = cmd.Run() + // Install arvados-cli gem (binaries go in + // /var/lib/arvados/bin) + if err = inst.runBash(` +/var/lib/arvados/bin/gem install --conservative --no-document arvados-cli +`, stdout, stderr); err != nil { + return 1 + } + + err = os.WriteFile("/lib/systemd/system/arvados.service", arvadosServiceFile, 0777) if err != nil { return 1 } + // This is equivalent to "systemd enable", but does + // not depend on the systemctl program being + // available. + symlink := "/etc/systemd/system/multi-user.target.wants/arvados.service" + err = os.Remove(symlink) + if err != nil && !errors.Is(err, os.ErrNotExist) { + return 1 + } + err = os.Symlink("/lib/systemd/system/arvados.service", symlink) + if err != nil { + return 1 + } + + // Symlink user-facing programs /usr/bin/x -> + // /var/lib/arvados/bin/x + for _, prog := range []string{"arvados-client", "arvados-server", "arv", "arv-tag"} { + err = os.Remove("/usr/bin/" + prog) + if err != nil && !errors.Is(err, os.ErrNotExist) { + return 1 + } + err = os.Symlink("/var/lib/arvados/bin/"+prog, "/usr/bin/"+prog) + if err != nil { + return 1 + } + } } return 0