From 5a170239e51618f72db5f1b16019474da5ce04d4 Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Mon, 22 Jan 2024 17:55:36 +0300 Subject: [PATCH 1/2] Propagate install_if and provider_priority to APKINDEX Resolves #28704 --- modules/packages/alpine/metadata.go | 32 ++++++++++++++++++-------- services/packages/alpine/repository.go | 6 +++++ 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/modules/packages/alpine/metadata.go b/modules/packages/alpine/metadata.go index c2d0caffa1259..80c11c0b51dd1 100644 --- a/modules/packages/alpine/metadata.go +++ b/modules/packages/alpine/metadata.go @@ -55,16 +55,18 @@ type VersionMetadata struct { } type FileMetadata struct { - Checksum string `json:"checksum"` - Packager string `json:"packager,omitempty"` - BuildDate int64 `json:"build_date,omitempty"` - Size int64 `json:"size,omitempty"` - Architecture string `json:"architecture,omitempty"` - Origin string `json:"origin,omitempty"` - CommitHash string `json:"commit_hash,omitempty"` - InstallIf string `json:"install_if,omitempty"` - Provides []string `json:"provides,omitempty"` - Dependencies []string `json:"dependencies,omitempty"` + Checksum string `json:"checksum"` + Packager string `json:"packager,omitempty"` + BuildDate int64 `json:"build_date,omitempty"` + Size int64 `json:"size,omitempty"` + Architecture string `json:"architecture,omitempty"` + Origin string `json:"origin,omitempty"` + CommitHash string `json:"commit_hash,omitempty"` + InstallIf string `json:"install_if,omitempty"` + Provides []string `json:"provides,omitempty"` + Dependencies []string `json:"dependencies,omitempty"` + ProviderPriority int64 `json:"provider_priority,omitempty"` + ReplacesPriority int64 `json:"replaces_priority,omitempty"` } // ParsePackage parses the Alpine package file @@ -188,6 +190,16 @@ func ParsePackageInfo(r io.Reader) (*Package, error) { if value != "" { p.FileMetadata.Dependencies = append(p.FileMetadata.Dependencies, value) } + case "provider_priority": + n, err := strconv.ParseInt(value, 10, 64) + if err == nil { + p.FileMetadata.ProviderPriority = n + } + case "replaces_priority": + n, err := strconv.ParseInt(value, 10, 64) + if err == nil { + p.FileMetadata.ReplacesPriority = n + } } } if err := scanner.Err(); err != nil { diff --git a/services/packages/alpine/repository.go b/services/packages/alpine/repository.go index 30b7a06eb36d9..104548b421555 100644 --- a/services/packages/alpine/repository.go +++ b/services/packages/alpine/repository.go @@ -230,6 +230,12 @@ func buildPackagesIndex(ctx context.Context, ownerID int64, repoVersion *package if len(pd.FileMetadata.Provides) > 0 { fmt.Fprintf(&buf, "p:%s\n", strings.Join(pd.FileMetadata.Provides, " ")) } + if pd.FileMetadata.InstallIf != "" { + fmt.Fprintf(&buf, "i:%s\n", pd.FileMetadata.InstallIf) + } + if pd.FileMetadata.ProviderPriority > 0 { + fmt.Fprintf(&buf, "k:%d\n", pd.FileMetadata.ProviderPriority) + } fmt.Fprint(&buf, "\n") } From 446269dfa3e708eb1cbb24336a103a2af83e714d Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Sat, 3 Feb 2024 22:54:43 +0100 Subject: [PATCH 2/2] Apply suggestions from code review --- modules/packages/alpine/metadata.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/modules/packages/alpine/metadata.go b/modules/packages/alpine/metadata.go index 80c11c0b51dd1..582c42610d207 100644 --- a/modules/packages/alpine/metadata.go +++ b/modules/packages/alpine/metadata.go @@ -66,7 +66,6 @@ type FileMetadata struct { Provides []string `json:"provides,omitempty"` Dependencies []string `json:"dependencies,omitempty"` ProviderPriority int64 `json:"provider_priority,omitempty"` - ReplacesPriority int64 `json:"replaces_priority,omitempty"` } // ParsePackage parses the Alpine package file @@ -195,11 +194,6 @@ func ParsePackageInfo(r io.Reader) (*Package, error) { if err == nil { p.FileMetadata.ProviderPriority = n } - case "replaces_priority": - n, err := strconv.ParseInt(value, 10, 64) - if err == nil { - p.FileMetadata.ReplacesPriority = n - } } } if err := scanner.Err(); err != nil {