Files
gitea-docs/i18n/zh-tw/docusaurus-plugin-content-docs/version-1.23/usage/packages/rpm.md
Lunny Xiao 965c269495 Update zh tw languages and fix some broken links (#455)
---------

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: silverwind <2021+silverwind@noreply.gitea.com>
Reviewed-on: https://gitea.com/gitea/docs/pulls/455
Reviewed-by: silverwind <2021+silverwind@noreply.gitea.com>
2026-07-09 23:41:46 +00:00

131 lines
4.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
date: "2023-03-08T00:00:00+00:00"
slug: "rpm"
sidebar_position: 105
---
# RPM 套件註冊表
為您的使用者或組織發布 [RPM](https://rpm.org/) 套件。
## 需求
要使用 RPM 註冊表,您需要使用像 `yum``dnf``zypper` 這樣的套件管理器來消費套件。
以下範例使用 `dnf`
## 設定套件註冊表
要註冊 RPM 註冊表,請將 URL 添加到已知來源列表中:
```shell
dnf config-manager --add-repo https://gitea.example.com/api/packages/{owner}/rpm/{group}.repo
```
| 佔位符 | 描述 |
| ------- | ----------------------------------------------------------- |
| `owner` | 套件的擁有者。 |
| `group` | 可選:所有內容,例如空的,`el7``rocky/el9``test/fc38`。 |
範例:
```shell
# 沒有分組
dnf config-manager --add-repo https://gitea.example.com/api/packages/testuser/rpm.repo
# 使用分組 'centos/el7'
dnf config-manager --add-repo https://gitea.example.com/api/packages/testuser/rpm/centos/el7.repo
```
如果註冊表是私有的,請在 URL 中提供憑證。您可以使用密碼或 [個人存取權杖](development/api-usage.md#認證)
```shell
dnf config-manager --add-repo https://{username}:{your_password_or_token}@gitea.example.com/api/packages/{owner}/rpm/{group}.repo
```
您還需要將憑證添加到建立的 `.repo` 文件中的 URL 中,位於 `/etc/yum.repos.d`
## 發布套件
要發布 RPM 套件(`*.rpm`),請執行 HTTP PUT 操作,請求體中包含套件內容。
```
PUT https://gitea.example.com/api/packages/{owner}/rpm/{group}/upload
```
| 參數 | 描述 |
| ------- | ----------------------------------------------------------- |
| `owner` | 套件的擁有者。 |
| `group` | 可選:所有內容,例如空的,`el7``rocky/el9``test/fc38`。 |
使用 HTTP 基本身份驗證的範例請求:
```shell
# 沒有分組
curl --user your_username:your_password_or_token \
--upload-file path/to/file.rpm \
https://gitea.example.com/api/packages/testuser/rpm/upload
# 使用分組 'centos/el7'
curl --user your_username:your_password_or_token \
--upload-file path/to/file.rpm \
https://gitea.example.com/api/packages/testuser/rpm/centos/el7/upload
```
如果您使用 2FA 或 OAuth請使用 [個人存取權杖](development/api-usage.md#認證) 代替密碼。
您不能將同名文件兩次發布到套件中。您必須先刪除現有的套件版本。
伺服器響應以下 HTTP 狀態碼。
| HTTP 狀態碼 | 含義 |
| ----------------- | ------------------------------------ |
| `201 Created` | 套件已發布。 |
| `400 Bad Request` | 套件無效。 |
| `409 Conflict` | 套件中已存在具有相同參數組合的文件。 |
## 刪除套件
要刪除 RPM 套件,請執行 HTTP DELETE 操作。如果沒有文件剩餘,這也會刪除套件版本。
```
DELETE https://gitea.example.com/api/packages/{owner}/rpm/{group}/package/{package_name}/{package_version}/{architecture}
```
| 參數 | 描述 |
| ----------------- | ---------------- |
| `owner` | 套件的擁有者。 |
| `group` | 可選:套件分組。 |
| `package_name` | 套件名稱。 |
| `package_version` | 套件版本。 |
| `architecture` | 套件架構。 |
使用 HTTP 基本身份驗證的範例請求:
```shell
# 沒有分組
curl --user your_username:your_token_or_password -X DELETE \
https://gitea.example.com/api/packages/testuser/rpm/package/test-package/1.0.0/x86_64
# 使用分組 'centos/el7'
curl --user your_username:your_token_or_password -X DELETE \
https://gitea.example.com/api/packages/testuser/rpm/centos/el7/package/test-package/1.0.0/x86_64
```
伺服器響應以下 HTTP 狀態碼。
| HTTP 狀態碼 | 含義 |
| ---------------- | ------------------ |
| `204 No Content` | 成功 |
| `404 Not Found` | 未找到套件或文件。 |
## 安裝套件
要從 RPM 註冊表中安裝套件,請執行以下命令:
```shell
# 使用最新版本
dnf install {package_name}
# 使用特定版本
dnf install {package_name}-{package_version}.{architecture}
```