1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-07-19 01:29:40 +02:00

several fixes of ALT Package registry (#8475)

closes #7946

- The `rpmsRepoPattern` regex has been fixed to handle releases with dots correctly. For example, the version `0.9.0-alt1.git.17.g2ba905d` is valid, just like `0.1.0-1.n1` mentioned in the issue (https://codeberg.org/forgejo/forgejo/issues/7946#issue-1628991)

- getEntries now returns entry names. In the integration tests, there were lines like:
```go
assert.Equal(t, []string{"", ""}, result.ProvideNames)
```
and it’s unclear how such test logic could have ever worked correctly (fixes problems with deps https://codeberg.org/forgejo/forgejo/issues/7946#issuecomment-5109795)

- ALT is an acronym for ALT Linux Team, so `Alt` was replaced with `ALT`. Strictly speaking, it should probably be `ALT Linux`, but since we use `Arch` instead of `Arch Linux`, this seems fine. Also, Distrowatch shows `Arch`/`ALT` in its dropdown, so it’s consistent.

- The strings `"Alt Linux Team"` and `"Sisyphus"` in the `Origin` and `Suite` fields have been replaced with `setting.AppName` and `"Unknown"`. `Unknown` is a valid value and is set by default, so this won’t cause any issues.

- The documentation link has been fixed: (404 docs.gitea.com/usage/packages/alt/ -> 200 forgejo.org/docs/latest/user/packages/alt/)

---

## Checklist

The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org).

### Tests

- I added test coverage for Go changes...
  - [ ] in their respective `*_test.go` for unit tests.
  - [x] in the `tests/integration` directory if it involves interactions with a live Forgejo server.
- I added test coverage for JavaScript changes...
  - [ ] in `web_src/js/*.test.js` if it can be unit tested.
  - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)).

### Documentation

- [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change.
- [x] I did not document these changes and I do not expect someone else to do it.

### Release notes

- [ ] I do not want this change to show in the release notes.
- [x] I want the title to show in the release notes with a link to this pull request.
- [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8475
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Maxim Slipenko <maks1ms@altlinux.org>
Co-committed-by: Maxim Slipenko <maks1ms@altlinux.org>
This commit is contained in:
Maxim Slipenko 2025-07-10 17:12:07 +02:00 committed by Earl Warren
parent 7c06db89e3
commit b332d1c2e4
6 changed files with 20 additions and 17 deletions

View file

@ -125,7 +125,7 @@ func (pt Type) Name() string {
case TypeRpm:
return "RPM"
case TypeAlt:
return "Alt"
return "ALT"
case TypeRubyGems:
return "RubyGems"
case TypeSwift:

View file

@ -232,9 +232,10 @@ func getEntries(h *rpmutils.RpmHeader, namesTag, versionsTag, flagsTag int, repo
case "alt":
for i := range names {
e := &Entry{
Name: names[i],
AltFlags: uint32(flags[i]),
Version: versions[i],
}
e.Version = versions[i]
entries = append(entries, e)
}
}

View file

@ -631,7 +631,7 @@ func CommonRoutes() *web.Route {
baseURLPattern = regexp.MustCompile(`\A(.*?)\.repo\z`)
uploadPattern = regexp.MustCompile(`\A(.*?)/upload\z`)
baseRepoPattern = regexp.MustCompile(`(\S+)\.repo/(\S+)\/base/(\S+)`)
rpmsRepoPattern = regexp.MustCompile(`(\S+)\.repo/(\S+)\.(\S+)\/([a-zA-Z0-9_-]+)-([\d.]+-[a-zA-Z0-9_-]+)\.(\S+)\.rpm`)
rpmsRepoPattern = regexp.MustCompile(`(\S+)\.repo/(\S+)\.(\S+)\/([a-zA-Z0-9_-]+)-([\d.]+-[a-zA-Z0-9_.-]+)\.(\S+)\.rpm`)
)
r.Methods("HEAD,GET,PUT,DELETE", "*", func(ctx *context.Context) {

View file

@ -714,21 +714,23 @@ func buildRelease(ctx context.Context, pv *packages_model.PackageVersion, pfs []
for architecture := range architectures.Seq() {
version := time.Now().Unix()
label := setting.AppName
data := fmt.Sprintf(`Archive: Alt Linux Team
origin := setting.AppName
archive := setting.AppName
data := fmt.Sprintf(`Archive: %s
Component: classic
Version: %d
Origin: Alt Linux Team
Origin: %s
Label: %s
Architecture: %s
NotAutomatic: false
`,
version, label, architecture)
archive, version, origin, label, architecture)
fileInfo, err := addReleaseAsFileToRepo(ctx, pv, "release.classic", data, group, architecture)
if err != nil {
return err
}
origin := setting.AppName
codename := time.Now().Unix()
date := time.Now().UTC().Format(time.RFC1123)
@ -744,7 +746,7 @@ NotAutomatic: false
data = fmt.Sprintf(`Origin: %s
Label: %s
Suite: Sisyphus
Suite: Unknown
Codename: %d
Date: %s
Architectures: %s

View file

@ -24,7 +24,7 @@ apt-get install {{$.PackageDescriptor.Package.Name}}</code></pre>
</div>
</div>
<div class="field">
<label>{{ctx.Locale.Tr "packages.registry.documentation" "ALT" "https://docs.gitea.com/usage/packages/alt/"}}</label>
<label>{{ctx.Locale.Tr "packages.registry.documentation" "ALT" "https://forgejo.org/docs/latest/user/packages/alt/"}}</label>
</div>
</div>
</div>

View file

@ -214,7 +214,7 @@ enabled=1`,
}
assert.Equal(t, "classic", result.Component)
assert.Equal(t, "Alt Linux Team", result.Origin)
assert.Equal(t, "Forgejo", result.Origin)
assert.Equal(t, "Forgejo", result.Label)
assert.Equal(t, "x86_64", result.Architecture)
assert.False(t, result.NotAutomatic)
@ -299,17 +299,17 @@ enabled=1`,
assert.Equal(t, "Forgejo", result.Origin)
assert.Equal(t, "Forgejo", result.Label)
assert.Equal(t, "Sisyphus", result.Suite)
assert.Equal(t, "Unknown", result.Suite)
assert.Equal(t, "x86_64", result.Architectures)
assert.Len(t, result.MD5Sum, 3)
assert.Equal(t, "bbf7ae6b2f540673ed1cfc0266b5f319", result.MD5Sum[0].Hash)
assert.Equal(t, 1003, result.MD5Sum[0].Size)
assert.Equal(t, "3f25f44163e8e512efb248d3b96949c3", result.MD5Sum[0].Hash)
assert.Equal(t, 1147, result.MD5Sum[0].Size)
assert.Equal(t, "base/pkglist.classic", result.MD5Sum[0].File)
assert.Len(t, result.BLAKE2B, 3)
assert.Equal(t, "b527bf038895ce29107ec3a6d2eebd7c365e8ce5ab767276eeddd7c549a159025225cb0ecfdbf7b71da13db7e865e77bcb0e2dae4d21335df01a4a17e0056a70", result.BLAKE2B[0].Hash)
assert.Equal(t, 1003, result.BLAKE2B[0].Size)
assert.Equal(t, "21a63e12a41f70e0697d354ae31e22ad6f024ec5ead2ea498b9a1b7db0f98a4e441f46c96d6912fba19148ff013457561fbb9bf3fca2a21d04cf15a325be7de9", result.BLAKE2B[0].Hash)
assert.Equal(t, 1147, result.BLAKE2B[0].Size)
assert.Equal(t, "base/pkglist.classic", result.BLAKE2B[0].File)
})
@ -567,9 +567,9 @@ enabled=1`,
assert.Equal(t, "https://gitea.io", result.URL)
assert.Equal(t, "x86_64", result.Arch)
assert.Equal(t, "gitea-test-1.0.2-1.src.rpm", result.SourceRpm)
assert.Equal(t, []string{"", ""}, result.ProvideNames)
assert.Equal(t, []string{"gitea-test(x86-64)", "gitea-test(x86-64)"}, result.ProvideNames)
assert.Equal(t, []int{16777226, 16777226, 16777226, 16777226, 16777226, 16777226, 16777226}, result.RequireFlags)
assert.Equal(t, []string{"", "", "", "", "", "", ""}, result.RequireNames)
assert.Equal(t, []string{"rpmlib(PayloadIsXz)", "rpmlib(PayloadIsXz)", "rpmlib(PayloadIsXz)", "rpmlib(PayloadIsXz)", "rpmlib(PayloadIsXz)", "rpmlib(PayloadIsXz)", "rpmlib(PayloadIsXz)"}, result.RequireNames)
assert.Equal(t, []string{"5.2-1", "5.2-1", "5.2-1", "5.2-1", "5.2-1", "5.2-1", "5.2-1"}, result.RequireVersions)
assert.Equal(t, []int{1678276800}, result.ChangeLogTimes)
assert.Equal(t, []string{"KN4CK3R <dummy@gitea.io>"}, result.ChangeLogNames)