Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type Config struct {
UpdateMode system.UpdateType
CheckUpdateMode system.UpdateType
IncrementalUpdate bool
IntranetUpdate bool

// 缓存大小超出限制时的清理时间间隔
CleanIntervalCacheOverLimit time.Duration
Expand Down Expand Up @@ -199,6 +200,7 @@ const (
dSettingsKeySecurityRepoType = "security-repo-type"
dSettingsKeyPlatformRepoComponents = "platform-repo-components"
dSettingsKeyIncrementalUpdate = "incremental-update"
dSettingsKeyIntranetUpdate = "intranet-update"
dSettingsKeyGetHardwareIdByHelper = "hardware-id-from-helper"
dSettingsKeyCheckPolicyInterval = "check-policy-interval"
)
Expand Down Expand Up @@ -275,6 +277,13 @@ func getConfigFromDSettings() *Config {
c.IncrementalUpdate = v.Value().(bool)
}

v, err = c.dsLastoreManager.Value(0, dSettingsKeyIntranetUpdate)
if err != nil {
logger.Warning(err)
} else {
c.IntranetUpdate = v.Value().(bool)
}

v, err = c.dsLastoreManager.Value(0, dSettingsKeyMirrorSource)
if err != nil {
logger.Warning(err)
Expand Down
8 changes: 5 additions & 3 deletions src/internal/system/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
)

const VarLibDir = "/var/lib/lastore"
const IupPath = "/usr/lib/iup-daemon"

// TODO: Assign value later
var IsPrivateLastore bool

type Status string
Expand Down Expand Up @@ -57,8 +57,10 @@ const (
)

const (
NotifyExpireTimeoutDefault = -1
NotifyExpireTimeoutNoHide = 0
NotifyExpireTimeoutDefault = -1
NotifyExpireTimeoutNoHide = 0
NotifyExpireTimeoutPrivate = 10000
NotifyExpireTimeoutPrivateLong = 600000
)

type JobProgressInfo struct {
Expand Down
17 changes: 12 additions & 5 deletions src/internal/system/update_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,15 @@ func UpdateOtherSystemSourceDir(otherSourceList []string) error {
// CustomSourceWrapper 根据updateType组合source文件,doRealAction完成实际操作,unref用于释放资源
func CustomSourceWrapper(updateType UpdateType, doRealAction func(path string, unref func()) error) error {
var sourcePathList []string
for _, t := range AllCheckUpdateType() {
category := updateType & t
if category != 0 {
sourcePath := GetCategorySourceMap()[t]
sourcePathList = append(sourcePathList, sourcePath)
if IsPrivateLastore {
sourcePathList = append(sourcePathList, SystemUpdateSource)
} else {
for _, t := range AllCheckUpdateType() {
category := updateType & t
if category != 0 {
sourcePath := GetCategorySourceMap()[t]
sourcePathList = append(sourcePathList, sourcePath)
}
}
}
// 由于103x版本兼容,检查更新时需要检查商店仓库
Expand All @@ -322,6 +326,9 @@ func CustomSourceWrapper(updateType UpdateType, doRealAction func(path string, u
case 1:
// 如果只有一个仓库,证明是单项的更新,可以直接使用默认的文件夹
if doRealAction != nil {
if IsPrivateLastore {
return doRealAction(sourcePathList[0], nil)
}
return doRealAction(GetCategorySourceMap()[updateType], nil)
}
return errors.New("doRealAction is nil")
Expand Down
4 changes: 3 additions & 1 deletion src/lastore-daemon/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import (
"github.com/linuxdeepin/dde-api/polkit"
utils2 "github.com/linuxdeepin/go-lib/utils"
"github.com/linuxdeepin/lastore-daemon/src/internal/config"
. "github.com/linuxdeepin/lastore-daemon/src/internal/config"
"github.com/linuxdeepin/lastore-daemon/src/internal/system"
"github.com/linuxdeepin/lastore-daemon/src/internal/system/apt"
"github.com/linuxdeepin/lastore-daemon/src/internal/utils"
. "github.com/linuxdeepin/lastore-daemon/src/internal/config"

"github.com/godbus/dbus/v5"
"github.com/linuxdeepin/go-lib/dbusutil"
Expand All @@ -39,6 +39,8 @@ import (

var _urlReg = regexp.MustCompile(`^[ ]*deb .*((?:https?|ftp|file|p2p)://[^ ]+)`)

const lastoreGatherInfo = "lastoreGatherInfo"

// 获取list文件或list.d文件夹中所有list文件的未被屏蔽的仓库地址
func getUpgradeUrls(path string) []string {
var upgradeUrls []string
Expand Down
4 changes: 4 additions & 0 deletions src/lastore-daemon/dbusutil.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion src/lastore-daemon/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"time"

"github.com/linuxdeepin/lastore-daemon/src/internal/system"
"github.com/linuxdeepin/lastore-daemon/src/internal/updateplatform"

"github.com/linuxdeepin/go-lib/dbusutil"
)
Expand All @@ -29,7 +30,8 @@ type Job struct {
CreateTime int64
DownloadSize int64

Type string
Type string
PolicyTyp int

Status system.Status
caller methodCaller
Expand Down Expand Up @@ -119,6 +121,16 @@ func (j *Job) initDownloadSize() {
j.PropsMu.Unlock()
}

func (j *Job) setUpdatePolicy(policyTyp updateplatform.UpdateTp) {
j.PropsMu.Lock()
policy := int(policyTyp)
if j.PolicyTyp != policy {
j.PolicyTyp = policy
_ = j.emitPropChangedUpdatePolicy(policy)
}
j.PropsMu.Unlock()
}

func (j *Job) String() string {
return fmt.Sprintf("Job{Id:%q:%q,Type:%q(%v,%v), %q(%.2f)}@%q",
j.Id, j.Packages,
Expand Down
12 changes: 11 additions & 1 deletion src/lastore-daemon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,18 @@ func main() {
if os.Getenv("DBUS_STARTER_BUS_TYPE") != "" {
_ = os.Setenv("PATH", os.Getenv("PATH")+":/bin:/sbin:/usr/bin:/usr/sbin")
}

config := NewConfig(path.Join(system.VarLibDir, "config.json"))
logger.Info("intranet update:", config.IntranetUpdate)
system.IsPrivateLastore = config.IntranetUpdate
if system.IsPrivateLastore {
go func() {
out, err := exec.Command("/usr/bin/lastore-tools", "gatherinfo", "-type=post").CombinedOutput()
if err != nil {
logger.Warning(string(out))
}
}()
}

aptImpl := dut.NewSystem(config.NonUnknownList, config.OtherSourceList, config.IncrementalUpdate)
system.SetSystemUpdate(config.PlatformUpdate) // 设置是否通过平台更新
allowInstallPackageExecPaths = append(allowInstallPackageExecPaths, config.AllowInstallRemovePkgExecPaths...)
Expand Down
44 changes: 40 additions & 4 deletions src/lastore-daemon/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ type Manager struct {
checkDpkgCapabilityOnce sync.Once
supportDpkgScriptIgnore bool

envIsValid bool
preBackUpCheck bool

logFds []*os.File
logFdsMu sync.Mutex
logTmpFile *os.File
Expand Down Expand Up @@ -140,6 +143,8 @@ func NewManager(service *dbusutil.Service, updateApi system.System, c *config.Co
abObj: abrecovery.NewABRecovery(service.Conn()),
securitySourceConfig: make(UpdateSourceConfig),
systemSourceConfig: make(UpdateSourceConfig),
envIsValid: true,
preBackUpCheck: true,
}
m.reloadOemConfig(true)
m.signalLoop.Start()
Expand All @@ -149,8 +154,9 @@ func NewManager(service *dbusutil.Service, updateApi system.System, c *config.Co
go m.handleOSSignal()
m.updateJobList()
m.initStatusManager()
m.HardwareId = updateplatform.GetHardwareId(m.config.IncludeDiskInfo, m.config.GetHardwareIdByHelper)

go func() {
m.setPropHardwareId(updateplatform.GetHardwareId(m.config.IncludeDiskInfo, m.config.GetHardwareIdByHelper))
}()
m.initDbusSignalListen()
m.initDSettingsChangedHandle()
m.syncThirdPartyDconfig()
Expand All @@ -160,10 +166,18 @@ func NewManager(service *dbusutil.Service, updateApi system.System, c *config.Co
m.rebootTimeoutTimer = time.AfterFunc(600*time.Second, func() {
// 启动后600s如果没有触发检查,那么上报更新失败

msg := "the check has not been triggered after reboot for 600 seconds"
m.updatePlatform.PostStatusMessage(updateplatform.StatusMessage{
Type: "error",
Detail: "the check has not been triggered after reboot for 600 seconds",
Detail: msg,
}, true)
procEvent := updateplatform.ProcessEvent{
TaskID: 1,
EventType: updateplatform.GetUpdateEvent,
EventStatus: false,
EventContent: msg,
}
m.updatePlatform.PostProcessEventMessage(procEvent)

err = m.delRebootCheckOption(all)
if err != nil {
Expand Down Expand Up @@ -249,7 +263,8 @@ func (m *Manager) initAgent() {

func (m *Manager) initPlatformManager() {
m.updatePlatform = updateplatform.NewUpdatePlatformManager(m.config, false)
if isFirstBoot() {
// TODO: 可能缺少 m.loadPlatformCache()
if isFirstBoot() || system.IsPrivateLastore {
// 不能阻塞初始化流程,防止dbus服务激活超时
go m.updatePlatform.RetryPostHistory() // 此处调用还没有export以及dispatch job,因此可以判断是否需要check.
}
Expand Down Expand Up @@ -654,6 +669,23 @@ func (m *Manager) categorySupportAutoInstall(category system.UpdateType) bool {
return autoInstallUpdates && (autoInstallUpdateType&category != 0)
}

// handleAutoCheckRegularlyEvent handles the regular automatic update check event.
// It triggers a partial system upgrade when the system is in CanUpgrade state or
// when local cache exists. The update platform type is set to UpdateRegularly
// to indicate this is a scheduled regular update rather than a user-initiated one.
func (m *Manager) handleAutoCheckRegularlyEvent() error {
if m.statusManager.updateModeStatusObj[system.SystemUpgradeJobType] == system.CanUpgrade ||
utils.IsFileExist(system.LocalCachePath) {
m.updatePlatform.Tp = updateplatform.UpdateRegularly
_, err := m.distUpgradePartly(dbus.Sender(m.service.Conn().Names()[0]), system.SystemUpdate, true)
if err != nil {
logger.Warning(err)
return err
}
}
return nil
}

func (m *Manager) handleAutoCheckEvent() error {
if m.config.AutoCheckUpdates && !m.ImmutableAutoRecovery {
_, err := m.updateSource(dbus.Sender(m.service.Conn().Names()[0]))
Expand Down Expand Up @@ -835,8 +867,12 @@ const (

func (m *Manager) sendNotify(appName string, replacesId uint32, appIcon string, summary string, body string, actions []string, hints map[string]dbus.Variant, expireTimeout int32) uint32 {
if !m.updater.UpdateNotify {
logger.Info("UpdateNotify is false")
return 0
}
if system.IsPrivateLastore {
appIcon = "intranet-update-platform-notification"
}
agent := m.userAgents.getActiveLastoreAgent()
if agent != nil {
id, err := agent.SendNotify(0, appName, replacesId, appIcon, summary, body, actions, hints, expireTimeout)
Expand Down
12 changes: 11 additions & 1 deletion src/lastore-daemon/manager_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,27 @@ func (m *Manager) checkUpgrade(sender dbus.Sender, checkMode system.UpdateType,
},
string(system.FailedStatus): func() error {
m.updatePlatform.PostUpgradeStatus(uuid, updateplatform.UpgradeFailed, job.Description)
// TODO 可能丢失调用 m.updatePlatform.SaveJobPostMsgByUUID(uuid, updateplatform.UpgradeFailed, job.Description)
go func() {
m.inhibitAutoQuitCountAdd()
defer m.inhibitAutoQuitCountSub()

msg := fmt.Sprintf("%v postcheck error: %v", checkOrder.JobType(), job.Description)
m.updatePlatform.PostStatusMessage(updateplatform.StatusMessage{
Type: "error",
UpdateType: checkOrder.JobType(),
JobDescription: job.Description,
Detail: fmt.Sprintf("%v postcheck error: %v", checkOrder.JobType(), job.Description),
Detail: msg,
}, false)

procEvent := updateplatform.ProcessEvent{
TaskID: 1,
EventType: updateplatform.CheckEnv,
EventStatus: false,
EventContent: msg,
}
m.updatePlatform.PostProcessEventMessage(procEvent)
// TODO: 可能丢失调用 m.updatePlatform.PostSystemUpgradeMessage(uuid)
m.reportLog(upgradeStatusReport, false, job.Description)
}()
inhibit(false)
Expand Down
Loading
Loading