mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	Add Arch package registry (#32692)
Close #25037 Close #31037 This PR adds a Arch package registry usable with pacman.  Rewrite of #25396 and #31037. You can follow [this tutorial](https://wiki.archlinux.org/title/Creating_packages) to build a package for testing. Docs PR: https://gitea.com/gitea/docs/pulls/111 Co-authored-by: [d1nch8g@ion.lc](mailto:d1nch8g@ion.lc) Co-authored-by: @ExplodingDragon --------- Co-authored-by: dancheg97 <dancheg97@fmnx.su> Co-authored-by: dragon <ExplodingFKL@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
		| @@ -14,6 +14,7 @@ import ( | ||||
| 	"code.gitea.io/gitea/modules/setting" | ||||
| 	"code.gitea.io/gitea/modules/web" | ||||
| 	"code.gitea.io/gitea/routers/api/packages/alpine" | ||||
| 	"code.gitea.io/gitea/routers/api/packages/arch" | ||||
| 	"code.gitea.io/gitea/routers/api/packages/cargo" | ||||
| 	"code.gitea.io/gitea/routers/api/packages/chef" | ||||
| 	"code.gitea.io/gitea/routers/api/packages/composer" | ||||
| @@ -135,6 +136,49 @@ func CommonRoutes() *web.Router { | ||||
| 				}) | ||||
| 			}) | ||||
| 		}, reqPackageAccess(perm.AccessModeRead)) | ||||
| 		r.Group("/arch", func() { | ||||
| 			r.Methods("HEAD,GET", "/repository.key", arch.GetRepositoryKey) | ||||
|  | ||||
| 			r.Methods("HEAD,GET,PUT,DELETE", "*", func(ctx *context.Context) { | ||||
| 				path := strings.Trim(ctx.PathParam("*"), "/") | ||||
|  | ||||
| 				if ctx.Req.Method == "PUT" { | ||||
| 					reqPackageAccess(perm.AccessModeWrite)(ctx) | ||||
| 					if ctx.Written() { | ||||
| 						return | ||||
| 					} | ||||
| 					ctx.SetPathParam("repository", path) | ||||
| 					arch.UploadPackageFile(ctx) | ||||
| 					return | ||||
| 				} | ||||
|  | ||||
| 				pathFields := strings.Split(path, "/") | ||||
| 				pathFieldsLen := len(pathFields) | ||||
|  | ||||
| 				if (ctx.Req.Method == "HEAD" || ctx.Req.Method == "GET") && pathFieldsLen >= 2 { | ||||
| 					ctx.SetPathParam("repository", strings.Join(pathFields[:pathFieldsLen-2], "/")) | ||||
| 					ctx.SetPathParam("architecture", pathFields[pathFieldsLen-2]) | ||||
| 					ctx.SetPathParam("filename", pathFields[pathFieldsLen-1]) | ||||
| 					arch.GetPackageOrRepositoryFile(ctx) | ||||
| 					return | ||||
| 				} | ||||
|  | ||||
| 				if ctx.Req.Method == "DELETE" && pathFieldsLen >= 3 { | ||||
| 					reqPackageAccess(perm.AccessModeWrite)(ctx) | ||||
| 					if ctx.Written() { | ||||
| 						return | ||||
| 					} | ||||
| 					ctx.SetPathParam("repository", strings.Join(pathFields[:pathFieldsLen-3], "/")) | ||||
| 					ctx.SetPathParam("name", pathFields[pathFieldsLen-3]) | ||||
| 					ctx.SetPathParam("version", pathFields[pathFieldsLen-2]) | ||||
| 					ctx.SetPathParam("architecture", pathFields[pathFieldsLen-1]) | ||||
| 					arch.DeletePackageVersion(ctx) | ||||
| 					return | ||||
| 				} | ||||
|  | ||||
| 				ctx.Status(http.StatusNotFound) | ||||
| 			}) | ||||
| 		}, reqPackageAccess(perm.AccessModeRead)) | ||||
| 		r.Group("/cargo", func() { | ||||
| 			r.Group("/api/v1/crates", func() { | ||||
| 				r.Get("", cargo.SearchPackages) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user