

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 迁移来源 dnf-plugin-support-info v1 到 v2

该dnf-plugin-support-info软件包具有新的主要版本 (v2)，其输出格式经过重新设计。本指南可帮助您更新任何解析`dnf supportinfo`输出的脚本或工具。

在过渡期间，v2 插件附带了 `legacy = 1` in`/etc/dnf/plugins/supportinfo.conf`，它保留了与 v1 兼容的输出。更新脚本后，设置切换`legacy = 0`到 v2 输出。

**Topics**
+ [概述](#dnf-supportinfo-migrate-overview)
+ [需要采取措施的重大更改](#dnf-supportinfo-migrate-breaking-changes)
+ [什么没有改变](#dnf-supportinfo-migrate-unchanged)
+ [过渡期](#dnf-supportinfo-migrate-transition-period)

## 概述
<a name="dnf-supportinfo-migrate-overview"></a>

### 时间轴
<a name="dnf-supportinfo-migrate-timeline"></a>


| 事件 | Timing | 
| --- | --- | 
| v2 插件 (dnf-plugin-support-info 2.0) 可用 | 现在 | 
| 插件附带legacy = 1（与 v1 兼容的输出） | 最初的 v2 版本 | 
| 默认更改为 legacy = 0 | 未来的 AL2023 季度版本 | 
| v1 格式不再维护 | 过渡期之后 | 

### 你需要做什么
<a name="dnf-supportinfo-migrate-what-to-do"></a>

如果您有解析控制台输出、XML 输出或从磁盘读取 XML 文件的脚本，请更新它们以处理新的字段名称、结构和文件路径。如果您使用`--showjson`，则无需更改脚本，因为 v1 和 v2 之间的 JSON 输出相同。如果您直接从磁盘读取 XML 文件，请切换到从已配置`baseurl`或使用的文件中下载 XML `dnf supportinfo --show installed --showxml`。

## 需要采取措施的重大更改
<a name="dnf-supportinfo-migrate-breaking-changes"></a>

### 如果你解析控制台输出
<a name="dnf-supportinfo-migrate-console-output"></a>

#### 详细信息字段
<a name="dnf-supportinfo-migrate-detail-fields"></a>

该插件更改了在您查询特定软件包时显示的字段标签：


| v1 标签 | v2 标签 | 注意 | 
| --- | --- | --- | 
| 支持状态 | 当前状态 | 重命名 | 
| 支持期 | 支持时间表 | 已重命名，移至输出末尾 | 
| 支持声明 | （已删除） | 不再显示 | 
| Link | Link | 不变（可用时显示） | 
| 其他信息 | 其他信息 | 不变（可用时显示） | 
| （不存在） | 补丁优先级 | 新字段 | 
| （不存在） | 支持级别描述 | 新字段 | 
| （不存在） | 承保的严重程度 | 新字段 | 
| （不存在） | Origin | 新字段 | 

字段标签列现在的宽度为 28 个字符（以前为 20 个字符）。

**v1：**`dnf supportinfo --pkg apr`

```
Name                 : apr
Version              : 1.7.5-1.amzn2023.0.4
State                : available
Support Status       : supported
Support Periods      : from 2023-03-15      : supported
                     : from 2029-06-30      : unsupported
Support Statement    : Amazon Linux 2023 end-of-life
Link                 : https://aws.amazon.com/amazon-linux-ami/faqs/
Other Info           : This is the support statement for AL2023. The end-of-life
                     : of Amazon Linux 2023 is June 2029. From this point, the
                     : Amazon Linux 2023 packages will no longer receive any
                     : updates from AWS.
```

**v2**：`dnf supportinfo --pkg apr`

```
Name                         : apr
Version                      : 1.7.5-1.amzn2023.0.4
State                        : available
Current Status               : Supported
Patch Priority               : Full Support
Support Level Description    : Full security and bug fix support for all severities
Covered Severities           : Low, Medium, Important, Critical
Origin                       : Amazon Linux 2023 Core
Support Timeline             : from 2023-03-15     : supported
                             : from 2029-06-30     : unsupported
```

#### 表列
<a name="dnf-supportinfo-migrate-table-columns"></a>

汇总表已从 6 列更改为 7 列。v2 表还显示标题行（v1 没有）：


| v1 专栏 | v2 专栏 | 更改 | 
| --- | --- | --- | 
| Name | 程序包 | 重命名 | 
| 版本 | 版本 | 不变 | 
| 州 | 州 | 不变 | 
| 支持状态 | 当前状态 | 重命名 | 
| （不存在） | 支持级别 | 新专栏 | 
| 日期（例如2029-06-30） | 直到（下一阶段）（例如2029-06-30 (end\_of\_support)） | 已重命名，格式已更改 | 
| 备注 | 备注 | 不变 | 

**重要**  
现在，日期列在括号中包含下一个阶段的名称。如果您解析此字段，请更新您的正则表达式或分隔符逻辑。

**v1：**`dnf supportinfo --show installed`

```
iproute              6.10.0-319.amzn2023.0.1    installed    supported    2029-06-30    Kernel6.18 has security support until June 2029
kernel6.12           6.12.90-120.164.amzn2023   installed    supported    2029-06-30    Kernel6.12 has security support until June 2029
```

**v2**：`dnf supportinfo --show installed`

```
Package                          Version                            State        Support Level    Current Status         Until (Next Phase)           Note
alternatives                     1.15-2.amzn2023.0.2                installed    Full Support     Supported              2029-06-30 (unsupported)
amazon-linux-repo-cdn            2023.12.20260611-0.amzn2023        installed    Full Support     Supported              2029-06-30 (unsupported)
redis6                           6.2.20-2.amzn2023.0.1              installed    End of Support   End of Life                                         Upstream end-of-life for Redis 6 (redis6) is 2026-01-31
```

### 如果你解析 `--` showxml 输出
<a name="dnf-supportinfo-migrate-xml-output"></a>

v2 `--showxml` 输出使用与 v1 不同的 XML 结构。根`<package_support>`元素相同，但子元素、属性和层次结构已更改。

**v1：**`dnf supportinfo --pkg apr --showxml`

```xml
<?xml version="1.0" ?>
<package_support current_as="2026-06-18">
  <statements>
    <statement id="eol" marker="supported" start_date="2023-03-15" end_date="2029-06-30">
      <summary>Amazon Linux 2023 end-of-life</summary>
      <text>This is the support statement for AL2023. The end-of-life of Amazon
Linux 2023 is June 2029. From this point, the Amazon Linux 2023 packages will
no longer receive any updates from AWS.</text>
      <link>https://aws.amazon.com/amazon-linux-ami/faqs/</link>
      <packages>
        <package name="apr" nevra="1.7.5-1.amzn2023.0.4"/>
      </packages>
    </statement>
  </statements>
</package_support>
```

**v2**：`dnf supportinfo --pkg apr --showxml`

```xml
<?xml version='1.0' encoding='utf-8'?>
<package_support current_as="2026-06-18">
  <statements>
    <statement id="eol_lc" current_phase="supported">
      <phases>
        <phase name="supported" start_date="2023-03-15">
          <patch_priority>Full Support</patch_priority>
          <support_level_description>Full security and bug fix support for all severities</support_level_description>
          <covered_severities>Low, Medium, Important, Critical</covered_severities>
        </phase>
        <phase name="unsupported" start_date="2029-06-30">
          <patch_priority>End of Support</patch_priority>
          <support_level_description>End of support - no further updates</support_level_description>
        </phase>
      </phases>
      <packages>
        <package name="apr" nevra="1.7.5-1.amzn2023.0.4" state="available" origin="Amazon Linux 2023 Core"/>
      </packages>
    </statement>
  </statements>
</package_support>
```

主要结构差异：
+ v1 在 with`marker`,`start_date`, ch `end_date` ildren 上`<statement>`使用`<summary>`,`<text>`, `<link>` 属性
+ v2 使用带有支持级别详细信息的`current_phase`属性和嵌套`<phases>`元素
+ v2 为空时`<covered_severities>`完全省略（而不是空元素）
+ v2 包元素包含`state`和`origin`属性
+ v2 不包含`<summary>``<text>`、或`<link>`元素

### 如果您直接从磁盘读取 XML 文件
<a name="dnf-supportinfo-migrate-xml-file"></a>

v1 插件将其数据文件捆绑在：

```
/usr/lib/python*/site-packages/dnf-plugins/support_info.xml
```

**警告**  
此文件一旦生`legacy = 0`效，将不再更新。不要依赖此路径获取当前数据。

v2 插件在以 root 身份运行`/var/cache/dnf/support-info/`时缓存数据。当以非 root 用户身份运行时，它会按照 DNF 的每个用户的标准临时目录惯例使用`/var/tmp/dnf-{{username}}-*/support-info/`。这些目录中的文件使用内容寻址文件名，并且不稳定。不要直接解析它们。

**推荐的替代方案：**

1. 直接从配置的 URL 下载 XML：

   ```
   https://cdn.amazonlinux.com/al2023/core/AL2023-supportinfo-1.0.xml
   ```

1. 使用 CLI 获取已安装软件包的结构化输出：

   ```bash
   dnf supportinfo --show installed --showxml
   ```

### 如果你使用 `--show 进行过滤`
<a name="dnf-supportinfo-migrate-show-filter"></a>

`--show`过滤器接受的值已更改：


| v1 过滤器值 | v2 过滤器值 | 
| --- | --- | 
| supported | full\_support | 
| unsupported | eos | 

v1 过滤器是**阶段名称 ** (`supported`,`unsupported`)。v2 过滤器是**支持级别名称**（`full_support``eos`、等）。

运行`--list-filters`以发现系统上可用的过滤器值：

```bash
dnf supportinfo --list-filters
```

## 什么没有改变
<a name="dnf-supportinfo-migrate-unchanged"></a>

安装 dnf-plugin-support-info v2 后，无论`legacy`设置如何，以下内容都保持不变：
+ **`--showjson`输出。**无论是还是，JSON 输出`legacy`都是`0`相同的`1`，因为插件在格式化之前会标准化为 v2 内部结构。
+ **CLI 参数。**所有标志（`--pkg`、`--show`、`--showxml`、、`--showjson`、`--clean-cache``--list-filters`、`--sync`）在两种模式下均有效。
+ **命令名。**你还在跑`dnf supportinfo`。

**注意**  
`--showjson`、`--clean-cache``--list-filters`、和`--sync`标志是 v2 中的新增内容，在 v1 中不可用。

## 过渡期
<a name="dnf-supportinfo-migrate-transition-period"></a>

v2 插件附带`legacy = 1``/etc/dnf/plugins/supportinfo.conf`了。在此期间：

1. 该插件从配置的 URL 下载 v2 数据。

1. 控制台输出、XML 输出和过滤器值继续表现得像 v1 一样。

1. v1 格式的 XML 文件在旧路径中仍然可用，因此现有脚本可以继续运行。

在未来的 AL2023 季度版本中，默认值更改为`legacy = 0`。那时：
+ 控制台输出使用 v2 字段名称和结构。
+ `--showxml`生成新的基于相位的格式。
+ `--show`过滤器值更改为支持级别名称。
+ 旧路径中的 v1 XML 文件不再更新。

**要暂时保留 v1 兼容的输出**，请设置`legacy = 1`：`/etc/dnf/plugins/supportinfo.conf`

```ini
[main]
legacy = 1
```

**重要**  
该`legacy = 1`选项是临时桥梁。计划将您的工具迁移到 v2 输出，而不是无限期地依赖此设置。