Skip to content

Commit 05209f0

Browse files
authored
Add RPM registry (#23380)
Fixes #20751 This PR adds a RPM package registry. You can follow [this tutorial](https://opensource.com/article/18/9/how-build-rpm-packages) to build a *.rpm package for testing. This functionality is similar to the Debian registry (#22854) and therefore shares some methods. I marked this PR as blocked because it should be merged after #22854. ![grafik](https://user-images.githubusercontent.com/1666336/223806549-d8784fd9-9d79-46a2-9ae2-f038594f636a.png)
1 parent 8f314c6 commit 05209f0

File tree

29 files changed

+1998
-43
lines changed

29 files changed

+1998
-43
lines changed

assets/go-licenses.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

custom/conf/app.example.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2512,6 +2512,8 @@ ROUTER = console
25122512
;LIMIT_SIZE_PUB = -1
25132513
;; Maximum size of a PyPI upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
25142514
;LIMIT_SIZE_PYPI = -1
2515+
;; Maximum size of a RPM upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
2516+
;LIMIT_SIZE_RPM = -1
25152517
;; Maximum size of a RubyGems upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
25162518
;LIMIT_SIZE_RUBYGEMS = -1
25172519
;; Maximum size of a Swift upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)

docs/content/doc/administration/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,7 @@ Task queue configuration has been moved to `queue.task`. However, the below conf
12591259
- `LIMIT_SIZE_NUGET`: **-1**: Maximum size of a NuGet upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
12601260
- `LIMIT_SIZE_PUB`: **-1**: Maximum size of a Pub upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
12611261
- `LIMIT_SIZE_PYPI`: **-1**: Maximum size of a PyPI upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1262+
- `LIMIT_SIZE_RPM`: **-1**: Maximum size of a RPM upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
12621263
- `LIMIT_SIZE_RUBYGEMS`: **-1**: Maximum size of a RubyGems upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
12631264
- `LIMIT_SIZE_SWIFT`: **-1**: Maximum size of a Swift upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
12641265
- `LIMIT_SIZE_VAGRANT`: **-1**: Maximum size of a Vagrant upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)

docs/content/doc/usage/packages/overview.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ The following package managers are currently supported:
4141
| [NuGet]({{< relref "doc/usage/packages/nuget.en-us.md" >}}) | .NET | `nuget` |
4242
| [Pub]({{< relref "doc/usage/packages/pub.en-us.md" >}}) | Dart | `dart`, `flutter` |
4343
| [PyPI]({{< relref "doc/usage/packages/pypi.en-us.md" >}}) | Python | `pip`, `twine` |
44+
| [RPM]({{< relref "doc/usage/packages/rpm.en-us.md" >}}) | - | `yum`, `dnf` |
4445
| [RubyGems]({{< relref "doc/usage/packages/rubygems.en-us.md" >}}) | Ruby | `gem`, `Bundler` |
4546
| [Swift]({{< relref "doc/usage/packages/rubygems.en-us.md" >}}) | Swift | `swift` |
4647
| [Vagrant]({{< relref "doc/usage/packages/vagrant.en-us.md" >}}) | - | `vagrant` |
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
---
2+
date: "2023-03-08T00:00:00+00:00"
3+
title: "RPM Packages Repository"
4+
slug: "packages/rpm"
5+
draft: false
6+
toc: false
7+
menu:
8+
sidebar:
9+
parent: "packages"
10+
name: "RPM"
11+
weight: 105
12+
identifier: "rpm"
13+
---
14+
15+
# RPM Packages Repository
16+
17+
Publish [RPM](https://rpm.org/) packages for your user or organization.
18+
19+
**Table of Contents**
20+
21+
{{< toc >}}
22+
23+
## Requirements
24+
25+
To work with the RPM registry, you need to use a package manager like `yum` or `dnf` to consume packages.
26+
27+
The following examples use `dnf`.
28+
29+
## Configuring the package registry
30+
31+
To register the RPM registry add the url to the list of known apt sources:
32+
33+
```shell
34+
dnf config-manager --add-repo https://gitea.example.com/api/packages/{owner}/rpm.repo
35+
```
36+
37+
| Placeholder | Description |
38+
| ----------- | ----------- |
39+
| `owner` | The owner of the package. |
40+
41+
If the registry is private, provide credentials in the url. You can use a password or a [personal access token]({{< relref "doc/developers/api-usage.en-us.md#authentication" >}}):
42+
43+
```shell
44+
dnf config-manager --add-repo https://{username}:{your_password_or_token}@gitea.example.com/api/packages/{owner}/rpm.repo
45+
```
46+
47+
You have to add the credentials to the urls in the `rpm.repo` file in `/etc/yum.repos.d` too.
48+
49+
## Publish a package
50+
51+
To publish a RPM package (`*.rpm`), perform a HTTP PUT operation with the package content in the request body.
52+
53+
```
54+
PUT https://gitea.example.com/api/packages/{owner}/rpm/upload
55+
```
56+
57+
| Parameter | Description |
58+
| --------- | ----------- |
59+
| `owner` | The owner of the package. |
60+
61+
Example request using HTTP Basic authentication:
62+
63+
```shell
64+
curl --user your_username:your_password_or_token \
65+
--upload-file path/to/file.rpm \
66+
https://gitea.example.com/api/packages/testuser/rpm/upload
67+
```
68+
69+
If you are using 2FA or OAuth use a [personal access token]({{< relref "doc/developers/api-usage.en-us.md#authentication" >}}) instead of the password.
70+
You cannot publish a file with the same name twice to a package. You must delete the existing package version first.
71+
72+
The server reponds with the following HTTP Status codes.
73+
74+
| HTTP Status Code | Meaning |
75+
| ----------------- | ------- |
76+
| `201 Created` | The package has been published. |
77+
| `400 Bad Request` | The package is invalid. |
78+
| `409 Conflict` | A package file with the same combination of parameters exist already in the package. |
79+
80+
## Delete a package
81+
82+
To delete a Debian package perform a HTTP DELETE operation. This will delete the package version too if there is no file left.
83+
84+
```
85+
DELETE https://gitea.example.com/api/packages/{owner}/rpm/{package_name}/{package_version}/{architecture}
86+
```
87+
88+
| Parameter | Description |
89+
| ----------------- | ----------- |
90+
| `owner` | The owner of the package. |
91+
| `package_name` | The package name. |
92+
| `package_version` | The package version. |
93+
| `architecture` | The package architecture. |
94+
95+
Example request using HTTP Basic authentication:
96+
97+
```shell
98+
curl --user your_username:your_token_or_password -X DELETE \
99+
https://gitea.example.com/api/packages/testuser/rpm/test-package/1.0.0/x86_64
100+
```
101+
102+
The server reponds with the following HTTP Status codes.
103+
104+
| HTTP Status Code | Meaning |
105+
| ----------------- | ------- |
106+
| `204 No Content` | Success |
107+
| `404 Not Found` | The package or file was not found. |
108+
109+
## Install a package
110+
111+
To install a package from the RPM registry, execute the following commands:
112+
113+
```shell
114+
# use latest version
115+
dnf install {package_name}
116+
# use specific version
117+
dnf install {package_name}-{package_version}.{architecture}
118+
```

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ require (
9393
github.com/quasoft/websspi v1.1.2
9494
github.com/redis/go-redis/v9 v9.0.4
9595
github.com/santhosh-tekuri/jsonschema/v5 v5.3.0
96+
github.com/sassoftware/go-rpmutils v0.2.0
9697
github.com/sergi/go-diff v1.3.1
9798
github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546
9899
github.com/stretchr/testify v1.8.2
@@ -130,6 +131,7 @@ require (
130131
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 // indirect
131132
github.com/ClickHouse/ch-go v0.55.0 // indirect
132133
github.com/ClickHouse/clickhouse-go/v2 v2.9.1 // indirect
134+
github.com/DataDog/zstd v1.4.5 // indirect
133135
github.com/Masterminds/goutils v1.1.1 // indirect
134136
github.com/Masterminds/semver/v3 v3.2.0 // indirect
135137
github.com/Masterminds/sprig/v3 v3.2.3 // indirect

go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ github.com/ClickHouse/ch-go v0.55.0 h1:jw4Tpx887YXrkyL5DfgUome/po8MLz92nz2heOQ6R
8787
github.com/ClickHouse/ch-go v0.55.0/go.mod h1:kQT2f+yp2p+sagQA/7kS6G3ukym+GQ5KAu1kuFAFDiU=
8888
github.com/ClickHouse/clickhouse-go/v2 v2.9.1 h1:IeE2bwVvAba7Yw5ZKu98bKI4NpDmykEy6jUaQdJJCk8=
8989
github.com/ClickHouse/clickhouse-go/v2 v2.9.1/go.mod h1:teXfZNM90iQ99Jnuht+dxQXCuhDZ8nvvMoTJOFrcmcg=
90+
github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
91+
github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
9092
github.com/Julusian/godocdown v0.0.0-20170816220326-6d19f8ff2df8/go.mod h1:INZr5t32rG59/5xeltqoCJoNY7e5x/3xoY9WSWVWg74=
9193
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
9294
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
@@ -775,6 +777,7 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI
775777
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
776778
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
777779
github.com/klauspost/compress v1.11.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
780+
github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
778781
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
779782
github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
780783
github.com/klauspost/compress v1.15.6/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
@@ -1081,6 +1084,8 @@ github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb
10811084
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
10821085
github.com/santhosh-tekuri/jsonschema/v5 v5.3.0 h1:uIkTLo0AGRc8l7h5l9r+GcYi9qfVPt6lD4/bhmzfiKo=
10831086
github.com/santhosh-tekuri/jsonschema/v5 v5.3.0/go.mod h1:FKdcjfQW6rpZSnxxUvEA5H/cDPdvJ/SZJQLWWXWGrZ0=
1087+
github.com/sassoftware/go-rpmutils v0.2.0 h1:pKW0HDYMFWQ5b4JQPiI3WI12hGsVoW0V8+GMoZiI/JE=
1088+
github.com/sassoftware/go-rpmutils v0.2.0/go.mod h1:TJJQYtLe/BeEmEjelI3b7xNZjzAukEkeWKmoakvaOoI=
10841089
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
10851090
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
10861091
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
@@ -1269,6 +1274,7 @@ go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
12691274
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
12701275
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
12711276
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
1277+
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
12721278
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
12731279
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
12741280
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
@@ -1300,6 +1306,7 @@ golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPh
13001306
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
13011307
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
13021308
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
1309+
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
13031310
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
13041311
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
13051312
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
@@ -1583,6 +1590,7 @@ golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtn
15831590
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
15841591
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
15851592
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
1593+
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
15861594
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
15871595
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
15881596
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=

models/packages/descriptor.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"code.gitea.io/gitea/modules/packages/nuget"
2626
"code.gitea.io/gitea/modules/packages/pub"
2727
"code.gitea.io/gitea/modules/packages/pypi"
28+
"code.gitea.io/gitea/modules/packages/rpm"
2829
"code.gitea.io/gitea/modules/packages/rubygems"
2930
"code.gitea.io/gitea/modules/packages/swift"
3031
"code.gitea.io/gitea/modules/packages/vagrant"
@@ -163,6 +164,8 @@ func GetPackageDescriptor(ctx context.Context, pv *PackageVersion) (*PackageDesc
163164
metadata = &pub.Metadata{}
164165
case TypePyPI:
165166
metadata = &pypi.Metadata{}
167+
case TypeRpm:
168+
metadata = &rpm.VersionMetadata{}
166169
case TypeRubyGems:
167170
metadata = &rubygems.Metadata{}
168171
case TypeSwift:

models/packages/package.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const (
4444
TypeNuGet Type = "nuget"
4545
TypePub Type = "pub"
4646
TypePyPI Type = "pypi"
47+
TypeRpm Type = "rpm"
4748
TypeRubyGems Type = "rubygems"
4849
TypeSwift Type = "swift"
4950
TypeVagrant Type = "vagrant"
@@ -64,6 +65,7 @@ var TypeList = []Type{
6465
TypeNuGet,
6566
TypePub,
6667
TypePyPI,
68+
TypeRpm,
6769
TypeRubyGems,
6870
TypeSwift,
6971
TypeVagrant,
@@ -100,6 +102,8 @@ func (pt Type) Name() string {
100102
return "Pub"
101103
case TypePyPI:
102104
return "PyPI"
105+
case TypeRpm:
106+
return "RPM"
103107
case TypeRubyGems:
104108
return "RubyGems"
105109
case TypeSwift:
@@ -141,6 +145,8 @@ func (pt Type) SVGName() string {
141145
return "gitea-pub"
142146
case TypePyPI:
143147
return "gitea-python"
148+
case TypeRpm:
149+
return "gitea-rpm"
144150
case TypeRubyGems:
145151
return "gitea-rubygems"
146152
case TypeSwift:

models/packages/package_file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func DeleteFileByID(ctx context.Context, fileID int64) error {
118118
// PackageFileSearchOptions are options for SearchXXX methods
119119
type PackageFileSearchOptions struct {
120120
OwnerID int64
121-
PackageType string
121+
PackageType Type
122122
VersionID int64
123123
Query string
124124
CompositeKey string

0 commit comments

Comments
 (0)