Fix some RPM registry flaws (#28782)

Related #26984
(https://github.com/go-gitea/gitea/pull/26984#issuecomment-1889588912)

Fix admin cleanup message.
Fix models `Get` not respecting default values.
Rebuild RPM repository files after cleanup.
Do not add RPM group to package version name.
Force stable sorting of Alpine/Debian/RPM repository data.
Fix missing deferred `Close`.
Add tests for multiple RPM groups.
Removed non-cached `ReplaceAllStringRegex`.

If there are multiple groups available, it's stated in the package
installation screen:

![grafik](https://github.com/go-gitea/gitea/assets/1666336/8f132760-882c-4ab8-9678-77e47dfc4415)
This commit is contained in:
KN4CK3R
2024-01-19 12:37:10 +01:00
committed by GitHub
parent b5e93334ca
commit 2e821366c4

View File

@@ -24,16 +24,26 @@ The following examples use `dnf`.
## Configuring the package registry ## Configuring the package registry
To register the RPM registry add the url to the list of known apt sources: To register the RPM registry add the url to the list of known sources:
```shell ```shell
dnf config-manager --add-repo https://gitea.example.com/api/packages/{owner}/rpm/{group}.repo dnf config-manager --add-repo https://gitea.example.com/api/packages/{owner}/rpm/{group}.repo
``` ```
| Placeholder | Description | | Placeholder | Description |
| ----------- |----------------------------------------------------| | ----------- | ----------- |
| `owner` | The owner of the package. | | `owner` | The owner of the package. |
| `group` | Everything, e.g. `el7`, `rocky/el9` , `test/fc38`.| | `group` | Optional: Everything, e.g. empty, `el7`, `rocky/el9`, `test/fc38`. |
Example:
```shell
# without a group
dnf config-manager --add-repo https://gitea.example.com/api/packages/testuser/rpm.repo
# with the group 'centos/el7'
dnf config-manager --add-repo https://gitea.example.com/api/packages/testuser/rpm/centos/el7.repo
```
If the registry is private, provide credentials in the url. You can use a password or a [personal access token](development/api-usage.md#authentication): If the registry is private, provide credentials in the url. You can use a password or a [personal access token](development/api-usage.md#authentication):
@@ -41,7 +51,7 @@ If the registry is private, provide credentials in the url. You can use a passwo
dnf config-manager --add-repo https://{username}:{your_password_or_token}@gitea.example.com/api/packages/{owner}/rpm/{group}.repo dnf config-manager --add-repo https://{username}:{your_password_or_token}@gitea.example.com/api/packages/{owner}/rpm/{group}.repo
``` ```
You have to add the credentials to the urls in the `rpm.repo` file in `/etc/yum.repos.d` too. You have to add the credentials to the urls in the created `.repo` file in `/etc/yum.repos.d` too.
## Publish a package ## Publish a package
@@ -54,11 +64,17 @@ PUT https://gitea.example.com/api/packages/{owner}/rpm/{group}/upload
| Parameter | Description | | Parameter | Description |
| --------- | ----------- | | --------- | ----------- |
| `owner` | The owner of the package. | | `owner` | The owner of the package. |
| `group` | Everything, e.g. `el7`, `rocky/el9` , `test/fc38`.| | `group` | Optional: Everything, e.g. empty, `el7`, `rocky/el9`, `test/fc38`. |
Example request using HTTP Basic authentication: Example request using HTTP Basic authentication:
```shell ```shell
# without a group
curl --user your_username:your_password_or_token \
--upload-file path/to/file.rpm \
https://gitea.example.com/api/packages/testuser/rpm/upload
# with the group 'centos/el7'
curl --user your_username:your_password_or_token \ curl --user your_username:your_password_or_token \
--upload-file path/to/file.rpm \ --upload-file path/to/file.rpm \
https://gitea.example.com/api/packages/testuser/rpm/centos/el7/upload https://gitea.example.com/api/packages/testuser/rpm/centos/el7/upload
@@ -84,9 +100,9 @@ DELETE https://gitea.example.com/api/packages/{owner}/rpm/{group}/package/{packa
``` ```
| Parameter | Description | | Parameter | Description |
|-------------------|----------------------------| | ----------------- | ----------- |
| `owner` | The owner of the package. | | `owner` | The owner of the package. |
| `group` | The package group . | | `group` | Optional: The package group. |
| `package_name` | The package name. | | `package_name` | The package name. |
| `package_version` | The package version. | | `package_version` | The package version. |
| `architecture` | The package architecture. | | `architecture` | The package architecture. |
@@ -94,6 +110,11 @@ DELETE https://gitea.example.com/api/packages/{owner}/rpm/{group}/package/{packa
Example request using HTTP Basic authentication: Example request using HTTP Basic authentication:
```shell ```shell
# without a group
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
# with the group 'centos/el7'
curl --user your_username:your_token_or_password -X DELETE \ 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 https://gitea.example.com/api/packages/testuser/rpm/centos/el7/package/test-package/1.0.0/x86_64
``` ```