1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
26 "git.arvados.org/arvados.git/lib/cmd"
27 "git.arvados.org/arvados.git/sdk/go/ctxlog"
31 var Command cmd.Handler = &installCommand{}
33 const goversion = "1.20.6"
37 bundlerversion = "2.2.19"
38 singularityversion = "3.10.4"
40 geckoversion = "0.24.0"
41 gradleversion = "5.3.1"
42 nodejsversion = "v12.22.12"
43 devtestDatabasePassword = "insecure_arvados_test"
44 workbench2version = "9a62117dbe56bdfa42489415eb6696638c2bb336" // 2.6.3
47 //go:embed arvados.service
48 var arvadosServiceFile []byte
50 type installCommand struct {
57 func (inst *installCommand) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int {
58 logger := ctxlog.New(stderr, "text", "info")
59 ctx := ctxlog.Context(context.Background(), logger)
60 ctx, cancel := context.WithCancel(ctx)
66 logger.WithError(err).Info("exiting")
70 flags := flag.NewFlagSet(prog, flag.ContinueOnError)
71 flags.SetOutput(stderr)
72 versionFlag := flags.Bool("version", false, "Write version information to stdout and exit 0")
73 flags.StringVar(&inst.ClusterType, "type", "production", "cluster `type`: development, test, production, or package")
74 flags.StringVar(&inst.SourcePath, "source", "/arvados", "source tree location (required for -type=package)")
75 flags.StringVar(&inst.PackageVersion, "package-version", "0.0.0", "version string to embed in executable files")
76 flags.BoolVar(&inst.EatMyData, "eatmydata", false, "use eatmydata to speed up install")
78 if ok, code := cmd.ParseFlags(flags, prog, args, "", stderr); !ok {
80 } else if *versionFlag {
81 return cmd.Version.RunCommand(prog, args, stdin, stdout, stderr)
84 var dev, test, prod, pkg bool
85 switch inst.ClusterType {
95 err = fmt.Errorf("invalid cluster type %q (must be 'development', 'test', 'production', or 'package')", inst.ClusterType)
100 err = errors.New("production install is not yet implemented")
104 osv, err := identifyOS()
109 listdir, err := os.Open("/var/lib/apt/lists")
111 logger.Warnf("error while checking whether to run apt-get update: %s", err)
112 } else if names, _ := listdir.Readdirnames(1); len(names) == 0 {
113 // Special case for a base docker image where the
114 // package cache has been deleted and all "apt-get
115 // install" commands will fail unless we fetch repos.
116 cmd := exec.CommandContext(ctx, "apt-get", "update")
126 cmd := exec.CommandContext(ctx, "apt-get", "install", "--yes", "--no-install-recommends", "eatmydata")
127 cmd.Env = append(os.Environ(), "DEBIAN_FRONTEND=noninteractive")
136 pkgs := prodpkgs(osv)
141 "eatmydata", // install it for later steps, even if we're not using it now
145 if dev || test || pkg {
154 "default-jdk-headless",
155 "default-jre-headless",
159 "libgbm1", // cypress / workbench2 tests
175 "postgresql-contrib",
178 "python3-virtualenv",
191 "zlib1g-dev", // services/api
194 if osv.Debian && osv.Major <= 10 {
195 pkgs = append(pkgs, "iceweasel")
196 } else if osv.Debian && osv.Major >= 11 {
197 pkgs = append(pkgs, "firefox-esr")
199 pkgs = append(pkgs, "firefox")
204 "libglib2.0-dev", // singularity (conmon)
205 "libseccomp-dev", // singularity (seccomp)
206 "squashfs-tools", // singularity
207 "gnupg") // docker install recipe
210 case osv.Debian && osv.Major >= 11:
211 pkgs = append(pkgs, "g++", "libcurl4", "libcurl4-openssl-dev")
212 case osv.Debian && osv.Major >= 10:
213 pkgs = append(pkgs, "g++", "libcurl4", "libcurl4-openssl-dev")
214 case osv.Debian || osv.Ubuntu:
215 pkgs = append(pkgs, "g++", "libcurl3", "libcurl3-openssl-dev")
217 pkgs = append(pkgs, "gcc", "gcc-c++", "libcurl-devel", "postgresql-devel")
219 cmd := exec.CommandContext(ctx, "apt-get")
221 cmd = exec.CommandContext(ctx, "eatmydata", "apt-get")
223 cmd.Args = append(cmd.Args, "install", "--yes", "--no-install-recommends")
224 cmd.Args = append(cmd.Args, pkgs...)
225 cmd.Env = append(os.Environ(), "DEBIAN_FRONTEND=noninteractive")
235 if havedockerversion, err := exec.Command("docker", "--version").CombinedOutput(); err == nil {
236 logger.Printf("%s installed, assuming that version is ok", bytes.TrimSuffix(havedockerversion, []byte("\n")))
237 } else if osv.Debian {
243 codename = "bullseye"
245 err = fmt.Errorf("don't know how to install docker-ce for debian %d", osv.Major)
249 rm -f /usr/share/keyrings/docker-archive-keyring.gpg
250 curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
251 echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian/ `+codename+` stable' | \
252 tee /etc/apt/sources.list.d/docker.list
254 DEBIAN_FRONTEND=noninteractive apt-get --yes --no-install-recommends install docker-ce
260 err = fmt.Errorf("don't know how to install docker for osversion %v", osv)
265 os.Mkdir("/var/lib/arvados", 0755)
266 os.Mkdir("/var/lib/arvados/tmp", 0700)
268 u, er := user.Lookup("www-data")
270 err = fmt.Errorf("user.Lookup(%q): %w", "www-data", er)
273 uid, _ := strconv.Atoi(u.Uid)
274 gid, _ := strconv.Atoi(u.Gid)
275 os.Mkdir("/var/lib/arvados/wwwtmp", 0700)
276 err = os.Chown("/var/lib/arvados/wwwtmp", uid, gid)
281 rubymajorversion := rubyversion[:strings.LastIndex(rubyversion, ".")]
282 if haverubyversion, err := exec.Command("/var/lib/arvados/bin/ruby", "-v").CombinedOutput(); err == nil && bytes.HasPrefix(haverubyversion, []byte("ruby "+rubyversion)) {
283 logger.Print("ruby " + rubyversion + " already installed")
287 trap 'rm -r "${tmp}"' ERR EXIT
288 wget --progress=dot:giga -O- https://cache.ruby-lang.org/pub/ruby/`+rubymajorversion+`/ruby-`+rubyversion+`.tar.gz | tar -C "${tmp}" -xzf -
289 cd "${tmp}/ruby-`+rubyversion+`"
290 ./configure --disable-install-static-library --enable-shared --disable-install-doc --prefix /var/lib/arvados
293 /var/lib/arvados/bin/gem install bundler --no-document
301 if havegoversion, err := exec.Command("/usr/local/bin/go", "version").CombinedOutput(); err == nil && bytes.HasPrefix(havegoversion, []byte("go version go"+goversion+" ")) {
302 logger.Print("go " + goversion + " already installed")
306 rm -rf /var/lib/arvados/go/
307 wget --progress=dot:giga -O- https://storage.googleapis.com/golang/go`+goversion+`.linux-amd64.tar.gz | tar -C /var/lib/arvados -xzf -
308 ln -sfv /var/lib/arvados/go/bin/* /usr/local/bin/
317 if havepjsversion, err := exec.Command("/usr/local/bin/phantomjs", "--version").CombinedOutput(); err == nil && string(havepjsversion) == "1.9.8\n" {
318 logger.Print("phantomjs " + pjsversion + " already installed")
321 PJS=phantomjs-`+pjsversion+`-linux-x86_64
322 wget --progress=dot:giga -O- https://cache.arvados.org/$PJS.tar.bz2 | tar -C /var/lib/arvados -xjf -
323 ln -sfv /var/lib/arvados/$PJS/bin/phantomjs /usr/local/bin/
330 if havegeckoversion, err := exec.Command("/usr/local/bin/geckodriver", "--version").CombinedOutput(); err == nil && strings.Contains(string(havegeckoversion), " "+geckoversion+" ") {
331 logger.Print("geckodriver " + geckoversion + " already installed")
335 wget --progress=dot:giga -O- https://github.com/mozilla/geckodriver/releases/download/$GD/geckodriver-$GD-linux64.tar.gz | tar -C /var/lib/arvados/bin -xzf - geckodriver
336 ln -sfv /var/lib/arvados/bin/geckodriver /usr/local/bin/
343 if havegradleversion, err := exec.Command("/usr/local/bin/gradle", "--version").CombinedOutput(); err == nil && strings.Contains(string(havegradleversion), "Gradle "+gradleversion+"\n") {
344 logger.Print("gradle " + gradleversion + " already installed")
348 zip=/var/lib/arvados/tmp/gradle-${G}-bin.zip
350 wget --progress=dot:giga -O${zip} https://services.gradle.org/distributions/gradle-${G}-bin.zip
351 unzip -o -d /var/lib/arvados ${zip}
352 ln -sfv /var/lib/arvados/gradle-${G}/bin/gradle /usr/local/bin/
360 if havesingularityversion, err := exec.Command("/var/lib/arvados/bin/singularity", "--version").CombinedOutput(); err == nil && strings.Contains(string(havesingularityversion), singularityversion) {
361 logger.Print("singularity " + singularityversion + " already installed")
362 } else if dev || test {
364 S=`+singularityversion+`
365 tmp=/var/lib/arvados/tmp/singularity
366 trap "rm -r ${tmp}" ERR EXIT
367 cd /var/lib/arvados/tmp
368 git clone --recurse-submodules https://github.com/sylabs/singularity
371 ./mconfig --prefix=/var/lib/arvados
373 make -C ./builddir install
381 install /usr/bin/nsenter /var/lib/arvados/bin/nsenter
382 setcap "cap_sys_admin+pei cap_sys_chroot+pei" /var/lib/arvados/bin/nsenter
388 // The entry in /etc/locale.gen is "en_US.UTF-8"; once
389 // it's installed, locale -a reports it as
391 wantlocale := "en_US.UTF-8"
392 if havelocales, err := exec.Command("locale", "-a").CombinedOutput(); err == nil && bytes.Contains(havelocales, []byte(strings.Replace(wantlocale+"\n", "UTF-", "utf", 1))) {
393 logger.Print("locale " + wantlocale + " already installed")
395 err = inst.runBash(`sed -i 's/^# *\(`+wantlocale+`\)/\1/' /etc/locale.gen && locale-gen`, stdout, stderr)
410 if pgLsclusters, err2 := exec.Command("pg_lsclusters", "--no-header").CombinedOutput(); err2 != nil {
411 err = fmt.Errorf("pg_lsclusters: %s", err2)
413 } else if pgclusters := strings.Split(strings.TrimSpace(string(pgLsclusters)), "\n"); len(pgclusters) != 1 {
414 logger.Warnf("pg_lsclusters returned %d postgresql clusters -- skipping postgresql initdb/startup, hope that's ok", len(pgclusters))
415 } else if _, err = fmt.Sscanf(pgclusters[0], "%s %s %d %s %s %s %s", &pgc.Version, &pgc.Cluster, &pgc.Port, &pgc.Status, &pgc.Owner, &pgc.DataDirectory, &pgc.LogFile); err != nil {
416 err = fmt.Errorf("error parsing pg_lsclusters output: %s", err)
418 } else if pgc.Status == "online" {
419 logger.Infof("postgresql cluster %s-%s is online", pgc.Version, pgc.Cluster)
421 logger.Infof("postgresql cluster %s-%s is %s; trying to start", pgc.Version, pgc.Cluster, pgc.Status)
422 cmd := exec.Command("pg_ctlcluster", "--foreground", pgc.Version, pgc.Cluster, "start")
430 cmd.Process.Signal(syscall.SIGTERM)
431 logger.Info("sent SIGTERM; waiting for postgres to shut down")
434 err = waitPostgreSQLReady()
440 if os.Getpid() == 1 {
441 // We are the init process (presumably in a
442 // docker container) so although postgresql is
443 // installed, it's not running, and initdb
444 // might never have been run.
447 var needcoll []string
448 // If the en_US.UTF-8 locale wasn't installed when
449 // postgresql initdb ran, it needs to be added
450 // explicitly before we can use it in our test suite.
451 for _, collname := range []string{"en_US", "en_US.UTF-8"} {
452 cmd := exec.Command("sudo", "-u", "postgres", "psql", "-t", "-c", "SELECT 1 FROM pg_catalog.pg_collation WHERE collname='"+collname+"' AND collcollate IN ('en_US.UTF-8', 'en_US.utf8')")
454 out, err2 := cmd.CombinedOutput()
456 err = fmt.Errorf("error while checking postgresql collations: %s", err2)
459 if strings.Contains(string(out), "1") {
460 logger.Infof("postgresql supports collation %s", collname)
462 needcoll = append(needcoll, collname)
465 if len(needcoll) > 0 && os.Getpid() != 1 {
466 // In order for the CREATE COLLATION statement
467 // below to work, the locale must have existed
468 // when PostgreSQL started up. If we're
469 // running as init, we must have started
470 // PostgreSQL ourselves after installing the
471 // locales. Otherwise, it might need a
472 // restart, so we attempt to restart it with
474 if err = inst.runBash(`sudo systemctl restart postgresql`, stdout, stderr); err != nil {
475 logger.Warn("`systemctl restart postgresql` failed; hoping postgresql does not need to be restarted")
476 } else if err = waitPostgreSQLReady(); err != nil {
480 for _, collname := range needcoll {
481 cmd := exec.Command("sudo", "-u", "postgres", "psql", "-c", "CREATE COLLATION \""+collname+"\" (LOCALE = \"en_US.UTF-8\")")
487 err = fmt.Errorf("error adding postgresql collation %s: %s", collname, err)
492 withstuff := "WITH LOGIN SUPERUSER ENCRYPTED PASSWORD " + pq.QuoteLiteral(devtestDatabasePassword)
493 cmd := exec.Command("sudo", "-u", "postgres", "psql", "-c", "ALTER ROLE arvados "+withstuff)
495 if err := cmd.Run(); err == nil {
496 logger.Print("arvados role exists; superuser privileges added, password updated")
498 cmd := exec.Command("sudo", "-u", "postgres", "psql", "-c", "CREATE ROLE arvados "+withstuff)
510 if havenodejsversion, err := exec.Command("/usr/local/bin/node", "--version").CombinedOutput(); err == nil && string(havenodejsversion) == nodejsversion+"\n" {
511 logger.Print("nodejs " + nodejsversion + " already installed")
514 NJS=`+nodejsversion+`
515 rm -rf /var/lib/arvados/node-*-linux-x64
516 wget --progress=dot:giga -O- https://nodejs.org/dist/${NJS}/node-${NJS}-linux-x64.tar.xz | sudo tar -C /var/lib/arvados -xJf -
517 ln -sfv /var/lib/arvados/node-${NJS}-linux-x64/bin/{node,npm} /usr/local/bin/
524 if haveyarnversion, err := exec.Command("/usr/local/bin/yarn", "--version").CombinedOutput(); err == nil && len(haveyarnversion) > 0 {
525 logger.Print("yarn " + strings.TrimSpace(string(haveyarnversion)) + " already installed")
529 ln -sfv /var/lib/arvados/node-`+nodejsversion+`-linux-x64/bin/{yarn,yarnpkg} /usr/local/bin/
536 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" {
537 logger.Print("workbench2 repo is already at " + workbench2version)
540 V=`+workbench2version+`
542 if [[ ! -e arvados-workbench2 ]]; then
543 git clone https://git.arvados.org/arvados-workbench2.git
544 cd arvados-workbench2
547 cd arvados-workbench2
548 if ! git checkout $V; then
550 git checkout yarn.lock
561 if err = inst.runBash(`
562 cd /var/lib/arvados/arvados-workbench2
564 `, stdout, stderr); err != nil {
570 // Install Go programs to /var/lib/arvados/bin/
571 for _, srcdir := range []string{
572 "cmd/arvados-client",
573 "cmd/arvados-server",
575 fmt.Fprintf(stderr, "building %s...\n", srcdir)
576 cmd := exec.Command("go", "install", "-ldflags", "-X git.arvados.org/arvados.git/lib/cmd.version="+inst.PackageVersion+" -X main.version="+inst.PackageVersion+" -s -w")
577 cmd.Env = append(cmd.Env, os.Environ()...)
578 cmd.Env = append(cmd.Env, "GOBIN=/var/lib/arvados/bin")
579 cmd.Dir = filepath.Join(inst.SourcePath, srcdir)
588 // Copy assets from source tree to /var/lib/arvados/share
589 cmd := exec.Command("install", "-v", "-t", "/var/lib/arvados/share", filepath.Join(inst.SourcePath, "sdk/python/tests/nginx.conf"))
597 // Install python SDK and arv-mount in
598 // /var/lib/arvados/lib/python.
600 // setup.py writes a file in the source directory in
601 // order to include the version number in the package
602 // itself. We don't want to write to the source tree
603 // (in "arvados-package" context it's mounted
604 // readonly) so we run setup.py in a temporary copy of
606 if err = inst.runBash(`
607 v=/var/lib/arvados/lib/python
608 tmp=/var/lib/arvados/tmp/python
611 pip3 install --no-cache-dir 'setuptools>=18.5' 'pip>=7'
612 export ARVADOS_BUILDING_VERSION="`+inst.PackageVersion+`"
613 for src in "`+inst.SourcePath+`/sdk/python" "`+inst.SourcePath+`/services/fuse"; do
614 rsync -a --delete-after "$src/" "$tmp/"
616 python3 setup.py install
620 `, stdout, stderr); err != nil {
624 // Install Rails apps to /var/lib/arvados/{railsapi,workbench1}/
625 for dstdir, srcdir := range map[string]string{
626 "railsapi": "services/api",
627 "workbench1": "apps/workbench",
629 fmt.Fprintf(stderr, "building %s...\n", srcdir)
630 cmd := exec.Command("rsync",
631 "-a", "--no-owner", "--no-group", "--delete-after", "--delete-excluded",
632 "--exclude", "/coverage",
634 "--exclude", "/node_modules",
636 "--exclude", "/public/assets",
637 "--exclude", "/vendor",
638 "--exclude", "/config/environments",
639 "./", "/var/lib/arvados/"+dstdir+"/")
640 cmd.Dir = filepath.Join(inst.SourcePath, srcdir)
647 for _, cmdline := range [][]string{
648 {"mkdir", "-p", "log", "public/assets", "tmp", "vendor", ".bundle", "/var/www/.bundle", "/var/www/.gem", "/var/www/.npm", "/var/www/.passenger"},
649 {"touch", "log/production.log"},
650 {"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"},
651 {"sudo", "-u", "www-data", "/var/lib/arvados/bin/gem", "install", "--user", "--conservative", "--no-document", "bundler:" + bundlerversion},
652 {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "config", "set", "--local", "deployment", "true"},
653 {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "config", "set", "--local", "path", "/var/www/.gem"},
654 {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "config", "set", "--local", "without", "development test diagnostics performance"},
655 {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "install", "--jobs", fmt.Sprintf("%d", runtime.NumCPU())},
657 {"chown", "www-data:www-data", ".", "public/assets"},
658 // {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "config", "set", "--local", "system", "true"},
659 {"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"},
660 {"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"},
661 {"chown", "root:root", "."},
662 {"chown", "-R", "root:root", "public/assets", "vendor"},
664 {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "exec", "passenger-config", "build-native-support"},
665 {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "exec", "passenger-config", "install-standalone-runtime"},
667 if cmdline[len(cmdline)-2] == "rake" && dstdir != "workbench1" {
670 cmd = exec.Command(cmdline[0], cmdline[1:]...)
671 cmd.Dir = "/var/lib/arvados/" + dstdir
674 fmt.Fprintf(stderr, "... %s\n", cmd.Args)
680 cmd = exec.Command("sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "exec", "passenger-config", "validate-install")
681 cmd.Dir = "/var/lib/arvados/" + dstdir
685 if err != nil && !strings.Contains(err.Error(), "exit status 2") {
686 // Exit code 2 indicates there were warnings (like
687 // "other passenger installations have been detected",
688 // which we can't expect to avoid) but no errors.
689 // Other non-zero exit codes (1, 9) indicate errors.
694 // Install workbench2 app to /var/lib/arvados/workbench2/
695 if err = inst.runBash(`
696 cd /var/lib/arvados/arvados-workbench2
697 VERSION="`+inst.PackageVersion+`" BUILD_NUMBER=1 GIT_COMMIT="`+workbench2version[:9]+`" yarn build
698 rsync -a --delete-after build/ /var/lib/arvados/workbench2/
699 `, stdout, stderr); err != nil {
703 // Install arvados-cli gem (binaries go in
704 // /var/lib/arvados/bin)
705 if err = inst.runBash(`
706 /var/lib/arvados/bin/gem install --conservative --no-document arvados-cli
707 `, stdout, stderr); err != nil {
711 err = os.WriteFile("/lib/systemd/system/arvados.service", arvadosServiceFile, 0777)
716 // (fpm will do this for us in the pkg case)
717 // This is equivalent to "systemd enable", but
718 // does not depend on the systemctl program
720 symlink := "/etc/systemd/system/multi-user.target.wants/arvados.service"
721 err = os.Remove(symlink)
722 if err != nil && !errors.Is(err, os.ErrNotExist) {
725 err = os.Symlink("/lib/systemd/system/arvados.service", symlink)
731 // Add symlinks in /usr/bin for user-facing programs
732 for _, srcdst := range [][]string{
734 {"bin/arvados-client"},
735 {"bin/arvados-client", "arv"},
736 {"bin/arvados-server"},
738 {"bin/arv", "arv-ruby"},
741 {"lib/python/bin/arv-copy"},
742 {"lib/python/bin/arv-federation-migrate"},
743 {"lib/python/bin/arv-get"},
744 {"lib/python/bin/arv-keepdocker"},
745 {"lib/python/bin/arv-ls"},
746 {"lib/python/bin/arv-migrate-docker19"},
747 {"lib/python/bin/arv-normalize"},
748 {"lib/python/bin/arv-put"},
749 {"lib/python/bin/arv-ws"},
751 {"lib/python/bin/arv-mount"},
753 src := "/var/lib/arvados/" + srcdst[0]
754 if _, err = os.Stat(src); err != nil {
757 dst := srcdst[len(srcdst)-1]
758 _, dst = filepath.Split(dst)
759 dst = "/usr/bin/" + dst
761 if err != nil && !errors.Is(err, os.ErrNotExist) {
764 err = os.Symlink(src, dst)
774 type osversion struct {
781 func identifyOS() (osversion, error) {
783 f, err := os.Open("/etc/os-release")
789 kv := map[string]string{}
790 scanner := bufio.NewScanner(f)
792 line := strings.TrimSpace(scanner.Text())
793 if strings.HasPrefix(line, "#") {
796 toks := strings.SplitN(line, "=", 2)
798 return osv, fmt.Errorf("invalid line in /etc/os-release: %q", line)
801 v := strings.Trim(toks[1], `"`)
803 v = strings.Trim(v, `'`)
807 if err = scanner.Err(); err != nil {
818 return osv, fmt.Errorf("unsupported ID in /etc/os-release: %q", kv["ID"])
820 vstr := kv["VERSION_ID"]
821 if i := strings.Index(vstr, "."); i > 0 {
824 osv.Major, err = strconv.Atoi(vstr)
826 return osv, fmt.Errorf("incomprehensible VERSION_ID in /etc/os-release: %q", kv["VERSION_ID"])
831 func waitPostgreSQLReady() error {
832 for deadline := time.Now().Add(10 * time.Second); ; {
833 output, err := exec.Command("pg_isready").CombinedOutput()
836 } else if time.Now().After(deadline) {
837 return fmt.Errorf("timed out waiting for pg_isready (%q)", output)
839 time.Sleep(time.Second)
844 func (inst *installCommand) runBash(script string, stdout, stderr io.Writer) error {
845 cmd := exec.Command("bash", "-")
847 cmd = exec.Command("eatmydata", "bash", "-")
849 cmd.Stdin = bytes.NewBufferString("set -ex -o pipefail\n" + script)
855 func prodpkgs(osv osversion) []string {
870 if osv.Debian || osv.Ubuntu {
871 if osv.Debian && osv.Major == 8 {
872 pkgs = append(pkgs, "libgnutls-deb0-28") // sdk/cwl
873 } else if osv.Debian && osv.Major >= 10 || osv.Ubuntu && osv.Major >= 16 {
874 pkgs = append(pkgs, "python3-distutils") // sdk/cwl
877 "mime-support", // keep-web
879 } else if osv.Centos {
881 "fuse-libs", // services/fuse
882 "mailcap", // keep-web
885 panic("os version not supported")
889 func ProductionDependencies() ([]string, error) {
890 osv, err := identifyOS()
894 return prodpkgs(osv), nil