Files
docs/i18n/zh-tw/docusaurus-plugin-content-docs/version-1.24/usage/packages/conan.md
T

90 lines
2.6 KiB
Markdown
Raw Normal View History

2025-05-05 16:47:20 +00:00
---
date: "2021-07-20T00:00:00+00:00"
slug: "conan"
sidebar_position: 20
---
2025-09-03 21:00:35 +00:00
# Conan 軟體包註冊表
2025-05-05 16:47:20 +00:00
2025-09-03 21:00:35 +00:00
為您的使用者或組織發佈 [Conan](https://conan.io/) 軟體包。
2025-05-05 16:47:20 +00:00
## 要求
2025-09-03 21:00:35 +00:00
要使用 [conan](https://conan.io/downloads.html) 軟體包註冊表,您需要使用 conan 命令行工具来消费和發佈軟體包。
2025-05-05 16:47:20 +00:00
2025-09-03 21:00:35 +00:00
## 配置軟體包註冊表
2025-05-05 16:47:20 +00:00
2025-09-03 21:00:35 +00:00
要注册軟體包註冊表,您需要配置一个新的 Conan remote:
2025-05-05 16:47:20 +00:00
```shell
conan remote add {remote} https://gitea.example.com/api/packages/{owner}/conan
conan user --remote {remote} --password {password} {username}
```
2025-09-03 21:00:35 +00:00
| 參數 | 描述 |
2025-05-05 16:47:20 +00:00
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
2025-09-03 21:00:35 +00:00
| `remote` | 远程名稱。 |
| `username` | 您的 Gitea 使用者名。 |
| `password` | 您的 Gitea 密碼。如果您使用 2FA 或 OAuth,請使用[个人访问令牌](development/api-usage.md#通過-api-認證)替代密碼。 |
| `owner` | 軟體包的所有者。 |
2025-05-05 16:47:20 +00:00
例如:
```shell
conan remote add gitea https://gitea.example.com/api/packages/testuser/conan
conan user --remote gitea --password password123 testuser
```
2025-09-03 21:00:35 +00:00
## 發佈軟體包
2025-05-05 16:47:20 +00:00
2025-09-03 21:00:35 +00:00
通過运行以下命令發佈 Conan 軟體包:
2025-05-05 16:47:20 +00:00
```shell
conan upload --remote={remote} {recipe}
```
2025-09-03 21:00:35 +00:00
| 參數 | 描述 |
2025-05-05 16:47:20 +00:00
| -------- | --------------- |
2025-09-03 21:00:35 +00:00
| `remote` | 远程名稱 |
2025-05-05 16:47:20 +00:00
| `recipe` | 要上传的 recipe |
For example:
```shell
conan upload --remote=gitea ConanPackage/1.2@gitea/final
```
2025-09-03 21:00:35 +00:00
Gitea Conan 軟體包註冊表支持完整的[版本修订](https://docs.conan.io/en/latest/versioning/revisions.html)。
2025-05-05 16:47:20 +00:00
2025-09-03 21:00:35 +00:00
## 安裝軟體包
2025-05-05 16:47:20 +00:00
2025-09-03 21:00:35 +00:00
要从軟體包註冊表中安裝Conan軟體包,請執行以下命令:
2025-05-05 16:47:20 +00:00
```shell
conan install --remote={remote} {recipe}
```
2025-09-03 21:00:35 +00:00
| 參數 | 描述 |
2025-05-05 16:47:20 +00:00
| -------- | --------------- |
2025-09-03 21:00:35 +00:00
| `remote` | 远程名稱 |
2025-05-05 16:47:20 +00:00
| `recipe` | 要下载的 recipe |
例如:
```shell
conan install --remote=gitea ConanPackage/1.2@gitea/final
```
## 支持的命令
```
conan install
conan get
conan info
conan search
conan upload
conan user
conan download
conan remove
```