src/Pure/Admin/other_isabelle.scala
changeset 69388 fc58534bc475
parent 69387 ff9095c91e87
child 69395 d1c4a1dee9e7
--- a/src/Pure/Admin/other_isabelle.scala	Sun Dec 02 14:12:08 2018 +0100
+++ b/src/Pure/Admin/other_isabelle.scala	Sun Dec 02 15:56:14 2018 +0100
@@ -24,7 +24,7 @@
 {
   other_isabelle =>
 
-  override def toString: String = isabelle_home.toString
+  override def toString: String = isabelle_home.absolute.toString
 
   if (proper_string(System.getenv("ISABELLE_SETTINGS_PRESENT")).isDefined)
     error("Cannot initialize with enclosing ISABELLE_SETTINGS_PRESENT")
@@ -66,6 +66,22 @@
       foreach(entry => File.copy(entry.path, target_dir))
 
 
+  /* components */
+
+  def default_components_base: Path = isabelle_home_user.absolute.dir + Path.explode("contrib")
+  def default_components_dir: Path = isabelle_home.absolute + Path.explode("Admin/components")
+  def default_catalogs: List[String] = List("main")
+
+  def init_components(
+    base: Path = default_components_base,
+    dir: Path = default_components_dir,
+    catalogs: List[String] = default_catalogs): List[String] =
+  {
+    catalogs.map(catalog =>
+      "init_components " + File.bash_path(base) + " " + File.bash_path(dir + Path.basic(catalog)))
+  }
+
+
   /* settings */
 
   def clean_settings(): Boolean =
@@ -75,7 +91,7 @@
     }
     else false
 
-  def init_settings(components_base: String, more_settings: List[String])
+  def init_settings(settings: List[String])
   {
     if (!clean_settings())
       error("Cannot proceed with existing user settings file: " + etc_settings)
@@ -83,25 +99,8 @@
     Isabelle_System.mkdirs(etc_settings.dir)
     File.write(etc_settings,
       "# generated by Isabelle " + Date.now() + "\n" +
-      "#-*- shell-script -*- :mode=shellscript:\n")
-
-    val component_settings =
-    {
-      val components_base_path =
-        if (components_base == "") isabelle_home_user.dir + Path.explode("contrib")
-        else Path.explode(components_base).expand
-
-      val catalogs = List("main", "optional")
-      catalogs.map(catalog =>
-        "init_components " + File.bash_path(components_base_path) +
-          " \"$ISABELLE_HOME/Admin/components/" + catalog + "\"")
-    }
-
-    val settings =
-      List(component_settings) :::
-      (if (more_settings.isEmpty) Nil else List(more_settings))
-
-    File.append(etc_settings, "\n" + cat_lines(settings.map(terminate_lines(_))))
+      "#-*- shell-script -*- :mode=shellscript:\n" +
+      settings.mkString("\n", "\n", "\n"))
   }