From e2582dad8c87bbf877fa335c6ee5b2a1623b13e3 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 5a6f3582..de122cb7 100644 --- a/pkg/pkg/rhel.go +++ b/pkg/pkg/rhel.go @@ -47,7 +47,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 881a2af6..f5626787 100644 --- a/pkg/pkg/utils.go +++ b/pkg/pkg/utils.go @@ -35,15 +35,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