Dne 31. 08. 20 v 16:41 Srinidhi B napsal(a):
This is fantastic! Thank you for implementing these!
Welcome!
I really like the yast2-pkg-bindings API implementation and I've dabbled a little bit with it over the years. Would it work in a non-YaST script? If this is not supported or not recommended, then I'll continue to parse the output of "zypper -q --xml ...". :-(
It depends what a "non-YaST script" actually means. If that means a script which does not use UI, is not integrated to YaST control center, etc... then yes, you can use it that way. Actually we already do that at some places, for example this script [1] runs several Pkg calls and serves as a simple unit/integration test in Travis CI. Another example [2] regularly checks whether the packages used/configured by the yast2-http-server package are still present in the distro. So yes, that works pretty well. But if that means running your script without YaST (just with yast2-pkg-bindings and libzypp) then the answer is "no". The yast2-pkg-bindings only provide an API for the old YCP component system, if you want to use it from a Ruby script you need at least the yast2-core and yast2-ruby-bindings packages (and their dependencies). But there is an alternative way, instead of the libzypp bindings you can use the libsolv bindings. Obviously it provides only a subset of the libzypp functionality but maybe it could be enough for your use case. We use it for scanning the available products on the FULL SLE15-SP2 installation medium and their dependencies. We do not use libzypp for that because it is too slow, it has quite big overhead with doing GPG signature checks, building repository caches, etc... for repositories which will not be used in the end (you can choose only one base product to install). See [3] and [4] how we do that. (Of course, after the user selects the base product to install we do the full work via libzypp, ie. check the GPGs, build the cache... so there is no problem with that "out-of-libzypp" step.) The advantage is then you do not rely on YaST at all and you can write a real standalone script. Just a note at the end: libsolv is a plain C library and its Ruby bindings do not hide that fact much. If you look at some examples [5] sometimes it feels like a C code written in Ruby... HTH, Ladislav [1] https://github.com/yast/yast-pkg-bindings/blob/master/smoke_test_run.rb [2] https://github.com/yast/yast-http-server/blob/master/travis_package_check.rb [3] https://github.com/yast/yast-packager/blob/master/src/lib/y2packager/solvabl... [4] https://github.com/yast/yast-packager/blob/master/src/lib/y2packager/product... [5] https://github.com/openSUSE/libsolv/blob/master/examples/rbsolv -- Ladislav Slezák YaST Developer SUSE LINUX, s.r.o. Corso IIa Křižíkova 148/34 18600 Praha 8 -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org