跳至主要内容
版本:1.24.6

Debian 軟體包註冊表

為您的使用者或組織發佈 Debian 軟體包。

要求

要使用 Debian 註冊表,您需要使用类似于 curl 的 HTTP 客户端進行上传,並使用类似于 apt 的軟體包管理器消费軟體包。

以下示例使用 apt

配置軟體包註冊表

要注册 Debian 註冊表,請将 URL 添加到已知 apt 源列表中:

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
占位符描述
owner軟體包的所有者
distribution要使用的发行版
component要使用的组件

如果註冊表是私有的,請在 URL 中提供凭据。您可以使用密碼或个人访问令牌

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

Debian 註冊表文件使用 PGP 密钥進行签名,apt 必須知道該密钥:

sudo curl https://gitea.example.com/api/packages/{owner}/debian/repository.key -o /etc/apt/keyrings/gitea-{owner}.asc

然后更新本地軟體包索引:

apt update

發佈軟體包

要發佈一个 Debian 軟體包(*.deb),執行 HTTP PUT 操作,並将軟體包内容放入請求主體中。

PUT https://gitea.example.com/api/packages/{owner}/debian/pool/{distribution}/{component}/upload
參數描述
owner軟體包的所有者
distribution发行版,可能与操作系统的发行版名稱匹配,例如 bionic
component组件,可用于分组軟體包,或僅為 main 或类似的组件。

使用 HTTP 基本身份驗證的示例請求:

curl --user your_username:your_password_or_token \
--upload-file path/to/file.deb \
https://gitea.example.com/api/packages/testuser/debian/pool/bionic/main/upload

如果您使用 2FA 或 OAuth,請使用个人访问令牌替代密碼。 您無法向軟體包中多次發佈具有相同名稱的文件。您必須首先删除現有的軟體包版本。

服务器将使用以下 HTTP 状态代码進行響應。

HTTP 状态码意义
201 Created軟體包已發佈
400 Bad Request軟體包名稱、版本、发行版、组件或架构無效
409 Conflict具有相同參數组合的軟體包文件已经存在

删除軟體包

要删除 Debian 軟體包,請執行 HTTP DELETE 操作。如果没有文件留下,这将同时删除軟體包版本。

DELETE https://gitea.example.com/api/packages/{owner}/debian/pool/{distribution}/{component}/{package_name}/{package_version}/{architecture}
參數描述
owner軟體包的所有者
package_name軟體包名稱
package_version軟體包版本
distribution軟體包发行版
component軟體包组件
architecture軟體包架构

使用 HTTP 基本身份驗證的示例請求:

curl --user your_username:your_token_or_password -X DELETE \
https://gitea.example.com/api/packages/testuser/debian/pools/bionic/main/test-package/1.0.0/amd64

服务器将使用以下 HTTP 状态代码進行響應。

HTTP 状态码含义
204 No Content成功
404 Not Found找不到軟體包或文件

安裝軟體包

要从 Debian 註冊表安裝軟體包,請執行以下命令:

# use latest version
apt install {package_name}
# use specific version
apt install {package_name}={package_version}