ó é=ûQc @sdZddlZddlZddlZddljjZddlZddl Zddl m Z dZ d Z dejfd„ƒYZdS(s¹Action describing a package dependency. This module contains the DependencyAction class, which represents a relationship between the package containing the action and another package. iÿÿÿÿN(tFirmwaret conditionaltexcludetgroupt incorporatetoptionaltorigintparenttrequires require-anysfeature/package/dependency/selftDependencyActioncBsreZdZgZdZdZejeZd d„Z d„Z d„Z d„Z d„Zd„Zd d „ZRS( s'Class representing a dependency packaging object. The fmri attribute is expected to be the pkg FMRI that this package depends on. The type attribute is one of these: optional - optional dependency on minimum version of other package. In other words, if installed, other packages must be at least at specified version level. require - dependency on minimum version of other package is needed for correct function of this package. conditional - dependency on minimum version of specified package if predicate package is installed at specified version or newer. require-any - dependency on minimum version of any of the specified packages. origin - specified package must be at this version or newer in order to install this package; if root-image=true, dependency is on version installed in / rather than image being modified. parent - dependency on same version of this package being present in the parent image. if the current image is not a child then this dependency is ignored. incorporate - optional dependency on precise version of other package; non-specified portion of version is free to float. exclude - package may not be installed together with named version or higher - reverse logic of require. group - a version of package is required unless stem is in image avoid list; version part of fmri is ignored. Obsolete packages are assumed to satisfy dependency.tdependtfmricKs•tjj|||yF|jdtkr[tjjt|ƒt dƒ|jdƒ‚nWn2t k rtjjt|ƒt dƒƒ‚nXdS(Nttypes"Unknown type (%s) in depend actionsMissing type attribute( tgenerictActiont__init__tattrst known_typestpkgtactionstInvalidActionErrortstrt_tKeyError(tselftdataR((s8/usr/lib/python2.7/vendor-packages/pkg/actions/depend.pyRhs   cCsA|jjƒsgStg|jjƒD]}|j|f^q&ƒ}g}|j|krw|jtdƒ|jƒ|S||j}|jrº|j|jkrº|jtdƒ|ƒ|S|j|jksê|jj |jt jj ƒrîgS|jj |jt jj ƒr&|jtdƒ|ƒn|jtdƒ|ƒ|S(Ns+Package is not installed in parent image %ss3Package in parent is from a different publisher: %ss.Parent image has a newer version of package %ss/Parent image has an older version of package %s( tlinkedtischildtdictt parent_fmristpkg_nametappendRt publishertversiont is_successorRtCONSTRAINT_AUTOtCONSTRAINT_NONE(RtimageR tit ppkgs_dictterrorstpf((s8/usr/lib/python2.7/vendor-packages/pkg/actions/depend.pyt__check_parent_installedss2+   c Cs(g}|s|S|j}|rs|jrs|jj|tjjƒrs|jtdƒi|d6|d6|d6ƒ|S|rÝ|jrÝ||jkrÝ|j|jtjjƒ rÝ|jtdƒi|d6|d6|d6ƒ|S|r$tj|j |ƒkr$|jtdƒi|d6|d6ƒ|S|S(Ns=%(dep_type)s dependency %(dep_val)s is downrev (%(inst_ver)s)tdep_typetdep_valtinst_vers;%(dep_type)s dependency %(dep_val)s is uprev (%(inst_ver)s)sg%(dep_type)s dependency on an obsolete package (%(obs_pkg)s); this package must be uninstalled manuallytobs_pkg( R!R"RR$RRR#tpkgdefstPKG_STATE_OBSOLETEt get_pkg_state( RR%tinstalled_versiontmin_fmritmax_fmritrequiredtctypeR(tvi((s8/usr/lib/python2.7/vendor-packages/pkg/actions/depend.pyt__check_installedœs<         c sçg}g}g}|js!t‚‡fd†}|jd}|tkrm|jtdƒ|ƒ|||fSg} xX|jdƒD]G} tjj | ˆjdƒ} | j t kr½|} n| j| ƒqƒW|dkrt | ƒdksòt‚|j |jˆ| dƒƒ|||fSg| D]} ˆj| ƒ^q#} | d} | d}d}d}t}|d krt}|}n|d krš|}|}nô|d kr¯|}nß|d krÜ|}|jƒ}|ƒ|_n²|d krGtjj |jdˆjdƒ}ˆj|ƒ}|dk rŽ|j|ƒrŽ|}t}qŽnG|dkr~|j ˆjƒˆjƒBkrŽt}qŽn|dkr/xbt| | ƒD]Q\}}|jˆ||dt|ƒ}|rÞ| rÞgggfS|j |ƒqšW|s"|jtdƒdjd„| Dƒƒƒn|||fS|dkrŽ|j jdƒrŽtƒj||j ƒ\}}|r~gggfS|j|ƒn|j |jˆ| ||||ƒƒ|rÚ| rÚ|jtdƒ|ƒn|||fS(s»Returns a tuple of lists of the form (errors, warnings, info). The error list will be empty if the action has been correctly installed in the given image.cstjjdˆjdƒS(Nt0s Build-Release(RR!tVersionR((R%(s8/usr/lib/python2.7/vendor-packages/pkg/actions/depend.pyt __min_versionÍs R s"Unknown type (%s) in depend actionR s Build-ReleaseRiiRRRRRt predicateRs require-anys(Required dependency on one of %s not mets, css|]}t|ƒVqdS(N(R(t.0tp((s8/usr/lib/python2.7/vendor-packages/pkg/actions/depend.pys sRsfeature/firmware/s'Required dependency %s is not installedN(R tAssertionErrorRRRRtattrlistRR tPkgFmriRt DEPEND_SELFtlentextendt)_DependencyAction__check_parent_installedtget_version_installedtNonetFalsetTruetcopyR!R"t avoid_set_gettobsolete_set_gettzipt"_DependencyAction__check_installedtjoint startswithRtcheck_firmware(RR%tpfmritargsR(twarningstinfot_DependencyAction__min_versionR6tpfmrisR&tftinstalled_versionsR2R3R4R5tcfmritinstalled_cversiontifmritrpfmritetoktreason((R%s8/usr/lib/python2.7/vendor-packages/pkg/actions/depend.pytverify¿s–                             cCsÕ|jd}|jd}|tkr*gSt|tƒrE|g}ng}tjdƒ}xt|D]l}|jd|ƒ}|jd||dfƒd|kra|j dƒd}|jd||dfƒqaqaW|S( swGenerates the indices needed by the search dictionary. See generic.py for a more detailed explanation.R R spkg:///|pkg://[^/]*/|pkg:/tR t@iN( RRt isinstancet basestringtretcompiletsubRRGtsplit(RR6RWtindstpatR>tstem((s8/usr/lib/python2.7/vendor-packages/pkg/actions/depend.pytgenerate_indices1s         cs§d}|‰|ˆj}tˆdƒrKˆjdkrK|dˆj7}n‡fd†‰‡fd†‰d|‰t‡fd†‰‡‡‡‡fd †}||ƒS( s­Write a dependency action across multiple lines. This is designed to be used in exceptions for cleaner printing of unsatisfied dependencies.s thashtNOHASHt csˆ|djdƒrdS|djdƒr.dSt|dtƒrEdS|ddkrYdS|dd krmdS|dˆjkr„d SdS( Nisvariant.isfacet.iiiR R i(RPRdtlisttkey_attr(ta(tact(s8/usr/lib/python2.7/vendor-packages/pkg/actions/depend.pytkvordbscs:tˆ|ƒˆ|ƒƒ}|r%|St|d|dƒS(Ni(tcmp(Rstbtc(Ru(s8/usr/lib/python2.7/vendor-packages/pkg/actions/depend.pytcmpkv}ss \ cs€|st|jdƒ}|dkr*d}n|dkr?d}nd}t|ƒ|t|ƒ|krt|d|Sn|ˆ|S(Ns iÿÿÿÿiiiPiNRp(trfindRC(RsRwt rem_valuestforce_nltlastnltmax_len(tJOIN_TOK(s8/usr/lib/python2.7/vendor-packages/pkg/actions/depend.pytgrow…s     c st}t‡fd†ˆjDƒƒ}xætˆjjƒdˆƒD]É\}}t|tƒpht|tƒs}|g}t}n |}t}x~t|ƒD]p}|o®|j dƒ}ˆ|dj |t j |ƒfƒ|d|ƒ}|rüˆ|krüt}n|d8}q–WqAW|S(Nc3s$|]}tˆj|ƒƒVqdS(N(RCR@(R=tk(Rt(s8/usr/lib/python2.7/vendor-packages/pkg/actions/depend.pys ¢sRvs pkg.debugt=R|i( RItsumRtsortedt iteritemsRdRqtsetRHRPROR tquote_attr_value( taoutt first_linet rem_countRtvtnvt use_force_nltlmtR|(RRtRyR€(s8/usr/lib/python2.7/vendor-packages/pkg/actions/depend.pytastrœs*(     (tnamethasattrRnRH(Rt base_indenttoutR((RRtRyR€Rus8/usr/lib/python2.7/vendor-packages/pkg/actions/depend.pyt pretty_printUs  "c Cs·dg}|jjdƒ}|dkr7|jdƒntjj|d|dtd|ddƒ}d|jkr˜|dkr˜|jdtd ƒfƒnd|jkrÏ|d krÏ|jdtd ƒfƒnx½dD]µ}x¬|j|ƒD]›}yt j j |d ƒWqìt j j t j jfk r†}|dkrK|d krKqìn|j|tdƒi|d6|d6t|ƒd6fƒqìXqìWqÖW|r³t jj||d|ƒ‚ndS(s9Performs additional validation of action attributes that for performance or other reasons cannot or should not be done during Action object creation. An ActionError exception (or subclass of) will be raised if any attributes are not valid. This is primarily intended for use during publication or during error handling to provide additional diagonostics. 'fmri' is an optional package FMRI (object or string) indicating what package contained this action.R RR<R t raise_errorstrequired_attrst single_attrss root-images>a predicate may only be specified for conditional dependenciesRs>the root-image attribute is only valid for origin dependenciess5.11t__TBDs-invalid %(attr)s value '%(value)s': %(error)stattrtvalueterrorN(s predicates root-image(s predicateR (RtgetRR Rt _validateRHRR@RR RAR!t VersionErrort FmriErrorRRtInvalidActionAttributesError(RR R–tdtypeR(R™RXR^((s8/usr/lib/python2.7/vendor-packages/pkg/actions/depend.pytvalidateÀs2       ( N(t__name__t __module__t__doc__t __slots__RRrR t _orderdictt ordinalityRGRRERNRaRmR”R¢(((s8/usr/lib/python2.7/vendor-packages/pkg/actions/depend.pyR >s"  ) # r $ k( s conditionalsexcludesgroups incorporatesoptionalsoriginsparentsrequires require-any(R¥R Rft pkg.actionsRtpkg.client.pkgdefstclientR/tpkg.fmrit pkg.versiontpkg.client.firmwareRRRBRR (((s8/usr/lib/python2.7/vendor-packages/pkg/actions/depend.pyt s$