Skip to content

Commit caeca20

Browse files
bugaevcKN4CK3R
authored andcommitted
Propagate install_if and provider_priority to APKINDEX (go-gitea#28899)
Resolves go-gitea#28704 Example of an entry in the generated `APKINDEX` file: ``` C:Q1xCO3H9LTTEbhKt9G1alSC87I56c= P:hello V:2.12-r1 A:x86_64 T:The GNU Hello program produces a familiar, friendly greeting U:https://www.gnu.org/software/hello/ L:GPL-3.0-or-later S:15403 I:36864 o:hello m: t:1705934118 D:so:libc.musl-x86_64.so.1 p:cmd:hello=2.12-r1 i:foobar=1.0 !baz k:42 ``` the `i:` and `k:` entries are new. --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
1 parent be4ff42 commit caeca20

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

modules/packages/alpine/metadata.go

+16-10
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,17 @@ type VersionMetadata struct {
5555
}
5656

5757
type FileMetadata struct {
58-
Checksum string `json:"checksum"`
59-
Packager string `json:"packager,omitempty"`
60-
BuildDate int64 `json:"build_date,omitempty"`
61-
Size int64 `json:"size,omitempty"`
62-
Architecture string `json:"architecture,omitempty"`
63-
Origin string `json:"origin,omitempty"`
64-
CommitHash string `json:"commit_hash,omitempty"`
65-
InstallIf string `json:"install_if,omitempty"`
66-
Provides []string `json:"provides,omitempty"`
67-
Dependencies []string `json:"dependencies,omitempty"`
58+
Checksum string `json:"checksum"`
59+
Packager string `json:"packager,omitempty"`
60+
BuildDate int64 `json:"build_date,omitempty"`
61+
Size int64 `json:"size,omitempty"`
62+
Architecture string `json:"architecture,omitempty"`
63+
Origin string `json:"origin,omitempty"`
64+
CommitHash string `json:"commit_hash,omitempty"`
65+
InstallIf string `json:"install_if,omitempty"`
66+
Provides []string `json:"provides,omitempty"`
67+
Dependencies []string `json:"dependencies,omitempty"`
68+
ProviderPriority int64 `json:"provider_priority,omitempty"`
6869
}
6970

7071
// ParsePackage parses the Alpine package file
@@ -188,6 +189,11 @@ func ParsePackageInfo(r io.Reader) (*Package, error) {
188189
if value != "" {
189190
p.FileMetadata.Dependencies = append(p.FileMetadata.Dependencies, value)
190191
}
192+
case "provider_priority":
193+
n, err := strconv.ParseInt(value, 10, 64)
194+
if err == nil {
195+
p.FileMetadata.ProviderPriority = n
196+
}
191197
}
192198
}
193199
if err := scanner.Err(); err != nil {

services/packages/alpine/repository.go

+6
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@ func buildPackagesIndex(ctx context.Context, ownerID int64, repoVersion *package
230230
if len(pd.FileMetadata.Provides) > 0 {
231231
fmt.Fprintf(&buf, "p:%s\n", strings.Join(pd.FileMetadata.Provides, " "))
232232
}
233+
if pd.FileMetadata.InstallIf != "" {
234+
fmt.Fprintf(&buf, "i:%s\n", pd.FileMetadata.InstallIf)
235+
}
236+
if pd.FileMetadata.ProviderPriority > 0 {
237+
fmt.Fprintf(&buf, "k:%d\n", pd.FileMetadata.ProviderPriority)
238+
}
233239
fmt.Fprint(&buf, "\n")
234240
}
235241

0 commit comments

Comments
 (0)