support for .tar.xz archives;
authorwenzelm
Fri, 14 Mar 2025 23:03:58 +0100
changeset 82276 d22e9c5b5dc6
parent 82273 365917fc6e31
child 82277 1a8aa332548b
support for .tar.xz archives;
src/Pure/General/file.scala
src/Pure/System/isabelle_system.scala
--- a/src/Pure/General/file.scala	Fri Mar 14 18:13:56 2025 +0100
+++ b/src/Pure/General/file.scala	Fri Mar 14 23:03:58 2025 +0100
@@ -104,6 +104,7 @@
   def is_scala(s: String): Boolean = s.endsWith(".scala")
   def is_tar_bz2(s: String): Boolean = s.endsWith(".tar.bz2")
   def is_tar_gz(s: String): Boolean = s.endsWith(".tar.gz")
+  def is_tar_xz(s: String): Boolean = s.endsWith(".tar.xz")
   def is_tgz(s: String): Boolean = s.endsWith(".tgz")
   def is_thy(s: String): Boolean = s.endsWith(".thy")
   def is_xz(s: String): Boolean = s.endsWith(".xz")
--- a/src/Pure/System/isabelle_system.scala	Fri Mar 14 18:13:56 2025 +0100
+++ b/src/Pure/System/isabelle_system.scala	Fri Mar 14 23:03:58 2025 +0100
@@ -487,11 +487,17 @@
         } Files.setLastModifiedTime(res, t)
       }
     }
-    else if (File.is_tar_bz2(name) || File.is_tgz(name) || File.is_tar_gz(name)) {
-      val flags = if (File.is_tar_bz2(name)) "-xjf " else "-xzf "
-      Isabelle_System.gnutar(flags + File.bash_path(archive), dir = dir, strip = strip).check
+    else {
+      val extr =
+        if (File.is_tar_bz2(name)) "-xjf"
+        else if (File.is_tgz(name) || File.is_tar_gz(name)) "-xzf"
+        else if (File.is_tar_xz(name)) "--xz -xf"
+        else ""
+      if (extr.nonEmpty) {
+        Isabelle_System.gnutar(extr + " " + File.bash_path(archive), dir = dir, strip = strip).check
+      }
+      else error("Cannot extract " + archive)
     }
-    else error("Cannot extract " + archive)
   }
 
   def make_patch(base_dir: Path, src: Path, dst: Path, diff_options: String = ""): String = {