Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 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
10 changes: 5 additions & 5 deletions pkg/pkgmgr/apk.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,15 @@

apkUpdated := imageStateCurrent.Run(llb.Shlex("apk update"), llb.WithProxy(utils.GetProxy()), llb.IgnoreCache).Root()

// If updating all packages, check for upgrades before proceeding with patch
if updates == nil {
checkUpgradable := `sh -c "apk list 2>/dev/null | grep -q "upgradable" || exit 1"`
apkUpdated = apkUpdated.Run(llb.Shlex(checkUpgradable)).Root()
checkUpgradable := `sh -c "apk list 2>/dev/null | grep -q "upgradable" > /upgradable.txt || exit 1"`
apkUpdated = apkUpdated.Run(llb.Shlex(checkUpgradable)).Root()
_, err := buildkit.ExtractFileFromState(ctx, am.config.Client, &apkUpdated, "/upgradable.txt")
if err != nil {
return nil, nil, fmt.Errorf("no patchable packages found")

Check warning on line 172 in pkg/pkgmgr/apk.go

View check run for this annotation

Codecov / codecov/patch

pkg/pkgmgr/apk.go#L172

Added line #L172 was not covered by tests
}

var apkInstalled llb.State
var resultManifestBytes []byte
var err error
if updates != nil {
// Add all requested update packages
// This works around cases where some packages (for example, tiff) require other packages in it's dependency tree to be updated
Expand Down
6 changes: 5 additions & 1 deletion pkg/pkgmgr/dpkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,12 @@
llb.IgnoreCache,
).Root()

checkUpgradable := `sh -c "apt-get -s upgrade 2>/dev/null | grep -q "^Inst" || exit 1"`
checkUpgradable := `sh -c "apt-get -s upgrade 2>/dev/null | grep -q "^Inst" > /upgradable.txt || exit 1"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do the same thing in the case of distroless images (unpackAndMergeUpdates func)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and then same thing for rpm distroless just to keep the errors consistent

aptGetUpdated = aptGetUpdated.Run(llb.Shlex(checkUpgradable)).Root()
_, err := buildkit.ExtractFileFromState(ctx, dm.config.Client, &aptGetUpdated, "/upgradable.txt")
if err != nil {
return nil, nil, fmt.Errorf("no patchable packages found")
}

Check warning on line 352 in pkg/pkgmgr/dpkg.go

View check run for this annotation

Codecov / codecov/patch

pkg/pkgmgr/dpkg.go#L351-L352

Added lines #L351 - L352 were not covered by tests

// detect held packages and log them
checkHeldCmd := `sh -c "apt-mark showhold | tee /held.txt"`
Expand Down
Loading