From 0a0c4df80e32b877000711dac81d9e3d73a1896a Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Sat, 14 Oct 2023 11:42:11 -0700 Subject: [PATCH] Use yumdownloader --- pkg/pkg/rhel.go | 2 +- pkg/pkg/utils.go | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/pkg/pkg/rhel.go b/pkg/pkg/rhel.go index d9433dde..592bcb98 100644 --- a/pkg/pkg/rhel.go +++ b/pkg/pkg/rhel.go @@ -43,7 +43,7 @@ func (pkg *RHELPackage) Download(ctx context.Context, dir string, force bool) (s return rpmpath, nil } - err := yumDownload(ctx, pkg.Name, dir) + err := yumDownload(ctx, pkg.Name, pkg.Architecture, dir) if err != nil { os.Remove(rpmpath) return "", fmt.Errorf("rpm download: %s", err) diff --git a/pkg/pkg/utils.go b/pkg/pkg/utils.go index 0f3eb566..a3f673d9 100644 --- a/pkg/pkg/utils.go +++ b/pkg/pkg/utils.go @@ -25,15 +25,10 @@ func TarballBTF(ctx context.Context, btf string, out string) error { // RHEL packages // -func yumDownload(ctx context.Context, pkg string, destdir string) error { - +func yumDownload(ctx context.Context, pkg string, arch string, destdir string) error { stderr := &bytes.Buffer{} - - destDirParam := fmt.Sprintf("--downloaddir=%s", destdir) - - binary, args := utils.SudoCMD("yum", "install", "-y", "--downloadonly", destDirParam, pkg) + binary, args := utils.SudoCMD("yumdownloader", "--archlist="+arch, "--destdir="+destdir, pkg) cmd := exec.CommandContext(ctx, binary, args...) - cmd.Stdout = os.Stdout cmd.Stderr = stderr