
Dne 05. 06. 22 v 10:01 Srinidhi B napsal(a): [...]
I need to implement a wrapper library over libzypp to fetch some simple software management information from the system like: * list of available updates - recommended - security * when was the last update installed (if possible) * is the system registered?
SUSE registration is handled completely outside of libzypp, it does not know whether the system is registered or not. That's handled at a different level. In case of YaST/SUSEConnect it is just a trivial file check for the presence of the /etc/zypp/credentials.d/SCCcredentials file: https://github.com/yast/yast-registration/blob/033c88c33009d34c986501609d109...
* apply available updates (optional/future)
But I'm not able to get started with a basic library. I've tried to go through the existing implementations. Most of the implementations start with calling `getZypp()` to acquire the lock. I'm not able to figure out what should be the next step.
Is there any guide, blog post, document, or (newer) example that would help me understand the process?
This is the minimal YaST code for initializing the libzypp: https://github.com/yast/yast-pkg-bindings/wiki/Code-Snippets#initialization The most important are the last 4 calls, at the beginning there is just some UI initialization code. Check the implementation of these calls.
Should I be using libzypp directly or should I use PackageKit? I'm more comfortable writing in C rather than C++.
It depends. PackageKit has some advantages and disadvantages. Pros: - High level API, no need to learn low-level implementation details - DBUs access, you can implement a client in any language which has DBus bindings, that practically means any language. Here is a Javascript (Cockpit plugin) example for reading the configured repositories: https://github.com/lslezak/cockpit-plugins/blob/master/repositories-packagek... - Can work with other backends (apt,...) so it is easy to support other distributions like Ubuntu or Debian - Possible non-root access, you can install package updates as a regular user Cons: - The high level API might not allow you to set all options or provide all low-level details (for repositories you cannot get the autorefresh status, you cannot set the target root so you cannot manage a system in chroot) - Additional dependencies (DBus, PackageKit libzypp backend) So it highly depends on your requirements and needs... -- Ladislav Slezák YaST Developer SUSE LINUX, s.r.o. Corso IIa Křižíkova 148/34 18600 Praha 8