[packagekit] Zypp backend code review

Richard Hughes hughsient at gmail.com
Wed Nov 21 09:15:29 PST 2007

On Tue, 2007-11-20 at 20:32 -0700, Boyd Timothy wrote: 
> Scott and I installed our first package today with the zypp backend!


> :)  Thanks to everyone so far for your help.  One thing that we're not
> quite clear on is which things our backend should be emitting.  Since
> we don't have everything figured out to perform extremely fast, our
> installs for a simple package are taking a long time.  We haven't
> added any sort of downloading or progress messages yet and the client
> (pkcon and pk-install-package) are timing out.

Well, they shouldn't time out. They should just sit there and wait for
the transaction to complete and then exit. Could you attach you complete
daemon log after you've done an install if you think that dbus is timing
out? Usually a client dbus timeout is because the daemon is exiting
before it sends a request back to the client.

> Could someone familiar with writing backends be kind enough to quick
> just glance over our code (backends/zypp/pk-backend-zypp.cpp) and let
> us know whether we're using the pk_backend_* calls properly to let PK
> know about our status?  Oh, and don't laugh too hard at our hacky
> proof-of-concept code!

Well, it looks okay - if you do anything _really_ crazy the daemon
should shout at you and push errors and warnings to stdout. If it
doesn't, it's a bug.

As it's not clear, I'll write some examples here. These are aimed at the
scripted backends, but for the compiled backends status-depsolving
should just be writted "pk_backend_status (backend,
PK_STATUS_ENUM_DEPSOLVING);" - also note the space has to be a tab in
the spawned backends, and any newlines converted to ";" chars.

Transaction that searches with no-percentage feedback, returning two
%status query
%package installed powertop;0.0.1;i386;installed Powertop saves power
%package available powertop-devel;0.0.1;noarch;fedora devel files for

NOTE: If you are using thread_helper or spawn_helper (you should be - we
have to stay async!) don't include finished signal unless you are
exiting with an error.

Transaction that depsolves, then downloads two packages, installing one
and updating a dep
%percentage 0
%status depsolving
%percentage 50
%package downloading powertop-devel;0.0.1;noarch;fedora devel files for
%percentage 75
%package downloading libc-devel;0.1.5;noarch;fedora devel files for libc
%subpercentage 100
%package installing powertop-devel;0.0.1;noarch;fedora devel files for
%package updating libc-devel;0.1.5;noarch;fedora devel files for libc

What you really need to think about in libzypp is how to get percentage
callbacks to packagekit. In the above example there will be just three
updates to the progressbar, and hence you'll not get an accurate "time
until completion" value from the daemon. The yum backend has pretty
small increments of subpercentage and percentage, which means we can get
a fairly accurate remaining time from this data.

Transaction that gets an update list
%status info
%package security libc-devel;0.1.5;noarch;fedora devel files for libc

Transaction that logs and error and then exits
%error oom Cannot allocate memory for thread

Does this help?


More information about the PackageKit mailing list