Commit 4a6aa872e6055d283e81f4306d8850d9b5b57a16

Implemented 3rd party package policy to no break SSU.

* src/apt-worker-proto.h: Added status_incompatible_thirdparty installable
  package status.
* src/apt-worker.cc (package_policy_status): New function.
  (cmd_get_package_info): Set the installable status given the new function.
  
284284 status_incompatible, // incompatible in general
285285 status_incompatible_current, // incompatible with current OS
286286 status_system_update_unremovable,// could be removed but it's a bad idea
287 status_not_found // there is no such package
287 status_not_found, // there is no such package
288 status_incompatible_thirdparty // package that breaks the SSU policy
288289};
289290
290291enum apt_proto_install_flags {
  
26802680
26812681 return res;
26822682}
2683
2683
26842684static string
26852685get_short_description (int summary_kind,
26862686 pkgCache::PkgIterator &pkg,
30033003 AptWorkerCache *awc = AptWorkerCache::GetCurrent ();
30043004 pkgDepCache &cache = *(awc->cache);
30053005 int installable_status = status_unable;
3006
3006
30073007 for (pkgCache::PkgIterator pkg = cache.PkgBegin();
30083008 pkg.end() != true;
30093009 pkg++)
30333033}
30343034
30353035static int
3036package_policy_status (pkgCache::PkgIterator pkg, bool only_user)
3037{
3038 AptWorkerCache *awc = AptWorkerCache::GetCurrent ();
3039 pkgDepCache &cache = *(awc->cache);
3040 pkgCache::VerIterator candidate = cache[pkg].CandidateVerIter (cache);
3041
3042 if (only_user
3043 && (candidate.end () || !is_user_package (candidate)))
3044 return status_able;
3045
3046 // skip system update meta-packages that are not installed
3047 if (only_user && !candidate.end ())
3048 {
3049 package_record rec (candidate);
3050 int flags = get_flags (rec);
3051 if (flags & pkgflag_system_update)
3052 return status_able;
3053 }
3054
3055 for (pkgCache::DepIterator Dep = candidate.DependsList ();
3056 Dep.end () != true;
3057 Dep++)
3058 {
3059 pkgCache::PkgIterator dpkg = Dep.TargetPkg ();
3060 pkgCache::VerIterator verdpkg = cache[dpkg].CandidateVerIter (cache);
3061
3062 // Check only non-user packages
3063 if (verdpkg.end () || is_user_package (verdpkg))
3064 continue;
3065
3066
3067 int op = Dep->CompareOp & 0x0F;
3068
3069 if (Dep->Type == pkgCache::Dep::Depends)
3070 {
3071 if (op == pkgCache::Dep::NoOp
3072 || op == pkgCache::Dep::GreaterEq
3073 || op == pkgCache::Dep::Greater)
3074 continue;
3075
3076 log_stderr ("%s breaks 3rd party dependencies policy:",
3077 pkg.Name ());
3078 return status_incompatible_thirdparty;
3079 }
3080 else if (Dep->Type == pkgCache::Dep::Conflicts)
3081 {
3082 if (op == pkgCache::Dep::NoOp
3083 || op == pkgCache::Dep::Less
3084 || op == pkgCache::Dep::LessEq
3085 || op == pkgCache::Dep::Equals)
3086 continue;
3087
3088 log_stderr ("%s breaks 3rd party conflicts policy", pkg.Name ());
3089 return status_incompatible_thirdparty;
3090 }
3091 }
3092
3093 return status_able;
3094}
3095
3096static int
30363097removable_status ()
30373098{
30383099 AptWorkerCache *awc = AptWorkerCache::GetCurrent ();
31053105 if (cache[pkg].InstBroken())
31063106 return status_needed;
31073107 }
3108
3108
31093109 return status_unable;
31103110}
31113111
31323132 pkgCache::PkgIterator pkg = cache.FindPkg (package);
31333133
31343134 // simulate install
3135
3135
31363136 mark_named_package_for_install (package);
31373137 if (any_newly_or_related_broken ())
31383138 info.installable_status = installable_status ();
31393139 else
3140 info.installable_status = status_able;
3140 info.installable_status = package_policy_status (pkg, true);
31413141 info.download_size = (int64_t) cache.DebSize ();
31423142 info.install_user_size_delta = (int64_t) cache.UsrSize ();
31433143
31593159 if (!only_installable_info)
31603160 {
31613161 // simulate remove
3162
3162
31633163 if (!strcmp (package, "magic:sys"))
31643164 {
31653165 info.removable_status = status_system_update_unremovable;
31983198 }
31993199 }
32003200 }
3201
3201
32023202 response.encode_mem (&info, sizeof (apt_proto_package_info));
32033203}
32043204