btpeer

package
v0.0.0-...-49abd51 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package btpeer contains utilities for accessing and managing btpeer devices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLineToFile

func AddLineToFile(ctx context.Context, runner components.Runner, filePath string, option string) error

AddLineToFile appends a single line option to a file if it does not already exist.

func BuildInitrd

func BuildInitrd(ctx context.Context, runner components.Runner) error

BuildInitrd builds a new /boot/initrd.img image.

func CreateShrinkInitrdHook

func CreateShrinkInitrdHook(ctx context.Context, runner components.Runner, size int64) (func(context.Context) error, error)

CreateShrinkInitrdHook creates an initrd image that will shrink the filesystem on the next reboot.

func FlashImage

func FlashImage(ctx context.Context, runner components.Runner, timeout time.Duration, input string, outputDev string) error

FlashImage writes an image to a device using dd.

func GetCurrentBootPath

func GetCurrentBootPath(ctx context.Context, runner components.Runner) (string, error)

GetCurrentBootPath gets the mounted boot directory that the OS is using.

Older versions of raspberry pi use /boot/, while newer versions use /boot/firmware. See: https://github.com/raspberrypi/documentation/blob/develop/documentation/asciidoc/computers/configuration/boot_folder.adoc

func GetFSWithLabel

func GetFSWithLabel(ctx context.Context, runner components.Runner, label string) (string, error)

GetFSWithLabel returns a device whose FS has the matching label.

func GetUsedFSSpace

func GetUsedFSSpace(ctx context.Context, runner components.Runner, path string) (int64, error)

GetUsedFSSpace returns the amount of used space on the filesystem.

func InitEXT4FS

func InitEXT4FS(ctx context.Context, runner components.Runner, device, label string) error

InitEXT4FS initializes an EXT4 FS on a new partition.

func InitFAT32FS

func InitFAT32FS(ctx context.Context, runner components.Runner, device, label string) error

InitFAT32FS initializes a FAT32 FS on a new partition.

func LoadImageAsLoopbackDevice

func LoadImageAsLoopbackDevice(ctx context.Context, runner components.Runner, image string) (string, error)

LoadImageAsLoopbackDevice loads an image as a loopback device and returns the device.

func MountDevice

func MountDevice(ctx context.Context, runner components.Runner, device string) (string, error)

MountDevice returns a devices mount point if it's already mounted or otherwise mounts it and returns the new mount path.

func NewPartitionHelperForPath

func NewPartitionHelperForPath(ctx context.Context, runner components.Runner, path string) (*partitionHelper, error)

NewPartitionHelperForPath creates a new helper for the device that owns the requested path.

func NewSshRunner

func NewSshRunner(sshAccess ssh.Access, resource string) ssh.Runner

NewSshRunner creates a normal ssh.Runner for a resource. TODO(jaredbennett) Move to common package when ssh package is refactored.

func PermBootIntoPartition

func PermBootIntoPartition(ctx context.Context, runner components.Runner, recoveryPartitionLabel, bootPartitionLabel string, rebootTime time.Duration) error

PermBootIntoPartition sets a partition as the permenent boot partition.

This is accomplished by writing a file "autoboot.txt" to the recovery partition which instructs the device as to which partition to boot from.

func RemoveLineFromFile

func RemoveLineFromFile(ctx context.Context, runner components.Runner, filePath string, option string) error

RemoveLineFromFile removes any matching lines from a config file.

func ReplacePartID

func ReplacePartID(ctx context.Context, runner components.Runner, oldDev, newDev, file string) error

ReplacePartID replaces the old partiion ID with the new one in the specified file.

func SetEXTLabel

func SetEXTLabel(ctx context.Context, runner components.Runner, device string, label string) error

SetEXTLabel sets a label on an EXT FS.

func SetFAT32Label

func SetFAT32Label(ctx context.Context, runner components.Runner, device string, label string) error

SetFAT32Label sets a label on a FAT32 FS.

func SetLabelForEXTPath

func SetLabelForEXTPath(ctx context.Context, runner components.Runner, path string, label string) error

SetLabelForEXTPath sets a label for a EXT file system given a path.

func SetLabelForFAT32Path

func SetLabelForFAT32Path(ctx context.Context, runner components.Runner, path string, label string) error

SetLabelForFAT32Path sets a label for a FAT32 file system given a path.

func TempBootIntoPartition

func TempBootIntoPartition(ctx context.Context, runner components.Runner, bootPartitionLabel string, rebootTime time.Duration) error

TempBootIntoPartition temporarily boots into a specific partition.

This is done by passing an additional argument to the "reboot" command which tells the system to use a different partition on next boot. This is temporary and only applies to the next boot.

Types

type Model

type Model int

Model is the btpeer HW model.

const (
	// Model4B is a Rasperry Pi 4B
	Model4B Model = 17
)

func GetHWInfo

func GetHWInfo(ctx context.Context, runner components.Runner) (Model, int, error)

GetHWInfo returns the btpeer's model and revision.

Directories

Path Synopsis
Package chameleond contains utilities for managing chameleond releases on btpeers devices.
Package chameleond contains utilities for managing chameleond releases on btpeers devices.
Package image contains utilities for managing btpeer images.
Package image contains utilities for managing btpeer images.

Jump to

Keyboard shortcuts

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