-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arch packages implementation #31037
base: main
Are you sure you want to change the base?
Arch packages implementation #31037
Conversation
9a3f45a
to
1a49dd9
Compare
1a49dd9
to
1007ce7
Compare
TODO:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking until I have time to have a look.
Do you have a estimated time? 1.23 is releasing soon? |
Made some changes:
Last call: if there is no other problem, I think this PR could be merged in a few days since it has enough tests. |
0d9547d
to
ce73234
Compare
@KN4CK3R did you have time to take a look at this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think this PR could be simpler just by following how the other package types are structured.
My implementation can still be found here: main...KN4CK3R:gitea:feature-arch
} | ||
|
||
// ValidatePackageSpec Arch package validation according to PKGBUILD specification. | ||
func ValidatePackageSpec(p *Package) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this detailed validation? If the spec changes we must keep this in sync. It is the responsibility of the client to check these when installing a package but for the registry it's less relevant.
|
||
// GetPackageFile Get data related to provided filename and distribution, for package files | ||
// update download counter. | ||
func GetPackageFile(ctx context.Context, group, file string, ownerID int64) (io.ReadSeekCloser, *url.URL, *packages_model.PackageFile, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use one of the existing methods in code.gitea.io/gitea/services/packages
?
} | ||
|
||
// Desc Create pacman package description file. | ||
func (p *Package) Desc() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this code into the repository.go
file to the other db related logic. Then it's not needed to have the MD5SUM
and SHA256SUM
fields because that info is already present.
return packages_service.GetPackageFileStream(ctx, pkgFile) | ||
} | ||
|
||
func GetPackageDBFile(ctx context.Context, group, arch string, ownerID int64, signFile bool) (io.ReadSeekCloser, *url.URL, *packages_model.PackageFile, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. I think this should be handled by the router.
defer tests.PrepareTestEnv(t)() | ||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}) | ||
unpack := func(s string) []byte { | ||
data, _ := base64.StdEncoding.DecodeString(strings.ReplaceAll(strings.ReplaceAll(strings.TrimSpace(s), "\n", ""), "\r", "")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these string replacements are not necessary for base64.StdEncoding.DecodeString
.
} | ||
rootURL := fmt.Sprintf("/api/packages/%s/arch", user.Name) | ||
|
||
pkgs := map[string][]byte{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we need so many test packages it may be better to generate them on the fly.
"zst": { | ||
magic: []byte{0x28, 0xB5, 0x2F, 0xFD}, | ||
archiver: func() archiver.Reader { | ||
return archiver.NewTarZstd() | ||
}, | ||
}, | ||
"xz": { | ||
magic: []byte{0xFD, 0x37, 0x7A, 0x58, 0x5A}, | ||
archiver: func() archiver.Reader { | ||
return archiver.NewTarXz() | ||
}, | ||
}, | ||
"gz": { | ||
magic: []byte{0x1F, 0x8B}, | ||
archiver: func() archiver.Reader { | ||
return archiver.NewTarGz() | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any other containers than zst in the wild? All repositories I have tested just contain zst.
pathFields := strings.Split(strings.Trim(ctx.PathParam("*"), "/"), "/") | ||
pathFieldsLen := len(pathFields) | ||
if pathFieldsLen < 2 { | ||
ctx.Status(http.StatusBadRequest) | ||
return | ||
} | ||
|
||
group := strings.Join(pathFields[:pathFieldsLen-2], "/") | ||
arch := pathFields[pathFieldsLen-2] | ||
file := pathFields[pathFieldsLen-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not simply specify a clean route with parameters so you don't need to rebuild the logic here?
If we'd like to include it in 1.23, what's your suggestion to move on? I think we have 3 choices:
Personally I think 1 could work. If you have time recently, 2 & 3 could also work. What's your opinion? |
Problem with option 1 is that the refactoring would most likely use different routes and perhaps different metadata (stored as json) which may require migrations. So it's 2 or 3 for me. @ExplodingDragon are you willing to make/accept changes? |
Yes, archlinuxarm uses xz.
The use of non-json storage is to avoid serialization when generating the db.
I'm ok with both, 3 is better for me, I don't have much time to work on things, I'll close this pr later, other things are up to you to determine. |
Thanks @wxiaoguang and @yp05327 , sorry. |
@KN4CK3R what's the next plan? Would you like to work on this PR, or propose a new one? |
I think the main conflict is the router path, other codes could be refactored later. Maybe we can do a discussion about which change's routers are better? |
close #25037
This Commit was created by d1nch8g (#25396).
This PR adds a package registry for Arch Linux packages with support for package files, signatures, and automatic pacman-database management.
Features:
tar.zst
package and Gitea sign it.SigLevel = Required
.You can follow this tutorial to build a *.pkg.tar.zst package for testing
docs pr: gitea/docs#47
Co-authored-by: d1nch8g@ion.lc
Co-authored-by: @KN4CK3R
Co-authored-by: @silverwind
Co-authored-by: @mahlzahn