Skip to content

fix(packages): serve noarch Alpine index for any requested architecture - #38479

Merged
silverwind merged 4 commits into
go-gitea:mainfrom
gaurav0107:fix/38456-alpine-package-registry-noarch-packages
Jul 16, 2026
Merged

silverwind merged 4 commits into
go-gitea:mainfrom
gaurav0107:fix/38456-alpine-package-registry-noarch-packages

Conversation

@gaurav0107

Copy link
Copy Markdown
Contributor

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.

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
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 16, 2026
@gaurav0107
gaurav0107 marked this pull request as ready for review July 16, 2026 01:43
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jul 16, 2026
Comment thread tests/integration/api_packages_alpine_test.go Outdated
Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
@bircni

bircni commented Jul 16, 2026

Copy link
Copy Markdown
Member

Backport?

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jul 16, 2026
@wxiaoguang wxiaoguang added the backport/v1.27 This PR should be backported to Gitea 1.27 label Jul 16, 2026
@silverwind
silverwind merged commit f15868d into go-gitea:main Jul 16, 2026
23 checks passed
@GiteaBot GiteaBot added this to the 28.0.0 milestone Jul 16, 2026
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/done All backports for this PR have been created backport/v1.27 This PR should be backported to Gitea 1.27 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Alpine Package Registry: noarch packages fail if x86_64 isn't present

5 participants