Open moberer opened 2 years ago
Hi @mlandres,
I'm starting out and I'd be happy to add this feature if it gets accepted.
Hi @0tanay, feel free to go ahead.
The xmlout.rnc can be modified to take an optional autoinstalled="true"
attribute.
attribute status { "installed" | "other-version" | "not-installed" },
+ attribute autoinstalled { xsd:boolean }?,
But beware that the information is not present, at least not reliably. The code unfortunately renders the not-XML table output as XML. In this case the Locked(il)
, Ptf(iP)
or Retracted(iR)
information supersedes the autoinstalled
info. In these cases you can not tell from the table's status whether it is autoinstalled or not.
Hey Michael,
I tried the method that @moberer suggested and it works - although only for search.
For info, the output by default looks something like this:
# zypper -x info zsh
<?xml version='1.0'?>
<stream>
<message type="info">Loading repository data...</message>
<message type="info">Reading installed packages...</message>
<message type="info">Repository : openSUSE-Tumbleweed-Oss
Name : zsh
Version : 5.9-6.3
Arch : x86_64
Vendor : openSUSE
Installed Size : 9.6 MiB
Installed : No
Status : not installed
Source package : zsh-5.9-6.3.src
Upstream URL : https://www.zsh.org
Summary : Shell with comprehensive completion
Description :
Zsh is a UNIX command interpreter (shell) that resembles the Korn shell
(ksh). It is not completely compatible. It includes many enhancements,
notably in the command-line editor, options for customizing its
behavior, file name globbing, features to make C-shell (csh) users feel
at home, and extra features drawn from tcsh (another `custom' shell).
Zsh is well known for its command line completion.
</message>
</stream>
Is this behavior correct? Should this output rather be broken down into tags (like <name>zsh</name>
)?
I can submit a fix just for search, or I can try to also fix info. What would you prefer?
(Sorry for the delay.) Frankly, we don't want to invest into the xml output. Many commands provide this poor-man's xml by simply wrapping the output into xml data. It was enhanced only on demand for specific (business) cases. But we don't think that further investment into this format pays.
The point is that XML is not the best machine readable output format. And our hardcoded data sets are not suitable for every client. We are working on a dedicated query command where the client is able to define the data to query as well as the format to render them. It will be similar to rpm's --queryformat option. With this one should be able to generate the most suitable format for a specific task.
'%{NAME}\n'
'name: "%{NAME}"\n'
'<name>%{NAME}<\\name>\n'
Zypper has the ability to differentiate between manually installed ("i+") and automatically installed ("i") packages. This information is e.g. shown when calling
zypper search -i
.However, when XML-output is enabled (e.g. with
zypper -x search -i
), this differentiation is not made. Both packages of status "i+" and "i" are only shown with the attribute status="installed", with no way to further differentiate.For the sake of consistency and to be able to better automate zypper, this information should be included in the XML output.
As far as I can tell, all the information required would be present where the XML-output is generated: https://github.com/openSUSE/zypper/blob/03fac32eddecb36a77e039933740726a4f3d44d2/src/output/OutXML.cc#L190