azldev-mock
它能做什么
这项技能展示如何使用 azldev 在 mock chroot 中运行软件包并检查 RPM 文件。它适用于希望在发布前安全检查已构建软件包的开发者。
适用场景
- ✓当你已构建一个 RPM,想在不安装到自己电脑上的情况下测试它时。
- ✓当 RPM 无法安装,你想查看错误详情时。
- ✓当你需要检查已构建软件包的文件列表或依赖项时。
技能链接
https://github.com/microsoft/azurelinux/blob/4.0/.agents/skills/azldev-mock/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我为我的软件包构建了一个 RPM。请帮我在 mock chroot 中测试它,并检查它的文件列表和依赖项。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会通过非交互式输入在模拟 shell 中运行命令,读取软件包信息,并在隔离环境中重试安装。主机上不会安装任何内容。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Test and inspect packages in a mock chroot
Never install built RPMs on the host. They target the distro you are building, not your dev machine. Use a mock chroot instead.
azldev tests and inspects packages inside mock build roots via mock shell,
which lives under the hidden advanced group (azldev adv is an alias for
azldev advanced; it does not appear in azldev --help).
Non-interactive chroot (preferred for agents)
Pipe commands in via a heredoc — fully autonomous, no user interaction needed:
azldev adv mock shell --add-package /path/to/package.rpm <<'CMDS'
<command> --version
echo "exit code: $?"
exit
CMDS
Use this for automated checks: running binaries, querying installed packages, inspecting paths.
Inspect an RPM without installing it
When --add-package fails to install, or you just want to look at an RPM's
contents, get the file inside the chroot and inspect it there rather than
installing on the host. If the RPM is not already reachable inside the build
root, copy it in first with mock --copyin <rpm> /tmp/ (using the project's
distro mock config), then:
azldev adv mock shell <<'CMDS'
rpm -qip /tmp/<name>*.rpm # package info
rpm -qlp /tmp/<name>*.rpm # file list
rpm -qRp /tmp/<name>*.rpm # dependencies
dnf install /tmp/<name>*.rpm # retry the install to see the error details
exit
CMDS
This gives you the full distro environment for debugging dependency issues, file conflicts, and failed installs, without touching the host.
Interactive chroot
Use when you need to explore interactively or react to output between commands:
azldev adv mock shell --add-package /path/to/package.rpm --enable-network
When driving an interactive shell as an agent:
- Run a simple command (e.g.
echo ready) in a foreground terminal to establish a shared shell. - Ask the user to run the
azldev adv mock shellcommand in that same terminal. - Wait for confirmation that they are inside the mock shell.
- Run diagnostic commands in the same foreground terminal — they execute inside the chroot.
- Run
exitto leave the chroot.
Prefer the non-interactive heredoc approach; use interactive only when you must react to output between commands.
Key flags
| Flag | Purpose |
|---|---|
-p, --add-package <path> |
Install a package into the chroot before entering. Accepts an RPM file path or a package name. May be repeated. |
--enable-network |
Allow network access (dependency resolution, downloads). |
-pmeans--add-package, not a component name. Unlikeazldev comp build -p <name>,mock shellhas no component selector.-p <name>installs a package by name from the configured repos — it does not set up a chroot with that component's build dependencies.
Gotchas
- Don't mix
-p <name>with--add-package /path/to/<name>.rpmfor the same package — that installs both the repo build and your local build, which conflict. Use one or the other. - The mock chroot is persistent across
azldev adv mock shellsessions — installed packages and created files survive. Handy (install once, re-enter later), but stale state can confuse. azldev has no built-in reset; clear it withmockdirectly (--scrub=chroot, or--scrub=allto also drop the bootstrap), pointing at the project's distro mock config. - One mock session per terminal. Running
azldev adv mock shellwhile a terminal is already inside a mock shell fails — runexitfirst.
Generated by azldev docs agent; do not hand-edit.
常见问题
为什么不在电脑上安装 RPM?
技能说明,构建好的软件包面向的是正在构建的发行版,而不是你自己的电脑。
它可以无需手动操作地运行吗?
可以。技能说明了一种非交互方式,可以把命令输入到 shell 中。
它需要特殊命令吗?
它使用高级模拟 shell 命令,该命令不会出现在标准帮助输出中。
详情
作者的原始描述
Read this before testing or inspecting a built RPM; do not drive mock by hand from memory. Explains how to test and inspect built packages in a mock chroot with 'azldev adv mock shell', covering non-interactive (heredoc) and interactive chroot workflows, the -p/--add-package flag, and resetting stale chroot state. Triggers include test package, mock shell, inspect rpm, smoke test, chroot, verify build output.
repo: microsoft/azurelinux
热度
- GitHub 星标
- 5.4k
- 排名
- #14964
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
azldev-add-component
5.4k帮你的智能体把新的软件组件添加到 azldev Linux 发行版构建中,从检查上游规格文件(spec)到验证结果。
azldev-build-component
5.4k帮你的智能体构建和调试 azldev 软件包,包括渲染、构建和测试循环,以及修复失败的构建检查。
azldev-comp-toml
5.4k帮你的智能体编写、编辑和审查 azldev 用来描述每个软件包如何构建的组件定义文件。
azldev-image
5.4k帮你的智能体使用 azldev 镜像命令构建、启动和测试 Linux 镜像,例如容器镜像或虚拟机镜像。