src/Pure/Tools/phabricator.scala
changeset 80224 db92e0b6a11a
parent 79525 9bc62f636fc4
child 80450 4355857e13a6
equal deleted inserted replaced
80223:d389577a6fba 80224:db92e0b6a11a
   235 
   235 
   236   sealed case class Config(name: String, root: Path) {
   236   sealed case class Config(name: String, root: Path) {
   237     def home: Path = root + Path.explode(phabricator_name())
   237     def home: Path = root + Path.explode(phabricator_name())
   238 
   238 
   239     def execute(command: String): Process_Result =
   239     def execute(command: String): Process_Result =
   240       Isabelle_System.bash("bin/" + command, cwd = home.file, redirect = true).check
   240       Isabelle_System.bash("bin/" + command, cwd = home, redirect = true).check
   241 
   241 
   242     def webroot: String = home.implode + "/webroot"
   242     def webroot: String = home.implode + "/webroot"
   243   }
   243   }
   244 
   244 
   245   def read_config(): List[Config] = {
   245   def read_config(): List[Config] = {
   300             progress.echo("phabricator " + quote(config.name) + " root " + config.root)
   300             progress.echo("phabricator " + quote(config.name) + " root " + config.root)
   301           }
   301           }
   302         }
   302         }
   303         else {
   303         else {
   304           val config = get_config(name)
   304           val config = get_config(name)
   305           val result = progress.bash(Bash.strings(more_args), cwd = config.home.file, echo = true)
   305           val result = progress.bash(Bash.strings(more_args), cwd = config.home, echo = true)
   306           if (!result.ok) error(result.print_return_code)
   306           if (!result.ok) error(result.print_return_code)
   307         }
   307         }
   308       })
   308       })
   309 
   309 
   310 
   310 
   345         else Path.explode(mercurial_source)
   345         else Path.explode(mercurial_source)
   346 
   346 
   347       Isabelle_System.extract(archive, tmp_dir)
   347       Isabelle_System.extract(archive, tmp_dir)
   348       val build_dir = File.get_dir(tmp_dir, title = mercurial_source)
   348       val build_dir = File.get_dir(tmp_dir, title = mercurial_source)
   349 
   349 
   350       progress.bash("make all && make install", cwd = build_dir.file, echo = true).check
   350       progress.bash("make all && make install", cwd = build_dir, echo = true).check
   351     }
   351     }
   352   }
   352   }
   353 
   353 
   354   def phabricator_setup(
   354   def phabricator_setup(
   355     options: Options,
   355     options: Options,
   414     }
   414     }
   415 
   415 
   416     Isabelle_System.chown(Bash.string(www_user) + ":" + Bash.string(www_user), root_path)
   416     Isabelle_System.chown(Bash.string(www_user) + ":" + Bash.string(www_user), root_path)
   417     Isabelle_System.chmod("755", root_path)
   417     Isabelle_System.chmod("755", root_path)
   418 
   418 
   419     progress.bash(cwd = root_path.file, echo = true,
   419     progress.bash(cwd = root_path, echo = true,
   420       script = """
   420       script = """
   421         set -e
   421         set -e
   422         echo "Cloning distribution repositories:"
   422         echo "Cloning distribution repositories:"
   423 
   423 
   424         git clone --branch stable https://we.phorge.it/source/arcanist.git
   424         git clone --branch stable https://we.phorge.it/source/arcanist.git
   506 
   506 
   507     config.execute("config set phabricator.cache-namespace " + Bash.string(mysql_name))
   507     config.execute("config set phabricator.cache-namespace " + Bash.string(mysql_name))
   508     config.execute("config set storage.default-namespace " + Bash.string(mysql_name))
   508     config.execute("config set storage.default-namespace " + Bash.string(mysql_name))
   509     config.execute("config set storage.mysql-engine.max-size 8388608")
   509     config.execute("config set storage.mysql-engine.max-size 8388608")
   510 
   510 
   511     progress.bash("bin/storage upgrade --force", cwd = config.home.file, echo = true).check
   511     progress.bash("bin/storage upgrade --force", cwd = config.home, echo = true).check
   512 
   512 
   513 
   513 
   514     /* database dump */
   514     /* database dump */
   515 
   515 
   516     val dump_name = isabelle_phabricator_name(name = "dump")
   516     val dump_name = isabelle_phabricator_name(name = "dump")
   608 WantedBy=multi-user.target
   608 WantedBy=multi-user.target
   609 """)
   609 """)
   610     }
   610     }
   611     catch {
   611     catch {
   612       case ERROR(msg) =>
   612       case ERROR(msg) =>
   613         progress.bash("bin/phd status", cwd = config.home.file, echo = true).check
   613         progress.bash("bin/phd status", cwd = config.home, echo = true).check
   614         error(msg)
   614         error(msg)
   615     }
   615     }
   616   }
   616   }
   617 
   617 
   618 
   618 
   704       progress.echo("Using mail configuration from " + mail_config)
   704       progress.echo("Using mail configuration from " + mail_config)
   705       config.execute("config set cluster.mailers --stdin < " + File.bash_path(mail_config))
   705       config.execute("config set cluster.mailers --stdin < " + File.bash_path(mail_config))
   706 
   706 
   707       if (test_user.nonEmpty) {
   707       if (test_user.nonEmpty) {
   708         progress.echo("Sending test mail to " + quote(test_user))
   708         progress.echo("Sending test mail to " + quote(test_user))
   709         progress.bash(cwd = config.home.file, echo = true,
   709         progress.bash(cwd = config.home, echo = true,
   710           script = """echo "Test from Phabricator ($(date))" | bin/mail send-test --subject "Test" --to """ +
   710           script = """echo "Test from Phabricator ($(date))" | bin/mail send-test --subject "Test" --to """ +
   711             Bash.string(test_user)).check
   711             Bash.string(test_user)).check
   712       }
   712       }
   713     }
   713     }
   714 
   714