From b332d1c2e4c4bff89f70986e4d11854cc44a0500 Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Thu, 10 Jul 2025 17:12:07 +0200 Subject: [PATCH] several fixes of ALT Package registry (#8475) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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/.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 Co-authored-by: Maxim Slipenko Co-committed-by: Maxim Slipenko --- models/packages/package.go | 2 +- modules/packages/rpm/metadata.go | 3 ++- routers/api/packages/api.go | 2 +- services/packages/alt/repository.go | 12 +++++++----- templates/package/content/alt.tmpl | 2 +- tests/integration/api_packages_alt_test.go | 16 ++++++++-------- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/models/packages/package.go b/models/packages/package.go index bdd1c74cad..c06dcf5eb3 100644 --- a/models/packages/package.go +++ b/models/packages/package.go @@ -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: diff --git a/modules/packages/rpm/metadata.go b/modules/packages/rpm/metadata.go index 4af9af620f..503b7b1a24 100644 --- a/modules/packages/rpm/metadata.go +++ b/modules/packages/rpm/metadata.go @@ -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) } } diff --git a/routers/api/packages/api.go b/routers/api/packages/api.go index 79e61cf352..c53edfbf96 100644 --- a/routers/api/packages/api.go +++ b/routers/api/packages/api.go @@ -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) { diff --git a/services/packages/alt/repository.go b/services/packages/alt/repository.go index 317862da9d..9693f4322e 100644 --- a/services/packages/alt/repository.go +++ b/services/packages/alt/repository.go @@ -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 diff --git a/templates/package/content/alt.tmpl b/templates/package/content/alt.tmpl index 9a5e9c7656..0a5c328e6d 100644 --- a/templates/package/content/alt.tmpl +++ b/templates/package/content/alt.tmpl @@ -24,7 +24,7 @@ apt-get install {{$.PackageDescriptor.Package.Name}}
- +
diff --git a/tests/integration/api_packages_alt_test.go b/tests/integration/api_packages_alt_test.go index c7ee2c49a5..f43759364e 100644 --- a/tests/integration/api_packages_alt_test.go +++ b/tests/integration/api_packages_alt_test.go @@ -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 "}, result.ChangeLogNames)