Skip to content

Commit

Permalink
add metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
bamarni committed Jul 31, 2017
1 parent 5a3f6fa commit 4ae8efb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
10 changes: 10 additions & 0 deletions cmd/pi64-build/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import (
"io/ioutil"
"os"
"os/exec"
"time"

"github.com/bamarni/pi64/pkg/multistrap"
"github.com/bamarni/pi64/pkg/pi64"
"github.com/bamarni/pi64/pkg/util"
)

Expand Down Expand Up @@ -131,6 +133,14 @@ iface wlan0 inet manual
return err
}

fmt.Fprintln(os.Stderr, " Writing metadata...")
metadata := pi64.Metadata{
Version: time.Now().Format("2006-01-02"),
}
if err := pi64.WriteMetadata(metadata); err != nil {
return err
}

return os.Remove("/usr/bin/qemu-aarch64-static")

}
7 changes: 6 additions & 1 deletion cmd/pi64-update/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func run() int {
return 0
}

releaseEndpoint := "https://github.com/bamarni/pi64-kernel/releases/download/" + path.Base(latestRelease.String())
releaseEndpoint := "https://github.com/bamarni/pi64-kernel/releases/download/" + latestVersion

fmt.Fprintf(os.Stderr, "Downloading '%s' release.\n", latestRelease)

Expand Down Expand Up @@ -159,6 +159,11 @@ func run() int {
return 1
}

metadata.KernelVersion = latestVersion
if err := pi64.WriteMetadata(metadata); err != nil {
fmt.Fprintln(os.Stderr, "Couldn't write metadata : "+err.Error())
}

fmt.Fprintln(os.Stderr, "Your kernel has been updated! You'll have to reboot for this to take effect.")
return 0
}
2 changes: 1 addition & 1 deletion pkg/pi64/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func ReadMetadata() (Metadata, error) {
}

func WriteMetadata(metadata Metadata) error {
file, err := os.OpenFile(metadataPath, os.O_WRONLY|os.O_TRUNC, 644)
file, err := os.OpenFile(metadataPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 644)
if err != nil {
return err
}
Expand Down

0 comments on commit 4ae8efb

Please sign in to comment.