Skip to content

Golang bindings for the RAUC update service

License

Notifications You must be signed in to change notification settings

CorrectRoadH/go-rauc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang bindings for RAUC

This Go package provides bindings for RAUC.

For details on the properties and calling semantics, please refer to the DBus API documentation of the RAUC project.

Install

Install the package like this:

go get github.com/holoplot/go-rauc/rauc

And then use it in your source code.

import "github.com/holoplot/go-rauc/rauc"

Example

Below is an example to illustrate the usage of this package. Note that you will need to have a working RAUC installation, including a valid config and all.

package main

import (
	"log"
	"github.com/holoplot/go-rauc/rauc"
)

func main() {
	raucInstaller, err := rauc.InstallerNew()
	if err != nil {
		log.Fatal("Cannot create RaucInstaller")
	}

	operation, err := raucInstaller.GetOperation()
	if err != nil {
		log.Fatal("GetOperation() failed")
	}
	log.Printf("Operation: %s", operation)


	bootSlot, err := raucInstaller.GetBootSlot()
	if err != nil {
		log.Fatal("GetBootSlot() failed")
	}
	log.Printf("Boot slot: %s", bootSlot)

	slotStatus, err := raucInstaller.GetSlotStatus()
	if err != nil {
		log.Fatal("GetSlotStatus() failed")
	}

	for count, status := range slotStatus {
		log.Printf("status[%d]: %s", count, status.SlotName)

		for k, v := range status.Status {
			log.Printf("    %s: %s", k, v.String())
		}
	}

	variant, err := raucInstaller.GetVariant()
	if err != nil {
		log.Fatal("GetVariant() failed")
	}
	log.Printf("Variant: %s", variant)

	percentage, message, nestingDepth, err := raucInstaller.GetProgress()
	if err != nil {
		log.Fatal("GetProgress() failed", message)
	}
	log.Printf("Progress: percentage=%d, message=%s, nestingDepth=%d", percentage, message, nestingDepth)

	filename := "/path/to/update.raucb"
	compatible, version, err := raucInstaller.Info(filename)
	if err != nil {
		log.Fatal("Info() failed", err.Error())
	}
	log.Printf("Info(): compatible=%s, version=%s", compatible, version)

	err = raucInstaller.InstallBundle(filename, rauc.InstallBundleOptions{})
	if err != nil {
		log.Fatal("InstallBundle() failed: ", err.Error())
	}
}

MIT License

See file LICENSE for details.

About

Golang bindings for the RAUC update service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%