fix(scanner/redhat): make cache before detect dnf modules (#1812)

Co-authored-by: wadahiroka <wadahiroka@192.168.0.4>
This commit is contained in:
hiroka-wada
2023-12-15 16:16:13 +09:00
committed by GitHub
parent d1224991a0
commit b2c91175b3

View File

@@ -420,6 +420,10 @@ func (o *redhatBase) scanPackages() (err error) {
return xerrors.Errorf("Failed to scan installed packages: %w", err)
}
if err := o.yumMakeCache(); err != nil {
return xerrors.Errorf("Failed to execute `yum makecache`: %w", err)
}
if o.EnabledDnfModules, err = o.detectEnabledDnfModules(); err != nil {
return xerrors.Errorf("Failed to detect installed dnf modules: %w", err)
}
@@ -645,10 +649,6 @@ func (o *redhatBase) yumMakeCache() error {
}
func (o *redhatBase) scanUpdatablePackages() (models.Packages, error) {
if err := o.yumMakeCache(); err != nil {
return nil, xerrors.Errorf("Failed to `yum makecache`: %w", err)
}
isDnf := o.exec(util.PrependProxyEnv(`repoquery --version | grep dnf`), o.sudo.repoquery()).isSuccess()
cmd := `repoquery --all --pkgnarrow=updates --qf='%{NAME} %{EPOCH} %{VERSION} %{RELEASE} %{REPO}'`
if isDnf {