Skip to content

Commit

Permalink
Propagate install_if and provider_priority to APKINDEX
Browse files Browse the repository at this point in the history
Resolves #28704
  • Loading branch information
bugaevc committed Jan 27, 2024
1 parent 5f82ead commit 5a17023
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
32 changes: 22 additions & 10 deletions modules/packages/alpine/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions services/packages/alpine/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down

0 comments on commit 5a17023

Please sign in to comment.