fix(scan): parse error on SUSE #515 (#786)

This commit is contained in:
Kota Kanbe
2019-03-12 17:36:27 +09:00
committed by GitHub
parent 5c6e06b05e
commit 53dd90302e
2 changed files with 13 additions and 6 deletions

View File

@@ -184,16 +184,16 @@ func (o *suse) parseZypperLULines(stdout string) (models.Packages, error) {
}
func (o *suse) parseZypperLUOneLine(line string) (*models.Package, error) {
fs := strings.Fields(line)
if len(fs) != 11 {
ss := strings.Split(line, "|")
if len(ss) != 6 {
return nil, fmt.Errorf("zypper -q lu Unknown format: %s", line)
}
available := strings.Split(fs[8], "-")
available := strings.Split(strings.TrimSpace(ss[4]), "-")
return &models.Package{
Name: fs[4],
Name: strings.TrimSpace(ss[2]),
NewVersion: available[0],
NewRelease: available[1],
Arch: fs[10],
Arch: strings.TrimSpace(ss[5]),
}, nil
}