|
@@ -26,7 +26,8 @@ NOTES:
|
|
|
|
|
|
|
|
type CheckResult struct {
|
|
type CheckResult struct {
|
|
|
Lines int // Number of lines read.
|
|
Lines int // Number of lines read.
|
|
|
- UpToDate bool // All packages are up to date.
|
|
|
|
|
|
|
+ Upgradable bool // 'apt list --upgradable'
|
|
|
|
|
+ // UpToDate bool // All packages are up to date.
|
|
|
AutoRemove bool // Use 'apt autoremove' to remove it.
|
|
AutoRemove bool // Use 'apt autoremove' to remove it.
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -40,11 +41,17 @@ func check_lines(r io.Reader, output chan CheckResult) {
|
|
|
for scanner.Scan() {
|
|
for scanner.Scan() {
|
|
|
line = scanner.Text()
|
|
line = scanner.Text()
|
|
|
|
|
|
|
|
- if line == "All packages are up to date." {
|
|
|
|
|
- result.UpToDate = true
|
|
|
|
|
|
|
+ /*
|
|
|
|
|
+ if line == "All packages are up to date." {
|
|
|
|
|
+ result.UpToDate = true
|
|
|
|
|
+ }
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ if strings.Contains(line, "apt list --upgradable") {
|
|
|
|
|
+ result.Upgradable = true
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if line == "Use 'apt autoremove' to remove it." {
|
|
|
|
|
|
|
+ if line == "Use 'apt autoremove' to remove it." || line == "Use 'sudo apt autoremove' to remove it" {
|
|
|
result.AutoRemove = true
|
|
result.AutoRemove = true
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -162,7 +169,7 @@ func main() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Is everything up to date?
|
|
// Is everything up to date?
|
|
|
- if !result.UpToDate {
|
|
|
|
|
|
|
+ if result.Upgradable {
|
|
|
// Perform upgrade.
|
|
// Perform upgrade.
|
|
|
result, err = run_check_command([]string{APT, "upgrade", "-y"}, output)
|
|
result, err = run_check_command([]string{APT, "upgrade", "-y"}, output)
|
|
|
if err != nil {
|
|
if err != nil {
|