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