PackageKit aptcc backend refactored

Last week was a busy week, it’s funny how I mostly work under release pressure😛

Well PackageKit 0.7.4 was to be released last Monday, so I decided to fix a few things I had planned, it all started to make aptcc emit the untrusted packages an installation is about to install, a thing I myself added to PackageKit but I’ve never managed to implement in my backend…

Currently if you use Apper or Gnome PackageKit, you choose a few packages to install/upgrade, and click “Apply” then what happens under the hood is:

  • First the simulateInstall() method is called to show you what is going to happen (packages to install, remove, update, downgrade)
  • You check the list, if you are ok you click continue.
  • Now installPackages(bool trusted = true) is called, This makes the PolicyKit auth prompts to install TRUSTED packages, and then PackageKit passes the packages to the backend
  • If the backend now detects any untrusted packages it fails with an error PACKAGE_UNTRUSTED_REQUIRED
  • The GUI has now to warn the user about untrusted packages being installed, but it don’t give any clue of which packages are actually untrusted…
  • The user accepts the untrusted dialog and a new PolicyKit auth prompts him to install UNTRUSTED packages. (note that this is the second dialog).
  • last installPackages is called on the backend with bool trusted = false, and the backend ignores the trusted check.

As you can see we have two issues, first two auth prompts, second you can’t know which package is causing the untrusted issue.

Some time ago I half fixed the issue by adding a new enum to enable backends to emit untrusted packages on simulate, this way the GUI could know before hand which packages are untrusted and that installPackages() must be called with UNTRUSTED = false. This way we show the user which packages are untrusted and prevent the first useless dialog.

With the new PackageKit release I fixed the other hald by implementing this support on aptcc, but as you guessed from the post title I didn’t stopped there😛

It turns out that I wrote aptcc back in 2008~2009 at that time I didn’t know anything about apt-pkg API, and of course didn’t had the experience with C++ I have now (not that is that much), so looking at the code I started to see a bunch of things that could be improved, and by improving I started to break a few things but fixing would end up rewriting a bunch of parts, the final result is probably a code much cleaner probably faster (since I found out I didn’t had to store a pair<pkgname, pkgversion>) but most importantly I fixed several potential bugs, and apt pinning using pin.d dirs now works exactly like apt-get.

Almost forgot, aptcc now has Support Filter (thanks to Matthias Klumpp), SimulateRepairSystem() and RepairSystem() support, which means no more apt-get -f install😀  , making it back again the fastest and most complete apt backend.

Take a look at the huge commit list:

– aptcc: Add a new class to show cache opening progress (Daniel Nicoletti)
– aptcc: Add AptCacheFile to handle all pkg cache openings (Daniel Nicoletti)
– aptcc: Add SimulateRepairSystem and RepairSystem methods (Daniel Nicoletti)
– aptcc: Avoid crashing when error messages containing invalid utf8 is sent (Daniel Nicoletti)
– aptcc: Change the way we mark auto-installed packages (Daniel Nicoletti)
– aptcc: Correctly emit if a repo is enabled (Matthias Klumpp)
– aptcc: Create a PkgList class to provide convience methods (Daniel Nicoletti)
– aptcc: Don’t emit error if repo is empty (Matthias Klumpp)
– aptcc: Don’t emit untrusted packages when we are not simulating (Daniel Nicoletti)
– aptcc: Emit newly-installed local package information (Matthias Klumpp)
– aptcc: Emit packages that are untrusted with the PK_INFO_ENUM_UNTRUSTED enum (Daniel Nicoletti)
– aptcc: Emit UnfinishedTransaction when we were not able to fix the cache (Daniel Nicoletti)
– aptcc: Fix a multiarch bug that failed to resolve packages (Daniel Nicoletti)
– aptcc: Fix crash when a package for an invalid version (Daniel Nicoletti)
– aptcc: Fix INSTALLED filter (Daniel Nicoletti)
– aptcc: Fix resolving of gdebi packages when they have :arch field (Daniel Nicoletti)
– aptcc: Fix SUPPORTED check and component-finding code (Matthias Klumpp)
– aptcc: Implement basic support for InstallFiles() (Matthias Klumpp)
– aptcc: Implement SUPPORTED support (Matthias Klumpp)
– aptcc: Improve classes readability, and fix a crash caused by an invalid package (Daniel Nicoletti)
– aptcc: Improve the autoremove code (Daniel Nicoletti)
– aptcc: Make sure BuildPolicy is called when getting the dep cache (Daniel Nicoletti)
– aptcc: Make sure we discard errors when closing the cache (Daniel Nicoletti)
– aptcc: Mark dependencies of a file-installation as automatic (Matthias Klumpp)
– aptcc: Move cache related functions to pkgCacheFile subclass (Daniel Nicoletti)
– aptcc: Move ShowBroken to AptCacheFile, and added CheckDeps from apt-get (Daniel Nicoletti)
– aptcc: Refactored to use AptCacheFile (Daniel Nicoletti)
– aptcc: Reident the code and re-enforce KDElibs coding style (Daniel Nicoletti)
– aptcc: Remove a code duplication and emit proper RestartRequired signal (Daniel Nicoletti)
– aptcc: Reorganise parts of AptCC to make the code more readable (Matthias Klumpp)
– aptcc: Separate the try install/remove functions (Daniel Nicoletti)
– aptcc: Simplify code for checking trusted packages (Matthias Klumpp)
– aptcc: Some more stuff required for installFiles() (Matthias Klumpp)
– aptcc: Update license headers & fix some more indentation and typos (Matthias Klumpp)
– aptcc: use const_iterators to avoid mistakes (Daniel Nicoletti)
– aptcc: Use _exit() to quit the child process as synaptic does (Daniel Nicoletti)
– aptcc: We are not apt-get so remove “APT::Get::*” confs (Daniel Nicoletti)
– aptcc: When on multiarch some packages that should have the :arch
– Add full integration so that UI can know when to repair the system (Daniel Nicoletti)

Stay tunned for the next Apper release😀

PackageKit aptcc backend refactored

One thought on “PackageKit aptcc backend refactored

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s