fix(packages): serve noarch Alpine index for any requested architecture - #38479
Merged
silverwind merged 4 commits intoJul 16, 2026
Merged
silverwind merged 4 commits into
silverwind merged 4 commits into
Conversation
The Alpine registry stores one APKINDEX.tar.gz per architecture. When a repository contains only `noarch` packages, no per-architecture index is built, so `apk` (which requests the index for its own architecture, e.g. `x86_64`) received HTTP 404 and could not use the repository. `GetRepositoryFile` now falls back to the `noarch` index when the requested architecture has no index, mirroring the existing fallback in `DownloadPackageFile`. noarch packages are installable on every architecture, so serving them for any requested architecture is correct. Fixes go-gitea#38456 Assisted-by: Claude Code:claude-opus-4-8
gaurav0107
marked this pull request as ready for review
July 16, 2026 01:43
wxiaoguang
approved these changes
Jul 16, 2026
wxiaoguang
reviewed
Jul 16, 2026
Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Member
|
Backport? |
bircni
approved these changes
Jul 16, 2026
silverwind
pushed a commit
that referenced
this pull request
Jul 16, 2026
…re (#38479) (#38486) Backport #38479 by @gaurav0107 Fixes #38456 ## Problem The Alpine package registry serves one `APKINDEX.tar.gz` per architecture. When a repository contains only `noarch` packages (no architecture-specific packages), only the `noarch` index is built. Because `apk` substitutes `$ARCH` with the host architecture and requests e.g. `x86_64/APKINDEX.tar.gz`, such a repository returned HTTP 404 and was unusable, matching the report in #38456. ## Fix `GetRepositoryFile` now falls back to the `noarch` index when the requested architecture has no index of its own, mirroring the fallback already present in the sibling `DownloadPackageFile` handler. `noarch` packages are installable on every architecture, so serving them for any requested architecture is correct. The index-build side is unchanged; only the serving path gains the fallback, so mixed repositories (which already merge `noarch` into each per-architecture index) are unaffected. ## AI assistance disclosure This change was implemented with the help of an AI coding assistant, which gitea's CONTRIBUTING.md explicitly welcomes when disclosed. I have reviewed the change, understand it, and can explain and defend it. ## Tests Added a `NoArchOnly` subtest to `TestPackageAlpine` that publishes only a `noarch` package to a fresh repository and asserts that `GET .../x86_64/APKINDEX.tar.gz` now returns `200` (previously `404`) and that the served index lists the noarch package. Verified locally with `go build`/`go vet` on the changed package and a compile of the integration test package (`go test -c`); the full integration run relies on CI. Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Gaurav Dubey <gauravdubey0107@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #38456
Problem
The Alpine package registry serves one
APKINDEX.tar.gzper architecture. When a repository contains onlynoarchpackages (no architecture-specific packages), only thenoarchindex is built. Becauseapksubstitutes$ARCHwith the host architecture and requests e.g.x86_64/APKINDEX.tar.gz, such a repository returned HTTP 404 and was unusable, matching the report in #38456.Fix
GetRepositoryFilenow falls back to thenoarchindex when the requested architecture has no index of its own, mirroring the fallback already present in the siblingDownloadPackageFilehandler.noarchpackages are installable on every architecture, so serving them for any requested architecture is correct. The index-build side is unchanged; only the serving path gains the fallback, so mixed repositories (which already mergenoarchinto each per-architecture index) are unaffected.AI assistance disclosure
This change was implemented with the help of an AI coding assistant, which gitea's CONTRIBUTING.md explicitly welcomes when disclosed. I have reviewed the change, understand it, and can explain and defend it.
Tests
Added a
NoArchOnlysubtest toTestPackageAlpinethat publishes only anoarchpackage to a fresh repository and asserts thatGET .../x86_64/APKINDEX.tar.gznow returns200(previously404) and that the served index lists the noarch package. Verified locally withgo build/go veton the changed package and a compile of the integration test package (go test -c); the full integration run relies on CI.