BVc@sdZddlZddlZddlZddljZddljj Z ddl Zddl Zddl j Z ddlZddljZddlmZddlmZddlmZddlmZddlmZmZddl mZmZmZd Zd Z d Z!d Z"d Z#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3dZ4dZ5d Z6d!Z7d"Z8d#Z9d$Z:d%e;fd&YZ<d'e=fd(YZ>dS()sProvides the interfaces and exceptions needed to determine which packages should be installed, updated, or removed to perform a requested operation.iN(t defaultdict(tchain(t DebugValues(tFirmware(tPKG_OP_UNINSTALLt PKG_OP_UPDATE(tEmptyIt EmptyDicttN_t Initializeds Not possibletFailedt Succeedediiiiiiiiii i i i i iiiiiiiiiitDependencyExceptioncBsGeZdZedZedZedZedZRS(sglocal exception used to pass failure to match dependencies in packages out of nested evaluationcCs,tj|||_||_||_dS(N(t Exceptiont__init__t_DependencyException__fmrist_DependencyException__reason_idt_DependencyException__reason(tselft reason_idtreasontfmris((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyR[s   cCs|jS(s#The FMRIs related to the exception.(R(R((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyRascCs|jS(s:A constant indicating why the related FMRIs were rejected.(R(R((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyRfscCs|jS(s8A string describing why the related FMRIs were rejected.(R(R((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyRks( t__name__t __module__t__doc__RRtpropertyRRR(((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyR Ws  t PkgSolverc BseZdZdZdZdZdZeedZ dZ dZ e e dZ d Zed Zeed Zd Zeed ZdZdZedZeedZdZdZee eeeeeedZe edZedZdZdZ dZ!eddZ"dZ#dZ$dZ%dZ&d Z'd!Z(d"Z)eed#Z*d$Z+d%Z,d&Z-eed'Z.eed(Z/d)Z0e d*Z1e d+Z2e ed,Z3e ed-Z4e ed.Z5d/Z6d0Z7d1Z8e eeed2Z9e eed3Z:e d4Z;e d5Z<d6Z=d7Z>d8Z?eed9Z@d:ZAe d;ZBd<ZCd=ZDd>eeed?ZEd>eeed@ZFdAZGedBZHdCZIdDZJdEZKdFZLdGZMdHZNdIZOe dJZPe dKZQdLZRdMZSe dNZTdOZUdPZVdQZWedRZXeedSZYdTZZdUZ[dVZ\dWZ]RS(XsProvides a SAT-based solution solver to determine which packages should be installed, updated, or removed to perform a requested operation.c Cstdrtdn||_t|_i|_tt|_||_ t |_ tt|_ |j |_t|j|_t|jj|_i|_t|_t|_x>|jD]3}|j} |j | dr| |j|j|_?iitt@6ttA6tA6|_BdS(sCreate a PkgSolver instance; catalog should contain all known pkgs, installed fmris should be a dict of fmris indexed by name that define pkgs current installed in the image. Pub_ranks dict contains (rank, stickiness, enabled) for each publisher. variants are the current image variants; avoids is the set of pkg stems being avoided in the image.t no_solvers!no_solver set, but solver invokediiN(CRt RuntimeErrort_PkgSolver__catalogtsett_PkgSolver__known_incst_PkgSolver__publisherRtlistt_PkgSolver__possible_dictt_PkgSolver__pub_rankstFalset_PkgSolver__depend_tst_PkgSolver__trim_dicttcopyt_PkgSolver__installed_dictt frozensett_PkgSolver__installed_pkgstvaluest_PkgSolver__installed_fmrist_PkgSolver__pub_trimt_PkgSolver__removal_fmrist_PkgSolver__req_pkg_namest publishertpkg_namet_PkgSolver__id2fmrit_PkgSolver__fmri2idtpkgtsolvert msat_solvert_PkgSolver__solvert_PkgSolver__progtracktNonet_PkgSolver__progitemt_PkgSolver__addclause_failuret_PkgSolver__variant_dictt_PkgSolver__variantst_PkgSolver__cachet_PkgSolver__actcachet_PkgSolver__trimdonet_PkgSolver__fmri_statet SOLVER_INITt_PkgSolver__statet_PkgSolver__iterationst_PkgSolver__clausest_PkgSolver__variablest_PkgSolver__subphasenamet_PkgSolver__timingst_PkgSolver__start_timet_PkgSolver__inc_listt_PkgSolver__dependentst_PkgSolver__root_fmrist_PkgSolver__avoid_sett_PkgSolver__obs_sett_PkgSolver__reject_sett_PkgSolver__fmridictt_PkgSolver__expl_install_dictt isinstancettypetAssertionErrort_PkgSolver__parent_pkgstdictt_PkgSolver__parent_dictRt_PkgSolver__firmwareRRt_PkgSolver__triggered_ops( Rtcattinstalled_dictt pub_rankstvariantstavoidst parent_pkgst progtracktftpub((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyRvsv                                   !  +  cCsd}|jttgkr@|dj|j|j|j7}n|dj|j7}|d7}|djg|jD]}dj|^qs7}|d7}|j rdjg|j D]}t |^q}nd }|d j|7}|S( Ns Solver: [s2 Variables: {0:d} Clauses: {1:d} Iterations: {2:d}s State: {0}]s Timings: [s, s{0}: {1: 6.3f}t]s R9s Maintained incorporations: {0} ( RCt SOLVER_FAILtSOLVER_SUCCESStformatRFRERDtjoinRHRJtstr(Rtstatincs((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__str__s     &  .cCsd|_i|_t|_t|_i|_i|_d|_i|_ t |_ d|_ d|_ d|_d|_t|_d|_d|_d|_d|_d|_d|_d|_d|_i|_d|_tdr|Sd|_|S(sDiscards all solver information except for that needed to show failure information or to stringify the solver object. This allows early garbage collection to take place, and should be performed after a solution is successfully returned.tplanN(R9RR(R)R*R,R R"R#R-RR.R2R3R7R8R$R;R<R=R>R?R@RARIRKRPRXRR&(Rtrval((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt __cleanups8                          cCs&|jst|jj|jdS(s7Bump progress tracker to indicate processing is active.N(R:RTR8tplan_add_progress(R((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt __progressscCs]|rg|_n|jdk r.|jntj|_dj||_|jdS(scAdd timing records and tickle progress tracker. Ends previous subphase if ongoing.s phase {0:d}N(RHRGR9t_PkgSolver__end_subphasettimeRIRft_PkgSolver__progress(Rtsubphasetreset((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__start_subphase$s  cCsBtj}|jj|j||jfd|_d|_dS(s8Mark the end of a solver subphase, recording time taken.N(RsRHtappendRGRIR9(Rtnow((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__end_subphase/s   cCsx|D]\}}}|rFtd|j|jj|ff}n$td|j|jjff}|j|j|dtdt|qWdS(s2Trim any packages we cannot update due to freezes.s^This version is excluded by a freeze on {0} at version {1}. The reason for the freeze is: {2}s;This version is excluded by a freeze on {0} at version {1}.tdotrimiN(RR1tversiontget_short_versiont_PkgSolver__trimt_PkgSolver__comb_auto_fmrisR$t _TRIM_FREEZE(Rtexisting_freezesRatrt_tR((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt __trim_frozen7s  cCsAd}tdr|j}ntjd|d|d|dS(s.Raise a plan exception due to solution errors.Rmt no_solutiont no_versiont solver_errorsN(R9Rtget_trim_errorst api_errorstPlanCreationException(RRRR((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__raise_solution_errorGs  cCs|dkrdSt}g}xv|D]n}|j||}|rU|||sN(R9RRMR.R(R,t%_PkgSolver__trim_nonmatching_variantsROR~t_PkgSolver__get_catalog_fmrist _TRIM_REJECTRR*R/(RtrejectedtproposedRRa((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt#__set_removed_and_required_packagesks(     !   c Cst}x|trt|j}|j|d|d|d|}|r[|j|t}nt|j}| s}||kr Pq q W|j|jjdS(sUpdate the provided possible set of fmris with the transitive closure of dependencies that can be satisfied, trimming those packages that cannot be installed. 'possible' is a set of FMRI objects representing all possible versions of packages to consider for the operation. 'full_trim' is an optional boolean indicating whether a full trim of the dependency graph should be performed. This is NOT required for the solver to find a solution. Trimming is only needed to reduce the size of clauses and to provide error messages. This requires multiple passes to determine if the transitive closure of dependencies can be satisfied. This is not required for correctness (and it greatly increases runtime). However, it does greatly improve error messaging for some error cases. 'filter_explicit' is an optional boolean indicating whether packages with pkg.depend.explicit-install set to true will be filtered out. An example of a case where full_trim will be useful (dueling incorporations): Installed: entire incorporates java-7-incorporation Proposed: osnet-incorporation incorporates system/resource-mgmt/dynamic-resource-pools system/resource-mgmt/dynamic-resource-pools requires new version of java not allowed by installed java-7-incorporationtexcludest full_trimtfilter_explicitN(tTruetlenR&t'_PkgSolver__generate_dependency_closuretupdateR$tdifference_updatetiterkeys( RtpossibleRRRtfirstttsizetrestnsize((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__update_possible_closures$    cCsx|jD]~}|j|j|j|j|xN|j|D]?}x6|j|d|D]}|j|j||qaWqEWq WdS(sConstrain the solver solution so that only one version of each package can be installed and generate dependency clauses for possible packages.RN(R"Rtt_PkgSolver__addclausest"_PkgSolver__gen_highlander_clausest"_PkgSolver__get_dependency_actionst"_PkgSolver__gen_dependency_clauses(RRRtfmritda((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__enforce_unique_packagess    cCs.|dkr|dks6|dk r0|dk s6t|dkrNt}n|dkrct}nxI|D]A}|j|j|jt||t|j|@qjWxx|j||j |j D][}|j|j ||j krqn||jkr|j|j|j|qqWdS(szGenerate initial solver clauses for the proposed packages (if any) and installed packages. 'proposed' is a set of FMRI objects representing packages to install or update. 'proposed_dict' contains user specified FMRI objects indexed by pkg_name that should be installed or updated within an image.N( R9RTRRRtRt$_PkgSolver__gen_one_of_these_clausesR"R*RORMR(R.(RRRR((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__generate_operation_clausess,           cCsl|jtkstt|_|j}|jdkrU|j|_|j|jn|j ddt |S(svPrepares solver for solution creation returning a ProgressTracker object to be used for the operation.iRvN( RCRBRTt SOLVER_OXYR8R:R9tPLAN_SOLVE_SETUPt plan_startt_PkgSolver__start_subphaseR(Rtpt((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt __begin_solves   cCsN|j}|j|j|j|j|j|||j|jffS(sjReturns the solution result to the caller after completing all necessary solution cleanup.(R8Rrt plan_donetPLAN_SOLVE_SOLVERt_PkgSolver__cleanupt"_PkgSolver__elide_possible_renamesRMRN(RtsolutionRR((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt __end_solve,s   cCs|dkrt}nt}g}x|j||j|jD]}|j|j||jkroqCn||jkrqCn|j |j|gd|}|rC|j t dj |g|j |qCqCW|r|j d|ndS(sRaises a PlanCreationException if the proposed operation would require the removal of installed packages that are not marked for removal by the proposed operation.RsPPackage {0} must be uninstalled before the requested operation can be performed.RN(R9RR*RORMRtR(R.R"RRRRfR(RRRRRR((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__assert_installed_allowed6s*        cCsSt|_|j||dtdt|j||j||jd|dS(s+Raises a PlanCreationException if any further trims would prevent the installation or update of proposed or installed/required packages. 'proposed' is an optional set of FMRI objects representing packages to install or update. 'proposed_dict' contains user specified FMRIs indexed by pkg_name that should be installed within an image. 'possible_set' is the set of FMRIs potentially allowed for use in the proposed operation.RRRN(R$R@t#_PkgSolver__update_possible_closureRt_PkgSolver__trim_proposedt_PkgSolver__assign_possiblet$_PkgSolver__assert_installed_allowed(Rt possible_setRRR((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__assert_trim_errors_s     cCs0|j||d|g}g}|jd|r|jdtjd}xFt|d|D]"} |jdj| jqdWn |jd|jd|jg|jD]} | D] } | ^qqd|} | r?|jd|jt d |jdx'| D]} |jdj| qWn|j } | r|jd|jt d |jdx'| D]} |jdj| qWn|s|jt d |jt d |jt d |jt dn|||_ t dr&|j |_n|dS(sPrivate logic for solve_install() to process a PlanCreationException and re-raise as appropriate. 'exp' is the related exception object raised by the solver when no solution was found. 'inc_list' is a list of package FMRIs representing installed incorporations that are being maintained. 'proposed_dict' contains user specified FMRIs indexed by pkg_name that should be installed within an image. 'possible_set' is the set of FMRIs potentially allowed for use in the proposed operation. Rtsmaintained incorporations:R1tkeys {0}smaintained incorporations: NoneRs8Plan Creation: dependency error(s) in proposed packages:sDPlan Creation: Errors in installed packages due to proposed changes:s<Plan Creation: Package solver is unable to compute solution.s7Dependency analysis is unable to determine exact cause.sGTry specifying expected results to obtain more detailed error messages.s8Include specific version of packages you wish installed.RmN(t_PkgSolver__assert_trim_errorsRxtoperatort attrgettertsortedRftget_short_fmrit&_PkgSolver__generate_dependency_errorsR+Rt_PkgSolver__check_installedRRRR(Rtexptinc_listRRRtinfoRktskeytilRjtbtmsRi((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__raise_install_errorsL  #            cCsr||jkstd|||j|ksBtd|t|tsWt|j||c|O| j?|_@| jA| j?|jd|jB} y|jC}!Wn/t)j*k rw}|j+|||||nX|jd|jD| x9|!D]1}|j|kr|jE|jF|gqqW|jd|jB} |jCdt}!|jd|jD| x.|!|j @D]}|jE|jF|gq!W|jC}"|j|jG|"|}"|jH|"|S(sm Logic to install packages, change variants, and/or change facets. Returns FMRIs to be installed / upgraded in system and a new set of packages to be avoided. 'existing_freezes' is a list of incorp. style FMRIs that constrain package motion. 'proposed_dict' contains user specified FMRIs indexed by pkg_name that should be installed within an image. 'new_variants' a dictionary containing variants which are being updated. (It should not contain existing variants which are not changing.) 'reject_set' contains user specified package names that should not be present within the final image. (These packages may or may not be currently installed.) 'trim_proposed_installed' is a boolean indicating whether the solver should elide versions of proposed packages older than those installed from the set of possible solutions. If False, package downgrades are allowed, but only for installed packages matching those in the proposed_dict. 'relax_all' indicates if the solver should relax all install holds, or only install holds specified by proposed packages. 'ignore_inst_parent_deps' indicates if the solver should ignore parent dependencies for installed packages. This allows us to modify images with unsatisfied parent dependencies (ie, out of sync images). Any packaging operation which needs to guarantee that we have an in sync image (for example, sync-linked operations, or any recursive packaging operations) should NOT enable this behavior. 'exact_install' is a flag to indicate whether we treat the current image as an empty one. Any previously installed packages that are not either specified in proposed_dict or are a dependency (require, origin and parent dependencies) of those packages will be removed. 'installed_dict_tmp' a dictionary containing the current installed FMRIs indexed by pkg_name. Used when exact_install is on.iRRRiis7This version excluded by specified installation versionis7This version is excluded by installed incorporation {0}tanarchytinclude_schemeiR{iiiiii t exact_installtinstalled_dict_tmpi i i Ri iitolderi(It_PkgSolver__begin_solveRRYRRR1RxtaddR)R=R,t_PkgSolver__get_variant_dictR.R(t_PkgSolver__mark_pub_trimmedR0R t-_PkgSolver__set_removed_and_required_packagesRtR*t)_PkgSolver__relax_parent_self_constrainedt*_PkgSolver__get_installed_unbound_inc_listRJRR+R|R$t_PkgSolver__trim_olderRR~Rt_TRIM_PROPOSED_VERRt"_PkgSolver__trim_recursive_incorpstzipRRt_TRIM_INSTALLED_INCt_PkgSolver__trim_frozenRRRRt_PkgSolver__raise_install_errort_PkgSolver__comb_newer_fmrisRR!RQtitemsRt_PkgSolver__is_explicit_installRt$_PkgSolver__trim_nonmatching_parentst$_PkgSolver__trim_nonmatching_originsRR&Rt_PkgSolver__assign_fmri_idst#_PkgSolver__enforce_unique_packagest&_PkgSolver__generate_operation_clausesRRRRR:Rt_PkgSolver__save_solvert_PkgSolver__solvet_PkgSolver__restore_solverRRt_PkgSolver__update_solution_sett_PkgSolver__end_solve(#RRRt new_variantsRt reject_setttrim_proposed_installedt relax_alltignore_inst_parent_depsRRRtr_setRat proposed_pkgstdtkRt relax_pkgsRt con_liststinstalled_fmris_tmptcandidate_fmristverlistt valid_triggerttftitflistRRRRt saved_solvertsaved_solutionR((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt solve_installs>4       &                                  (                           cCs#|j}|jd||jx(|jD]}|j|j|q0W|j||jdt}xW|j|jD]E}|j|j |d}|st|g}n||O}qW|jd|j ||xE|D]=}|j ||r|j |r/|j ||q/qqW|jd|j|jj|j||j||jd|jy|jWn'tjk r|j||nX|j|j|j|_|j|j|jdy|j}Wn'tjk r1|j||nX|j||x3|jD]%}|j |rO|j!|qOqOW||jkr|j"||S|j#|} | s|j$r|j"||S|j||t%j&d} g} | j't(d | j't(d | j'd | j't(d | j'd | j)d t*| d| D| j'd |j+| d|} | j)|j,| r| j't(d| j'd xM| D]} | j'dj-| qWn&| j't(d| j't(d|j.d| dS(s"Logic to update all packages within an image to the latest versions possible. Returns FMRIs to be installed / upgraded in system and a new set of packages to be avoided. 'existing_freezes' is a list of incorp. style FMRIs that constrain pkg motion 'reject_set' contains user specified FMRIs that should not be present within the final image. (These packages may or may not be currently installed.) RiiiiiiR1s9No solution found to update to latest available versions.sFThis may indicate an overly constrained set of packages are installed.t slatest incorporations:css|]}dj|VqdS(s {0}N(Rf(RRa((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pys sRRsKThe following indicates why the system cannot update to the latest version:s {0}s5Dependency analysis is unable to determine the cause.sHTry specifying expected versions to obtain more detailed error messages.RN(/RRRtR,RRRRR.RRRRRRR&RRRRRRRRRRRR:RRRR't_PkgSolver__fmri_is_obsoletetremoveRt-_PkgSolver__get_installed_upgradeable_incorpst_PkgSolver__is_childRRRxRRRRRRfR(RRRRRRaRtmatchingRtincorpsRRRRi((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pytsolve_update_all&s                         c s|j|j}||j||}t||B|jttB}tx&|jttD]}j|qcWx|D]} |j|j | ||} t fd| D} x| D]} t } xk|j | |D]W}|j ddkrqntjj|j ddj}|| jkrt} PqqW| r| j| | qqW| rtj| | qqWtd|D}t|_|j|id|d|d |S( s$Compute changes needed for uninstallc3s:|]0}D]#}|j|jkr ||fVq qdS(N(R1(RRaR (t triggered_set(s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pys s RStrequireRs5.11css|]}|jVqdS(N(R1(RRa((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pys sRRR(RR,RRRYRRRRtt_PkgSolver__get_dependentsRVRRtattrsR4RtPkgFmriR1R$RRtNonLeafPackageExceptionRBRCR(RRtuninstall_listRRtorig_installed_sett renamed_settproposed_removalsRatpfmrit dependentst candidatesR RRR1R((Rs;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pytsolve_uninstallsJ               c CsLtd|D}t}x|D]}x|j|d|dtD]}|jddkrgqHn|jd}y|j|}Wn3tk rtjj|d}||j|sRt trim_invalidRStgroupRs5.11(RRR$RRPtKeyErrorR4RRRR1RMR'RRRN( RRRtsolution_stemst tracked_stemsRRjttttmpRtobsRa((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__update_solution_set s.         cCs|jtjj|jfS(s5Duplicate current current solver state and return it.(R;R4R5R6R7(R((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt __save_solver.scCs|\|_|_d|_dS(s8Set the current solver state to the previously saved oneiN(R;R7RD(RR5((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__restore_solver3sic Cs{g}t|_t}x|j r)|jjgr)|j|jd7_|j|krcPn|j}|syPnx|D]~}|j |}|j |\}}|s|} n|t|g|} x+| D]#} |j |j |  ggqWqW|j g|D] } | ^qgqW|jsF|j dtnt|_tg|D]} |j | ^qY} | S(sQPerform iterative solution; try for newest pkgs unless older=TrueiR(RdRCRR;R7tsolveRtRDt_PkgSolver__get_solution_vectort_PkgSolver__getfmriRRt_PkgSolver__getidRRRe( RRtmax_iterationstsolution_vectort eliminatedtfidR$Rt remainingRRaR R((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__solve8s4       %(  (cCsBtgt|jjD]"}|jj|r|d^qS(s"Return solution vector from solveri(R)trangeR7t get_variablest dereference(RR ((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__get_solution_vectordscCsg|jjx%|D]}|j|jj|qWx"|jD]}|j|jq?Wt|_dS(shAssign __possible_dict of possible package FMRIs by pkg stem and mark trimming complete.N(R"tclearR1RxtsortRR@(RRRaR((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__assign_possibleks   cCs|j|d}x_t|jjD]H}x?t|j|D]*}||j|<||j|<|d7}qCWq)W|d|_dS(s) give a set of possible fmris, assign idsiN(RRR"RtreversedR2R3RF(RRtpkgidRR((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__assign_fmri_idsxs   cCs |j|S(s&Translate fmri to variable number (id)(R3(RR((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__getidscCs |j|S(s'Translate variable number (id) to fmris(R2(RR:((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt __getfmriscCsI||jkr>g|jj|D] }|^q"|j|Rtfmris_by_version(RR1R-((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__get_fmris_by_versions,cCsl||jkr|j|n|jr;|jj|gSg|j|D]}|dD] }|^qYqKS(s6 return the list of fmris in catalog for this pkg namei(R-t_PkgSolver__filter_publishersR@R"tgett _PkgSolver__get_fmris_by_version(RR1ttpRa((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__get_catalog_fmriss c Cse|s$| s$|j s$|jj r=|j||tj|S||tj|f}y|j|SWntk rtnX|j}|j|jddd}d}xBt |D]4\}} || jkr|}q|dk rPqqW|dk rt ||d } t ||d} nt } t |} |j sG| | fS| | f|j|<|j|S(sReturns tuple of set of fmris that are matched within CONSTRAINT.NONE of specified version and set of remaining fmris.Nii( R|ttimestrt_PkgSolver__comb_commontCONSTRAINT_NONER>R*RR1R9t enumerateR)R@( RRR{t obsolete_okRNtmvert all_fmristlast_verR RaRR;((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__comb_newer_fmriss4            csTj|j}tfd|D}tt||}||fS(s"Implements versionless comb logic.c3sA|]7} s|jkrs5j| r|VqdS(N(R&R(RRa(R{RTR(s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pys s(RR1R)R(RRR{RTRVRR;((R{RTRs;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__comb_common_noversions  cCs|j}|j o=|jo=|tjtjtjtjfk}|j|j}|rt j dd}t |d|dt } n|ddd} d} d} xrt| D]d\} } | j}|j|d|s||kr| dkr| } n| } q| dk rPqqW| dk rg}g}xb| | | d!D]O} | s_| |jkr|su|j|  r|j| qC|j| qCWt|}tt| | || | d}nt}t| }||fS( s Implements versioned comb logic.sversion.branchsversion.releaseRtreverseNit constrainti(R|RPtbranchRRtCONSTRAINT_RELEASEtCONSTRAINT_RELEASE_MAJORtCONSTRAINT_RELEASE_MINORRR1RRRRR9RSt is_successorR&RRxR)R(RRR{R[RTRUt branch_sortRVRt comb_fmrist first_verRWR RatfverRR;((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__comb_common_versionsT               cCs|j||||f}|j r,|s;||jkr|j sR|jj rp|j|||\}}n|j||||\}}|js||fS||f|j|R|treleaset!_PkgSolver__comb_common_noversiont_PkgSolver__comb_common_version(RRR{R[RTRNRR;((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt __comb_common=s     cCsq|j|dtd|\}}|s1||fStg|D]}||jkr;|^q;}||||BfS(soReturns tuple of set of fmris that are older than specified version and set of remaining fmris.R{RT(RR$RR&(RRR{RTtnewerRRat trimmed_older((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__comb_older_fmrisXs  cCs|j||tj|S(sReturns tuple of set of fmris that are match within CONSTRAINT.AUTO of specified version and set of remaining fmris.(RQR|tCONSTRAINT_AUTO(RRR{RT((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__comb_auto_fmriskscCsywtg|jj|tjjgd|D]B}|jdkr+|jdd kr+|jd|jdf^q+}Wn/tj k rd |j |<|j |dSX|j ddj d k|j ddj d kf|j |5sRSRRtoriginRs5.11(s incorporatesoptionalR(Rt_PkgSolver__fmri_is_renamedRVRRRRtattrlistRPR*R4RRR1tdiscard( RRRR$t renamed_fmrist fmris_by_nameRRRRaR.Rtnew_fmri((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__elide_possible_renames$sF !                 cCs|jdkri|_x|jD]}xx|j||D]d}|jddkrZq;ntjj|jddj}|jj |j |t j |q;Wq"Wn|jj |t S(shreturn set of installed fmris that have require dependencies on specified installed fmriRSRRs5.11N(RKR9R,RRR4RRR1t setdefaultR(RRRL(RR$RRaRR1((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__get_dependents]s      c Cst}|g}x|r|j}|jt||j||}x{|D]s}|j||dttd|djff||d}|rSt||krS|j t |qSqSWqWdS(s(trim packages affected by incorporationsis(Excluded by proposed incorporation '{0}'iN( RRRR)t_PkgSolver__combine_incorpsR~t_TRIM_PROPOSED_INCRR1RxR!( Rt fmri_listRt processedtworkRRRtto_do((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__trim_recursive_incorpsns      cs[g|D]}|j||^qttjdD}tfd|DS(sGiven a list of fmris, one of which must be present, produce a dictionary indexed by package name, which contains a tuple of two sets (matching fmris, nonmatching)css!|]}t|jVqdS(N(Rtkeys(RR((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pys sc3sY|]OttjfdDttjfdDffVqdS(c3s1|]'}|jttfdVqdS(iN(RLR(RR(R(s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pys sc3s1|]'}|jttfdVqdS(iN(RLR(RR(R(s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pys sN(treduceRtuniont intersection(R(t dict_list(Rs;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pys s(t$_PkgSolver__get_incorp_nonmatch_dictRRRRV(RRRRatall_keys((Rs;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__combine_incorpss"  c Cst}x|j|d|D]}|jddkr>qn|j||dt\}}}}} } |j| jttf|| jdjt ||| jdjt |qWxF|D]>} t t j || dt t j || df|| }|j||d| \}}| j||j|qWt| } t|}n4|d krG|jst} }n!|j|dt dt \} }t } n|dkr}|j|dt d| \} }t } n|dkrt } |jdk r|j}d|_n|j|jks|j|jkrt } t} }q)|j||d| \} }ntjdj|| s=| s=| rS|| | || |fS|jdt dt }|dkrI|j|dt dt \} }t }x'|D]}||j krt }PqqW| r|rt!t"t#d|ffq| r%| r%t!t"t#d|ffqt!t$t#d|ff| n|d kry|j|dt d| \} }nj| t krt%|dkr|j||dt \} }nUg} g}xF|D]>}|j||dt \}}| j||j|qW| rt%|dkrIt!t&t#d||ffqtg|D]}|jdt dt ^qS}t!t&t#d||ffn|j|dt d| \} }n!|j|dt d| \} }| s t!t't#d||ffn$t!t$t#d||ff| dS(svReturn tuple of (disallowed fmri list, allowed fmri list, conditional_list, dependency_type, required)RSRs5.11iRRTRRRRt predicates require-anytparentR{RR)sUnknown dependency type {0}RRs>Package contains 'exclude' dependency {0} on installed packages=Package contains 'exclude' dependency {0} on proposed packagesANo version allowed by 'exclude' dependency {0} could be installedis?All acceptable versions of '{0}' dependency on {1} are obsoletesAAll acceptable versions of '{0}' dependencies on {1} are obsoletes3No version for '{0}' dependency on {1} can be founds9No version matching '{0}' dependency {1} can be installedN((RRRPR*R4RRR%R|RPRRxR9R$RR1R/t_PkgSolver__comb_older_fmrisRRRRRRR)R'RMRORRvRftget_fmriR,R t_TRIM_INSTALLED_EXCLUDERt_TRIM_DEP_TRIMMEDRt_TRIM_DEP_OBSOLETEt_TRIM_DEP_MISSING(Rtdependency_actiontsourceR{RtdtypeRtfmristrRRdtrequiredRRTRt nonmatchingt cond_fmriRaRRtfstrt installedtsfmris((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__parse_dependencys"                                         +     cCst}|js|S|r#|Sxy|jD]n}xe|j||D]Q}|jddkreqFntjjj|j dkrF|j |j PqFqFWq-W|S(sIf we're a child image then we need to relax packages that are dependent upon themselves in the parent image. This is necessary to keep those packages in sync.RSRR( RRR,RRR4tactionsRt DEPEND_SELFRRR1(RRRRRaR((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__relax_parent_self_constraineds    c Csg}t|}t}t}xY|r|j}|j|||\}} |j||j||| |O}q'W|S(s Returns a list of strings describing why fmris cannot be installed, or returns an empty list if installation is possible. (RRt_PkgSolver__do_error_workRR( RRRRRRRRterrorstnewfmris((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__generate_dependency_errorss        cCsJ|jtksttds%t|j|jjdtdtS(sReturns a list of strings for all FMRIs evaluated by the solver explaining why they were rejected. (All packages found in solver's trim database.)RmRtverbose( RCRBRTRRR&RRR(R((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyRscCst}g}x|j|jD]}|j|dtdtd}|rQq n|j|dtdtd}|jtdj|j |j |j |d|q W|S(swGenerate list of strings describing why currently installed packages cannot be installed, or empty listR{RTis2No suitable version of installed package {0} foundR( RR,R.RRR$RxRRfR1RR(RRRRaR((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__check_installeds    Rc syg|d krt}ng}tjd}xZt|d|D]F}j||d|d|d} | d k rF|j| qFqFWgfd} d } x|D]\} } | | krdt| d}sj|nj|| d qq| | r5j| nj| d| d | } qW| ru| j| nS( saGiven a list of FMRIs, return indented strings indicating why they were rejected.R1RRtomitRcsrjd}s-tdkr=jqj rgdjdjrgqj|dtdjdngddd sRRspkg.depend.install-holdRot.c3s7|]-}|jkr|jkr|VqdS(N(R1(Rtinc(Rt relaxed_holds(s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pys s(RR,R.RRrRsRtRuRRRPR*R4RRRxRRR1RRt itervaluest startswitht_PkgSolver__get_child_holdsRTt iteritemsR((RRRRtversioned_dependentsRRaRRtflR.RtholdRt child_holdst child_holdR1t hold_valueR[RRR R((RRs;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt __get_installed_unbound_inc_list sl          < "   #-cCst|j| siiis(Higher ranked publisher {0} was selecteds1Package publisher is ranked lower in search order(R-RRR R(t_TRIM_PUB_STICKYRRRRR#RLR$t_TRIM_PUB_RANKR~R0R|( RR1Rtacceptable_pubsRRt pubs_foundtptrankedRtinst_fRa((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__filter_publishers sD   B (   cCs|jyt|}Wntk r6|g}nX|ttksOt||t|f}x"|D]}|j|j|qkWdS(sQRemove specified fmri(s) from consideration for specified reason.N( RttiterRR=t _TRIM_MAXRTR)R&R(RRRRRtitttupR((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__trim4 s    cCs?td|ff}|j|j|dtdt|dS(s"Trim any fmris older than this ones&Newer version {0} is already installedR{iN(RR~RR$R(RRR((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt __trim_olderD scCs|j|}d}x|jjD]}||kr%|j|||kr%|dkritd}n&td||||j|ff}|j|t|q%q%W|dkS(s[Trim packages that don't support image architecture or other image variant.Rs variant.archs*Package doesn't support image architecturesSPackage supports image variant {0}=[{1}] but doesn't support this image's {0} ({2})(RR=RRR~t _TRIM_VARIANT(RRtvdRtv((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__trim_nonmatching_variantsJ s#  cCs||jkrtS|j|jkr{|jrLtd|jff}ntd|jff}|j|t|tS|j|j}|j r|j |j kr|jrtd|ff}ntd|ff}|j|t |tS|j |j ks#|j j |j t j r'tS|j j |j t jrt}|jrltd|ff}qtd|ff}n?t}|jrtd|ff}ntd|ff}|j|||tS( sNPrivate helper function for __trim_nonmatching_parents that trims any pkg_fmri that matches a parent dependency and that is not installed in the parent image, that is from a different publisher than the parent image, or that is a different version than the parent image.s,Package {0} is not installed in global zone.s-Package {0} is not installed in parent image.s9Package in global zone is from a different publisher: {0}s4Package in parent is from a different publisher: {0}s$Global zone has a newer version: {0}s%Parent image has a newer version: {0}s0Global zone has an older version of package: {0}s1Parent image has an older version of package: {0}(RURR1RWt_PkgSolver__is_zoneRR~t_TRIM_PARENT_MISSINGR$R0t_TRIM_PARENT_PUBR|R`RmRRt_TRIM_PARENT_NEWERt_TRIM_PARENT_OLDER(Rtpkg_fmriRRtpfR((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__trim_nonmatching_parents1_ sL               c Cs|jst|jstS|r8||jkr8tStg|j||D]D}|jddkrN|jdD]}t j j |d^qtqN}|stSt}xP|D]H}|}|j t j jjkr|}n|j||st}qqW|S(snTrim any pkg_fmri that contains a parent dependency that is not satisfied by the parent image.RSRRs5.11(R0RTRRR,RRRRR4RRR1RRRt%_PkgSolver__trim_nonmatching_parents1R$( RR5RRRRatpkg_depstallowedR((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__trim_nonmatching_parents s* 4   c Csx |j||D]}|jddkr2qntjj|jdd}|jjddjdkre|jjdr|j j ||j\}}|s|j |t |t Sqn|jdkr2tjjjtjd t d td t} tg| jD]} | j| f^q|_n|jj|j} t} td |ff}nK|r|j|j} n|jj|j} t} td |ff}| s|j s|j| jks| jj|jtjrqn|j || |t SWtS(sxTrim any fmri that contains a origin dependency that is not satisfied by the current image or root-imageRSRRs5.11s root-imageRRqsfeature/firmware/tallow_ondisk_upgradetuser_provided_dirt should_existsDInstalled version in root image is too old for origin dependency {0}sNInstalled version in image being upgraded is too old for origin dependency {0}N(RRR4RRRLRxR1RRXtcheck_firmwareR~t_TRIM_FIRMWARER$RLR9tclienttimagetImagetmisctliverootRRVtgen_installed_pkgst_TRIM_INSTALLED_ROOT_ORIGINRR(t_TRIM_INSTALLED_ORIGINR|R`RR( RRRRRRtreq_fmritfw_okRtimgRaRR((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__trim_nonmatching_origins sX!        .        cCs|j|ttddS(s+Indicate given package FMRI is unsupported.s/Package contains invalid or unsupported actionsN(R~t_TRIM_UNSUPPORTEDR(RR((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__trim_unsupported s cCs&g|D]}||jkr|^qS(s9Return fmri_list trimmed of any fmris in self.__trim_dict(R&(RRRa((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt__dotrim s cCs |jdk S(s2Return True if this image is a linked image child.N(RUR9(R((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt __is_child scCs(d|jkr |jddkStSdS(s(Return True if image is a nonglobal zonesvariant.opensolaris.zonet nonglobalN(R=R$(R((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyt __is_zone s (^RRRRRlRRtR9R$RRrRRRRRRRRRRRRRRRR)RRRR'RRRRR4RRR6R5RMRRRgRhRQRRR{RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRKR~RRR8RRRwRRR0(((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyRqs k  &     39  +  )  K  K I $  ,     8 R          9       @m      C  e  @    > )E  (?RRRst pkg.actionsR4t pkg.catalogRstpkg.client.api_errorsRARtpkg.client.imagetpkg.fmritpkg.miscRDt pkg.solvert pkg.versionR|t collectionsRt itertoolsRtpkg.client.debugvaluesRtpkg.client.firmwareRtpkg.client.pkgdefsRRRRRRBRRdReRRRR@RRRRRHRGR1R3R4R2RRRRRRRMR,RR'R R tobjectR(((s;/usr/lib/python2.7/vendor-packages/pkg/client/pkg_solver.pyts\