service

package
v0.2.0-alpha2 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RAUC_OFFLINE_PATH             = "/DATA/rauc/"
	RAUC_OFFLINE_RELEASE_FILENAME = "release.yaml"
	RAUC_OFFLINE_RAUC_FILENAME    = "rauc.tar"
	OFFLINE_RAUC_TEMP_PATH        = "/tmp/offline_rauc"
)
View Source
const (
	FlagUpgradeFile = "/var/lib/casaos/upgradInfo.txt"
)

Variables

View Source
var (
	CurrentReleaseLocalPath = "/etc/casaos/release.yaml"
	TargetReleaseLocalPath  = "/etc/casaos/target-release.yaml"
)
View Source
var (
	ErrReleaseNotFound = fmt.Errorf("release not found")
)
View Source
var EventTypeMapMessageType = make(map[EventType]message_bus.EventType)
View Source
var EventTypeMapStatus = make(map[EventType]codegen.Status)
View Source
var FallbackStaticFiles embed.FS

embeded static files

Functions

func CurrentModuleVersion

func CurrentModuleVersion(module string, sysrootPath string) (*semver.Version, error)

func CurrentReleaseVersion

func CurrentReleaseVersion(sysrootPath string) (*semver.Version, error)

func DownloadAllMigrationTools

func DownloadAllMigrationTools(ctx context.Context, release codegen.Release, sysrootPath string) (bool, error)

func DownloadChecksum

func DownloadChecksum(ctx context.Context, release codegen.Release, mirror string) (string, error)

func DownloadMigrationTool

func DownloadMigrationTool(ctx context.Context, release codegen.Release, moduleName string, migration MigrationTool, force bool) (string, error)

func DownloadRelease

func DownloadRelease(ctx context.Context, release codegen.Release, force bool) (string, error)

returns releaseFilePath if successful

func DownloadUninstallScript

func DownloadUninstallScript(ctx context.Context, sysRoot string) (string, error)

func ExecuteMigrationTool

func ExecuteMigrationTool(moduleName string, migrationFilePath string, sysRoot string) error

func ExecuteModuleInstallScript

func ExecuteModuleInstallScript(releaseFilePath string, release codegen.Release) error

func ExtractOfflineRAUCToTemp added in v0.2.0

func ExtractOfflineRAUCToTemp(sysRoot string) error

func ExtractRAUCRelease added in v0.2.0

func ExtractRAUCRelease(packageFilepath string, release codegen.Release) error

func GetChecksums

func GetChecksums(release codegen.Release) (map[string]string, error)

func GetFileNameFromMigrationURL

func GetFileNameFromMigrationURL(url string) string

func GetMigrationDownloadURLFromMigrationListURL

func GetMigrationDownloadURLFromMigrationListURL(url string) string

func GetRelease

func GetRelease(ctx context.Context, tag string) (*codegen.Release, error)

func GetReleaseBranch added in v0.2.0

func GetReleaseBranch(sysRoot string) string

func GetStatus added in v0.2.0

func GetStatus() (codegen.Status, string)

func InitEventTypeMapStatus added in v0.2.0

func InitEventTypeMapStatus()

func InstallDependencies

func InstallDependencies(release codegen.Release, sysrootPath string) error

func InstallRAUC

func InstallRAUC(release codegen.Release, sysRoot string, InstallRAUCHandler func(raucPath string) error) error

dependent config.ServerInfo.CachePath

func InstallRAUCHandlerV1 added in v0.2.0

func InstallRAUCHandlerV1(RAUCFilePath string) error

func InstallRAUCTest added in v0.2.0

func InstallRAUCTest(raucfilepath string) error

func InstallRelease

func InstallRelease(release codegen.Release, sysrootPath string) error

func IsCasaOS

func IsCasaOS(sysRoot string) bool

func IsUpgradable

func IsUpgradable(release codegen.Release, sysrootPath string) bool

to check the new version is upgradable and packages are already cached(download)

func IsZimaOS

func IsZimaOS(sysRoot string) bool

func LaunchModule

func LaunchModule(release codegen.Release) error

func MarkGood added in v0.2.0

func MarkGood() error

func MigrationToolsDir

func MigrationToolsDir() string

func MigrationToolsMap

func MigrationToolsMap(release codegen.Release) (map[string][]MigrationTool, error)

func NormalizationVersion added in v0.2.0

func NormalizationVersion(version string) string

func NormalizeMigrationToolURL

func NormalizeMigrationToolURL(url string) string

Normalize migraiton tool URL to a standard format which uses `${MIRROR}` as the mirror placeholder

func NormalizeMigrationToolURLPass1

func NormalizeMigrationToolURLPass1(url string) string

func NormalizeMigrationToolURLPass2

func NormalizeMigrationToolURLPass2(url string) string

func NormalizeVersion

func NormalizeVersion(version string) string

func PostInstallRAUC added in v0.2.0

func PostInstallRAUC(release codegen.Release, sysRoot string) error

func PostMigration

func PostMigration(sysRoot string) error

func PostReleaseInstall

func PostReleaseInstall(release codegen.Release, sysrootPath string) error

func PublishEventWrapper

func PublishEventWrapper(ctx context.Context, eventType message_bus.EventType, properties map[string]string)

func RebootSystem

func RebootSystem()

func ReleaseDir

func ReleaseDir(release codegen.Release) (string, error)

func ShouldUpgrade

func ShouldUpgrade(release codegen.Release, sysrootPath string) bool

func StartFallbackWebsite added in v0.2.0

func StartFallbackWebsite()

func StartMigration

func StartMigration(sysRoot string) error

func StopFallbackWebsite added in v0.2.0

func StopFallbackWebsite()

func StopModule

func StopModule(release codegen.Release) error

func UpdateStatusWithMessage added in v0.2.0

func UpdateStatusWithMessage(eventType EventType, newPackageStatus string)

func VerifyAllMigrationTools

func VerifyAllMigrationTools(targetRelease codegen.Release, sysRoot string) bool

verify migration tools for a release are already cached

func VerifyChecksumByFilePath

func VerifyChecksumByFilePath(filepath, checksum string) error

sha256sum

func VerifyMigrationTool

func VerifyMigrationTool(moduleName string, fileName string) (string, error)

func VerifyRAUC

func VerifyRAUC(release codegen.Release) (string, error)

func VerifyRAUCOfflineRelease added in v0.2.0

func VerifyRAUCOfflineRelease(release codegen.Release) (string, error)

func VerifyRAUCRelease added in v0.2.0

func VerifyRAUCRelease(release codegen.Release) (string, error)

func VerifyRelease

func VerifyRelease(release codegen.Release) (string, error)

func VerifyUninstallScript

func VerifyUninstallScript(sysRoot string) bool

Types

type EventType added in v0.2.0

type EventType string
const (
	DownloadBegin    EventType = "downloadBegin"
	DownloadEnd      EventType = "downloadEnd"
	DownloadError    EventType = "downloadError"
	FetchUpdateEnd   EventType = "fetchUpdateEnd"
	FetchUpdateBegin EventType = "fetchUpdateBegin"
	FetchUpdateError EventType = "fetchUpdateError"

	Idle         EventType = "idle"
	InstallEnd   EventType = "installEnd"
	InstallBegin EventType = "installBegin"
	InstallError EventType = "installError"
)

type InstallerServiceInterface added in v0.2.0

type InstallerServiceInterface interface {
}

type InstallerType added in v0.2.0

type InstallerType string
const (
	RAUC        InstallerType = "rauc"
	RAUCOFFLINE InstallerType = "rauc_offline"
	TAR         InstallerType = "tar"
)

func GetInstallMethod

func GetInstallMethod(sysRoot string) (InstallerType, error)

type MigrationTool

type MigrationTool struct {
	Version semver.Version
	URL     string
}

func GetMigrationPath

func GetMigrationPath(module codegen.Module, release codegen.Release, migrationToolMap map[string][]MigrationTool, sysRoot string) ([]MigrationTool, error)

func RemoveDuplication

func RemoveDuplication(arr []MigrationTool) []MigrationTool

type RAUCOfflineService added in v0.2.0

type RAUCOfflineService struct {
	SysRoot            string
	InstallRAUCHandler func(raucPath string) error
}

func (*RAUCOfflineService) DownloadAllMigrationTools added in v0.2.0

func (r *RAUCOfflineService) DownloadAllMigrationTools(ctx context.Context, release codegen.Release) error

func (*RAUCOfflineService) DownloadRelease added in v0.2.0

func (r *RAUCOfflineService) DownloadRelease(ctx context.Context, release codegen.Release, force bool) (string, error)

func (*RAUCOfflineService) ExtractRelease added in v0.2.0

func (r *RAUCOfflineService) ExtractRelease(packageFilepath string, release codegen.Release) error

func (*RAUCOfflineService) GetMigrationInfo added in v0.2.0

func (r *RAUCOfflineService) GetMigrationInfo(ctx context.Context, release codegen.Release) error

func (*RAUCOfflineService) GetRelease added in v0.2.0

func (r *RAUCOfflineService) GetRelease(ctx context.Context, tag string) (*codegen.Release, error)

func (*RAUCOfflineService) Install added in v0.2.0

func (r *RAUCOfflineService) Install(release codegen.Release, sysRoot string) error

func (*RAUCOfflineService) IsUpgradable added in v0.2.0

func (r *RAUCOfflineService) IsUpgradable(release codegen.Release, sysrootPath string) bool

func (*RAUCOfflineService) LoadReleaseFromOfflineRAUC added in v0.2.0

func (r *RAUCOfflineService) LoadReleaseFromOfflineRAUC(sysRoot string) (*codegen.Release, error)

func (*RAUCOfflineService) MigrationInLaunch added in v0.2.0

func (r *RAUCOfflineService) MigrationInLaunch(sysRoot string) error

func (*RAUCOfflineService) PostInstall added in v0.2.0

func (r *RAUCOfflineService) PostInstall(release codegen.Release, sysRoot string) error

func (*RAUCOfflineService) PostMigration added in v0.2.0

func (r *RAUCOfflineService) PostMigration(sysRoot string) error

func (*RAUCOfflineService) ShouldUpgrade added in v0.2.0

func (r *RAUCOfflineService) ShouldUpgrade(release codegen.Release, sysRoot string) bool

func (*RAUCOfflineService) VerifyRelease added in v0.2.0

func (r *RAUCOfflineService) VerifyRelease(release codegen.Release) (string, error)

type RAUCService added in v0.2.0

type RAUCService struct {
	InstallRAUCHandler func(raucPath string) error
}

func (*RAUCService) DownloadAllMigrationTools added in v0.2.0

func (r *RAUCService) DownloadAllMigrationTools(ctx context.Context, release codegen.Release) error

func (*RAUCService) DownloadRelease added in v0.2.0

func (r *RAUCService) DownloadRelease(ctx context.Context, release codegen.Release, force bool) (string, error)

func (*RAUCService) ExtractRelease added in v0.2.0

func (r *RAUCService) ExtractRelease(packageFilepath string, release codegen.Release) error

func (*RAUCService) GetMigrationInfo added in v0.2.0

func (r *RAUCService) GetMigrationInfo(ctx context.Context, release codegen.Release) error

func (*RAUCService) GetRelease added in v0.2.0

func (r *RAUCService) GetRelease(ctx context.Context, tag string) (*codegen.Release, error)

func (*RAUCService) Install added in v0.2.0

func (r *RAUCService) Install(release codegen.Release, sysRoot string) error

func (*RAUCService) IsUpgradable added in v0.2.0

func (r *RAUCService) IsUpgradable(release codegen.Release, sysrootPath string) bool

func (*RAUCService) MigrationInLaunch added in v0.2.0

func (r *RAUCService) MigrationInLaunch(sysRoot string) error

func (*RAUCService) PostInstall added in v0.2.0

func (r *RAUCService) PostInstall(release codegen.Release, sysRoot string) error

func (*RAUCService) PostMigration added in v0.2.0

func (r *RAUCService) PostMigration(sysRoot string) error

func (*RAUCService) ShouldUpgrade added in v0.2.0

func (r *RAUCService) ShouldUpgrade(release codegen.Release, sysRoot string) bool

func (*RAUCService) VerifyRelease added in v0.2.0

func (r *RAUCService) VerifyRelease(release codegen.Release) (string, error)

type Services

type Services interface {
	Gateway() (external.ManagementService, error)
	MessageBus() (*message_bus.ClientWithResponses, error)
}
var MyService Services

func NewService

func NewService(RuntimePath string) Services

type StatusService added in v0.2.0

type StatusService struct {
	ImplementService UpdaterServiceInterface
	SysRoot          string
}

func (*StatusService) Cronjob added in v0.2.0

func (r *StatusService) Cronjob(sysRoot string) error

func (*StatusService) DownloadAllMigrationTools added in v0.2.0

func (r *StatusService) DownloadAllMigrationTools(ctx context.Context, release codegen.Release) error

func (*StatusService) DownloadRelease added in v0.2.0

func (r *StatusService) DownloadRelease(ctx context.Context, release codegen.Release, force bool) (string, error)

func (*StatusService) ExtractRelease added in v0.2.0

func (r *StatusService) ExtractRelease(packageFilepath string, release codegen.Release) error

func (*StatusService) GetMigrationInfo added in v0.2.0

func (r *StatusService) GetMigrationInfo(ctx context.Context, release codegen.Release) error

func (*StatusService) GetRelease added in v0.2.0

func (r *StatusService) GetRelease(ctx context.Context, tag string) (*codegen.Release, error)

func (*StatusService) Install added in v0.2.0

func (r *StatusService) Install(release codegen.Release, sysRoot string) error

func (*StatusService) IsUpgradable added in v0.2.0

func (r *StatusService) IsUpgradable(release codegen.Release, sysRootPath string) bool

func (*StatusService) MigrationInLaunch added in v0.2.0

func (r *StatusService) MigrationInLaunch(sysRoot string) error

func (*StatusService) PostInstall added in v0.2.0

func (r *StatusService) PostInstall(release codegen.Release, sysRoot string) error

func (*StatusService) PostMigration added in v0.2.0

func (r *StatusService) PostMigration(sysRoot string) error

func (*StatusService) ShouldUpgrade added in v0.2.0

func (r *StatusService) ShouldUpgrade(release codegen.Release, sysRoot string) bool

func (*StatusService) VerifyRelease added in v0.2.0

func (r *StatusService) VerifyRelease(release codegen.Release) (string, error)

type TarService added in v0.2.0

type TarService struct {
}

func (*TarService) GetRelease added in v0.2.0

func (r *TarService) GetRelease(ctx context.Context, tag string) (*codegen.Release, error)

func (*TarService) Install added in v0.2.0

func (r *TarService) Install(release codegen.Release, sysRoot string) error

type TestService added in v0.2.0

type TestService struct {
	InstallRAUCHandler func(raucPath string) error
	// contains filtered or unexported fields
}

func (*TestService) DownloadAllMigrationTools added in v0.2.0

func (r *TestService) DownloadAllMigrationTools(ctx context.Context, release codegen.Release) error

func (*TestService) DownloadRelease added in v0.2.0

func (r *TestService) DownloadRelease(ctx context.Context, release codegen.Release, force bool) (string, error)

func (*TestService) ExtractRelease added in v0.2.0

func (r *TestService) ExtractRelease(packageFilepath string, release codegen.Release) error

func (*TestService) GetMigrationInfo added in v0.2.0

func (r *TestService) GetMigrationInfo(ctx context.Context, release codegen.Release) error

func (*TestService) GetRelease added in v0.2.0

func (r *TestService) GetRelease(ctx context.Context, tag string) (*codegen.Release, error)

func (*TestService) Install added in v0.2.0

func (r *TestService) Install(release codegen.Release, sysRoot string) error

func (*TestService) IsUpgradable added in v0.2.0

func (r *TestService) IsUpgradable(release codegen.Release, sysRootPath string) bool

func (*TestService) MigrationInLaunch added in v0.2.0

func (r *TestService) MigrationInLaunch(sysRoot string) error

func (*TestService) PostInstall added in v0.2.0

func (r *TestService) PostInstall(release codegen.Release, sysRoot string) error

func (*TestService) PostMigration added in v0.2.0

func (r *TestService) PostMigration(sysRoot string) error

func (*TestService) ShouldUpgrade added in v0.2.0

func (r *TestService) ShouldUpgrade(release codegen.Release, sysRoot string) bool

func (*TestService) VerifyRelease added in v0.2.0

func (r *TestService) VerifyRelease(release codegen.Release) (string, error)

type UpdaterServiceInterface added in v0.2.0

type UpdaterServiceInterface interface {
	GetRelease(ctx context.Context, tag string) (*codegen.Release, error)
	VerifyRelease(release codegen.Release) (string, error)
	DownloadRelease(ctx context.Context, release codegen.Release, force bool) (string, error)
	ExtractRelease(packageFilepath string, release codegen.Release) error
	GetMigrationInfo(ctx context.Context, release codegen.Release) error
	DownloadAllMigrationTools(ctx context.Context, release codegen.Release) error
	Install(release codegen.Release, sysRoot string) error
	PostInstall(release codegen.Release, sysRoot string) error

	MigrationInLaunch(sysRoot string) error
	PostMigration(sysRoot string) error

	ShouldUpgrade(release codegen.Release, sysRoot string) bool
	IsUpgradable(release codegen.Release, sysRootPath string) bool // 检测预下载的包好了没有
}
var InstallerService UpdaterServiceInterface

func NewInstallerService added in v0.2.0

func NewInstallerService(sysRoot string) UpdaterServiceInterface

Jump to

Keyboard shortcuts

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