Skip to content

Commit cfe8e62

Browse files
authored
Merge pull request #17271 from rifelpet/dpkg-query
Split dpkg-query fields with a tab
2 parents 12931dd + 24fb33d commit cfe8e62

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Diff for: upup/pkg/fi/nodeup/nodetasks/package.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func (e *Package) Find(c *fi.NodeupContext) (*Package, error) {
145145
}
146146

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

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

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

176176
switch state {
177177
case "ii":

0 commit comments

Comments
 (0)