Ñò ²7ÈOc @sáddkZddkiiZddkZddkZddki i Z ddk l Z l Z lZddgade ifd„ƒYZd„Zd„Zd „Zd „Zd „Zd „Zd „Zd„Zdd„ZdS(iÿÿÿÿN(t PD_LOCAL_PATHt PD_PROTO_DIRtPD_PROTO_DIR_LISTslib/svc/manifestsvar/svc/manifesttSMFManifestDependencycBs\eZdZdZdZd„Zd„Zed„ƒZ ee d„ƒZ ed„ƒZ RS(c CsÞ||_d}t|tƒo.tii|ƒg}tii|ƒg}nft|tƒoFg}g}g}|D]"} || i |dƒi dƒqt~}nt i dƒ‚t i i||||||dd|ƒdS(s8 See __init__ for PublishingDependency. tt/s/A string or tuple must be specified for 'path'.t smf_manifestt full_pathsN(tmanifesttNonet isinstancet basestringtostpathtbasenametdirnamettupletreplacetlstriptbasetInvalidPublishingDependencytPublishingDependencyt__init__( tselftactionR tpkg_varst proto_dirRt base_namestpathst_[1]tp((s=/usr/lib/python2.6/vendor-packages/pkg/flavor/smf_manifest.pyR1s 3cCs d|i|i|i|ifS(NsSMFDep(%s, %s, %s, %s)(RRt run_pathsR(R((s=/usr/lib/python2.6/vendor-packages/pkg/flavor/smf_manifest.pyt__repr__Ls cCsdt_dt_dS(sUClear our manifest caches. This is primarily provided for test code.N(R Rt instance_mft instance_deps(((s=/usr/lib/python2.6/vendor-packages/pkg/flavor/smf_manifest.pyt _clear_cachePs c Cs|ptidjodSnht_ht_d„}g}x*tD]"}|itiid|ƒƒqHWxAt |ƒD]3}x*tD]"}|itii||ƒƒqˆWq{WxH|D]@}g}tii |||ƒx|D]}ti |ƒqâWq¹WdS(sËBuild our instance_mf and instance_deps dictionaries from the known SMF manifests installed on the current system and those that appear in the proto_dirs. NcSsNxG|D]?}tii||ƒ}tii|ƒo|i|ƒqqWdS(N(R R tjointisfiletappend(t manifestsRtfnamestfileR ((s=/usr/lib/python2.6/vendor-packages/pkg/flavor/smf_manifest.pytfindes R( RR!R R"tmanifest_locationsR&R R R$treversedtwalkt)_SMFManifestDependency__populate_smf_dics(t proto_dirst force_updateR*tmanifest_pathstlocationRR't manifest_file((s=/usr/lib/python2.6/vendor-packages/pkg/flavor/smf_manifest.pytpopulate_cacheWs0      cCsLt|ƒ\}}|otii|ƒn|otii|ƒndS(sªAdd a information information about the SMF instances and their dependencies from the given manifest_file to a global set of dictionaries.N(tparse_smf_manifestRR!tupdateR"(R3R!R"((s=/usr/lib/python2.6/vendor-packages/pkg/flavor/smf_manifest.pyt__populate_smf_dics~s   N( t__name__t __module__R R!R"RRR t staticmethodR#tFalseR4R.(((s=/usr/lib/python2.6/vendor-packages/pkg/flavor/smf_manifest.pyR's  &cCsºd}d}d}|idƒ}t|ƒdjo%|ddjod}|d}nUt|ƒdjo/|ddjod}|d}|d}nttdƒƒ‚|||fS( s~Split an SMF FMRI into constituent parts, returning the svc protocol, the service name, and the instance name, if any.t:iitsvciis FMRI does not appear to be validN(R tsplittlent ValueErrort_(tfmritprotocoltservicetinstancetarr((s=/usr/lib/python2.6/vendor-packages/pkg/flavor/smf_manifest.pytsplit_smf_fmri“s$$ cCs”t|ƒ\}}}g}|dj o&||jo|i||ƒqnCx?|D]7}|i|d|dƒo|i||ƒqUqUW|S(sVSearch a dictionary of SMF FMRI mappings, returning a list of results. If the FMRI points to an instance, we can return quickly. If the FMRI points to a service, we return all matching instances. Note if the dictionary contains service FMRIs, those won't appear in the results - we only ever return instances.R<N(RGR R&t startswith(RBt dictionaryRCRDREtresultstitem((s=/usr/lib/python2.6/vendor-packages/pkg/flavor/smf_manifest.pytsearch_smf_dic§s  cCs·t||ƒ}t|ƒdjo |dSt|ƒdjottdƒ|ƒ‚nt|tiƒ}t|ƒdjo |dSt|ƒdjottdƒ|ƒ‚ngS(s{Given an instance FMRI, determine the FMRIs it depends on. If we match more than one fmri, we raise an exception. iis+more than one set of dependencies found: %s(RLR?R@RARR"(RBR"RJ((s=/usr/lib/python2.6/vendor-packages/pkg/flavor/smf_manifest.pytget_smf_dependenciesºs  cCsktƒ}|it||ƒƒ|it|tiƒƒt|ƒdjottdƒƒ‚nt|ƒS(s Given an SMF FMRI that satisfies a given SMF dependency, determine which file(s) deliver that dependency using both the provided instance_mf dictionary and the global SmfManifestDependency dictionary. If multiple files match, we have a problem.is'cannot resolve FMRI to a delivered file( tsetR6RLRR!R?R@RAtlist(RBR!R'((s=/usr/lib/python2.6/vendor-packages/pkg/flavor/smf_manifest.pytresolve_smf_dependencyÐs  cKsë|idjogtdƒ|ighfSt|idƒpgghfS|it}ti|itƒg}g}tƒ}t |ƒ\}}|djogtdƒ|ghfSxÔ|D]Ì} y-t | ƒ\} } } | djowÇnWn2t j o&} |i tdƒtƒƒqÇnXtƒ}ytt| |ƒƒ}Wn/t j o#} |i tdƒtƒƒnXx |D]}yt||ƒ}Wn5t j o)} g}|i tdƒtƒƒnXt|ƒdjo|i|d ƒqŠt|ƒdjoyt |ƒ\} } } | dj o@|i td ƒh|d 6|d 6| d 6di|ƒd6ƒn|it|ƒƒqŠqŠWqÇWx1|D])}|i t||||itƒƒqžWh|iƒd6}|||fS(s‹Given an action and a place to find the file it references, if the file is an SMF manifest, we return a list of SmfManifestDependencies pointing to the SMF manifests in the proto area that would satisfy each dependency, a list of errors, and a dictionary containing the SMF FMRIs that were contained in the SMF manifest that this action delivers. Note that while we resolve SMF dependencies from SMF FMRIs to the files that deliver them, we don't attempt to further resolve those files to pkg(5) packages at this point. That stage is done using the normal "pkgdepend resolve" mechanism.R)s'%s actions cannot deliver SMF manifestsR sUnable to parse SMF manifest %ss#Problem resolving %(fmri)s: %(err)ss5Problem determining dependencies for %(fmri)s:%(err)ssaUnable to generate SMF dependency on %(dep_fmri)s declared in %(proto_file)s by %(fmri)s: %(err)siisÿUnable to generate SMF dependency on the service FMRI %(dep_fmri)s declared in %(proto_file)s by %(fmri)s. SMF dependencies should always resolve to SMF instances rather than SMF services and multiple files deliver instances of this service: %(manifests)stdep_fmrit proto_fileRBs, R'sorg.opensolaris.smf.fmriN(tnameRAthas_smf_manifest_dirtattrsRRR4RRNR5R RGR@R&tlocalsRMRPR?taddR$RRtkeys(RRtkwargsRRtdepstelistt dep_manifestsR!R"RBRCRDREterrt dep_fmrisRQR'Rt pkg_attrs((s=/usr/lib/python2.6/vendor-packages/pkg/flavor/smf_manifest.pytprocess_smf_manifest_depsãs|               cCsÁg}x´|D]¬}|idƒ}|idƒ}|idƒ}|idƒ}|oc|djoV|djoI|djo<x9|D]-}|idƒ}|o|i|ƒq„q„Wq q W|S( sƒGiven a minidom Element deps, search for the elements inside it, and return the values as a list of strings.t service_fmrittypetgroupingtdeleteRDt require_allttruetvalue(tgetElementsByTagNamet getAttributeR&(RZt dependenciest dependencytfmristdep_typeRcRdRa((s=/usr/lib/python2.6/vendor-packages/pkg/flavor/smf_manifest.pyt__get_smf_dependenciesRs   cCsdyti|ƒ}Wn#tiiitfj otSX|iptS|ii djotSt S(s6Quickly determine if smf_file is a valid SMF manifest.s+/usr/share/lib/xml/dtd/service_bundle.dtd.1( tminidomtparsetxmltparserstexpatt ExpatErrorR@R;tdoctypetsystemIdtTrue(tsmf_filetsmf_doc((s=/usr/lib/python2.6/vendor-packages/pkg/flavor/smf_manifest.pytis_smf_manifesths   c Cs±h}h}yti|ƒ}Wn#tiiitfj od SX|ipdS|ii djodSd }t |t ƒo |}n|i dƒ}x |D]}g}g}t } t } |idƒ} | o0| idƒ od| } |id| ƒnq¢g} xE|iD]:} t | tiƒo!| idjo| i| ƒqqW|it| ƒƒ|i dƒo t} n|i dƒ}x°|D]¨}g}|idƒ}d }|oT|d jo| o t} nd | |f}|i dƒ}|it|ƒƒn|d j o||||<|i|ƒqšqšW| o-| o%d | }|i|ƒ|||s    l     o   q