Commit 4a6aa872e6055d283e81f4306d8850d9b5b57a16
- Diff rendering mode:
- inline
- side by side
src/apt-worker-proto.h
(2 / 1)
|   | |||
| 284 | 284 | status_incompatible, // incompatible in general | |
| 285 | 285 | status_incompatible_current, // incompatible with current OS | |
| 286 | 286 | 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 | ||
| 288 | 289 | }; | |
| 289 | 290 | ||
| 290 | 291 | enum apt_proto_install_flags { |
src/apt-worker.cc
(68 / 7)
|   | |||
| 2680 | 2680 | ||
| 2681 | 2681 | return res; | |
| 2682 | 2682 | } | |
| 2683 | |||
| 2683 | |||
| 2684 | 2684 | static string | |
| 2685 | 2685 | get_short_description (int summary_kind, | |
| 2686 | 2686 | pkgCache::PkgIterator &pkg, | |
| … | … | ||
| 3003 | 3003 | AptWorkerCache *awc = AptWorkerCache::GetCurrent (); | |
| 3004 | 3004 | pkgDepCache &cache = *(awc->cache); | |
| 3005 | 3005 | int installable_status = status_unable; | |
| 3006 | |||
| 3006 | |||
| 3007 | 3007 | for (pkgCache::PkgIterator pkg = cache.PkgBegin(); | |
| 3008 | 3008 | pkg.end() != true; | |
| 3009 | 3009 | pkg++) | |
| … | … | ||
| 3033 | 3033 | } | |
| 3034 | 3034 | ||
| 3035 | 3035 | static int | |
| 3036 | package_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 | |||
| 3096 | static int | ||
| 3036 | 3097 | removable_status () | |
| 3037 | 3098 | { | |
| 3038 | 3099 | AptWorkerCache *awc = AptWorkerCache::GetCurrent (); | |
| … | … | ||
| 3105 | 3105 | if (cache[pkg].InstBroken()) | |
| 3106 | 3106 | return status_needed; | |
| 3107 | 3107 | } | |
| 3108 | |||
| 3108 | |||
| 3109 | 3109 | return status_unable; | |
| 3110 | 3110 | } | |
| 3111 | 3111 | ||
| … | … | ||
| 3132 | 3132 | pkgCache::PkgIterator pkg = cache.FindPkg (package); | |
| 3133 | 3133 | ||
| 3134 | 3134 | // simulate install | |
| 3135 | |||
| 3135 | |||
| 3136 | 3136 | mark_named_package_for_install (package); | |
| 3137 | 3137 | if (any_newly_or_related_broken ()) | |
| 3138 | 3138 | info.installable_status = installable_status (); | |
| 3139 | 3139 | else | |
| 3140 | info.installable_status = status_able; | ||
| 3140 | info.installable_status = package_policy_status (pkg, true); | ||
| 3141 | 3141 | info.download_size = (int64_t) cache.DebSize (); | |
| 3142 | 3142 | info.install_user_size_delta = (int64_t) cache.UsrSize (); | |
| 3143 | 3143 | ||
| … | … | ||
| 3159 | 3159 | if (!only_installable_info) | |
| 3160 | 3160 | { | |
| 3161 | 3161 | // simulate remove | |
| 3162 | |||
| 3162 | |||
| 3163 | 3163 | if (!strcmp (package, "magic:sys")) | |
| 3164 | 3164 | { | |
| 3165 | 3165 | info.removable_status = status_system_update_unremovable; | |
| … | … | ||
| 3198 | 3198 | } | |
| 3199 | 3199 | } | |
| 3200 | 3200 | } | |
| 3201 | |||
| 3201 | |||
| 3202 | 3202 | response.encode_mem (&info, sizeof (apt_proto_package_info)); | |
| 3203 | 3203 | } | |
| 3204 | 3204 |

