@@ -35,7 +35,7 @@ const (
35
35
rpmManifest2 = "container-manifest-2"
36
36
rpmManifestWildcard = "container-manifest-*"
37
37
38
- installToolsCmd = "yum install busybox -y"
38
+ installToolsCmd = "yum install busybox cpio -y"
39
39
resultQueryFormat = "%{NAME}\t %{VERSION}-%{RELEASE}\t %{ARCH}\n "
40
40
)
41
41
@@ -359,17 +359,16 @@ func (rm *rpmManager) unpackAndMergeUpdates(ctx context.Context, updates types.U
359
359
// - Reports being slightly out of date, where a newer security revision has displaced the one specified leading to not found errors.
360
360
// - 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)
361
361
// - Reports specifying remediation packages for cbl-mariner v1 instead of v2 (e.g. *.cm1.aarch64 instead of *.cm2.aarch64)
362
- const aptDownloadTemplate = " yum reinstall --downloadonly --downloaddir=. --best -y %s"
362
+ const rpmDownloadTemplate = ` yum reinstall --downloadonly --downloaddir=. --best -y %s`
363
363
pkgStrings := []string {}
364
364
for _ , u := range updates {
365
365
pkgStrings = append (pkgStrings , u .Name )
366
366
}
367
- downloadCmd := fmt .Sprintf (aptDownloadTemplate , strings .Join (pkgStrings , " " ))
367
+ downloadCmd := fmt .Sprintf (rpmDownloadTemplate , strings .Join (pkgStrings , " " ))
368
368
downloaded := busyboxCopied .Run (llb .Shlex (downloadCmd ), llb .WithProxy (utils .GetProxy ())).Root ()
369
369
370
370
// Scripted enumeration and rpm install of all downloaded packages under the download folder as root
371
- // `rpm -i` doesn't support installing to a target directory, so chroot into the download folder to install the packages.
372
- const extractTemplate = `chroot %s ./busybox find . -name '*.rpm' -exec ./busybox rpm -i '{}' \;`
371
+ const extractTemplate = `sh -c 'for f in %[1]s/*.rpm ; do rpm2cpio "$f" | cpio -idmv -D %[1]s ; done'`
373
372
extractCmd := fmt .Sprintf (extractTemplate , downloadPath )
374
373
unpacked := downloaded .Run (llb .Shlex (extractCmd )).Root ()
375
374
0 commit comments