aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--README.md2
-rw-r--r--internal/manifest/manifest.go13
-rw-r--r--internal/sources/sources.go17
-rwxr-xr-xkiirobin8584770 -> 8585534 bytes
5 files changed, 28 insertions, 7 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..7132ba6
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,3 @@
+all:
+ go build -o kiiro ./cmd/kiiro
+
diff --git a/README.md b/README.md
index 9995efd..54ddfb2 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,5 @@
# kiiro
A lightweight, rootless userland package manager for Linux.
+
+(unfinished)
diff --git a/internal/manifest/manifest.go b/internal/manifest/manifest.go
index aea7fbe..79642cc 100644
--- a/internal/manifest/manifest.go
+++ b/internal/manifest/manifest.go
@@ -3,6 +3,15 @@
package manifest
+import (
+ "fmt"
+ "encoding/json"
+ "net/http"
+ "log"
+ "io"
+ "errors"
+)
+
type KiiroToml struct {
Name string `toml:"pkgname"`
Version string `toml:"version"`
@@ -12,3 +21,7 @@ type KiiroToml struct {
Depends []string `toml:"deps"`
}
+func FetchKiiroToml(url string) (*KiiroToml, error) {
+ fmt.Println("Fetching kiiro.toml...")
+ return nil, errors.New("not implemented")
+}
diff --git a/internal/sources/sources.go b/internal/sources/sources.go
index 6a99cb2..434e734 100644
--- a/internal/sources/sources.go
+++ b/internal/sources/sources.go
@@ -7,7 +7,6 @@ import (
"fmt"
"encoding/json"
"net/http"
- "log"
"io"
)
@@ -22,7 +21,6 @@ func FetchPackageListing(url string) (*PackageListing, error) {
res, err := http.Get(url)
if err != nil {
- log.Fatal(err)
return nil, err
}
@@ -30,20 +28,25 @@ func FetchPackageListing(url string) (*PackageListing, error) {
res.Body.Close()
if res.StatusCode > 299 {
- log.Fatalf("Response failed with status code: %d", res.StatusCode)
return nil, err
}
if err != nil {
- log.Fatal(err)
return nil, err
}
- var packageListing PackageListing
- err = json.Unmarshal(body, &packageListing)
+ packageListing, err := ParsePackageListing(body)
if err != nil {
- log.Fatal(err)
return nil, err
}
fmt.Println("Fetched package listing!")
+ return packageListing, nil
+}
+
+func ParsePackageListing(pkgListingJSON []byte) (*PackageListing, error) {
+ var packageListing PackageListing
+ err := json.Unmarshal(pkgListingJSON, &packageListing)
+ if err != nil {
+ return nil, err
+ }
return &packageListing, nil
}
diff --git a/kiiro b/kiiro
index 3c4156f..9b7570b 100755
--- a/kiiro
+++ b/kiiro
Binary files differ