Original code from PackageKit