# HG changeset patch # User wenzelm # Date 1572368904 -3600 # Node ID fe9496df62988009aaf8b7d2658f86dbc331e890 # Parent 99eec58dc5516b9bc568be978e08305fc6b4920c specific support for Linux, notably Ubuntu/Debian; diff -r 99eec58dc551 -r fe9496df6298 src/Pure/System/linux.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Pure/System/linux.scala Tue Oct 29 18:08:24 2019 +0100 @@ -0,0 +1,49 @@ +/* Title: Pure/System/linux.scala + Author: Makarius + +Specific support for Linux, notably Ubuntu/Debian. +*/ + +package isabelle + + +import scala.util.matching.Regex + + +object Linux +{ + /* check system */ + + def check_system(): Unit = + if (!Platform.is_linux) error("Not a Linux system") + + def check_system_root(): Unit = + { + check_system() + if (Isabelle_System.bash("id -u").check.out != "0") error("Not running as superuser (root)") + } + + + /* release */ + + object Release + { + private val ID = """^Distributor ID:\s*(\S.*)$""".r + private val RELEASE = """^Release:\s*(\S.*)$""".r + private val DESCRIPTION = """^Description:\s*(\S.*)$""".r + + def apply(): Release = + { + val lines = Isabelle_System.bash("lsb_release -a").check.out_lines + def find(R: Regex): String = lines.collectFirst({ case R(a) => a }).getOrElse("Unknown") + new Release(find(ID), find(RELEASE), find(DESCRIPTION)) + } + } + + final class Release private(val id: String, val release: String, val description: String) + { + override def toString: String = description + + def is_ubuntu: Boolean = id == "Ubuntu" + } +} diff -r 99eec58dc551 -r fe9496df6298 src/Pure/build-jars --- a/src/Pure/build-jars Mon Oct 28 20:51:38 2019 +0100 +++ b/src/Pure/build-jars Tue Oct 29 18:08:24 2019 +0100 @@ -125,6 +125,7 @@ System/isabelle_process.scala System/isabelle_system.scala System/isabelle_tool.scala + System/linux.scala System/numa.scala System/options.scala System/platform.scala