Skip to content

Commit 28e8dfe

Browse files
xmlqiuzhiqian
authored andcommitted
fix: Add source list parameter for upgrade check
Bug: https://pms.uniontech.com/bug-view-342367.html
1 parent c4d607a commit 28e8dfe

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/internal/system/apt/apt.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,11 @@ func DownloadPackages(packages []string, environ map[string]string, options map[
294294
}
295295

296296
// In incremental update mode, returns true if all packages are cached, otherwise returns false.
297-
func IsIncrementalUpdateCached() bool {
297+
func IsIncrementalUpdateCached(sourceArgs string) bool {
298298
cmd := exec.Command("/usr/sbin/deepin-immutable-ctl", "upgrade", "check")
299+
if sourceArgs != "" {
300+
cmd.Env = append(os.Environ(), "DEEPIN_IMMUTABLE_UPGRADE_APT_OPTION="+sourceArgs)
301+
}
299302
// Need download count: xxx
300303
output, err := cmd.Output()
301304
if err == nil {

src/lastore-daemon/manager_ifc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func (m *Manager) PackagesDownloadSize(packages []string) (int64, *dbus.Error) {
214214
logger.Warningf("PackagesDownloadSize(%q)=%0.2f %v\n", strings.Join(packages, " "), size, err)
215215
}
216216

217-
if m.config.IncrementalUpdate && size > 0 && apt.IsIncrementalUpdateCached() {
217+
if m.config.IncrementalUpdate && size > 0 && apt.IsIncrementalUpdateCached("") {
218218
size = 0.0
219219
}
220220

src/lastore-daemon/update_status.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strings"
1010
"sync"
1111

12+
"github.com/linuxdeepin/go-lib/utils"
1213
"github.com/linuxdeepin/lastore-daemon/src/internal/config"
1314
"github.com/linuxdeepin/lastore-daemon/src/internal/system"
1415
"github.com/linuxdeepin/lastore-daemon/src/internal/system/apt"
@@ -431,7 +432,16 @@ func (m *UpdateModeStatusManager) updateModeStatusBySize(mode system.UpdateType,
431432
changed = true
432433
}
433434
} else {
434-
if m.lsConfig.IncrementalUpdate && needDownloadSize > 0 && apt.IsIncrementalUpdateCached() {
435+
sourceList, ok := system.GetCategorySourceMap()[typ]
436+
sourceArgs := ""
437+
if ok && sourceList != "" {
438+
if utils.IsDir(sourceList) {
439+
sourceArgs = "-o Dir::Etc::sourcelist=/dev/null -o Dir::Etc::SourceParts=" + sourceList
440+
} else {
441+
sourceArgs = "-o Dir::Etc::sourcelist=" + sourceList + " -o Dir::Etc::SourceParts=/dev/null"
442+
}
443+
}
444+
if m.lsConfig.IncrementalUpdate && needDownloadSize > 0 && apt.IsIncrementalUpdateCached(sourceArgs) {
435445
needDownloadSize = 0.0
436446
}
437447

0 commit comments

Comments
 (0)