aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/packages/alpine/alpine.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2024-02-25 16:10:55 +0100
committerGitHub <noreply@github.com>2024-02-25 15:10:55 +0000
commit1c6858543ca976933004c21b3056a7301e1729d6 (patch)
tree9ba318d08d06afb392d893266c9a3aaca1b80b94 /routers/api/packages/alpine/alpine.go
parent756b952c52f1efbb137df36d5b97b370c8a45565 (diff)
downloadgitea-1c6858543ca976933004c21b3056a7301e1729d6.tar.gz
gitea-1c6858543ca976933004c21b3056a7301e1729d6.zip
Integrate alpine `noarch` packages into other architectures index (#29137)
Fixes #26691 Revert #24972 The alpine package manager expects `noarch` packages in the index of other architectures too. --------- Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'routers/api/packages/alpine/alpine.go')
-rw-r--r--routers/api/packages/alpine/alpine.go33
1 files changed, 26 insertions, 7 deletions
diff --git a/routers/api/packages/alpine/alpine.go b/routers/api/packages/alpine/alpine.go
index bb14c5163a..3fd8288c01 100644
--- a/routers/api/packages/alpine/alpine.go
+++ b/routers/api/packages/alpine/alpine.go
@@ -72,7 +72,7 @@ func GetRepositoryFile(ctx *context.Context) {
ctx,
pv,
&packages_service.PackageFileInfo{
- Filename: alpine_service.IndexFilename,
+ Filename: alpine_service.IndexArchiveFilename,
CompositeKey: fmt.Sprintf("%s|%s|%s", ctx.Params("branch"), ctx.Params("repository"), ctx.Params("architecture")),
},
)
@@ -182,19 +182,38 @@ func UploadPackageFile(ctx *context.Context) {
}
func DownloadPackageFile(ctx *context.Context) {
- pfs, _, err := packages_model.SearchFiles(ctx, &packages_model.PackageFileSearchOptions{
+ branch := ctx.Params("branch")
+ repository := ctx.Params("repository")
+ architecture := ctx.Params("architecture")
+
+ opts := &packages_model.PackageFileSearchOptions{
OwnerID: ctx.Package.Owner.ID,
PackageType: packages_model.TypeAlpine,
Query: ctx.Params("filename"),
- CompositeKey: fmt.Sprintf("%s|%s|%s", ctx.Params("branch"), ctx.Params("repository"), ctx.Params("architecture")),
- })
+ CompositeKey: fmt.Sprintf("%s|%s|%s", branch, repository, architecture),
+ }
+ pfs, _, err := packages_model.SearchFiles(ctx, opts)
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
}
- if len(pfs) != 1 {
- apiError(ctx, http.StatusNotFound, nil)
- return
+ if len(pfs) == 0 {
+ // Try again with architecture 'noarch'
+ if architecture == alpine_module.NoArch {
+ apiError(ctx, http.StatusNotFound, nil)
+ return
+ }
+
+ opts.CompositeKey = fmt.Sprintf("%s|%s|%s", branch, repository, alpine_module.NoArch)
+ if pfs, _, err = packages_model.SearchFiles(ctx, opts); err != nil {
+ apiError(ctx, http.StatusInternalServerError, err)
+ return
+ }
+
+ if len(pfs) == 0 {
+ apiError(ctx, http.StatusNotFound, nil)
+ return
+ }
}
s, u, pf, err := packages_service.GetPackageFileStream(ctx, pfs[0])