Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

apk: plumb more replaces_priority settings #250

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/apk/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,5 +497,8 @@ replaces = {{ $dep }}
{{- if .ProviderPriority }}
provider_priority = {{ .Dependencies.ProviderPriority }}
{{- end }}
{{- if .ReplacesPriority }}
replaces_priority = {{ .Dependencies.ReplacesPriority }}
{{- end }}
datahash = {{.DataHash}}
`
6 changes: 6 additions & 0 deletions pkg/apk/installed.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@ func ParseInstalled(installed io.Reader) ([]*InstalledPackage, error) { //nolint
return nil, fmt.Errorf("cannot parse provider priority field %s: %w", val, err)
}
pkg.ProviderPriority = priority
case "q":
priority, err := strconv.ParseUint(val, 10, 64)
if err != nil {
return nil, fmt.Errorf("cannot parse replaces priority field %s: %w", val, err)
}
pkg.ReplacesPriority = priority
case "C":
// Handle SHA1 checksums:
if strings.HasPrefix(val, "Q1") {
Expand Down
2 changes: 2 additions & 0 deletions pkg/apk/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func PackageToInstalled(pkg *Package) (out []string) {
out = append(out, fmt.Sprintf("S:%d", pkg.Size))
out = append(out, fmt.Sprintf("I:%d", pkg.InstalledSize))
out = append(out, fmt.Sprintf("k:%d", pkg.ProviderPriority))
out = append(out, fmt.Sprintf("q:%d", pkg.ReplacesPriority))
if len(pkg.Checksum) > 0 {
out = append(out, fmt.Sprintf("C:%s", pkg.ChecksumString()))
}
Expand Down Expand Up @@ -79,6 +80,7 @@ type Package struct {
Size uint64 `ini:"size"`
InstalledSize uint64
ProviderPriority uint64 `ini:"provider_priority"`
ReplacesPriority uint64 `ini:"replaces_priority"`
BuildTime time.Time
BuildDate int64 `ini:"builddate"`
RepoCommit string `ini:"commit"`
Expand Down