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

azldev-overlays

它能做什么

这项技能说明如何使用在渲染时应用的覆盖层修改上游软件包规格文件。它适用于在 azldev 发行版中定制软件包并需要排查问题的开发者。

适用场景

  • ✓当你需要修改上游规格文件中的一行或一段内容时。
  • ✓当覆盖层失败,或渲染后的规格文件看起来不对时。
  • ✓当你想添加本地补丁,而不复制整个规格文件时。

技能链接

https://github.com/microsoft/azurelinux/blob/4.0/.agents/skills/azldev-overlays/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

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

可以这样问 AI

“我需要修改上游规格文件中的一个设置,但不想分叉它。请帮我编写一个覆盖层。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会把覆盖层添加到组件配置中,渲染规格文件并检查结果。它会用差异输出找出覆盖层失败的原因,并进行修复。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Working with overlays

Overlays are semantic patches applied to a component's RPM spec and loose source files at render time. They let you make targeted changes to an upstream spec without forking it. Prefer an overlay over hand-editing a rendered spec: overlays are re-applied on every render, so a manual edit to a rendered spec is overwritten.

The inner loop

Overlays live in the component's TOML config — inline [[components.<name>.overlays]] entries, or per-file overlay documents referenced by the component's overlay-files glob. They apply in order and are non-atomic: if one fails part-way, the overlays before it stay applied.

  1. Add or edit the overlay in the component config.

  2. Re-render and inspect the result:

    azldev comp render -p <name>
    

    Read the rendered spec (under specs/) to confirm the change landed where you intended, and iterate until it is correct.

  3. Finalize the lock and changelog with the normal end-of-work refresh (see the azldev-update-component skill): update the lock, commit, then re-render and amend.

Config errors reference the offending overlay by its description, so give every overlay a short, specific description.

Diagnose common failures

Start with azldev comp diff-sources -p <name> to see the exact overlay effect. Use separate pre/post prep-sources directories only when you need persistent trees for deeper inspection.

Symptom Likely cause and fix
spec-add-tag: tag already exists Upstream already has the tag. Use spec-set-tag, or spec-update-tag when its prior existence is an invariant.
spec-search-replace: no match Inspect the current upstream line, check TOML regex quoting, and narrow the expression to the actual section/package.
Section or file not found Inspect the upstream spec/source names; upstream may have renamed or removed the target.
Overlay applies but output/build is wrong Inspect diff-sources for an over-broad match, malformed replacement, or a dependency/file change the overlay omitted.

Choosing an overlay type

Match the change to the narrowest overlay type. Required fields are enforced when the config loads, so a missing field fails fast rather than at apply time.

Spec overlays (structured .spec edits)

Type Use for Required
spec-add-tag add a tag; fails if it already exists tag, value
spec-insert-tag add a tag next to its family (e.g. after the last Source*) tag, value
spec-set-tag set a tag, replacing it if present or adding it if not tag, value
spec-update-tag change an existing tag; fails if it is missing tag, value
spec-remove-tag delete tag instances; without value, deletes every instance tag
spec-prepend-lines insert lines at the top of a section (or the whole file) lines
spec-append-lines insert lines at the end of a section (or the whole file) lines
spec-search-replace regex replace within a section (or the whole spec) regex
spec-remove-section delete a whole section section
spec-remove-subpackage delete every section of a sub-package package
patch-add add a .patch file and register it in the spec source
patch-remove remove a patch and its spec references file

File overlays (loose non-spec files; never .spec)

Type Use for Required
file-prepend-lines prepend lines to a file file, lines
file-search-replace regex replace in a file file, regex
file-add copy in a new file; fails if it already exists file, source
file-remove delete a file file
file-rename rename a file in place file, replacement

Rules that trip people up

  • spec-remove-tag without value removes every instance of the named tag. To remove one dependency, set both tag and the exact value to match:

    [[components.mypackage.overlays]]
    description = "Remove an unavailable build dependency"
    type = "spec-remove-tag"
    tag = "BuildRequires"
    value = "unwanted-package"
    
  • section is optional only for spec-prepend-lines, spec-append-lines, and spec-search-replace (omit it to target the whole spec). It is required for spec-remove-section.

  • package needs section on the whole-file-capable overlays — a sub-package is a sub-qualifi

常见问题

为什么不直接编辑渲染后的规格文件?

技能说明,覆盖层会在每次渲染时重新应用,因此手动编辑的渲染规格文件会被覆盖。

覆盖层按顺序应用吗?

是的。技能说明,它们按顺序应用,如果中途失败,之前已应用的覆盖层会保持生效。

为什么要为每个覆盖层添加描述?

配置错误会通过描述来指代覆盖层,因此简短而具体的描述有助于找到问题。

详情

作者的原始描述

Read this before adding, changing, or diagnosing any overlay; never edit a spec or rendered file from memory. Explains how to modify a component's RPM spec or loose source files with azldev overlays (semantic patches applied at render time) instead of forking the spec, covering overlay types, the render-and-inspect loop, common failures, pitfalls, and metadata. Triggers include overlay, overlay failed, no match, spec-add-tag, spec-remove-tag, patch-add, fix spec, backport, disable test, prune subpackage, edit spec.

repo: microsoft/azurelinux

热度

GitHub 星标
5.4k
排名
#14966
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能