21055: Add debian 12 codename to fix docker install.
[arvados.git] / lib / install / deps.go
index 44215a773a60ece36078111c0e02504c39022cd9..c4f104f30ac142055dcd94a5b724f1ef7e453b78 100644 (file)
@@ -17,6 +17,7 @@ import (
        "os/exec"
        "os/user"
        "path/filepath"
+       "runtime"
        "strconv"
        "strings"
        "syscall"
@@ -29,18 +30,17 @@ import (
 
 var Command cmd.Handler = &installCommand{}
 
-const goversion = "1.17.7"
+const goversion = "1.20.6"
 
 const (
-       rubyversion             = "2.7.5"
+       rubyversion             = "2.7.7"
        bundlerversion          = "2.2.19"
-       singularityversion      = "3.9.9"
+       singularityversion      = "3.10.4"
        pjsversion              = "1.9.8"
        geckoversion            = "0.24.0"
        gradleversion           = "5.3.1"
-       nodejsversion           = "v12.22.11"
+       nodejsversion           = "v12.22.12"
        devtestDatabasePassword = "insecure_arvados_test"
-       workbench2version       = "2454ac35292a79594c32a80430740317ed5005cf"
 )
 
 //go:embed arvados.service
@@ -154,16 +154,14 @@ func (inst *installCommand) RunCommand(prog string, args []string, stdin io.Read
                        "default-jre-headless",
                        "gettext",
                        "libattr1-dev",
-                       "libcrypt-ssleay-perl",
                        "libfuse-dev",
+                       "libgbm1", // cypress / workbench2 tests
                        "libgnutls28-dev",
-                       "libjson-perl",
                        "libpam-dev",
                        "libpcre3-dev",
                        "libpq-dev",
                        "libreadline-dev",
                        "libssl-dev",
-                       "libwww-perl",
                        "libxml2-dev",
                        "libxslt1-dev",
                        "linkchecker",
@@ -189,25 +187,33 @@ func (inst *installCommand) RunCommand(prog string, args []string, stdin io.Read
                        "uuid-dev",
                        "wget",
                        "xvfb",
+                       "zlib1g-dev", // services/api
                )
                if test {
                        if osv.Debian && osv.Major <= 10 {
                                pkgs = append(pkgs, "iceweasel")
+                       } else if osv.Debian && osv.Major >= 11 {
+                               pkgs = append(pkgs, "firefox-esr")
                        } else {
                                pkgs = append(pkgs, "firefox")
                        }
                }
                if dev || test {
-                       pkgs = append(pkgs, "squashfs-tools") // for singularity
-                       pkgs = append(pkgs, "gnupg")          // for docker install recipe
+                       pkgs = append(pkgs,
+                               "libglib2.0-dev", // singularity (conmon)
+                               "libseccomp-dev", // singularity (seccomp)
+                               "squashfs-tools", // singularity
+                               "gnupg")          // docker install recipe
                }
                switch {
                case osv.Debian && osv.Major >= 11:
-                       pkgs = append(pkgs, "libcurl4", "perl-modules-5.32")
+                       pkgs = append(pkgs, "g++", "libcurl4", "libcurl4-openssl-dev")
                case osv.Debian && osv.Major >= 10:
-                       pkgs = append(pkgs, "libcurl4", "perl-modules")
-               default:
-                       pkgs = append(pkgs, "libcurl3", "perl-modules")
+                       pkgs = append(pkgs, "g++", "libcurl4", "libcurl4-openssl-dev")
+               case osv.Debian || osv.Ubuntu:
+                       pkgs = append(pkgs, "g++", "libcurl3", "libcurl3-openssl-dev")
+               case osv.Centos:
+                       pkgs = append(pkgs, "gcc", "gcc-c++", "libcurl-devel", "postgresql-devel")
                }
                cmd := exec.CommandContext(ctx, "apt-get")
                if inst.EatMyData {
@@ -225,7 +231,7 @@ func (inst *installCommand) RunCommand(prog string, args []string, stdin io.Read
        }
 
        if dev || test {
-               if havedockerversion, err := exec.Command("docker", "--version").CombinedOutput(); err == nil {
+               if havedockerversion, err2 := exec.Command("docker", "--version").CombinedOutput(); err2 == nil {
                        logger.Printf("%s installed, assuming that version is ok", bytes.TrimSuffix(havedockerversion, []byte("\n")))
                } else if osv.Debian {
                        var codename string
@@ -234,6 +240,8 @@ func (inst *installCommand) RunCommand(prog string, args []string, stdin io.Read
                                codename = "buster"
                        case 11:
                                codename = "bullseye"
+                       case 12:
+                               codename = "bookworm"
                        default:
                                err = fmt.Errorf("don't know how to install docker-ce for debian %d", osv.Major)
                                return 1
@@ -253,6 +261,21 @@ DEBIAN_FRONTEND=noninteractive apt-get --yes --no-install-recommends install doc
                        err = fmt.Errorf("don't know how to install docker for osversion %v", osv)
                        return 1
                }
+
+               err = inst.runBash(`
+key=fs.inotify.max_user_watches
+min=524288
+if [[ "$(sysctl --values "${key}")" -lt "${min}" ]]; then
+    sysctl "${key}=${min}"
+    # writing sysctl worked, so we should make it permanent
+    echo "${key}=${min}" | tee -a /etc/sysctl.conf
+    sysctl -p
+fi
+`, stdout, stderr)
+               if err != nil {
+                       err = fmt.Errorf("couldn't set fs.inotify.max_user_watches value. (Is this a docker container? Fix this on the docker host by adding fs.inotify.max_user_watches=524288 to /etc/sysctl.conf and running `sysctl -p`)")
+                       return 1
+               }
        }
 
        os.Mkdir("/var/lib/arvados", 0755)
@@ -358,7 +381,7 @@ S=`+singularityversion+`
 tmp=/var/lib/arvados/tmp/singularity
 trap "rm -r ${tmp}" ERR EXIT
 cd /var/lib/arvados/tmp
-git clone https://github.com/sylabs/singularity
+git clone --recurse-submodules https://github.com/sylabs/singularity
 cd singularity
 git checkout v${S}
 ./mconfig --prefix=/var/lib/arvados
@@ -505,6 +528,7 @@ setcap "cap_sys_admin+pei cap_sys_chroot+pei" /var/lib/arvados/bin/nsenter
                } else {
                        err = inst.runBash(`
 NJS=`+nodejsversion+`
+rm -rf /var/lib/arvados/node-*-linux-x64
 wget --progress=dot:giga -O- https://nodejs.org/dist/${NJS}/node-${NJS}-linux-x64.tar.xz | sudo tar -C /var/lib/arvados -xJf -
 ln -sfv /var/lib/arvados/node-${NJS}-linux-x64/bin/{node,npm} /usr/local/bin/
 `, stdout, stderr)
@@ -524,38 +548,6 @@ ln -sfv /var/lib/arvados/node-`+nodejsversion+`-linux-x64/bin/{yarn,yarnpkg} /us
                                return 1
                        }
                }
-
-               if havewb2version, err := exec.Command("git", "--git-dir=/var/lib/arvados/arvados-workbench2/.git", "log", "-n1", "--format=%H").CombinedOutput(); err == nil && string(havewb2version) == workbench2version+"\n" {
-                       logger.Print("workbench2 repo is already at " + workbench2version)
-               } else {
-                       err = inst.runBash(`
-V=`+workbench2version+`
-cd /var/lib/arvados
-if [[ ! -e arvados-workbench2 ]]; then
-  git clone https://git.arvados.org/arvados-workbench2.git
-  cd arvados-workbench2
-  git checkout $V
-else
-  cd arvados-workbench2
-  if ! git checkout $V; then
-    git fetch
-    git checkout yarn.lock
-    git checkout $V
-  fi
-fi
-rm -rf build
-`, stdout, stderr)
-                       if err != nil {
-                               return 1
-                       }
-               }
-
-               if err = inst.runBash(`
-cd /var/lib/arvados/arvados-workbench2
-yarn install
-`, stdout, stderr); err != nil {
-                       return 1
-               }
        }
 
        if prod || pkg {
@@ -563,8 +555,6 @@ yarn install
                for _, srcdir := range []string{
                        "cmd/arvados-client",
                        "cmd/arvados-server",
-                       "services/crunch-dispatch-local",
-                       "services/crunch-dispatch-slurm",
                } {
                        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")
@@ -579,19 +569,6 @@ 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
@@ -601,6 +578,33 @@ yarn install
                        return 1
                }
 
+               // Install python SDK and arv-mount in
+               // /var/lib/arvados/lib/python.
+               //
+               // setup.py writes a file in the source directory in
+               // order to include the version number in the package
+               // itself.  We don't want to write to the source tree
+               // (in "arvados-package" context it's mounted
+               // readonly) so we run setup.py in a temporary copy of
+               // the source dir.
+               if err = inst.runBash(`
+v=/var/lib/arvados/lib/python
+tmp=/var/lib/arvados/tmp/python
+python3 -m venv "$v"
+. "$v/bin/activate"
+pip3 install --no-cache-dir 'setuptools>=18.5' 'pip>=7'
+export ARVADOS_BUILDING_VERSION="`+inst.PackageVersion+`"
+for src in "`+inst.SourcePath+`/sdk/python" "`+inst.SourcePath+`/services/fuse"; do
+  rsync -a --delete-after "$src/" "$tmp/"
+  cd "$tmp"
+  python3 setup.py install
+  cd ..
+  rm -rf "$tmp"
+done
+`, stdout, stderr); err != nil {
+                       return 1
+               }
+
                // Install Rails apps to /var/lib/arvados/{railsapi,workbench1}/
                for dstdir, srcdir := range map[string]string{
                        "railsapi":   "services/api",
@@ -629,12 +633,15 @@ yarn install
                                {"touch", "log/production.log"},
                                {"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"},
+                               {"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", fmt.Sprintf("%d", runtime.NumCPU())},
 
                                {"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"},
+                               {"sudo", "-u", "www-data", "ARVADOS_CONFIG=none", "RAILS_GROUPS=assets", "RAILS_ENV=production", "PATH=/var/lib/arvados/bin:" + os.Getenv("PATH"), "/var/lib/arvados/bin/bundle", "exec", "rake", "npm:install"},
+                               {"sudo", "-u", "www-data", "ARVADOS_CONFIG=none", "RAILS_GROUPS=assets", "RAILS_ENV=production", "PATH=/var/lib/arvados/bin:" + os.Getenv("PATH"), "/var/lib/arvados/bin/bundle", "exec", "rake", "assets:precompile"},
                                {"chown", "root:root", "."},
                                {"chown", "-R", "root:root", "public/assets", "vendor"},
 
@@ -670,28 +677,78 @@ yarn install
 
                // 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
+cd `+inst.SourcePath+`/services/workbench2
+VERSION="`+inst.PackageVersion+`" BUILD_NUMBER=1 GIT_COMMIT=000000000 yarn build
 rsync -a --delete-after build/ /var/lib/arvados/workbench2/
 `, stdout, stderr); err != nil {
                        return 1
                }
 
+               // 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
+               if prod {
+                       // (fpm will do this for us in the pkg case)
+                       // 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
+                       }
                }
-               err = os.Symlink("/lib/systemd/system/arvados.service", symlink)
-               if err != nil {
-                       return 1
+
+               // Add symlinks in /usr/bin for user-facing programs
+               for _, srcdst := range [][]string{
+                       // go
+                       {"bin/arvados-client"},
+                       {"bin/arvados-client", "arv"},
+                       {"bin/arvados-server"},
+                       // sdk/cli
+                       {"bin/arv", "arv-ruby"},
+                       {"bin/arv-tag"},
+                       // sdk/python
+                       {"lib/python/bin/arv-copy"},
+                       {"lib/python/bin/arv-federation-migrate"},
+                       {"lib/python/bin/arv-get"},
+                       {"lib/python/bin/arv-keepdocker"},
+                       {"lib/python/bin/arv-ls"},
+                       {"lib/python/bin/arv-migrate-docker19"},
+                       {"lib/python/bin/arv-normalize"},
+                       {"lib/python/bin/arv-put"},
+                       {"lib/python/bin/arv-ws"},
+                       // services/fuse
+                       {"lib/python/bin/arv-mount"},
+               } {
+                       src := "/var/lib/arvados/" + srcdst[0]
+                       if _, err = os.Stat(src); err != nil {
+                               return 1
+                       }
+                       dst := srcdst[len(srcdst)-1]
+                       _, dst = filepath.Split(dst)
+                       dst = "/usr/bin/" + dst
+                       err = os.Remove(dst)
+                       if err != nil && !errors.Is(err, os.ErrNotExist) {
+                               return 1
+                       }
+                       err = os.Symlink(src, dst)
+                       if err != nil {
+                               return 1
+                       }
                }
        }
 
@@ -791,7 +848,7 @@ func prodpkgs(osv osversion) []string {
                "libcurl3-gnutls",
                "libxslt1.1",
                "nginx",
-               "python",
+               "python3",
                "sudo",
        }
        if osv.Debian || osv.Ubuntu {
@@ -801,21 +858,12 @@ func prodpkgs(osv osversion) []string {
                        pkgs = append(pkgs, "python3-distutils") // sdk/cwl
                }
                return append(pkgs,
-                       "g++",
-                       "libcurl4-openssl-dev", // services/api
-                       "libpq-dev",
-                       "libpython2.7", // services/fuse
                        "mime-support", // keep-web
-                       "zlib1g-dev",   // services/api
                )
        } else if osv.Centos {
                return append(pkgs,
                        "fuse-libs", // services/fuse
-                       "gcc",
-                       "gcc-c++",
-                       "libcurl-devel",    // services/api
-                       "mailcap",          // keep-web
-                       "postgresql-devel", // services/api
+                       "mailcap",   // keep-web
                )
        } else {
                panic("os version not supported")