Documentation ¶
Overview ¶
Copyright 2023 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 2023 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 2023 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 2023 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 ReadHeaders(art io.ReadCloser, dt string, keys []*conf.VerificationKey, scrDir string, ...) (*Installer, []PayloadUpdatePerformer, error)
- type AllModules
- type ArtifactInfoGetter
- type BlockDevice
- type BlockDeviceGetSectorSizeFunc
- type BlockDeviceGetSizeFunc
- type BlockDevicer
- type BlockFrameWriter
- type BootEnvReadWriter
- type BootVars
- type DeviceInfoGetter
- type DualRootfsDevice
- type FlushingWriter
- type Installer
- func (i *Installer) GetArtifactClearsProvides() []string
- func (i *Installer) GetArtifactDepends() (map[string]interface{}, error)
- func (i *Installer) GetArtifactName() string
- func (i *Installer) GetArtifactProvides() (map[string]string, error)
- func (i *Installer) GetCompatibleDevices() []string
- func (i *Installer) StorePayloads() error
- 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 OptimizedBlockDeviceWriter
- type PayloadUpdatePerformer
- 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
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 ReadHeaders ¶
func ReadHeaders(art io.ReadCloser, dt string, keys []*conf.VerificationKey, 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 // contains filtered or unexported fields }
BlockDevice is a low-level wrapper for a block device. The wrapper implements the io.Writer and io.Closer interfaces, which is all that is needed by the mender-client.
func (*BlockDevice) Close ¶
func (bd *BlockDevice) Close() error
Close closes the underlying block device, thus 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.
func (*BlockDevice) Write ¶
func (bd *BlockDevice) Write(b []byte) (n int, err error)
Write writes data 'b' to the underlying writer. Although this is just one line, the underlying implementation is currently slightly more involved. The BlockDevice writer will write to a chain of writers as follows:
LimitWriter Make sure that no more than image-size bytes are written to the block-device. | | v BlockFrameWriter Buffers the writes into 'chunkSize' frames for writing to the underlying writer. | | v OptimizedBlockDeviceWriter Only writes dirty frames to the underlying block-device. Note: This is not done for UBI volumes | | v BlockDevicer This is an interface with all the main functionality of a file, and is in this case a FlushingWriter, which writes a chunk to the underlying file-descriptor, and then calls Sync() on every 'FlushIntervalBytes' written.
Due to the underlying writer caching writes, the block-device needs to be closed, in order to make sure that all data has been flushed to the device.
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 BlockDevicer ¶
type BlockDevicer interface { io.Reader io.Writer io.Closer io.Seeker Sync() error // Commits previously-written data to stable storage. }
BlockDevicer is a file-like interface for the block-device.
type BlockFrameWriter ¶
type BlockFrameWriter struct {
// contains filtered or unexported fields
}
func (*BlockFrameWriter) Close ¶
func (bw *BlockFrameWriter) Close() error
Close flushes the remaining cached bytes -- if any.
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 conf.DualRootfsDeviceConfig, ) DualRootfsDevice
Returns nil if config doesn't contain partition paths.
type FlushingWriter ¶
type FlushingWriter struct { BlockDevicer FlushIntervalBytes uint64 // contains filtered or unexported fields }
FlushingWriter is a wrapper around a BlockDevice which forces a Sync() to occur every FlushIntervalBytes.
func NewFlushingWriter ¶
func NewFlushingWriter(wf *os.File, flushIntervalBytes uint64) *FlushingWriter
NewFlushingWriter returns a FlushingWriter which wraps the provided block-device (BlockDevicer) 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) Close ¶
func (fw *FlushingWriter) Close() error
func (*FlushingWriter) Sync ¶
func (fw *FlushingWriter) Sync() error
type Installer ¶
type Installer struct {
// contains filtered or unexported fields
}
func (*Installer) GetArtifactClearsProvides ¶
Returns all `clears_artifact_depends` fields from all payloads.
func (*Installer) GetArtifactDepends ¶
Returns the merged artifact depends header-info and type-info fields for artifact version >= 3. Returns nil if version < 3
func (*Installer) GetArtifactName ¶
func (*Installer) GetArtifactProvides ¶
Returns the merged artifact provides header-info and type-info fields for artifact version >= 3. Returns nil if version < 3
func (*Installer) GetCompatibleDevices ¶
Returns a list of compatible devices
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 OptimizedBlockDeviceWriter ¶
type OptimizedBlockDeviceWriter struct {
// contains filtered or unexported fields
}
OptimizedBlockDeviceWriter wraps an underlying blockDevice write, however, with the optimization that it compares the bytes passed in to the Write method, with the next len([]byte) bytes (considered a frame) on the block device, and if they match, the write is discarded. The lingo is that only dirty frames are written. Clean ones are discarded.
func (*OptimizedBlockDeviceWriter) Close ¶
func (obw *OptimizedBlockDeviceWriter) Close() 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, keys []*conf.VerificationKey, scrDir string, inst *AllModules) ([]PayloadUpdatePerformer, error)
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