img

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package img implements OS image related functionality for micro computers.

It includes fetching images and flashing them on an SDCard.

It includes gathering environmental information, like the current country and location on the host to enable configuring the board with the same settings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoardHelp

func BoardHelp() string

BoardHelp generates the help for Board.

func DistroHelp added in v1.0.1

func DistroHelp() string

DistroHelp generates the help for Distro.

func FindPublicKey

func FindPublicKey() string

FindPublicKey returns the absolute path to a public key for the user, if any.

func Flash

func Flash(imgPath, disk string) error

Flash flashes imgPath to disk.

Before flashing, it unmounts any partition mounted on disk.

func GetCountry

func GetCountry() string

GetCountry returns the automatically detected country.

WARNING: This causes an outgoing HTTP request.

func GetSetupSH

func GetSetupSH() []byte

GetSetupSH returns the content of setup.sh.

Returns nil in case of catastrophic error.

func GetTimeLocation

func GetTimeLocation() string

GetTimeLocation returns the time location, e.g. America/Toronto.

This is then used by Debian to figure out the right timezone (e.g. EST/EDT) based on the location via tables.

We didn't find a way on Windows to retrieve the local "time zone location" in expected format. In the meantime, "Etc/UTC" is returned on Windows.

func ListSDCards

func ListSDCards() []string

ListSDCards returns the SD cards found.

Returns nil in case of error.

func ManufacturerHelp

func ManufacturerHelp() string

ManufacturerHelp generates the help for Manufacturer.

func Mount

func Mount(disk string, n int) (string, error)

Mount mounts a partition number n on disk p and returns the mount path.

func Umount

func Umount(disk string) error

Umount unmounts all the partitions on disk 'disk'.

Types

type Board

type Board string

Board is a board from a brand manufacturer.

const (
	// OdroidC1 is a board sold by HardKernel.
	OdroidC1 Board = "odroidc1"
	// RaspberryPi is a series of boards sold by Raspberry.
	RaspberryPi Board = "raspberrypi"

	// CHIP used to be sold by NextThingCo.
	CHIP Board = "chip"
	// CHIPPro used to be sold by NextThingCo.
	CHIPPro Board = "chippro"
	// PocketCHIP used to be sold by NextThingCo.
	PocketCHIP Board = "pocketchip"
)

func (*Board) Set

func (b *Board) Set(s string) error

Set implements flag.Value.

func (*Board) String

func (b *Board) String() string

type Distro

type Distro string

Distro is an OS distribution.

const (
	// Debian is https://www.debian.org/
	Debian Distro = "debian"
	// RaspiOS is Raspberry Pi OS Lite.
	// See https://www.raspberrypi.com/software/operating-systems/
	RaspiOS Distro = "raspios"
	// RaspiOS64 is Raspberry Pi OS 64 Lite.
	// See https://www.raspberrypi.com/software/operating-systems/
	RaspiOS64 Distro = "raspios64"
	// Ubuntu is https://ubuntu.com/
	Ubuntu Distro = "ubuntu"
)

func (*Distro) Set added in v1.0.1

func (d *Distro) Set(s string) error

Set implements flag.Value.

func (*Distro) String

func (d *Distro) String() string

type Image added in v1.0.1

type Image struct {
	Manufacturer Manufacturer
	Board        Board
	Distro       Distro
}

Image is an image that can be used on a board by a manufacturer.

func (*Image) Check added in v1.0.1

func (i *Image) Check() error

Check sets default values and confirm specified values.

func (*Image) DefaultHostname added in v1.0.1

func (i *Image) DefaultHostname() string

DefaultHostname returns the default hostname as set by the image.

func (*Image) DefaultUser added in v1.0.1

func (i *Image) DefaultUser() string

DefaultUser returns the default user account created by the image.

func (*Image) Fetch added in v1.0.1

func (i *Image) Fetch() (string, error)

Fetch fetches the distro image remotely.

Returns the absolute path to the file downloaded.

func (*Image) String added in v1.0.1

func (i *Image) String() string

type Manufacturer

type Manufacturer string

Manufacturer is a board brand manufacturer.

const (
	// HardKernel can be bought at http://hardkernel.com
	HardKernel Manufacturer = "hardkernel"
	// Raspberry is Raspberry Pi foundation; https://www.raspberrypi.org/about/
	Raspberry Manufacturer = "raspberrypi"

	// NextThingCo was a company at https://getchip.com
	NextThingCo Manufacturer = "ntc"
)

func (*Manufacturer) Set

func (m *Manufacturer) Set(s string) error

Set implements flag.Value.

func (*Manufacturer) String

func (m *Manufacturer) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL