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.18.8"
37 bundlerversion = "2.2.19"
38 singularityversion = "3.9.9"
40 geckoversion = "0.24.0"
41 gradleversion = "5.3.1"
42 nodejsversion = "v12.22.12"
43 devtestDatabasePassword = "insecure_arvados_test"
44 workbench2version = "e30e54d674c95ee15e296c71e471c1555bdc5a38" // 2.4.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")
197 pkgs = append(pkgs, "firefox")
201 pkgs = append(pkgs, "squashfs-tools") // for singularity
202 pkgs = append(pkgs, "gnupg") // for docker install recipe
205 case osv.Debian && osv.Major >= 11:
206 pkgs = append(pkgs, "g++", "libcurl4", "libcurl4-openssl-dev")
207 case osv.Debian && osv.Major >= 10:
208 pkgs = append(pkgs, "g++", "libcurl4", "libcurl4-openssl-dev")
209 case osv.Debian || osv.Ubuntu:
210 pkgs = append(pkgs, "g++", "libcurl3", "libcurl3-openssl-dev")
212 pkgs = append(pkgs, "gcc", "gcc-c++", "libcurl-devel", "postgresql-devel")
214 cmd := exec.CommandContext(ctx, "apt-get")
216 cmd = exec.CommandContext(ctx, "eatmydata", "apt-get")
218 cmd.Args = append(cmd.Args, "install", "--yes", "--no-install-recommends")
219 cmd.Args = append(cmd.Args, pkgs...)
220 cmd.Env = append(os.Environ(), "DEBIAN_FRONTEND=noninteractive")
230 if havedockerversion, err := exec.Command("docker", "--version").CombinedOutput(); err == nil {
231 logger.Printf("%s installed, assuming that version is ok", bytes.TrimSuffix(havedockerversion, []byte("\n")))
232 } else if osv.Debian {
238 codename = "bullseye"
240 err = fmt.Errorf("don't know how to install docker-ce for debian %d", osv.Major)
244 rm -f /usr/share/keyrings/docker-archive-keyring.gpg
245 curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
246 echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian/ `+codename+` stable' | \
247 tee /etc/apt/sources.list.d/docker.list
249 DEBIAN_FRONTEND=noninteractive apt-get --yes --no-install-recommends install docker-ce
255 err = fmt.Errorf("don't know how to install docker for osversion %v", osv)
260 os.Mkdir("/var/lib/arvados", 0755)
261 os.Mkdir("/var/lib/arvados/tmp", 0700)
263 u, er := user.Lookup("www-data")
265 err = fmt.Errorf("user.Lookup(%q): %w", "www-data", er)
268 uid, _ := strconv.Atoi(u.Uid)
269 gid, _ := strconv.Atoi(u.Gid)
270 os.Mkdir("/var/lib/arvados/wwwtmp", 0700)
271 err = os.Chown("/var/lib/arvados/wwwtmp", uid, gid)
276 rubymajorversion := rubyversion[:strings.LastIndex(rubyversion, ".")]
277 if haverubyversion, err := exec.Command("/var/lib/arvados/bin/ruby", "-v").CombinedOutput(); err == nil && bytes.HasPrefix(haverubyversion, []byte("ruby "+rubyversion)) {
278 logger.Print("ruby " + rubyversion + " already installed")
282 trap 'rm -r "${tmp}"' ERR EXIT
283 wget --progress=dot:giga -O- https://cache.ruby-lang.org/pub/ruby/`+rubymajorversion+`/ruby-`+rubyversion+`.tar.gz | tar -C "${tmp}" -xzf -
284 cd "${tmp}/ruby-`+rubyversion+`"
285 ./configure --disable-install-static-library --enable-shared --disable-install-doc --prefix /var/lib/arvados
288 /var/lib/arvados/bin/gem install bundler --no-document
296 if havegoversion, err := exec.Command("/usr/local/bin/go", "version").CombinedOutput(); err == nil && bytes.HasPrefix(havegoversion, []byte("go version go"+goversion+" ")) {
297 logger.Print("go " + goversion + " already installed")
301 rm -rf /var/lib/arvados/go/
302 wget --progress=dot:giga -O- https://storage.googleapis.com/golang/go`+goversion+`.linux-amd64.tar.gz | tar -C /var/lib/arvados -xzf -
303 ln -sfv /var/lib/arvados/go/bin/* /usr/local/bin/
312 if havepjsversion, err := exec.Command("/usr/local/bin/phantomjs", "--version").CombinedOutput(); err == nil && string(havepjsversion) == "1.9.8\n" {
313 logger.Print("phantomjs " + pjsversion + " already installed")
316 PJS=phantomjs-`+pjsversion+`-linux-x86_64
317 wget --progress=dot:giga -O- https://cache.arvados.org/$PJS.tar.bz2 | tar -C /var/lib/arvados -xjf -
318 ln -sfv /var/lib/arvados/$PJS/bin/phantomjs /usr/local/bin/
325 if havegeckoversion, err := exec.Command("/usr/local/bin/geckodriver", "--version").CombinedOutput(); err == nil && strings.Contains(string(havegeckoversion), " "+geckoversion+" ") {
326 logger.Print("geckodriver " + geckoversion + " already installed")
330 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
331 ln -sfv /var/lib/arvados/bin/geckodriver /usr/local/bin/
338 if havegradleversion, err := exec.Command("/usr/local/bin/gradle", "--version").CombinedOutput(); err == nil && strings.Contains(string(havegradleversion), "Gradle "+gradleversion+"\n") {
339 logger.Print("gradle " + gradleversion + " already installed")
343 zip=/var/lib/arvados/tmp/gradle-${G}-bin.zip
345 wget --progress=dot:giga -O${zip} https://services.gradle.org/distributions/gradle-${G}-bin.zip
346 unzip -o -d /var/lib/arvados ${zip}
347 ln -sfv /var/lib/arvados/gradle-${G}/bin/gradle /usr/local/bin/
355 if havesingularityversion, err := exec.Command("/var/lib/arvados/bin/singularity", "--version").CombinedOutput(); err == nil && strings.Contains(string(havesingularityversion), singularityversion) {
356 logger.Print("singularity " + singularityversion + " already installed")
357 } else if dev || test {
359 S=`+singularityversion+`
360 tmp=/var/lib/arvados/tmp/singularity
361 trap "rm -r ${tmp}" ERR EXIT
362 cd /var/lib/arvados/tmp
363 git clone https://github.com/sylabs/singularity
366 ./mconfig --prefix=/var/lib/arvados
368 make -C ./builddir install
376 install /usr/bin/nsenter /var/lib/arvados/bin/nsenter
377 setcap "cap_sys_admin+pei cap_sys_chroot+pei" /var/lib/arvados/bin/nsenter
383 // The entry in /etc/locale.gen is "en_US.UTF-8"; once
384 // it's installed, locale -a reports it as
386 wantlocale := "en_US.UTF-8"
387 if havelocales, err := exec.Command("locale", "-a").CombinedOutput(); err == nil && bytes.Contains(havelocales, []byte(strings.Replace(wantlocale+"\n", "UTF-", "utf", 1))) {
388 logger.Print("locale " + wantlocale + " already installed")
390 err = inst.runBash(`sed -i 's/^# *\(`+wantlocale+`\)/\1/' /etc/locale.gen && locale-gen`, stdout, stderr)
405 if pgLsclusters, err2 := exec.Command("pg_lsclusters", "--no-header").CombinedOutput(); err2 != nil {
406 err = fmt.Errorf("pg_lsclusters: %s", err2)
408 } else if pgclusters := strings.Split(strings.TrimSpace(string(pgLsclusters)), "\n"); len(pgclusters) != 1 {
409 logger.Warnf("pg_lsclusters returned %d postgresql clusters -- skipping postgresql initdb/startup, hope that's ok", len(pgclusters))
410 } 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 {
411 err = fmt.Errorf("error parsing pg_lsclusters output: %s", err)
413 } else if pgc.Status == "online" {
414 logger.Infof("postgresql cluster %s-%s is online", pgc.Version, pgc.Cluster)
416 logger.Infof("postgresql cluster %s-%s is %s; trying to start", pgc.Version, pgc.Cluster, pgc.Status)
417 cmd := exec.Command("pg_ctlcluster", "--foreground", pgc.Version, pgc.Cluster, "start")
425 cmd.Process.Signal(syscall.SIGTERM)
426 logger.Info("sent SIGTERM; waiting for postgres to shut down")
429 err = waitPostgreSQLReady()
435 if os.Getpid() == 1 {
436 // We are the init process (presumably in a
437 // docker container) so although postgresql is
438 // installed, it's not running, and initdb
439 // might never have been run.
442 var needcoll []string
443 // If the en_US.UTF-8 locale wasn't installed when
444 // postgresql initdb ran, it needs to be added
445 // explicitly before we can use it in our test suite.
446 for _, collname := range []string{"en_US", "en_US.UTF-8"} {
447 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')")
449 out, err2 := cmd.CombinedOutput()
451 err = fmt.Errorf("error while checking postgresql collations: %s", err2)
454 if strings.Contains(string(out), "1") {
455 logger.Infof("postgresql supports collation %s", collname)
457 needcoll = append(needcoll, collname)
460 if len(needcoll) > 0 && os.Getpid() != 1 {
461 // In order for the CREATE COLLATION statement
462 // below to work, the locale must have existed
463 // when PostgreSQL started up. If we're
464 // running as init, we must have started
465 // PostgreSQL ourselves after installing the
466 // locales. Otherwise, it might need a
467 // restart, so we attempt to restart it with
469 if err = inst.runBash(`sudo systemctl restart postgresql`, stdout, stderr); err != nil {
470 logger.Warn("`systemctl restart postgresql` failed; hoping postgresql does not need to be restarted")
471 } else if err = waitPostgreSQLReady(); err != nil {
475 for _, collname := range needcoll {
476 cmd := exec.Command("sudo", "-u", "postgres", "psql", "-c", "CREATE COLLATION \""+collname+"\" (LOCALE = \"en_US.UTF-8\")")
482 err = fmt.Errorf("error adding postgresql collation %s: %s", collname, err)
487 withstuff := "WITH LOGIN SUPERUSER ENCRYPTED PASSWORD " + pq.QuoteLiteral(devtestDatabasePassword)
488 cmd := exec.Command("sudo", "-u", "postgres", "psql", "-c", "ALTER ROLE arvados "+withstuff)
490 if err := cmd.Run(); err == nil {
491 logger.Print("arvados role exists; superuser privileges added, password updated")
493 cmd := exec.Command("sudo", "-u", "postgres", "psql", "-c", "CREATE ROLE arvados "+withstuff)
505 if havenodejsversion, err := exec.Command("/usr/local/bin/node", "--version").CombinedOutput(); err == nil && string(havenodejsversion) == nodejsversion+"\n" {
506 logger.Print("nodejs " + nodejsversion + " already installed")
509 NJS=`+nodejsversion+`
510 rm -rf /var/lib/arvados/node-*-linux-x64
511 wget --progress=dot:giga -O- https://nodejs.org/dist/${NJS}/node-${NJS}-linux-x64.tar.xz | sudo tar -C /var/lib/arvados -xJf -
512 ln -sfv /var/lib/arvados/node-${NJS}-linux-x64/bin/{node,npm} /usr/local/bin/
519 if haveyarnversion, err := exec.Command("/usr/local/bin/yarn", "--version").CombinedOutput(); err == nil && len(haveyarnversion) > 0 {
520 logger.Print("yarn " + strings.TrimSpace(string(haveyarnversion)) + " already installed")
524 ln -sfv /var/lib/arvados/node-`+nodejsversion+`-linux-x64/bin/{yarn,yarnpkg} /usr/local/bin/
531 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" {
532 logger.Print("workbench2 repo is already at " + workbench2version)
535 V=`+workbench2version+`
537 if [[ ! -e arvados-workbench2 ]]; then
538 git clone https://git.arvados.org/arvados-workbench2.git
539 cd arvados-workbench2
542 cd arvados-workbench2
543 if ! git checkout $V; then
545 git checkout yarn.lock
556 if err = inst.runBash(`
557 cd /var/lib/arvados/arvados-workbench2
559 `, stdout, stderr); err != nil {
565 // Install Go programs to /var/lib/arvados/bin/
566 for _, srcdir := range []string{
567 "cmd/arvados-client",
568 "cmd/arvados-server",
570 fmt.Fprintf(stderr, "building %s...\n", srcdir)
571 cmd := exec.Command("go", "install", "-ldflags", "-X git.arvados.org/arvados.git/lib/cmd.version="+inst.PackageVersion+" -X main.version="+inst.PackageVersion+" -s -w")
572 cmd.Env = append(cmd.Env, os.Environ()...)
573 cmd.Env = append(cmd.Env, "GOBIN=/var/lib/arvados/bin")
574 cmd.Dir = filepath.Join(inst.SourcePath, srcdir)
583 // Copy assets from source tree to /var/lib/arvados/share
584 cmd := exec.Command("install", "-v", "-t", "/var/lib/arvados/share", filepath.Join(inst.SourcePath, "sdk/python/tests/nginx.conf"))
592 // Install python SDK and arv-mount in
593 // /var/lib/arvados/lib/python.
595 // setup.py writes a file in the source directory in
596 // order to include the version number in the package
597 // itself. We don't want to write to the source tree
598 // (in "arvados-package" context it's mounted
599 // readonly) so we run setup.py in a temporary copy of
601 if err = inst.runBash(`
602 v=/var/lib/arvados/lib/python
603 tmp=/var/lib/arvados/tmp/python
606 pip3 install --no-cache-dir 'setuptools>=18.5' 'pip>=7'
607 export ARVADOS_BUILDING_VERSION="`+inst.PackageVersion+`"
608 for src in "`+inst.SourcePath+`/sdk/python" "`+inst.SourcePath+`/services/fuse"; do
609 rsync -a --delete-after "$src/" "$tmp/"
611 python3 setup.py install
615 `, stdout, stderr); err != nil {
619 // Install Rails apps to /var/lib/arvados/{railsapi,workbench1}/
620 for dstdir, srcdir := range map[string]string{
621 "railsapi": "services/api",
622 "workbench1": "apps/workbench",
624 fmt.Fprintf(stderr, "building %s...\n", srcdir)
625 cmd := exec.Command("rsync",
626 "-a", "--no-owner", "--no-group", "--delete-after", "--delete-excluded",
627 "--exclude", "/coverage",
629 "--exclude", "/node_modules",
631 "--exclude", "/public/assets",
632 "--exclude", "/vendor",
633 "--exclude", "/config/environments",
634 "./", "/var/lib/arvados/"+dstdir+"/")
635 cmd.Dir = filepath.Join(inst.SourcePath, srcdir)
642 for _, cmdline := range [][]string{
643 {"mkdir", "-p", "log", "public/assets", "tmp", "vendor", ".bundle", "/var/www/.bundle", "/var/www/.gem", "/var/www/.npm", "/var/www/.passenger"},
644 {"touch", "log/production.log"},
645 {"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"},
646 {"sudo", "-u", "www-data", "/var/lib/arvados/bin/gem", "install", "--user", "--conservative", "--no-document", "bundler:" + bundlerversion},
647 {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "config", "set", "--local", "deployment", "true"},
648 {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "config", "set", "--local", "path", "/var/www/.gem"},
649 {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "config", "set", "--local", "without", "development test diagnostics performance"},
650 {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "install", "--jobs", fmt.Sprintf("%d", runtime.NumCPU())},
652 {"chown", "www-data:www-data", ".", "public/assets"},
653 // {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "config", "set", "--local", "system", "true"},
654 {"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"},
655 {"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"},
656 {"chown", "root:root", "."},
657 {"chown", "-R", "root:root", "public/assets", "vendor"},
659 {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "exec", "passenger-config", "build-native-support"},
660 {"sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "exec", "passenger-config", "install-standalone-runtime"},
662 if cmdline[len(cmdline)-2] == "rake" && dstdir != "workbench1" {
665 cmd = exec.Command(cmdline[0], cmdline[1:]...)
666 cmd.Dir = "/var/lib/arvados/" + dstdir
669 fmt.Fprintf(stderr, "... %s\n", cmd.Args)
675 cmd = exec.Command("sudo", "-u", "www-data", "/var/lib/arvados/bin/bundle", "exec", "passenger-config", "validate-install")
676 cmd.Dir = "/var/lib/arvados/" + dstdir
680 if err != nil && !strings.Contains(err.Error(), "exit status 2") {
681 // Exit code 2 indicates there were warnings (like
682 // "other passenger installations have been detected",
683 // which we can't expect to avoid) but no errors.
684 // Other non-zero exit codes (1, 9) indicate errors.
689 // Install workbench2 app to /var/lib/arvados/workbench2/
690 if err = inst.runBash(`
691 cd /var/lib/arvados/arvados-workbench2
692 VERSION="`+inst.PackageVersion+`" BUILD_NUMBER=1 GIT_COMMIT="`+workbench2version[:9]+`" yarn build
693 rsync -a --delete-after build/ /var/lib/arvados/workbench2/
694 `, stdout, stderr); err != nil {
698 // Install arvados-cli gem (binaries go in
699 // /var/lib/arvados/bin)
700 if err = inst.runBash(`
701 /var/lib/arvados/bin/gem install --conservative --no-document arvados-cli
702 `, stdout, stderr); err != nil {
706 err = os.WriteFile("/lib/systemd/system/arvados.service", arvadosServiceFile, 0777)
711 // (fpm will do this for us in the pkg case)
712 // This is equivalent to "systemd enable", but
713 // does not depend on the systemctl program
715 symlink := "/etc/systemd/system/multi-user.target.wants/arvados.service"
716 err = os.Remove(symlink)
717 if err != nil && !errors.Is(err, os.ErrNotExist) {
720 err = os.Symlink("/lib/systemd/system/arvados.service", symlink)
726 // Add symlinks in /usr/bin for user-facing programs
727 for _, srcdst := range [][]string{
729 {"bin/arvados-client"},
730 {"bin/arvados-client", "arv"},
731 {"bin/arvados-server"},
733 {"bin/arv", "arv-ruby"},
736 {"lib/python/bin/arv-copy"},
737 {"lib/python/bin/arv-federation-migrate"},
738 {"lib/python/bin/arv-get"},
739 {"lib/python/bin/arv-keepdocker"},
740 {"lib/python/bin/arv-ls"},
741 {"lib/python/bin/arv-migrate-docker19"},
742 {"lib/python/bin/arv-normalize"},
743 {"lib/python/bin/arv-put"},
744 {"lib/python/bin/arv-ws"},
746 {"lib/python/bin/arv-mount"},
748 src := "/var/lib/arvados/" + srcdst[0]
749 if _, err = os.Stat(src); err != nil {
752 dst := srcdst[len(srcdst)-1]
753 _, dst = filepath.Split(dst)
754 dst = "/usr/bin/" + dst
756 if err != nil && !errors.Is(err, os.ErrNotExist) {
759 err = os.Symlink(src, dst)
769 type osversion struct {
776 func identifyOS() (osversion, error) {
778 f, err := os.Open("/etc/os-release")
784 kv := map[string]string{}
785 scanner := bufio.NewScanner(f)
787 line := strings.TrimSpace(scanner.Text())
788 if strings.HasPrefix(line, "#") {
791 toks := strings.SplitN(line, "=", 2)
793 return osv, fmt.Errorf("invalid line in /etc/os-release: %q", line)
796 v := strings.Trim(toks[1], `"`)
798 v = strings.Trim(v, `'`)
802 if err = scanner.Err(); err != nil {
813 return osv, fmt.Errorf("unsupported ID in /etc/os-release: %q", kv["ID"])
815 vstr := kv["VERSION_ID"]
816 if i := strings.Index(vstr, "."); i > 0 {
819 osv.Major, err = strconv.Atoi(vstr)
821 return osv, fmt.Errorf("incomprehensible VERSION_ID in /etc/os-release: %q", kv["VERSION_ID"])
826 func waitPostgreSQLReady() error {
827 for deadline := time.Now().Add(10 * time.Second); ; {
828 output, err := exec.Command("pg_isready").CombinedOutput()
831 } else if time.Now().After(deadline) {
832 return fmt.Errorf("timed out waiting for pg_isready (%q)", output)
834 time.Sleep(time.Second)
839 func (inst *installCommand) runBash(script string, stdout, stderr io.Writer) error {
840 cmd := exec.Command("bash", "-")
842 cmd = exec.Command("eatmydata", "bash", "-")
844 cmd.Stdin = bytes.NewBufferString("set -ex -o pipefail\n" + script)
850 func prodpkgs(osv osversion) []string {
865 if osv.Debian || osv.Ubuntu {
866 if osv.Debian && osv.Major == 8 {
867 pkgs = append(pkgs, "libgnutls-deb0-28") // sdk/cwl
868 } else if osv.Debian && osv.Major >= 10 || osv.Ubuntu && osv.Major >= 16 {
869 pkgs = append(pkgs, "python3-distutils") // sdk/cwl
872 "mime-support", // keep-web
874 } else if osv.Centos {
876 "fuse-libs", // services/fuse
877 "mailcap", // keep-web
880 panic("os version not supported")
884 func ProductionDependencies() ([]string, error) {
885 osv, err := identifyOS()
889 return prodpkgs(osv), nil