Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cherry pick #295 into 0.4 #314

Merged
Merged
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: 4 additions & 5 deletions pkg/pkgmgr/rpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
rpmManifest2 = "container-manifest-2"
rpmManifestWildcard = "container-manifest-*"

installToolsCmd = "yum install busybox -y"
installToolsCmd = "yum install busybox cpio -y"
resultQueryFormat = "%{NAME}\t%{VERSION}-%{RELEASE}\t%{ARCH}\n"
)

Expand Down Expand Up @@ -359,17 +359,16 @@
// - Reports being slightly out of date, where a newer security revision has displaced the one specified leading to not found errors.
// - Reports not specifying version epochs correct (e.g. bsdutils=2.36.1-8+deb11u1 instead of with epoch as 1:2.36.1-8+dev11u1)
// - Reports specifying remediation packages for cbl-mariner v1 instead of v2 (e.g. *.cm1.aarch64 instead of *.cm2.aarch64)
const aptDownloadTemplate = "yum reinstall --downloadonly --downloaddir=. --best -y %s"
const rpmDownloadTemplate = `yum reinstall --downloadonly --downloaddir=. --best -y %s`

Check warning on line 362 in pkg/pkgmgr/rpm.go

View check run for this annotation

Codecov / codecov/patch

pkg/pkgmgr/rpm.go#L362

Added line #L362 was not covered by tests
pkgStrings := []string{}
for _, u := range updates {
pkgStrings = append(pkgStrings, u.Name)
}
downloadCmd := fmt.Sprintf(aptDownloadTemplate, strings.Join(pkgStrings, " "))
downloadCmd := fmt.Sprintf(rpmDownloadTemplate, strings.Join(pkgStrings, " "))

Check warning on line 367 in pkg/pkgmgr/rpm.go

View check run for this annotation

Codecov / codecov/patch

pkg/pkgmgr/rpm.go#L367

Added line #L367 was not covered by tests
downloaded := busyboxCopied.Run(llb.Shlex(downloadCmd), llb.WithProxy(utils.GetProxy())).Root()

// Scripted enumeration and rpm install of all downloaded packages under the download folder as root
// `rpm -i` doesn't support installing to a target directory, so chroot into the download folder to install the packages.
const extractTemplate = `chroot %s ./busybox find . -name '*.rpm' -exec ./busybox rpm -i '{}' \;`
const extractTemplate = `sh -c 'for f in %[1]s/*.rpm ; do rpm2cpio "$f" | cpio -idmv -D %[1]s ; done'`

Check warning on line 371 in pkg/pkgmgr/rpm.go

View check run for this annotation

Codecov / codecov/patch

pkg/pkgmgr/rpm.go#L371

Added line #L371 was not covered by tests
extractCmd := fmt.Sprintf(extractTemplate, downloadPath)
unpacked := downloaded.Run(llb.Shlex(extractCmd)).Root()

Expand Down