aboutsummaryrefslogtreecommitdiffstats
path: root/models/packages/debian
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2023-05-12 19:27:50 +0200
committerGitHub <noreply@github.com>2023-05-12 17:27:50 +0000
commit9173e079ae9ddf18685216fd846ca1727297393c (patch)
tree3437a68d48c338f5721146e951f553fb40facbab /models/packages/debian
parent80bde0141bb4a04b65b399b40ab547bf56c0567e (diff)
downloadgitea-9173e079ae9ddf18685216fd846ca1727297393c.tar.gz
gitea-9173e079ae9ddf18685216fd846ca1727297393c.zip
Add Alpine package registry (#23714)
This PR adds an Alpine package registry. You can follow [this tutorial](https://wiki.alpinelinux.org/wiki/Creating_an_Alpine_package) to build a *.apk package for testing. This functionality is similar to the Debian registry (#22854) and therefore shares some methods. I marked this PR as blocked because it should be merged after #22854. ![grafik](https://user-images.githubusercontent.com/1666336/227779595-b76163aa-eea1-4a79-9583-775c24ad74e8.png) --------- Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'models/packages/debian')
-rw-r--r--models/packages/debian/search.go62
1 files changed, 30 insertions, 32 deletions
diff --git a/models/packages/debian/search.go b/models/packages/debian/search.go
index 332a4f7040..c63a319304 100644
--- a/models/packages/debian/search.go
+++ b/models/packages/debian/search.go
@@ -88,44 +88,42 @@ func SearchLatestPackages(ctx context.Context, opts *PackageSearchOptions) ([]*p
// GetDistributions gets all available distributions
func GetDistributions(ctx context.Context, ownerID int64) ([]string, error) {
- return getDistinctPropertyValues(ctx, ownerID, "", debian_module.PropertyDistribution)
+ return packages.GetDistinctPropertyValues(
+ ctx,
+ packages.TypeDebian,
+ ownerID,
+ packages.PropertyTypeFile,
+ debian_module.PropertyDistribution,
+ nil,
+ )
}
// GetComponents gets all available components for the given distribution
func GetComponents(ctx context.Context, ownerID int64, distribution string) ([]string, error) {
- return getDistinctPropertyValues(ctx, ownerID, distribution, debian_module.PropertyComponent)
+ return packages.GetDistinctPropertyValues(
+ ctx,
+ packages.TypeDebian,
+ ownerID,
+ packages.PropertyTypeFile,
+ debian_module.PropertyComponent,
+ &packages.DistinctPropertyDependency{
+ Name: debian_module.PropertyDistribution,
+ Value: distribution,
+ },
+ )
}
// GetArchitectures gets all available architectures for the given distribution
func GetArchitectures(ctx context.Context, ownerID int64, distribution string) ([]string, error) {
- return getDistinctPropertyValues(ctx, ownerID, distribution, debian_module.PropertyArchitecture)
-}
-
-func getDistinctPropertyValues(ctx context.Context, ownerID int64, distribution, propName string) ([]string, error) {
- var cond builder.Cond = builder.Eq{
- "package_property.ref_type": packages.PropertyTypeFile,
- "package_property.name": propName,
- "package.type": packages.TypeDebian,
- "package.owner_id": ownerID,
- }
- if distribution != "" {
- innerCond := builder.
- Expr("pp.ref_id = package_property.ref_id").
- And(builder.Eq{
- "pp.ref_type": packages.PropertyTypeFile,
- "pp.name": debian_module.PropertyDistribution,
- "pp.value": distribution,
- })
- cond = cond.And(builder.Exists(builder.Select("pp.ref_id").From("package_property pp").Where(innerCond)))
- }
-
- values := make([]string, 0, 5)
- return values, db.GetEngine(ctx).
- Table("package_property").
- Distinct("package_property.value").
- Join("INNER", "package_file", "package_file.id = package_property.ref_id").
- Join("INNER", "package_version", "package_version.id = package_file.version_id").
- Join("INNER", "package", "package.id = package_version.package_id").
- Where(cond).
- Find(&values)
+ return packages.GetDistinctPropertyValues(
+ ctx,
+ packages.TypeDebian,
+ ownerID,
+ packages.PropertyTypeFile,
+ debian_module.PropertyArchitecture,
+ &packages.DistinctPropertyDependency{
+ Name: debian_module.PropertyDistribution,
+ Value: distribution,
+ },
+ )
}