xdvdfs
是用于与 XDVDFS/XISO 映像交互的工具集合。
xdvdfs-cli
是一个用于与 xiso 文件交互的命令行工具。
如果货物在路径中设置正确,则可以使用以下命令安装:
$ cargo install xdvdfs-cli
否则,它可以作为默认项目从工作空间根运行。
github 版本中还提供了 xdvdfs-cli 的二进制发行版。
运行不带参数的xdvdfs
将弹出帮助屏幕,显示支持的子命令:
Usage: xdvdfs [COMMAND]
Commands:
ls List files in an image
tree List all files in an image, recursively
md5 Show MD5 checksums for files in an image
checksum Compute deterministic checksum of image contents
info Print information about image metadata
copy-out Copy a file or directory out of the provided image file
unpack Unpack an entire image to a directory
pack Pack an image from a given directory or source ISO image
build-image Pack an image from a given specification
image-spec Manage image spec `xdvdfs.toml` files
compress Pack and compress an image from a given directory or source ISO image
help Print this message or the help of the given subcommand(s)
使用-h
标志运行子命令将显示该特定子命令的帮助信息。
要从目录打包图像,请运行:
$ xdvdfs pack < directory > [optional output path]
这将创建一个与输入目录一对一匹配的 iso。
可以从现有 ISO 映像重新打包映像:
$ xdvdfs pack < input-image > [optional output path]
这将创建一个与输入图像一对一匹配的 iso。
可以使用xdvdfs build-image
命令在底层映像中重写到不同目标的主机路径时打包映像。
如果不需要路径重新映射功能(即您只需要/**:/{1}
规则),那么您应该更喜欢xdvdfs pack
。
实现此目的的主要方法是使用xdvdfs.toml
文件:
[ metadata ]
# Relative path to output iso, if not specified in command [optional]
output = " dist/image.xiso.iso "
# List of host-to-image path mapping rules. At least one rule is required.
# All paths are relative to the provided source path, the `xdvdfs.toml` file,
# or the working directory, in that priority order
# Host paths are matched by glob pattern
# Image paths have fields given by `{x}` substituted, where `x` is the index
# of the glob match, starting at 1. `{0}` matches the entire host path.
# Globs are evaluated in the provided order
[ map_rules ]
# Map contents of the "bin" directory to the image root
bin = " / "
# Map anything in the assets directory to `/assets/`
# Equivalent to `assets = "/assets"`
"assets/**" = " /assets/{1} "
# Map any file in the `sound` subdirectory with name `priority`
# and any extension to the same path in the image
# Note that `{0}` matches the entire relative host path
# Also note that due to the linear ordering of glob matches,
# this takes precedence over the below rule
"sound/priority.*" = " /{0} "
# Map any file in the `sound` subdirectory with extension `a`, `b`, or `c`,
# to `/a/filename`, "/b/filename" or `/c/filename`, based on its filename
# and extension.
"sound/*.{a,b,c}" = " /{2}/{1} "
# but, exclude any files in the `sound` subdirectory with filename `excluded`
# The image path is a don't-care value, and has no effect
"!sound/excluded.*" = " "
# Since globs are evaluated in order, this includes any otherwise excluded
# files in the `sound` subdirectory with name `excluded` and extension `c`
"sound/excluded.c" = " /c/excluded "
假设xdvdfs.toml
和所有上述路径都相对于当前目录,则可以使用以下内容打包图像:
# Produces `dist/image.xiso.iso` with the above configuration
$ xdvdfs build-image
还有其他方法可以从其他目录打包图像:
# Produces `/dist/image.xiso.iso`
$ xdvdfs build-image < path-to-source-dir >
# Also produces `/dist/image.xiso.iso`
$ xdvdfs build-image < path-to-source-dir > /xdvdfs.toml
# Produces `./dist/output.xiso.iso` in the current directory
$ xdvdfs build-image < path-to-source-dir > dist/output.xiso.iso
# Produces `/dist/image.xiso.iso`, with `xdvdfs.toml` not
# necessarily being in `. Here it is in the current directory
$ xdvdfs build-image -f xdvdfs.toml < path-to-source-dir >
要查看xdvdfs.toml
给出的真实映射而不实际打包映像,请使用-D
或--dry-run
标志。
还可以直接在命令行中提供xdvdfs.toml
文件的所有配置以build-image
。
-O
提供output
字段-m :
提供映射规则。这可以重复,并按照给定的顺序进行匹配。这些也可以与--dry-run
结合使用来测试不同的映射。
要将build-image
一组命令行选项转换为xdvdfs.toml
文件,请使用具有相同参数的xdvdfs image-spec from
命令。
# Outputs equivalent `xdvdfs.toml` to stdout
$ xdvdfs image-spec from -O dist/image.iso -m " bin:/ " -m " assets:/{0} "
# Outputs equivalent `xdvdfs.toml` to a file
$ xdvdfs image-spec from -O dist/image.iso -m " bin:/ " -m " assets:/{0} " xdvdfs.toml
生成的规范文件可以与build-image
一起使用。
要解压图像,请运行:
$ xdvdfs unpack < path to image > [optional output path]
xdvdfs-cli
支持用于图像的其他实用工具。
命令 | 行动 |
---|---|
xdvsfs ls | 列出指定目录中的文件,默认为 root |
xdvdfs tree | 打印图像中每个文件的列表 |
xdvdfs md5 | 打印图像中指定文件或每个文件的 md5 和 |
xdvdfs checksum [path to img1]... | 计算所有图像内容的校验和,以检查其他图像的完整性 |
xdvdfs info | 打印指定目录条目或根卷的元数据信息 |
xdvdfs copy-out | 从提供的图像中复制单个文件或目录 |
xdvdfs-core
是一个用于处理 XDVDFS 元数据的库。
从给定路径读取文件的一个简单示例是:
async fn read_from_path ( xiso : & Path , file_path : & str ) -> Box < [ u8 ] > {
let mut xiso = std :: fs :: File :: open ( xiso ) . unwrap ( ) ;
let volume = xdvdfs :: read :: read_volume ( & mut xiso ) . await . unwrap ( ) ;
let file_dirent = volume . root_table . walk_path ( & mut xiso , file_path ) . await . unwrap ( ) ;
let data = file_dirent . node . dirent . read_data_all ( & mut xiso ) . await . unwrap ( ) ;
data
}
该库支持 no_std。可以通过实现xdvdfs::blockdev
中的特征来定义自定义块设备。
如果没有alloc
功能,则仅支持基本元数据功能。 alloc
功能启用了多个需要分配的实用函数(例如上面的read_data_all
。
xdvdfs-cli 的源代码提供了如何在带有 std 的环境中使用 xdvdfs-core 的更详细示例。
请注意,xdvdfs 目前 API 不稳定,并且在主要版本 0 的 semver 之后,每个次要版本的提升可能会或可能不会包含重大更改。