18947: Refactor keep-web as arvados-server command.
[arvados.git] / lib / install / deps.go
index ec1eb1957385adf4165e61a8610fd49a33b22765..62b295a1f1dca79b58d6fe4cab0f98c6b9be8b7f 100644 (file)
@@ -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"
+       bundlerversion          = "2.2.19"
        singularityversion      = "3.7.4"
        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       = "5e020488f67b5bc919796e0dc8b0b9f3b3ff23b0"
 )
 
+//go:embed arvados.service
+var arvadosServiceFile []byte
+
 type installCommand struct {
        ClusterType    string
        SourcePath     string
@@ -167,7 +172,6 @@ func (inst *installCommand) RunCommand(prog string, args []string, stdin io.Read
                        "make",
                        "net-tools",
                        "pandoc",
-                       "perl-modules",
                        "pkg-config",
                        "postgresql",
                        "postgresql-contrib",
@@ -197,10 +201,12 @@ func (inst *installCommand) RunCommand(prog string, args []string, stdin io.Read
                        pkgs = append(pkgs, "squashfs-tools") // for singularity
                }
                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 {
@@ -493,6 +499,7 @@ else
   cd arvados-workbench2
   if ! git checkout $V; then
     git fetch
+    git checkout yarn.lock
     git checkout $V
   fi
 fi
@@ -516,13 +523,10 @@ yarn install
                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",
                } {
@@ -539,6 +543,19 @@ yarn install
                        }
                }
 
+               // Symlink user-facing Go programs /usr/bin/x ->
+               // /var/lib/arvados/bin/x
+               for _, prog := range []string{"arvados-client", "arvados-server"} {
+                       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
+                       }
+               }
+
                // 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
@@ -558,7 +575,9 @@ yarn install
                                "-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+"/")
@@ -570,14 +589,25 @@ yarn install
                                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", "install", "--deployment", "--jobs", "8", "--path", "/var/www/.gem", "--without", "development test diagnostics performance"},
+
+                               {"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
@@ -610,6 +640,23 @@ rsync -a --delete-after build/ /var/lib/arvados/workbench2/
 `, 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
+               }
        }
 
        return 0