'dpkg-query --showformat' equivalent for snap

Bug #1773842 reported by Eric Desrochers
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
snapd
Confirmed
Undecided
Unassigned
snapd (Ubuntu)
Confirmed
Wishlist
Unassigned

Bug Description

[WHISHLIST]

While investigating how we can integrate snap detection in sosreport as a packagemanager just like 'rpm' and 'deb' package does when using "packages = (<PKG_NAME>,) to detect the presence of the package (if installed) in a sosreport plugin.

I notice there is no easy way to query all installed snaps and have it into a 'dpkg-query' output equivalent, unless doing a 'snap list' along with some 'awk', 'grep', 'sed' and family.

That would be helpful to be able to have a 'dpkg-query --showformat' equivalent for snap if possible.

# man dpkg-query
......
     -f, --showformat=format
              This option is used to specify the format of the output --show will produce. The format is a string that will be output for each package listed.

              In the format string, “\” introduces escapes:

                  \n newline
                  \r carriage return
                  \t tab
......

According to sosreport official documentation :
https://github.com/sosreport/sos/wiki/How-to-Write-a-Policy

The expected output from sosreport packagemanager is :
package name|major.minor.bugfix version\n....

The output was based on what the following command offers and still in use as of today in sosreport :
# dpkg-query -W -f='${Package}|${Version}\\n' # debian
# rpm -qa --queryformat "%{NAME}|%{VERSION}|%{RELEASE}\\n"

Revision history for this message
Eric Desrochers (slashd) wrote :

I talked to mvo about that this morning, and he said, he might be able to work on this on his spare time as it look trivial to add this feature according to him.

Changed in snapd (Ubuntu):
importance: Undecided → Wishlist
description: updated
Eric Desrochers (slashd)
Changed in snapd (Ubuntu):
assignee: nobody → Michael Vogt (mvo)
Revision history for this message
Michael Vogt (mvo) wrote :
Changed in snapd (Ubuntu):
status: New → In Progress
Revision history for this message
Michael Vogt (mvo) wrote :

I discussed this with Gustavo on the standup today. It seems like he prefers to not add a new feature but just use "snap list | awk '{print $1"|"$2}'|tail +2". Would that work for you? Or do you needs bits that are not visible via "snap list"?

Revision history for this message
Eric Desrochers (slashd) wrote :

As long as "snap list" output remain the same and have no intention to change the output in the future, I guess it should be fine, I've been testing "sosreport" expected output with a similar command.

The intent of this bug was to have a more fancy way to do it, but again I'm fine with manipulating "snap list" with awk, tail and family, if this wishlist is not in the snap scope.

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

The referenced pull request was closed without being merged into snapd. I'm not sure that there's anyone working on resurrecting it so I'm marking this as confirmed. Mvo, please feel free to remove yourself from the assignee field if you don't plan on working on implementing this.

Changed in snapd:
status: New → Confirmed
Changed in snapd (Ubuntu):
status: In Progress → Confirmed
Michael Vogt (mvo)
Changed in snapd (Ubuntu):
assignee: Michael Vogt (mvo) → nobody
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.