Skip to content

Commit

Permalink
Merge pull request #17271 from rifelpet/dpkg-query
Browse files Browse the repository at this point in the history
Split dpkg-query fields with a tab
  • Loading branch information
k8s-ci-robot authored Feb 20, 2025
2 parents 12931dd + 24fb33d commit cfe8e62
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions upup/pkg/fi/nodeup/nodetasks/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (e *Package) Find(c *fi.NodeupContext) (*Package, error) {
}

func (e *Package) findDpkg(c *fi.NodeupContext) (*Package, error) {
args := []string{"dpkg-query", "-f", "${db:Status-Abbrev}${Version}\\n", "-W", e.Name}
args := []string{"dpkg-query", "-f", "${db:Status-Abbrev}\\t${Version}\\n", "-W", e.Name}
human := strings.Join(args, " ")

klog.V(2).Infof("Listing installed packages: %s", human)
Expand All @@ -166,12 +166,12 @@ func (e *Package) findDpkg(c *fi.NodeupContext) (*Package, error) {
continue
}

tokens := strings.Split(line, " ")
tokens := strings.Split(line, "\t")
if len(tokens) != 2 {
return nil, fmt.Errorf("error parsing dpkg-query line %q", line)
}
state := tokens[0]
version := tokens[1]
state := strings.TrimSpace(tokens[0])
version := strings.TrimSpace(tokens[1])

switch state {
case "ii":
Expand Down

0 comments on commit cfe8e62

Please sign in to comment.