code.gitea.io/gitea@v1.22.3/docs/content/usage/packages/debian.zh-cn.md (about)

     1  ---
     2  date: "2023-01-07T00:00:00+00:00"
     3  title: "Debian 软件包注册表"
     4  slug: "debian"
     5  draft: false
     6  toc: false
     7  menu:
     8    sidebar:
     9      parent: "packages"
    10      name: "Debian"
    11      sidebar_position: 35
    12      identifier: "debian"
    13  ---
    14  
    15  # Debian 软件包注册表
    16  
    17  为您的用户或组织发布 [Debian](https://www.debian.org/distrib/packages) 软件包。
    18  
    19  ## 要求
    20  
    21  要使用 Debian 注册表,您需要使用类似于 `curl` 的 HTTP 客户端进行上传,并使用类似于 `apt` 的软件包管理器消费软件包。
    22  
    23  以下示例使用 `apt`。
    24  
    25  ## 配置软件包注册表
    26  
    27  要注册 Debian 注册表,请将 URL 添加到已知 `apt` 源列表中:
    28  
    29  ```shell
    30  echo "deb [signed-by=/etc/apt/keyrings/gitea-{owner}.asc] https://gitea.example.com/api/packages/{owner}/debian {distribution} {component}" | sudo tee -a /etc/apt/sources.list.d/gitea.list
    31  ```
    32  
    33  | 占位符         | 描述           |
    34  | -------------- | -------------- |
    35  | `owner`        | 软件包的所有者 |
    36  | `distribution` | 要使用的发行版 |
    37  | `component`    | 要使用的组件   |
    38  
    39  如果注册表是私有的,请在 URL 中提供凭据。您可以使用密码或[个人访问令牌](development/api-usage.md#通过-api-认证):
    40  
    41  ```shell
    42  echo "deb [signed-by=/etc/apt/keyrings/gitea-{owner}.asc] https://{username}:{your_password_or_token}@gitea.example.com/api/packages/{owner}/debian {distribution} {component}" | sudo tee -a /etc/apt/sources.list.d/gitea.list
    43  ```
    44  
    45  Debian 注册表文件使用 PGP 密钥进行签名,`apt` 必须知道该密钥:
    46  
    47  ```shell
    48  sudo curl https://gitea.example.com/api/packages/{owner}/debian/repository.key -o /etc/apt/keyrings/gitea-{owner}.asc
    49  ```
    50  
    51  然后更新本地软件包索引:
    52  
    53  ```shell
    54  apt update
    55  ```
    56  
    57  ## 发布软件包
    58  
    59  要发布一个 Debian 软件包(`*.deb`),执行 HTTP `PUT` 操作,并将软件包内容放入请求主体中。
    60  
    61  ```
    62  PUT https://gitea.example.com/api/packages/{owner}/debian/pool/{distribution}/{component}/upload
    63  ```
    64  
    65  | 参数           | 描述                                                  |
    66  | -------------- | ----------------------------------------------------- |
    67  | `owner`        | 软件包的所有者                                        |
    68  | `distribution` | 发行版,可能与操作系统的发行版名称匹配,例如 `bionic` |
    69  | `component`    | 组件,可用于分组软件包,或仅为 `main` 或类似的组件。  |
    70  
    71  使用 HTTP 基本身份验证的示例请求:
    72  
    73  ```shell
    74  curl --user your_username:your_password_or_token \
    75       --upload-file path/to/file.deb \
    76       https://gitea.example.com/api/packages/testuser/debian/pool/bionic/main/upload
    77  ```
    78  
    79  如果您使用 2FA 或 OAuth,请使用[个人访问令牌](development/api-usage.md#通过-api-认证)替代密码。
    80  您无法向软件包中多次发布具有相同名称的文件。您必须首先删除现有的软件包版本。
    81  
    82  服务器将使用以下 HTTP 状态代码进行响应。
    83  
    84  | HTTP 状态码       | 意义                                     |
    85  | ----------------- | ---------------------------------------- |
    86  | `201 Created`     | 软件包已发布                             |
    87  | `400 Bad Request` | 软件包名称、版本、发行版、组件或架构无效 |
    88  | `409 Conflict`    | 具有相同参数组合的软件包文件已经存在     |
    89  
    90  ## 删除软件包
    91  
    92  要删除 Debian 软件包,请执行 HTTP `DELETE` 操作。如果没有文件留下,这将同时删除软件包版本。
    93  
    94  ```
    95  DELETE https://gitea.example.com/api/packages/{owner}/debian/pool/{distribution}/{component}/{package_name}/{package_version}/{architecture}
    96  ```
    97  
    98  | 参数              | 描述           |
    99  | ----------------- | -------------- |
   100  | `owner`           | 软件包的所有者 |
   101  | `package_name`    | 软件包名称     |
   102  | `package_version` | 软件包版本     |
   103  | `distribution`    | 软件包发行版   |
   104  | `component`       | 软件包组件     |
   105  | `architecture`    | 软件包架构     |
   106  
   107  使用 HTTP 基本身份验证的示例请求:
   108  
   109  ```shell
   110  curl --user your_username:your_token_or_password -X DELETE \
   111       https://gitea.example.com/api/packages/testuser/debian/pools/bionic/main/test-package/1.0.0/amd64
   112  ```
   113  
   114  服务器将使用以下 HTTP 状态代码进行响应。
   115  
   116  | HTTP 状态码      | 含义               |
   117  | ---------------- | ------------------ |
   118  | `204 No Content` | 成功               |
   119  | `404 Not Found`  | 找不到软件包或文件 |
   120  
   121  ## 安装软件包
   122  
   123  要从 Debian 注册表安装软件包,请执行以下命令:
   124  
   125  ```shell
   126  # use latest version
   127  apt install {package_name}
   128  # use specific version
   129  apt install {package_name}={package_version}
   130  ```