Documentation ¶
Overview ¶
This is system package manager need implement for porting lastore-daemon
Index ¶
- Constants
- Variables
- func CheckInstallAddSize(updateType UpdateType) bool
- func CheckLock(p string) (string, bool)
- func CustomSourceWrapper(updateType UpdateType, doRealAction func(path string, unref func()) error) error
- func DecodeJson(fpath string, d interface{}) error
- func EncodeJson(fpath string, d interface{}) error
- func GetAppStoreAppName() string
- func GetArchivesDir(configPath string) (string, error)
- func GetCategorySourceMap() map[UpdateType]string
- func GetGrubNormalTitle(grubPath string) string
- func GetGrubRollbackTitle(grubPath string) string
- func HandleDelayPackage(hold bool, packages []string)
- func IsActiveCodeExist() bool
- func IsAuthorized() bool
- func ListPackageFile(packages ...string) []string
- func NormalFileExists(fpath string) bool
- func QueryFileCacheSize(path string) (float64, error)
- func QueryPackageDependencies(pkgId string) []string
- func QueryPackageDownloadSize(updateType UpdateType, packages ...string) (float64, float64, error)
- func QueryPackageInstallable(pkgId string) bool
- func QueryPackageInstalled(pkgId string) bool
- func QuerySourceAddSize(updateType UpdateType) (float64, error)
- func QuerySourceDownloadSize(updateType UpdateType, pkgList []string) (float64, float64, error)
- func SetSystemUpdate(platform bool)
- func UpdateOtherSystemSourceDir(otherSourceList []string) error
- func UpdateSecurityDefaultSourceDir(sourceList []string) error
- func UpdateSourceDirUseUrl(updateType UpdateType, repoUrl []string, fileName string, annotation string) error
- func UpdateSystemDefaultSourceDir(sourceList []string) error
- func UpdateUnknownSourceDir(nonUnknownList strv.Strv) error
- type ABErrorType
- type ABStatus
- type Architecture
- type Command
- func (c *Command) Abort() error
- func (c *Command) AbortWithFailed() error
- func (c *Command) IndicateFailed(errType JobErrorType, errDetail string, isFatalErr bool)
- func (c *Command) SetEnv(envVarMap map[string]string)
- func (c *Command) Start() error
- func (c *Command) String() string
- func (c *Command) Wait() (err error)
- type CommandSet
- type Indicator
- type JobError
- type JobErrorType
- type JobProgressInfo
- type MirrorSource
- type NotFoundErrorType
- type PackageInfo
- type ParseJobError
- type ParseProgressInfo
- type PlatformPackageInfo
- type RepositoryInfo
- type SourceUpgradeInfoMap
- type Status
- type System
- type UiActiveState
- type UpdateInfoError
- type UpdateModeStatus
- type UpdateType
- type UpgradeInfo
- type UpgradeStatus
- type UpgradeStatusAndReason
- type Version
Constants ¶
const ( ExitSuccess = 0 ExitFailure = 1 ExitPause = 2 )
const ( GrubTitleRollbackPrefix = "BEGIN /etc/grub.d/11_deepin_ab_recovery" GrubTitleRollbackSuffix = "END /etc/grub.d/11_deepin_ab_recovery" GrubTitleNormalPrefix = "BEGIN /etc/grub.d/10_linux" GrubTitleNormalSuffix = "END /etc/grub.d/10_linux" )
const ( DownloadJobType = "download" InstallJobType = "install" OnlyInstallJobType = "only_install" RemoveJobType = "remove" UpdateJobType = "update" DistUpgradeJobType = "dist_upgrade" PrepareDistUpgradeJobType = "prepare_dist_upgrade" UpdateSourceJobType = "update_source" CleanJobType = "clean" FixErrorJobType = "fix_error" CheckSystemJobType = "check_system" OfflineUpdateJobType = "offline_update" // UpgradeJobType 创建任务时会根据四种下载和安装类型,分别创建带有不同参数的下载和更新任务 PrepareSystemUpgradeJobType = "prepare_system_upgrade" PrepareAppStoreUpgradeJobType = "prepare_appstore_upgrade" PrepareSecurityUpgradeJobType = "prepare_security_upgrade" PrepareUnknownUpgradeJobType = "prepare_unknown_upgrade" SystemUpgradeJobType = "system_upgrade" AppStoreUpgradeJobType = "appstore_upgrade" SecurityUpgradeJobType = "security_upgrade" UnknownUpgradeJobType = "unknown_upgrade" OfflineUpgradeJobType = "offline_update" OtherUpgradeJobType = "other_system_update" AppendUpgradeJobTye = "append_upgrade" )
const ( NotifyExpireTimeoutDefault = -1 NotifyExpireTimeoutNoHide = 0 )
const ( LastoreAptOrgConfPath = "/var/lib/lastore/apt.conf" LastoreAptV2ConfPath = "/var/lib/lastore/apt_v2.conf" LastoreAptV2CommonConfPath = "/var/lib/lastore/apt_v2_common.conf" // 该配置指定了通过lastore更新的deb包缓存路径 )
const ( DutOnlineMetaConfPath = "/var/lib/lastore/online_meta.json" // 在线更新元数据 DutOfflineMetaConfPath = "/var/lib/lastore/offline_meta.json" // 离线更新元数据 )
const ( OnlineListPath = "/var/lib/apt/lists" OfflineListPath = "/var/lib/lastore/offline_list" )
const ( OriginSourceFile = "/etc/apt/sources.list" OriginSourceDir = "/etc/apt/sources.list.d" AppStoreList = "appstore.list" UnstableSourceList = "deepin-unstable-source.list" HweSourceList = "hwe.list" DriverList = "driver.list" SecurityList = "security.list" AppStoreSourceFile = "/etc/apt/sources.list.d/" + AppStoreList UnstableSourceFile = "/etc/apt/sources.list.d/" + UnstableSourceList HweSourceFile = "/etc/apt/sources.list.d/" + HweSourceList SecuritySourceFile = "/etc/apt/sources.list.d/" + SecurityList SoftLinkSystemSourceDir = "/var/lib/lastore/SystemSource.d" // 系统更新仓库 SecuritySourceDir = "/var/lib/lastore/SecuritySource.d" PlatFormSourceFile = "/var/lib/lastore/platform.list" // 从更新平台获取的仓库,为系统更新仓库,在message_report.go 中的 获取升级版本信息genUpdatePolicyByToken后即可 更新 UnknownSourceDir = "/var/lib/lastore/unknownSource.d" // 未知来源更新的源个数不定,需要创建软链接放在同一目录内 OtherSystemSourceDir = "/var/lib/lastore/otherSystemSource.d" // 其他需要检查的系统仓库 OfflineSourceFile = "/var/lib/lastore/offline.list" // 在offline_repo.go 中的 UpdateOfflineSourceFile 更新 AppendSourceDir = "/etc/deepin/lastore-daemon/sources.list.d" // 追加仓库的路径 )
const ( LastoreSourcesPath = "/var/lib/lastore/sources.list" // 历史版本遗留,已废弃 CustomSourceDir = "/var/lib/lastore/sources.list.d" // 历史版本遗留,已废弃 )
const DefaultMirrorsUrl = "http://packages.deepin.com/mirrors/community.json"
const (
LocalCachePath = "/var/cache/lastore/archives"
)
const NotFoundErrorMsg = "not found resource: "
const SizeDownloaded = 0
const SizeUnknown = -1
const VarLibDir = "/var/lib/lastore"
Variables ¶
var NotSupportError = errors.New("not support operation")
var RepoInfos []RepositoryInfo
var ResourceExitError = errors.New("resource exists")
var SystemUpdateSource = SoftLinkSystemSourceDir
Functions ¶
func CheckInstallAddSize ¶
func CheckInstallAddSize(updateType UpdateType) bool
func CustomSourceWrapper ¶
func CustomSourceWrapper(updateType UpdateType, doRealAction func(path string, unref func()) error) error
CustomSourceWrapper 根据updateType组合source文件,doRealAction完成实际操作,unref用于释放资源
func DecodeJson ¶
func EncodeJson ¶
func GetAppStoreAppName ¶
func GetAppStoreAppName() string
func GetArchivesDir ¶
$ apt-config --format '%f=%v%n' dump Dir Dir=/ Dir::Cache=var/cache/apt Dir::Cache::archives=archives/ Dir::Cache::srcpkgcache=srcpkgcache.bin Dir::Cache::pkgcache=pkgcache.bin
func GetCategorySourceMap ¶
func GetCategorySourceMap() map[UpdateType]string
GetCategorySourceMap 缺省更新类型与对应仓库的map
func GetGrubNormalTitle ¶
func GetGrubRollbackTitle ¶
func HandleDelayPackage ¶
func IsActiveCodeExist ¶
func IsActiveCodeExist() bool
func IsAuthorized ¶
func IsAuthorized() bool
func ListPackageFile ¶
ListPackageFile list files path contained in the packages
func NormalFileExists ¶
func QueryFileCacheSize ¶
QueryFileCacheSize parsing the file total size(kb) of the path
func QueryPackageDependencies ¶
QueryPackageDependencies return the directly dependencies
func QueryPackageDownloadSize ¶
func QueryPackageDownloadSize(updateType UpdateType, packages ...string) (float64, float64, error)
QueryPackageDownloadSize parsing the total size of download archives when installing the packages. return arg0:需要下载的量;arg1:所有包的大小;arg2:error
func QueryPackageInstallable ¶
QueryPackageInstallable query whether the pkgId can be installed
func QueryPackageInstalled ¶
QueryPackageInstalled query whether the pkgId installed
func QuerySourceAddSize ¶
func QuerySourceAddSize(updateType UpdateType) (float64, error)
func QuerySourceDownloadSize ¶
func QuerySourceDownloadSize(updateType UpdateType, pkgList []string) (float64, float64, error)
QuerySourceDownloadSize 根据更新类型(仓库),获取需要的下载量,return arg0:需要下载的量;arg1:所有包的大小;arg2:error
func SetSystemUpdate ¶
func SetSystemUpdate(platform bool)
func UpdateOtherSystemSourceDir ¶
UpdateOtherSystemSourceDir otherSourceList 需要list文件的绝对路径
func UpdateSourceDirUseUrl ¶
func UpdateSourceDirUseUrl(updateType UpdateType, repoUrl []string, fileName string, annotation string) error
func UpdateSystemDefaultSourceDir ¶
UpdateSystemDefaultSourceDir systemSourceList需要list文件的绝对路径;更新系统仓库文件夹,如果从更新平台获取系统仓库,那么不需要调用这里
func UpdateUnknownSourceDir ¶
UpdateUnknownSourceDir 更新未知来源仓库文件夹
Types ¶
type ABErrorType ¶
type ABErrorType string
const ( NoABError ABErrorType = "noError" CanNotBackup ABErrorType = "canNotBackup" OtherError ABErrorType = "otherError" )
type Architecture ¶
type Architecture string
func SystemArchitectures ¶
func SystemArchitectures() ([]Architecture, error)
SystemArchitectures return the system package manager supported architectures
type Command ¶
type Command struct { JobId string Cancelable bool CmdSet CommandSet Cmd *exec.Cmd ExitCode int Indicator Indicator ParseProgressInfo ParseProgressInfo ParseJobError ParseJobError Stdout bytes.Buffer Stderr bytes.Buffer AtExitFn func() bool // contains filtered or unexported fields }
func (*Command) AbortWithFailed ¶
func (*Command) IndicateFailed ¶
func (c *Command) IndicateFailed(errType JobErrorType, errDetail string, isFatalErr bool)
type CommandSet ¶
type Indicator ¶
type Indicator func(JobProgressInfo)
type JobError ¶
type JobError struct { ErrType JobErrorType ErrDetail string IsCheckError bool ErrorLog []string }
type JobErrorType ¶
type JobErrorType string
const ( NoError JobErrorType = "NoError" ErrorUnknown JobErrorType = "ErrorUnknown" ErrorProgram JobErrorType = "ErrorProgram" ErrorFetchFailed JobErrorType = "fetchFailed" ErrorDpkgError JobErrorType = "dpkgError" ErrorPkgNotFound JobErrorType = "pkgNotFound" ErrorDpkgInterrupted JobErrorType = "dpkgInterrupted" ErrorDependenciesBroken JobErrorType = "dependenciesBroken" ErrorUnmetDependencies JobErrorType = "unmetDependencies" ErrorNoInstallationCandidate JobErrorType = "noInstallationCandidate" ErrorInsufficientSpace JobErrorType = "insufficientSpace" ErrorUnauthenticatedPackages JobErrorType = "unauthenticatedPackages" ErrorOperationNotPermitted JobErrorType = "operationNotPermitted" ErrorIndexDownloadFailed JobErrorType = "IndexDownloadFailed" ErrorIO JobErrorType = "ioError" ErrorDamagePackage JobErrorType = "damagePackage" // 包损坏,需要删除后重新下载或者安装 ErrorInvalidSourcesList JobErrorType = "invalidSourceList" ErrorPlatformUnreachable JobErrorType = "platformUnreachable" ErrorOfflineCheck JobErrorType = "offlineCheckError" ErrorMissCoreFile JobErrorType = "missCoreFile" ErrorScript JobErrorType = "scriptError" ErrorProgressCheck JobErrorType = "progressCheckError" // running状态 ErrorNeedCheck JobErrorType = "needCheck" )
func (JobErrorType) String ¶
func (j JobErrorType) String() string
type JobProgressInfo ¶
type MirrorSource ¶
type NotFoundErrorType ¶
type NotFoundErrorType string
func NotFoundError ¶
func NotFoundError(w string) NotFoundErrorType
func (NotFoundErrorType) Error ¶
func (e NotFoundErrorType) Error() string
type PackageInfo ¶
type ParseJobError ¶
type ParseProgressInfo ¶
type ParseProgressInfo func(id, line string) (JobProgressInfo, error)
type PlatformPackageInfo ¶
type RepositoryInfo ¶
type RepositoryInfo struct { Name string `json:"name"` Url string `json:"url"` Mirror string `json:"mirror"` }
func DetectDefaultRepoInfo ¶
func DetectDefaultRepoInfo(rInfos []RepositoryInfo) RepositoryInfo
type SourceUpgradeInfoMap ¶
type SourceUpgradeInfoMap map[string][]UpgradeInfo
type System ¶
type System interface { DownloadPackages(jobId string, packages []string, environ map[string]string, cmdArgs map[string]string) error DownloadSource(jobId string, packages []string, environ map[string]string, cmdArgs map[string]string) error Install(jobId string, packages []string, environ map[string]string, cmdArgs map[string]string) error Remove(jobId string, packages []string, environ map[string]string) error DistUpgrade(jobId string, packages []string, environ map[string]string, cmdArgs map[string]string) error UpdateSource(jobId string, environ map[string]string, cmdArgs map[string]string) error Clean(jobId string) error Abort(jobId string) error AbortWithFailed(jobId string) error AttachIndicator(Indicator) FixError(jobId string, errType string, environ map[string]string, cmdArgs map[string]string) error CheckSystem(jobId string, checkType string, environ map[string]string, cmdArgs map[string]string) error }
type UiActiveState ¶
type UiActiveState int32
const ( Unknown UiActiveState = -1 // 未知 Authorized UiActiveState = 1 // 已授权 AuthorizedLapse UiActiveState = 2 // 授权失效 TrialAuthorized UiActiveState = 3 // 试用期已授权 TrialExpired UiActiveState = 4 // 试用期已过期 )
type UpdateInfoError ¶
func (*UpdateInfoError) Error ¶
func (err *UpdateInfoError) Error() string
type UpdateModeStatus ¶
type UpdateModeStatus string
const ( NoUpdate UpdateModeStatus = "noUpdate" // 无更新 NotDownload UpdateModeStatus = "notDownload" // 包含了有更新没下载 IsDownloading UpdateModeStatus = "isDownloading" DownloadPause UpdateModeStatus = "downloadPause" DownloadErr UpdateModeStatus = "downloadFailed" CanUpgrade UpdateModeStatus = "downloaded" // Downloaded WaitRunUpgrade UpdateModeStatus = "upgradeReady" // 进行备份+更新时,当处于更新未开始状态 Upgrading UpdateModeStatus = "upgrading" UpgradeErr UpdateModeStatus = "upgradeFailed" Upgraded UpdateModeStatus = "needReboot" // need reboot )
type UpdateType ¶
type UpdateType uint64
const ( SystemUpdate UpdateType = 1 << 0 // 系统仓库更新,检查该仓库,显示更新内容 AppStoreUpdate UpdateType = 1 << 1 // 应用仓库更新,检查该仓库,不显示更新内容 SecurityUpdate UpdateType = 1 << 2 // 安全仓库更新,检查该仓库,显示更新内容 UnknownUpdate UpdateType = 1 << 3 // 未知来源仓库更新:排除 系统、商店、安全、驱动、hwe仓库的其他仓库,不检查该仓库,不显示更新内容 OnlySecurityUpdate UpdateType = 1 << 4 // 仅安全仓库更新,已经废弃,用于处理历史版本升级后的兼容问题 OtherSystemUpdate UpdateType = 1 << 5 // 其他来源系统的仓库更新:对应dconfig non-unknown-sources 字段去掉商店和安全仓库,通常为驱动、hwe仓库(hwe仓库应该从平台获取),检查该仓库,不显示更新内容 AllCheckUpdate = SystemUpdate | AppStoreUpdate | SecurityUpdate | UnknownUpdate | OtherSystemUpdate | AppendUpdate // 所有需要检查的仓库 TODO 该字段变动,需要检查所有使用者 AllInstallUpdate = SystemUpdate | SecurityUpdate | UnknownUpdate // 所有控制中心需要显示的仓库 OfflineUpdate UpdateType = 1 << 6 // 离线仓库,控制中心不检查、不显示;离线更新工具检查和显示; AppendUpdate UpdateType = 1 << 7 // 追加仓库/etc/deepin/lastore-daemon/sources.list.d/ 用于打印管理追加离线包.检查该仓库,不显示更新内容 )
用于设置UpdateMode属性,最大支持64位
func AllCheckUpdateType ¶
func AllCheckUpdateType() []UpdateType
AllCheckUpdateType 对应 system.AllCheckUpdate
func AllInstallUpdateType ¶
func AllInstallUpdateType() []UpdateType
AllInstallUpdateType 对应 system.AllInstallUpdate
func AllUpdateType ¶
func AllUpdateType() []UpdateType
func UpdateTypeBitToArray ¶
func UpdateTypeBitToArray(mode UpdateType) []UpdateType
func (UpdateType) JobType ¶
func (m UpdateType) JobType() string
type UpgradeInfo ¶
type UpgradeStatus ¶
type UpgradeStatus string
UpgradeStatus 整体更新安装的流程状态
const ( UpgradeReady UpgradeStatus = "ready" UpgradeRunning UpgradeStatus = "running" UpgradeFailed UpgradeStatus = "failed" )
type UpgradeStatusAndReason ¶
type UpgradeStatusAndReason struct { Status UpgradeStatus ReasonCode JobErrorType }
UpgradeStatusAndReason 用于记录整体更新安装的流程状态和原因,dde-session-daemon和回滚界面会根据该配置进行提示