跳到正文
Skillpedia
部署与云(DevOps)5.4k · #14964

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。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/microsoft/azurelinux/blob/4.0/.agents/skills/azldev-mock/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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:

  1. Run a simple command (e.g. echo ready) in a foreground terminal to establish a shared shell.
  2. Ask the user to run the azldev adv mock shell command in that same terminal.
  3. Wait for confirmation that they are inside the mock shell.
  4. Run diagnostic commands in the same foreground terminal — they execute inside the chroot.
  5. Run exit to 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).

-p means --add-package, not a component name. Unlike azldev comp build -p <name>, mock shell has 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>.rpm for 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 shell sessions — 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 with mock directly (--scrub=chroot, or --scrub=all to also drop the bootstrap), pointing at the project's distro mock config.
  • One mock session per terminal. Running azldev adv mock shell while a terminal is already inside a mock shell fails — run exit first.

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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能