From 075bc9a33b0f0df8dd59b55e3f425816448750c7 Mon Sep 17 00:00:00 2001 From: Arslaan Pathan Date: Mon, 4 May 2026 19:07:02 +1200 Subject: Annotate a few things and implement FetchKiiroToml --- internal/manifest/manifest.go | 44 ++++++++++++++++++++++++++++++++++++++++-- internal/sources/sources.go | 1 + kiiro | Bin 8585534 -> 9164903 bytes 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/internal/manifest/manifest.go b/internal/manifest/manifest.go index 79642cc..ffb73f8 100644 --- a/internal/manifest/manifest.go +++ b/internal/manifest/manifest.go @@ -10,18 +10,58 @@ import ( "log" "io" "errors" + "github.com/BurntSushi/toml" ) type KiiroToml struct { + // package name Name string `toml:"pkgname"` - Version string `toml:"version"` + // supported architectures Architectures string `toml:"archs"` + // authors Authors []string `toml:"authors"` + // maintainers of the Kiirofile/kiiro.toml Maintainers []string `toml:"maintainers"` + // Dependencies on other Kiiro packages - you can refer to a package from a specific source by using : + // If no source is provided (just a bare URL), we clone directly from git Depends []string `toml:"deps"` + // Platforms it runs on: e.g. "Windows", "macOS", "Linux", "BSD" + Platforms []string `toml:"platforms"` } func FetchKiiroToml(url string) (*KiiroToml, error) { fmt.Println("Fetching kiiro.toml...") - return nil, errors.New("not implemented") + + res, err := http.Get(url) + if err != nil { + return nil, err + } + + body, err := io.ReadAll(res.Body) + res.Body.Close() + + if res.StatusCode > 299 { + return nil, err + } + + if err != nil { + return nil, err + } + + kiirotoml, err := ParseKiiroToml(body) + if err != nil { + return nil, err + } + + fmt.Println("Fetched package listing!") + return packageListing, nil +} + +func ParseKiiroToml(kiirotomlTOML []byte) (*Kiirotoml, error) { + var kiirotoml Kiirotoml + err := toml.Unmarshal(kiirotomlTOML, kiirotoml); + if err != nil { + return nil, err + } + return &kiirotoml, nil; } diff --git a/internal/sources/sources.go b/internal/sources/sources.go index 434e734..d99ff5e 100644 --- a/internal/sources/sources.go +++ b/internal/sources/sources.go @@ -11,6 +11,7 @@ import ( ) type PackageListing struct { + // no need for a Name field, that's handled by kiirotoml, and the structure for a Kiiro source would be a "listing.json" file inside of a folder with the package name, we all goods Repository string `json:"repo"` KiirofileOverride *string `json:"kiirofile_override"` KiirotomlOverride *string `json:"kiirotoml_override"` diff --git a/kiiro b/kiiro index 9b7570b..60d03db 100755 Binary files a/kiiro and b/kiiro differ -- cgit v1.2.3