Documentation
¶
Overview ¶
Copyright 2019 Northern.tech AS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2019 Northern.tech AS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2019 Northern.tech AS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2019 Northern.tech AS
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func FetchUpdateFromFile(file string) (io.ReadCloser, int64, error)
- func MissingFeaturesCheck(artifactAugmentedHeaders artifact.HeaderInfoer, ...) error
- func ReadHeaders(art io.ReadCloser, dt string, key []byte, scrDir string, inst *AllModules) (*Installer, []PayloadUpdatePerformer, error)
- type AllModules
- type ArtifactInfoGetter
- type BlockDevice
- type BlockDeviceGetSectorSizeFunc
- type BlockDeviceGetSizeFunc
- type BootEnvReadWriter
- type BootVars
- type DeviceInfoGetter
- type DualRootfsDevice
- type DualRootfsDeviceConfig
- type FlushingWriter
- type Installer
- type ModuleInstaller
- func (mod *ModuleInstaller) Cleanup() error
- func (mod *ModuleInstaller) CommitUpdate() error
- func (mod *ModuleInstaller) Failure() error
- func (mod *ModuleInstaller) FinishStoreUpdate() error
- func (mod *ModuleInstaller) GetType() string
- func (mod *ModuleInstaller) Initialize(artifactHeaders, artifactAugmentedHeaders artifact.HeaderInfoer, ...) error
- func (mod *ModuleInstaller) InstallUpdate() error
- func (mod *ModuleInstaller) NeedsReboot() (RebootAction, error)
- func (mod *ModuleInstaller) PrepareStoreUpdate() error
- func (mod *ModuleInstaller) Reboot() error
- func (mod *ModuleInstaller) Rollback() error
- func (mod *ModuleInstaller) RollbackReboot() error
- func (mod *ModuleInstaller) StoreUpdate(r io.Reader, info os.FileInfo) error
- func (mod *ModuleInstaller) SupportsRollback() (bool, error)
- func (mod *ModuleInstaller) VerifyReboot() error
- func (mod *ModuleInstaller) VerifyRollbackReboot() error
- type ModuleInstallerFactory
- type PayloadUpdatePerformer
- type ReadLogger
- type RebootAction
- type Rebooter
- type StubInstaller
- func (d *StubInstaller) Cleanup() error
- func (d *StubInstaller) CommitUpdate() error
- func (d *StubInstaller) Failure() error
- func (d *StubInstaller) FinishStoreUpdate() error
- func (d *StubInstaller) GetType() string
- func (d *StubInstaller) Initialize(artifactHeaders, artifactAugmentedHeaders artifact.HeaderInfoer, ...) error
- func (d *StubInstaller) InstallUpdate() error
- func (d *StubInstaller) NeedsReboot() (RebootAction, error)
- func (d *StubInstaller) PrepareStoreUpdate() error
- func (d *StubInstaller) Reboot() error
- func (d *StubInstaller) Rollback() error
- func (d *StubInstaller) RollbackReboot() error
- func (d *StubInstaller) StoreUpdate(r io.Reader, info os.FileInfo) error
- func (d *StubInstaller) SupportsRollback() (bool, error)
- func (d *StubInstaller) VerifyReboot() error
- func (d *StubInstaller) VerifyRollbackReboot() error
- type UBootEnv
- type WriteSyncer
Constants ¶
const ( NoReboot = iota RebootRequired AutomaticReboot )
Variables ¶
var ( BlockDeviceGetSizeOf BlockDeviceGetSizeFunc = system.GetBlockDeviceSize BlockDeviceGetSectorSizeOf BlockDeviceGetSectorSizeFunc = system.GetBlockDeviceSectorSize )
var ( RootPartitionDoesNotMatchMount = errors.New("Can not match active partition and any of mounted devices.") ErrorNoMatchBootPartRootPart = errors.New("No match between boot and root partitions.") ErrorPartitionNumberNotSet = errors.New("RootfsPartA and RootfsPartB settings are not both set.") ErrorPartitionNumberSame = errors.New("RootfsPartA and RootfsPartB cannot be set to the same value.") ErrorPartitionNoMatchActive = errors.New("Active root partition matches neither RootfsPartA nor RootfsPartB.") )
var (
ErrorNothingToCommit = errors.New("There is nothing to commit")
)
Functions ¶
func FetchUpdateFromFile ¶
func FetchUpdateFromFile(file string) (io.ReadCloser, int64, error)
FetchUpdateFromFile returns a byte stream of the given file, size of the file and an error if one occurred.
func MissingFeaturesCheck ¶
func MissingFeaturesCheck(artifactAugmentedHeaders artifact.HeaderInfoer, payloadHeaders handlers.ArtifactUpdateHeaders) error
func ReadHeaders ¶
func ReadHeaders(art io.ReadCloser, dt string, key []byte, scrDir string, inst *AllModules) (*Installer, []PayloadUpdatePerformer, error)
Types ¶
type AllModules ¶
type AllModules struct { // Built-in module. DualRootfs handlers.UpdateStorerProducer // External modules. Modules *ModuleInstallerFactory }
type ArtifactInfoGetter ¶
type BlockDevice ¶
type BlockDevice struct { Path string // device path, ex. /dev/mmcblk0p1 ImageSize int64 // image size FlushIntervalBytes uint64 // Force a flush to disk each time this many bytes are written // contains filtered or unexported fields }
BlockDevice is a low-level wrapper for a block device. The wrapper implements io.Writer and io.Closer interfaces.
func (*BlockDevice) Close ¶
func (bd *BlockDevice) Close() error
Close closes underlying block device automatically syncing any unwritten data. Othewise, behaves like io.Closer.
func (*BlockDevice) SectorSize ¶
func (bd *BlockDevice) SectorSize() (int, error)
SectorSize queries the logical sector size of the underlying block device. Automatically opens a new fd in O_RDONLY mode, thus can be used in parallel to other operations.
func (*BlockDevice) Size ¶
func (bd *BlockDevice) Size() (uint64, error)
Size queries the size of the underlying block device. Automatically opens a new fd in O_RDONLY mode, thus can be used in parallel to other operations.
type BlockDeviceGetSectorSizeFunc ¶
BlockDeviceGetSectorSizeFunc is a helper for obtaining the sector size of a block device.
type BlockDeviceGetSizeFunc ¶
BlockDeviceGetSizeFunc is a helper for obtaining the size of a block device.
type BootEnvReadWriter ¶
type DeviceInfoGetter ¶
type DualRootfsDevice ¶
type DualRootfsDevice interface { PayloadUpdatePerformer handlers.UpdateStorerProducer GetInactive() (string, error) GetActive() (string, error) }
This interface is only here for tests.
func NewDualRootfsDevice ¶
func NewDualRootfsDevice(env BootEnvReadWriter, sc system.StatCommander, config DualRootfsDeviceConfig) DualRootfsDevice
Returns nil if config doesn't contain partition paths.
type DualRootfsDeviceConfig ¶
type FlushingWriter ¶
type FlushingWriter struct { WF WriteSyncer FlushIntervalBytes uint64 // contains filtered or unexported fields }
FlushingWriter is a wrapper around a WriteSyncer which forces a Sync() to occur every so many bytes. FlushingWriter implements WriteSyncer.
func NewFlushingWriter ¶
func NewFlushingWriter(wf WriteSyncer, flushIntervalBytes uint64) *FlushingWriter
NewFlushingWriter returns a FlushingWriter which wraps the provided WriteSyncer and automatically flushes (calls Sync()) each time the specified number of bytes is written. Setting flushIntervalBytes == 0 causes Sync() to be called after every Write().
func (*FlushingWriter) Sync ¶
func (fw *FlushingWriter) Sync() error
type Installer ¶
type Installer struct {
// contains filtered or unexported fields
}
func (*Installer) GetArtifactName ¶
func (*Installer) StorePayloads ¶
type ModuleInstaller ¶
type ModuleInstaller struct {
// contains filtered or unexported fields
}
func (*ModuleInstaller) Cleanup ¶
func (mod *ModuleInstaller) Cleanup() error
func (*ModuleInstaller) CommitUpdate ¶
func (mod *ModuleInstaller) CommitUpdate() error
func (*ModuleInstaller) Failure ¶
func (mod *ModuleInstaller) Failure() error
func (*ModuleInstaller) FinishStoreUpdate ¶
func (mod *ModuleInstaller) FinishStoreUpdate() error
func (*ModuleInstaller) GetType ¶
func (mod *ModuleInstaller) GetType() string
func (*ModuleInstaller) Initialize ¶
func (mod *ModuleInstaller) Initialize(artifactHeaders, artifactAugmentedHeaders artifact.HeaderInfoer, payloadHeaders handlers.ArtifactUpdateHeaders) error
func (*ModuleInstaller) InstallUpdate ¶
func (mod *ModuleInstaller) InstallUpdate() error
func (*ModuleInstaller) NeedsReboot ¶
func (mod *ModuleInstaller) NeedsReboot() (RebootAction, error)
func (*ModuleInstaller) PrepareStoreUpdate ¶
func (mod *ModuleInstaller) PrepareStoreUpdate() error
func (*ModuleInstaller) Reboot ¶
func (mod *ModuleInstaller) Reboot() error
func (*ModuleInstaller) Rollback ¶
func (mod *ModuleInstaller) Rollback() error
func (*ModuleInstaller) RollbackReboot ¶
func (mod *ModuleInstaller) RollbackReboot() error
func (*ModuleInstaller) StoreUpdate ¶
func (*ModuleInstaller) SupportsRollback ¶
func (mod *ModuleInstaller) SupportsRollback() (bool, error)
func (*ModuleInstaller) VerifyReboot ¶
func (mod *ModuleInstaller) VerifyReboot() error
func (*ModuleInstaller) VerifyRollbackReboot ¶
func (mod *ModuleInstaller) VerifyRollbackReboot() error
type ModuleInstallerFactory ¶
type ModuleInstallerFactory struct {
// contains filtered or unexported fields
}
func NewModuleInstallerFactory ¶
func NewModuleInstallerFactory(modulesPath, modulesWorkPath string, artifactInfo ArtifactInfoGetter, deviceInfo DeviceInfoGetter, moduleTimeoutSecs int) *ModuleInstallerFactory
func (*ModuleInstallerFactory) GetModuleTypes ¶
func (mf *ModuleInstallerFactory) GetModuleTypes() []string
func (*ModuleInstallerFactory) NewUpdateStorer ¶
func (mf *ModuleInstallerFactory) NewUpdateStorer(updateType string, payloadNum int) (handlers.UpdateStorer, error)
type PayloadUpdatePerformer ¶
type PayloadUpdatePerformer interface { Rebooter handlers.UpdateStorer InstallUpdate() error NeedsReboot() (RebootAction, error) CommitUpdate() error SupportsRollback() (bool, error) Rollback() error // Verify that rebooting into the new update worked. VerifyReboot() error RollbackReboot() error // Verify that rebooting into the old update worked. VerifyRollbackReboot() error Failure() error Cleanup() error GetType() string }
func CreateInstallersFromList ¶
func CreateInstallersFromList(inst *AllModules, desiredTypes []string) ([]PayloadUpdatePerformer, error)
func Install ¶
func Install(art io.ReadCloser, dt string, key []byte, scrDir string, inst *AllModules) ([]PayloadUpdatePerformer, error)
type ReadLogger ¶
type ReadLogger struct {
// contains filtered or unexported fields
}
type RebootAction ¶
type RebootAction int
type StubInstaller ¶
type StubInstaller struct {
// contains filtered or unexported fields
}
A stub installer that fails nearly every step. For use as a stub when we cannot find the module we're looking for.
func NewStubInstaller ¶
func NewStubInstaller(payloadType string) *StubInstaller
func (*StubInstaller) Cleanup ¶
func (d *StubInstaller) Cleanup() error
func (*StubInstaller) CommitUpdate ¶
func (d *StubInstaller) CommitUpdate() error
func (*StubInstaller) Failure ¶
func (d *StubInstaller) Failure() error
func (*StubInstaller) FinishStoreUpdate ¶
func (d *StubInstaller) FinishStoreUpdate() error
func (*StubInstaller) GetType ¶
func (d *StubInstaller) GetType() string
func (*StubInstaller) Initialize ¶
func (d *StubInstaller) Initialize(artifactHeaders, artifactAugmentedHeaders artifact.HeaderInfoer, payloadHeaders handlers.ArtifactUpdateHeaders) error
func (*StubInstaller) InstallUpdate ¶
func (d *StubInstaller) InstallUpdate() error
func (*StubInstaller) NeedsReboot ¶
func (d *StubInstaller) NeedsReboot() (RebootAction, error)
func (*StubInstaller) PrepareStoreUpdate ¶
func (d *StubInstaller) PrepareStoreUpdate() error
func (*StubInstaller) Reboot ¶
func (d *StubInstaller) Reboot() error
func (*StubInstaller) Rollback ¶
func (d *StubInstaller) Rollback() error
func (*StubInstaller) RollbackReboot ¶
func (d *StubInstaller) RollbackReboot() error
func (*StubInstaller) StoreUpdate ¶
func (*StubInstaller) SupportsRollback ¶
func (d *StubInstaller) SupportsRollback() (bool, error)
func (*StubInstaller) VerifyReboot ¶
func (d *StubInstaller) VerifyReboot() error
func (*StubInstaller) VerifyRollbackReboot ¶
func (d *StubInstaller) VerifyRollbackReboot() error
type UBootEnv ¶
func NewEnvironment ¶
type WriteSyncer ¶
type WriteSyncer interface { io.Writer Sync() error // Commits previously-written data to stable storage. }
A WriteSyncer is an io.Writer that also implements a Sync() function which commits written data to stable storage. For instance, an os.File is a WriteSyncer.