The unpac monorepo manager self-hosting as a monorepo using unpac

Add support for zstd-compressed archives

+11 -5
+2
share/0install.net/unzstd
···
··· 1 + #!/bin/sh 2 + exec 0install run --command=decompress https://apps.0install.net/utils/zstd.xml "$@"
+9 -5
src/zeroinstall/archive.ml
··· 19 | ".tar.gz" -> "application/x-compressed-tar" 20 | ".tar.lzma" -> "application/x-lzma-compressed-tar" 21 | ".tar.xz" -> "application/x-xz-compressed-tar" 22 | ".rpm" -> "application/x-rpm" 23 | ".deb" -> "application/x-deb" 24 | ".tbz" -> "application/x-bzip-compressed-tar" ··· 53 | "application/x-apple-diskimage" -> if missing "hdiutil" then 54 Safe_exn.failf "This package looks like a Apple Disk Image, but you don't have the \"hdiutil\" command \ 55 I need to extract it." 56 - | "application/x-lzma-compressed-tar" -> () (* We can get it through Zero Install *) 57 - | "application/x-xz-compressed-tar" -> if missing "unxz" then 58 - Safe_exn.failf "This package looks like a xz-compressed package, but you don't have the \"unxz\" command \ 59 - I need to extract it. Install the package containing it (it's probably called \"xz-utils\") first." 60 | "application/x-compressed-tar" | "application/x-tar" | "application/x-ruby-gem" -> () 61 | mime_type -> 62 Safe_exn.failf "Unsupported archive type \"%s\" (for 0install version %s)" mime_type About.version 63 64 - type compression = Bzip2 | Gzip | Lzma | Xz | Uncompressed 65 66 let make_command = U.make_command 67 ··· 159 let unxz = U.find_in_path system "unxz" |? lazy ( 160 Lazy.force share_dir +/ "0install.net" +/ "unxz" 161 ) in ["--use-compress-program=" ^ unxz] 162 | Uncompressed -> [] end @ 163 164 begin match extract with ··· 219 | "data.tar.bz2" -> (name, Bzip2) 220 | "data.tar.lzma" -> (name, Lzma) 221 | "data.tar.xz" -> (name, Xz) 222 | _ -> get_type stream 223 with Stream.Failure -> Safe_exn.failf "File is not a Debian package." in 224 let data_tar, compression = get_type (U.stream_of_lines output) in ··· 289 | "application/zip" -> tmpfile |> extract_zip config ~dstdir ?extract 290 | "application/x-lzma-compressed-tar" -> tmpfile |> extract_tar config ~dstdir ?extract ~compression:Lzma 291 | "application/x-xz-compressed-tar" -> tmpfile |> extract_tar config ~dstdir ?extract ~compression:Xz 292 | _ -> Safe_exn.failf "Unknown MIME type '%s'" mime_type 293 294 (** Move each item in [srcdir] into [dstdir]. Symlinks are copied as is. Does not follow any symlinks in [destdir]. *)
··· 19 | ".tar.gz" -> "application/x-compressed-tar" 20 | ".tar.lzma" -> "application/x-lzma-compressed-tar" 21 | ".tar.xz" -> "application/x-xz-compressed-tar" 22 + | ".tar.zst" -> "application/x-zstd-compressed-tar" 23 | ".rpm" -> "application/x-rpm" 24 | ".deb" -> "application/x-deb" 25 | ".tbz" -> "application/x-bzip-compressed-tar" ··· 54 | "application/x-apple-diskimage" -> if missing "hdiutil" then 55 Safe_exn.failf "This package looks like a Apple Disk Image, but you don't have the \"hdiutil\" command \ 56 I need to extract it." 57 + | "application/x-lzma-compressed-tar" | "application/x-xz-compressed-tar" | "application/x-zstd-compressed-tar" -> () (* We can get it through Zero Install *) 58 | "application/x-compressed-tar" | "application/x-tar" | "application/x-ruby-gem" -> () 59 | mime_type -> 60 Safe_exn.failf "Unsupported archive type \"%s\" (for 0install version %s)" mime_type About.version 61 62 + type compression = Bzip2 | Gzip | Lzma | Xz | Zstd | Uncompressed 63 64 let make_command = U.make_command 65 ··· 157 let unxz = U.find_in_path system "unxz" |? lazy ( 158 Lazy.force share_dir +/ "0install.net" +/ "unxz" 159 ) in ["--use-compress-program=" ^ unxz] 160 + | Zstd -> 161 + let unzstd = U.find_in_path system "unzstd" |? lazy ( 162 + Lazy.force share_dir +/ "0install.net" +/ "unzstd" 163 + ) in ["--use-compress-program=" ^ unzstd] 164 | Uncompressed -> [] end @ 165 166 begin match extract with ··· 221 | "data.tar.bz2" -> (name, Bzip2) 222 | "data.tar.lzma" -> (name, Lzma) 223 | "data.tar.xz" -> (name, Xz) 224 + | "data.tar.zst" -> (name, Zstd) 225 | _ -> get_type stream 226 with Stream.Failure -> Safe_exn.failf "File is not a Debian package." in 227 let data_tar, compression = get_type (U.stream_of_lines output) in ··· 292 | "application/zip" -> tmpfile |> extract_zip config ~dstdir ?extract 293 | "application/x-lzma-compressed-tar" -> tmpfile |> extract_tar config ~dstdir ?extract ~compression:Lzma 294 | "application/x-xz-compressed-tar" -> tmpfile |> extract_tar config ~dstdir ?extract ~compression:Xz 295 + | "application/x-zstd-compressed-tar" -> tmpfile |> extract_tar config ~dstdir ?extract ~compression:Zstd 296 | _ -> Safe_exn.failf "Unknown MIME type '%s'" mime_type 297 298 (** Move each item in [srcdir] into [dstdir]. Symlinks are copied as is. Does not follow any symlinks in [destdir]. *)