diff --git a/pkg/assessor/manifest/manifest.go b/pkg/assessor/manifest/manifest.go index 4013735..834d316 100644 --- a/pkg/assessor/manifest/manifest.go +++ b/pkg/assessor/manifest/manifest.go @@ -354,7 +354,7 @@ func reducableAptGetInstall(cmdSlices map[int][]string) bool { useAptLibrary = true } // remove cache must be run after apt library directory changed - if useAptLibrary && containsThreshold(cmdSlice, removeAptLibCmds, 3) { + if useAptLibrary && (containsThreshold(cmdSlice, removeAptLibCmds, 3) || checkAptCommand(cmdSlice, "dist-clean") || checkAptCommand(cmdSlice, "distclean")) { return false } } diff --git a/pkg/assessor/manifest/manifest_test.go b/pkg/assessor/manifest/manifest_test.go index a30f626..a5c0694 100644 --- a/pkg/assessor/manifest/manifest_test.go +++ b/pkg/assessor/manifest/manifest_test.go @@ -392,6 +392,39 @@ func TestReducableAptGetInstall(t *testing.T) { }, expected: false, }, + "UnReducableDistClean": { + cmdSlices: map[int][]string{ + 0: { + "apt-get", "install", "-y", "git", + }, + 1: { + "apt-get", "dist-clean", + }, + }, + expected: false, + }, + "UnReducableDistclean": { + cmdSlices: map[int][]string{ + 0: { + "apt-get", "install", "-y", "git", + }, + 1: { + "apt", "distclean", + }, + }, + expected: false, + }, + "UnReducableDistCleanWithOptions": { + cmdSlices: map[int][]string{ + 0: { + "apt-get", "install", "-y", "git", + }, + 1: { + "apt-get", "-q", "-y", "dist-clean", + }, + }, + expected: false, + }, } for testname, v := range tests { actual := reducableAptGetInstall(v.cmdSlices)