support for Linux packages;
authorwenzelm
Tue, 29 Oct 2019 19:42:40 +0100
changeset 70966 acc3bac0d7c5
parent 70965 fe9496df6298
child 70967 79736ffe77c3
support for Linux packages;
src/Pure/System/linux.scala
--- a/src/Pure/System/linux.scala	Tue Oct 29 18:08:24 2019 +0100
+++ b/src/Pure/System/linux.scala	Tue Oct 29 19:42:40 2019 +0100
@@ -46,4 +46,21 @@
 
     def is_ubuntu: Boolean = id == "Ubuntu"
   }
+
+
+  /* packages */
+
+  def reboot_required(): Boolean =
+    Path.explode("/var/run/reboot-required").is_file
+
+  def check_reboot_required(): Unit =
+    if (reboot_required()) error("Reboot required")
+
+  def package_update(progress: Progress = No_Progress): Unit =
+    progress.bash(
+      """apt-get update -y && apt-get upgrade -y && apt autoremove -y""",
+      echo = true).check
+
+  def package_install(packages: List[String], progress: Progress = No_Progress): Unit =
+    progress.bash("apt-get install -y -- " + Bash.strings(packages), echo = true).check
 }