Vc6@s,ddkZddkZddkZddkZddkZddkZddkZddkZddk Z ddk Z ddk Z ddk Z ddkZddkZddkZddkZddkZddklZddklZeiZddkZddkZddkiiZddkii Z ddk!ii"Z"ddk#ii$Z$ddk%ii&Z&ddk'ii(Z)ddk*ii+Z+ddk,ii-Z-ddk.ii/Z/ddk0ii1Z1ddk2ii3Z3ddk4ii5Z5ddk6ii7i7Z7ddk8i9Z:ddk;i<i=Z>ddk?Zddk@iAZAddkBiCZCddkDiEZFddkGiHZHddkIZddkJiKZLddkMiNZNddkOZddkPiQZQddkRZddkSlTZTddkUlVZVlWZWddkXlYZYddkGlZZZl[Z[dZ\d Z]d Z^d e_fd YZ`dS( iN(tcontextmanager(tglobal_settings(t DebugValues(tIMG_USERt IMG_ENTIRE(tInvalidContentException(tEmptyIt EmptyDicts.org.opensolaris,pkgsvar/pkgt publishertImagec BseZdZdZdZdZdZeee eee ee i ed Z dZ dZedZed Zed Zed Zed Zed ZedZedZeee dZedZdZdZeedZdZdZ dZ!dZ"eedZ#eeedZ$eedZ%dZ&edZ'e eee e e dZ(edZ)d Z*d!Z+d"Z,d#Z-d$Z.d%Z/d&Z0ed'Z1ed(Z2d)Z3d*Z4e5d+Z6eed,Z7eeed-Z8e d.Z9e d/Z:eeed0Z;d1Z<d2Z=d3Z>d4Z?d5Z@eeed6ZAd7ZBd8ZCd9ZDd:ZEd;ZFd<ZGd=ZHd>ZId?ZJe ee5e5eeee5d@ZKee dAZLe ee5e5eeee5dBZMdCZNdDZOedEZPedFZQdGZRdHZSdIZTdJZUe5eedKZVeeedLZWdMZXdNZYdOZZdPZ[dQZ\dRZ]dSZ^dTZ_dUZ`eedVZadWZbdXZcdYZddZZed[Zfed\Zgeeeed]Zhd^Zid_Zjd`Zkee daZle dbZme5edcZne5ddZodeZpedfZqdgZrdhZsediZtdjZuedkZvdlZwdmZxdnZydoZzedpZ{dqZ|edrZ}dsdtZ~duZedvZedwZdxZdyZe dzZd{Zd|Zd}Zd~ZdZdZdZedZee i5dZee i5edZdZe e i5dZdZeee i5dZdZdZdZdZdZe edZdZdZdZdZeedZdZdZdZdZedZRS(sAn Image object is a directory tree containing the laid-down contents of a self-consistent graph of Packages. An Image has a root path. An Image of type IMG_ENTIRE does not have a parent Image. Other Image types must have a parent Image. The external state of the parent Image must be accessible from the Image's context, or duplicated within the Image (IMG_PARTIAL for zones, for instance). The parent of a user Image can be a partial Image. The parent of a partial Image must be an entire Image. An Image of type IMG_USER stores its external state at self.root + ".org.opensolaris,pkg". An Image of type IMG_ENTIRE or IMG_PARTIAL stores its external state at self.root + "/var/pkg". An Image needs to be able to have a different repository set than the system's root Image. For image format details, see section 5.3 of doc/on-disk-format.txt in the pkg(5) gate. itknownt installedtstate_updatingc Cs|o'|djpt| ptn|dj ptd|_d|_d|_t|_| djoti} n| |_ |i djot i i | |_ n|i o7dt ijo'|i it ido tdnd|_||_t|_|id|_||_hdd6|_t|_d|_ti|_d|_d|_d|_d|_ d|_!g|_"d|_#d|_$d|_%d|_&t'i(i)|_*d|_+d|_,d|_-g|_.d|_/t0|_1t0|_2h|_3h|_4d|_5t|_6d|_7d|_8d|_9h| d6|_:t;i<t;i=||_;t>i?||_|o|i@|iA||n| o/|iB|iAdjotCiD|iAn| ot i iE|iAot i iF|iAd} t0t iG|iA} t i iH| o| t0dg8} ntI| d jotCiJ|iAqn|iKd |iAd |d |d tLt iMd||_NdS(NtPKG_NO_RUNPY_CMDPATHsrun.pys? An Image object was allocated from within ipkg test suite and cmdpath was not explicitly overridden. Please make sure to explicitly set cmdpath when allocating an Image object, or override cmdpath when allocating an Image object by setting PKG_CMDPATH in the environment or by setting simulate_cmdpath in DebugValues.s5.11s Build-Releaseitpropertys.zfsitroottimgtypet progtracktpurgei(OtNonetAssertionErrort_Image__alt_pkg_pub_mapt_Image__alt_pubst_Image__alt_known_cattFalset_Image__alt_pkg_sources_loadedtmisct api_cmdpathtcmdpathtostpathtdirnamet_Image__cmddirtenvirontendswithtsept RuntimeErrortlinkedtallow_ondisk_upgradet_Image__upgradedt_Image__init_catalogst_Image__imgdirt _Image__roottattrstblocking_lockstcfgthistorytHistoryt imageplant img_prefixt index_dirtplandirtversiont_Image__read_cache_dirst_Image__write_cache_dirt_Image__user_cache_dirt_incoming_cache_dirt_Image__write_cache_roottpkgtnrlocktNRLockt _Image__lockt_Image__lockfilet_Image__sig_policyt_Image__trust_anchorst_Image__bad_trust_anchorst_Image__boot_archivetsett_userst_groupst _usersbynamet _groupsbynamet_Image__avoid_sett_Image__avoid_set_alteredt_Image__group_obsoletet_Image__actdictt_Image__actdict_timestampt_Image__property_overridest transportt TransporttImageTransportCfgtlit LinkedImaget find_rootRt image_typetapxtImageAlreadyExiststexiststjointlistdirtisdirtlentCreatingImageInNonEmptyDirt_Image__set_dirstTruetumasktaugment_ta_from_parent_image( tselfRtuser_provided_dirRt should_existRtforceR`R&tpropsRtsnapdirRY((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__init__zs                                         !  cCs ||ijS(sReturns a boolean value indicating whether the named catalog has already been loaded. This is intended to be used as an optimization function to determine which catalog to request.(t_Image__catalogs(Ratname((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__catalog_loadedscCs5|io|idjodSh|_t|_dS(sgInitializes default catalog state. Actual data is provided on demand via get_catalog()iN(R'R4RhRR(Ra((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__init_catalogss cOs t||S(N(R (targstkwargs((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytallocscCs|iS(s*The absolute path of the image's metadata.(R)(Ra((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytimgdirscCs|io |iiS(sQA boolean value indicating whether the image is currently locked.(R=tlocked(Ra((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyRpscCs|iS(s*The absolute path of the image's location.(R*(Ra((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR#scCsa|idj o|iS|iiti}|iidd}tii |||_|iS(s,The current signature policy for this image.Rssignature-required-namesN( R?RR-tget_policy_strt imageconfigtSIGNATURE_POLICYt get_propertyt sigpolicytPolicytpolicy_factory(Rattxttnames((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytsignature_policy(s  c Cs|idj o|iSt}|id}|ddjo|d}ntii|i|}tii|}h}|i o/|i o%t |i dt d|i i}n| o0tii|otitd|nh|_|oxti|D]}tii||}tii|oq nytii|}Wn7tiij o%} |ii|t| fq X|ii} |ii| g|i| i|q Wnx3|D]+} | |ijo|| |i| RtEnvironmentErrorRterrnotENOENTtEACCEStUnprivilegedUserErrortfilenametEROFStReadOnlyFileSystemExceptiontrelease(RaRRRtexc((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyRs,    cCs4z|io|iinWd|iiXdS(sUnlocks the image.N(R>RR=R(Ra((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyRs cCsd}d}tiitii|to||to t}n=tiitii|to||to t}n|S(s2Returns the type of image at directory: d; or NonecSstiitii||dotStiitii||dptSx8dD]0}tiitii|||ptSq[WtS(Ns pkg5.imaget cfg_cachetstateR:(sstatespkg(RRtisfileRXR^RRZ(tsub_dtprefixtn((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytis_images    N( RRRRZRXtimg_user_prefixRtimg_root_prefixR(RatdtrvR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyRTs " " c Cs |}tii|}xto|i|}|ttfjol|o>tii|tii|joti|||n|i d|d|d|d|dS|}tii tii |tii }||joti|||qqWdS(NRRtstartdR( RRtrealpathR^RTRRRUtImageNotFoundExceptionR]tnormpathRXtpardir(RaRt exact_matchRRRtoldpath((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyRSs& ' cCs|idjotdnd}|idjo'|idjo d}q]|i}nti|i|id|d|i|_|i oIti |i|i |i i |i|i|iid|_n|idS(sLoad this image's cached configuration from the default location. This function should not be called anywhere other than __set_dirs().sself.root must be setiiR4t overridessuse-system-repoN(RRR$R4Rrt ImageConfigt_Image__cfgpathnameRMR-R't BlendedConfigt get_catalogtIMG_CATALOG_INSTALLEDtget_package_counts_by_pubRoRNt get_policyt_Image__load_publisher_ssl(RaR4((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt __load_configs       c stii|idfd}x|iiiD]}|i}|pq:nx|i|i D]}xdD]}}t ||}|o||}n|pqunt ||tii |i dtiiti|d|i quWqhWq:WdS( sNormalizes publisher SSL configuration data, storing any certificate files as needed in the image's SSL directory. This logic is performed here in the image instead of ImageConfig as it relies on special knowledge of the image structure.tsslc sy%| ptii| odSWn$tj o}ti|nXtiyctiiti |dt i d}||jot i ||nti|tiWn$tj o}ti|nX|S(Nt hash_funci(RRRWRRUt_convert_errorRtmakedirsRXtget_data_digestthashlibtsha1tportabletcopyfiletchmodt PKG_FILE_MODE(tsrcRtdest(tssl_dir(s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytstore_ssl_fileGs      tssl_certtssl_keyitstartN(sssl_certsssl_key(RRRXRoR-t publisherstvaluest repositorytoriginstmirrorstgetattrtsetattrt splitdriveRR#Rtrelpath(RaRtpubtrepotutproptpval((Rs6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__store_publisher_ssl?s&    c Cstii|id}x|iiiD]}|i}|pq+nx|i|i D]}xdD]}t ||}|pqfntii|i dtii |joqfnt ||tii|tii|qfWqYWq+WdS(sShould be called every time image configuration is loaded; ensure ssl_cert and ssl_key properties of publisher repository URI objects match current image location.RRRN(sssl_certsssl_key(RRRXRoR-RRRRRRR1RRtbasename(RaRRRRRR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__load_publisher_ssls$ cCs|i|i|ii|itii|it i }yt i |Wn;t j o/}|itijoti|qnX|io6tidtitifjotidgntiti||_dS(Ns.svc:/application/pkg/system-repository:default(tmkdirst_Image__store_publisher_sslR-twriteRRRRXRRtsysrepo_pub_cache_pathRtremoveRRRRURt is_liveroottsmft get_statetSMF_SVC_TMP_ENABLEDtSMF_SVC_ENABLEDtrefreshRNRORP(Rat cache_pathR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt save_configs&      c Cs|p |i}n|p |i}n||ijo+ddddddddd d d g }n(d d ddddddd d dg }xU|D]M}y titii||Wqtj o}t i |qXqWdS(sCreate any missing parts of the image's directory structure. 'root' is an optional path to a directory to create the new image structure in. If not provided, the current image directory is the default. 'version' is an optional integer value indicating the version of the structure to create. If not provided, the current image version is the default. s cache/indexscache/publishers cache/tmpt gui_cacheR.tlicenses lost+foundRRsstate/installeds state/knowntdownloadtfiletindexR:ttmpN( RoR4tCURRENT_VERSIONRRRRRXRRUR(RaRR4timg_dirstsdR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyRs$         cCs t|_|i oG|tijo4|djo |}ntdti|fn||_||_|it jo t |_ n t |_ t it i||_ tii|oyti}Wntj o}d}nXzKy ti|ti|_Wn$tj o}ti|nXWd|oti|nXn|io|i}|o|intii|i|i |_d|_tii|id|_ |otii!|ioxti"|iD]} | djoqntii|i| } y5tii| ot#i$| nt%i&| Wqtj o}ti|qXqWnA|p9tii!|i ptii|id|_ qn|i'|pNy"t(|i)i*dd|_Wq,t)i+t,fj od|_q,Xn|idjotii|it-} |o|i.|_q(tii!| oXtii|id } tii!| oti/|in d |_|i'q(tii!tii|id od |_|i'q(ti/|in|i|i.jp|id joti/|in|i)i0dd|i|i|i.jo"tii|id d |_1ntii|id |_1tii|id|_2tii|i1d|_3|i4|i|i5_6t7i8tii|iddt7i9dt7i:dti;dt|_<|o|i=ng|_>d|_?d|_@d|_Ad|_BdtiCjo,tiiDtiCd|_@|i@|_BnPdtiCjo?tiiDtiCd|_@|i@|_A|i>iE|i@n|i@o)tii|i@dtiF|_?n|idjo|iG|_Hntii|id |_H|idjo|i@pDtii|id|_Atii|iAdtiF|_?n|i>iEtiiDtii|idn7|i?p,tii|id dtiF|_?nytiI|i?Wntj o}|iJtJiKjp|iJtJiLjotMiNddtiF|_AtiiDtii|iAdtiF|_?|i>iE|iAtOiPt#i$|iAdtQqGnXtiR|i?|iS|iTdtQd|tU|i)tViWoItViX|i)|iY|iZi[|i|i |i)i\d|_)nx2|i)i]D]$} |i^| i_| _`d| _aqWt}x_|i)ibD]Q} |i^| i_| _`y|ic| d ttQ}Wq tidj oq Xq W|o|ien|i)if|ig|o|ihn|iiij|ikdS(!NslLive root image access is disabled but was attempted. liveroot: %s image path: %sis pkg5.imageRRtimageR4itcacheitcatalogiRRtplanRt set_lockstrt get_lockstrt failure_exct provide_mutext PKG_CACHEROOTt PKG_CACHEDIRs incoming-%diRRs download-%d-t ignore_errorsRRsuse-system-repotrebuild(lRR't_Image__allow_liverootRtliverootRR$R*ttypeRRR1RRNRORPRRRZtgetcwdRtchdirRRURRoRpRRXRR)R4RRWRYtshutiltrmtreeRRt_Image__load_configtintR-RttPropertyConfigErrort ValueErrorRRtUnsupportedImageErrort set_propertyt_Image__tmpdirt _statedirR3tupdate_index_dirR.troot_dirtlockfiletLockFiletclient_lock_set_strtclient_lock_get_strRR>RR5R8R7R6R9R!RRtgetpidt temporary_dirt_Image__action_cache_dirRRRRttempfiletmkdtemptatexittregisterR^t removedirsR(t update_formatt isinstanceRrRRRRRRt modified_pubst_get_publisher_meta_rootRt meta_roottlast_refreshedt removed_pubstremove_publisher_metadatatPermissionsExceptiont_Image__rebuild_image_catalogst write_sys_cfgRRR%t _init_roott_Image__avoid_set_load(RaRRRRRtcwdRtrelocktentrytepathtpub_roott cache_rootRtchanged((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt __set_dirssN !              #                    &                cCsY|i|ijogt|_|id}ttid}tii |o't i d|dtd|d|nt S|pt i}n|i|it|_|it jotS|id jo>|itjo.|i o|i ot |_tSn|idd|iiz|i|d|Wd QX|itS( sTransform the existing image structure and its data to the newest format. Callers are responsible for locking. 'allow_unprivileged' is an optional boolean indicating whether a fallback to an in-memory only upgrade should be performed if a PermissionsException is encountered during the operation. 'progtrack' is an optional ProgressTracker object. s.oldtws rm -rf %stshelltstdouttstderrs update-formatRN(R4RR^R'RotopenRtdevnullRRWt subprocesstPopenRtprogresstNullProgressTrackertcache_catalogs_startt_Image__upgrade_catalogsR&RRRRtis_zoneRt__exit__t __enter__t_Image__upgrade_image_formattcache_catalogs_done(RaRRt orig_roottnullf((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR3s2             csidjodSfddi}hfd}xFti|D]5}dti|}tii|}||q\Wti i dt di d t }ti i dt di d t }h}g} xiD]} ytii i| id t d | i} | i| | fxB| iD]4}|i|id} t| |i||i|i}|\}}|i}|i}|iWnltj o`|o0|d}|i}dtii|f}ndtiiif}|}nX|pt |S(szFind the pkg's installed file named by filepath. Return the publisher that installed this package.is%s_%s( Rt readlineststriptcloseR R:tfmrit PREF_PUB_PFXtget_highest_ranked_publisherR(tfilepathtftflinesR4Rtnewpub(Ra(s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytinstalled_file_publisher@s&         s%s/state/installedcsCdi|if}|}|i|||it i i |i|id}|i|t|i|fqqWn|S(snReturns a list of tuples of the form (dir, readonly, pub, layout) where 'dir' is the absolute path of the cache directory, 'readonly' is a boolean indicating whether the cache can be written to, 'pub' is the prefix of the publisher that the cache directory should be used for, and 'layout' is a FileManager object used to access file content in the cache. If 'pub' is None, the cache directory is intended for all publishers. If 'layout' is None, file content layout can vary. it inc_disabledRN(RR4tfltV1LayoutR5R^R6RRRRuRRRXR7R9R(Rat file_layoutRtcdirtcdirsRtfroottreadonly((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt get_cachedirsDs2 )         cCs|iS(N(R(Ra((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytget_rootxscCs<|i|ii}|djp| o|S|idS(s5Return the UTC time of the image's last state change or None if unknown. By default the time is returned via datetime object. If 'string' is true and a time is available, then the time is returned as a string (instead of as a datetime object).s%Y-%m-%dT%H:%M:%S.%fN(t_Image__get_catalogRRRtstrftime(RatstringR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytget_last_modified{s c #s|ipti|inh}|iotd|iD}x|iiD]}yZ|ii|}|i pwYnt i |}t |_ |i }|i |iWntj o||}nX|||s c3s*x#|]}|jo |VqqWdS(N((RR(R(s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pys s (R-RUtImageCfgEmptyErrorRRtdictRRRtdisabledtcopyRRt reset_originst reset_mirrorstKeyErrorRRyRtextendR6R7RN( RaRtalt_pubst alt_src_pubstpfxtimg_pubtnew_pubRRRR((Rs6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyRus@      5 cCs|idt}tg}tdt|D]*}|||i|||itffq/~}x9|iD]+}t|}|i ||ttfqrW|S(sReturn dictionary of configured + enabled publishers and unconfigured publishers which still have packages installed. Each entry contains a tuple of search order index starting at 0, and a boolean indicating whether or not this publisher is "sticky", and a boolean indicating whether or not the publisher is enabledRi( tget_sorted_publishersRRtrangeR[RtstickyR^tget_installed_pubsR(RaRRtitretR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytget_publisher_rankss I  cCsn|iidd}|o|id|dSx|iD]}|SWx|iD]}ti|SWdS(s$Return the highest ranked publisher.Rspublisher-search-orderRiN(R-RtRRuRRt PublisherR(RaRR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR`s    cCs3|p|i}ng}x|D]}|i}x|iD]}|ioOy#ti|id|id|Wqtij o}|i |qXn|i ogy<t i i |i p"ti|i d|d|nWq tj o}ti|q Xq=q=Wq$W|oti|ndS(sValidate the certificates of the specified publishers. Raise an exception if any of the certificates has expired or is close to expiring.RturiRN(RuRRRRtvalidate_ssl_certRRUtExpiredCertificateRRRRRWt NoSuchKeyRRtExpiredCertificates(RaRterrorsRtrRR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytcheck_cert_validitys8           cCsMxF|idtD]2}||ijp|o||ijotSqWtS(sReturns a boolean value indicating whether a publisher exists in the image configuration that matches the given prefix or alias.R(RuR^RtaliasR(RaRRR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt has_publisher s  c Cs|pti}n|idiizL|id|d|}|ii|i|i |d||i WdQXdS(sPRemoves the publisher with the matching identity from the image.sremove-publisherRRRN( RPRQRRURVRR-tremove_publisherRR:R(RaRRRR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyRs cCs td|id|DS(sReturn a dictionary of configured publishers. This doesn't include unconfigured publishers which still have packages installed.css"x|]}|i|fVqWdS(N(R(RR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pys *s R(RRu(RaR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytget_publishers$sc Cs|id|}|iidd}t|t|}g}|D]"}||jo|||qHqH~g}t|D]}|||q~}|S(sReturn a list of configured publishers sorted by rank. This doesn't include unconfigured publishers which still have packages installed.RRspublisher-search-order(RR-RtRCtsorted( RaRRRytunrankedRRt_[2]R((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR.s   "%cCsx{|idtD]g}|o||ijo|S|o||ijo|S|o"|io|ii|o|SqWtit|||dS(NR( RuR^RRRt has_originRUtUnknownPublisherRz(RaRRtoriginR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyRIs cCs|ii||dtdS(sMoves publisher "being_moved" to before "staying_put" in search order. The caller is responsible for locking the image.tafterN(R-tchange_publisher_search_orderR(Rat being_movedt staying_put((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytpub_search_beforeTscCs|ii||dtdS(sMoves publisher "being_moved" to after "staying_put" in search order. The caller is responsible for locking the image.R N(R-R R^(RaR R ((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytpub_search_after]scs|i}| p |iodSfd}i|id|it|_|i|ii_|i |ii_ |iii dS(Ncs]|dd}ti|jo tdfSid|}|dj o tdfSt|fS(NRoRnR(R}RRRt get_entryR^(talt_kcatRt new_entryRnt img_entry(timg_kcat(s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt merge_checkos   tcb( RRRRRR^RNR-t pkg_pub_mapRRt reset_caches(RaRRR((Rs6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__apply_alt_pkg_sourcesfs    cCsW|ipdSxA|iD]6}y|ii|i}Wqtj o qqXqWdS(swPrivate helper function to cleanup package certificate information after use of temporary package data.N(RR-RRR(RaRtipub((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__cleanup_alt_pkg_certss  cCs|pa|id|_d|_d|_t|_d|ii_ d|ii_ |iii dS|io|in|\}}}}||_||_||_dS(sSpecifies an alternate source of package metadata to be temporarily merged with image state so that it can be used as part of packaging operations.N( R(RRRRRRRNR-RRR(Rat alt_sourcesRRRtignored((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytset_alt_pkg_sourcess         cCs|p|id|d|}n|ii|ptitd|n|i}d}x>|D]6}||jodS|ii|o |}PqlqlW|ptdd|t f|ii |i |i dt dS(sKSets the preferred publisher for packaging operations. 'prefix' is an optional string value specifying the name of a publisher; ignored if 'pub' is provided. 'alias' is an optional string value specifying the alias of a publisher; ignored if 'pub' is provided. 'pub' is an optional Publisher object identifying the publisher to set as the preferred publisher. One of the above parameters must be provided. The caller is responsible for locking the image.RRs9Publisher '%s' is a system publisher and cannot be moved.Ns&Expected %s to already be part of the ssearch order:%sR ( RR-tallowed_to_moveRUtModifyingSyspubExceptionR~RRRtranksR RR(RaRRRRtrelativeR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytset_highest_ranked_publishers$    cCsE|idiiz$|iid|||iWdQXdS(Ns set-propertyR(RRURVR-R"R(Rat prop_namet prop_value((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR"scCsLh|d6}|idiiz|ii||iWdQXdS(NRs set-property(RRURVR-RR(Rat properties((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyRs cCs|iid|S(NR(R-Rt(RaR#((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyRtscCs9y|iid|tSWntij otSXdS(NR(R-RtR^t ConfigErrorR(RaR#((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt has_propertys cCsB|idiiz!|iid||iWdQXdS(Nsunset-propertyR(RRURVR-tremove_propertyR(RaR#((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytdelete_propertyscCsE|idiiz$|iid|||iWdQXdS(Nsadd-property-valueR(RRURVR-tadd_property_valueR(RaR#R$((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR*scCsE|idiiz$|iid|||iWdQXdS(Nsremove-property-valueR(RRURVR-tremove_property_valueR(RaR#R$((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR+scCs|i ptii|i odStii|idjodSyti|iWn$tj o}ti |nXdS(sODestroys the image; image object should not be used afterwards.NR{( RoRRRWtabspathRRRRUR(RaR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR{s"cCs7|ipti|in|iidiS(NR(R-RURRt get_indextkeys(Ra((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR% s c Csb|idiizA|i|d|d|dtdtd|d|d|d tSWd QXd S( s`Adds the provided publisher object to the image configuration. 'refresh_allowed' is an optional, boolean value indicating whether the publisher's metadata should be retrieved when adding it to the image's configuration. 'progtrack' is an optional ProgressTracker object.s add-publisherRRt approved_cast revoked_cast search_aftert search_beforet search_firstt unset_casN(RRURVt_Image__add_publisherR( RaRRRR/R0R1R2R3R4((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyRs    cCs|i|d|dt|i}|o|ioy7|ii||i|id|gd|Wqtj o-}|i p|i i |i nq|i p|i i |i nqXndS(NRRR( R:RRRRNtvalid_publisher_testtvalidate_configRRtsys_pubR-RR(RaRRRRR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__update_publisher_catalogs#s"     c Cs| o| p'| o| p| o| pt|i|ijoti|inx|iiiD]o} |i | i jpC|i | i jp0|i o9|i | i jp|i | i joti |qsqsW|pt i }n|i|i |_|i|_y|id|gWn+tij o} tit| nX||ii|i <|i|d|d|x|D]} y;tii| } t| d} | i}| iWnJtj o>} | itijoti | nti!| nX|i"|dt#qWx|D]}|i$|qBWx| D]}|i%|q`W|o|i&d|i n=|o|i'|i |n|o|i(|i |n|i)dS(sVPrivate version of add_publisher(); caller is responsible for locking.RRRtrbtmanualRN(*RR4RRUtImageFormatUpdateNeededRR-RRRRtDuplicatePublisherRPRQR6R7RNRtExpiringCertificatetloggerRRt!_Image__update_publisher_catalogsRRR,RLtreadR]RRRtMissingFileArgumentExceptionRtapprove_ca_certR^trevoke_ca_certt unset_ca_certR"R RR(RaRRRR/R0R1R2R3R4RRtcatfhRthsh((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__add_publisherAsd   c +sByid|i}Wntij o d}nXii|i}|i|ii |dt }t |i ddi }|o|p|idjoy2|i||i|iiidWqMtij o)}||_|i|gggfVqMtij o}d|gggfVqMXn|i|iddfd } i } iiig} iid d } | o-i| } | i| | i| nxb|iD]T}|i|idd|id jp|id jo| | oqng}g}g}|i| d|io%|id||\}}}n|i| d|iom|i ob|i i!dd}|dj o<t"i#i$t"i#i%i&|o|it'dqnq|p|p|o||||fVqqWdS(sGenerator that returns a tuple of the form (action, errors, warnings, info) if there are any error, warning, or other messages about an action contained within the specified package. Where the returned messages are lists of strings indicating fatal problems, potential issues (that can be ignored), or extra information to be displayed respectively. 'fmri' is the fmri of the package to verify. 'progresstracker' is a ProgressTracker object. 'kwargs' is a dict of additional keyword arguments to be passed to each action verification routine.Rtignore_excludest signaturetexcludestignorescheck-certificate-revocationtnitemsics|iid}| p|iijotSii|id}ii|id}|iid}|otii|d}n|iid}||joti ||S(s#Helper function to determine if the mediation delivered by a link is allowed. If it is, then the link should be verified. (Yes, this does mean that the non-existence of links is not verified.) tmediatorR4timplementationsmediator-versions5.11smediator-implementation( R+RyR-t mediatorsR^R:R4tVersiontmedtmediator_impl_matches(tactROtcfg_med_versiont cfg_med_implt med_versiontmed_impl(Ra(s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytmediation_alloweds    Rt dehydratedRthardlinkRRRsFile should not existN((RRRURRRztcombinetplan_add_progresstPLAN_PKG_VERIFYt get_manifestR^tlisttgen_actions_by_typet list_excludesRitprocess_signaturest gen_actionsR|R-RtSigningExceptionRtsigtInvalidResourceLocationRt allow_actionRttget_dehydrated_exclude_funcRt include_thistverifyt refcountableR+RyRRRWRXRR~(RaR^tprogresstrackerRmRtsig_poltmanftsigsRRZRLtvardrate_excludest dehydratetfuncRURtwarningstinfoR((Ras6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyRlsp           cCsl|dj o|iii|n|dj o||i_n|dj o||i_n|idS(supdate variants in image configN(RR-RRRRQR(Rat new_variantst new_facetst new_mediators((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytimage_config_updates   c Cs;y |ii|d|d|SWntj otSXdS(sVerify a manifest. The caller must supply the FMRI for the package in 'fmri', as well as the path to the manifest file that will be verified.tmfstpathRN(RNt_verify_manifestRR(RaR^R{talt_pub((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__verify_manifest s cCsa|i|}tii|}| p/|i|p|id|d|d|o|StS(scCheck to see if the manifest for pfmri is present on disk and has the correct hash.R^R{R}(RRRRWtis_pkg_installedt_Image__verify_manifestR(RaRR}Rton_disk((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt has_manifest scCsF|i|ijo&tii|id|idtS|i|S(s)Return path to package license directory.RR( R4RRRRXRoRfR^R(RaR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytget_license_dir! scCs6x/|iD]!}|i|ijo|iSq WdS(sReturns the publisher for the FMRI of an installed package or None if the package is not installed. N(RRhRR(RaRRb((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__get_installed_pkg_publisher. s   cCs|ip"|i}|i||_n|ipt|i|ijo|i|i}n |i}ti i |d|i S(s0Return path to on-disk manifest cache directory.R:( RRt#_Image__get_installed_pkg_publisherRR4Rt_get_publisher_cache_rootRoRRRXRf(RaRR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR7 s   cCs|ip"|i}|i||_n|ipt|i|ijo;tii|i |i}tii|d|i Stii|i |dS(s%Return path to on-disk manifest file.R:tmanifest( RRRRR4RRRRXR6RfR(RaRR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyRF s  c Csy|i|d|p tnti||i|d|d|i|}|o]d}|o |i}ny|ii ||d|Wqt i t i fj oqXnWn1tj o%|ii |||d|}nX|S(siFind on-disk manifest and create in-memory Manifest object.... grab from server if neededR}RLtpathnametalt_repoRN(RRRtFactoredManifestRRRRRNttouch_manifestRURtTransportErrorR`(RaR^RLtintentR}RR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__get_manifestV s*     c Cs|o t}n|iii|iiig}y%|i|d|d|d|}WnGtij o }n.ti i j o}ti |gnX|S(sreturn manifest; uses cached version if available. ignore_excludes controls whether manifest contains actions for all variants If 'ignore_excludes' is set to True, then all actions in the manifest are included, regardless of variant or facet tags. If set to False, then the variants and facets currently set in the image will be applied, potentially filtering out some of the actions.RLRR}( RR-RRiRt_Image__get_manifestRUtActionExecutionErrorR:tactionst ActionErrortInvalidPackageErrors(RaR^RJRR}RLtmR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR`v s  c#Cs|i|ijoti|in|i|i}|i|i}t}t}h}x|D]\}} || joqln|o|i |n| o|i | n|o0| o)t |i | i dh||i?|Wn;t@j o/}|iAtAiBjotiC|qnXyt9i:t9i;i<|WnnX|i|i3qW|i#|i3|i|iD|iE}zyx||if||iffD]\}}t9i;iF||}|i|iDtGiH|iI||i|iD||_I|iJd ||i|iD|iK|i|iDq.W~~|iL|i|iDxxt9iM|iND]d}|i|iDt9i;iF|iN|}t9i;iO|o#t>iP|t9i;iF||qqW|iQ|iNd tR} t>iS||iN|i|iDtTiU| tR|i|iDWnt@j o}tV|tTiWotX|iYd t joud }!xY|iYD]N}"xE|"D]=} tX| tZjo|!d| d7}!q|!d| 7}!qWqWti[|!ntiC|nXWd|iLt9i;i\|otTiU|tRnX|i#|iDdS(sSets the recorded installed state of each package pair in 'pkg_pairs'. 'pkg_pair' should be an iterable of tuples of the format (added, removed) where 'removed' is the FMRI of the package that was uninstalled, and 'added' is the package installed for the operation. These pairs are representative of the destination and origin package for each part of the operation.RoRns last-installs last-updateRcssx|]}|iVqWdS(N(R(RRb((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pys  s RRtgoaltpfmrist full_pathiRs%s iN(]R4RRUR<RRRRRCtaddRRRytuniont job_startt JOB_STATE_DBtjob_add_progresstremove_packagetdiscardR}RtpopRR:R tnow_to_basic_tstPKG_STATE_ALT_SOURCERR~tPKG_STATE_UNINSTALLEDtPKG_STATE_UNKNOWNtImagePkgStateErrorRat update_entryRtjob_doneRRRxRRR-RR.RRt RepositoryR5Rt_Image__cleanup_alt_pkg_certsRt JOB_PKG_CACHER[RRRt clear_cacheRtrmdirRRRRRRRRRtJOB_IMAGE_STATER,RXRtcopytreeR7RRR(RYR$RRtsalvageR^RRRR4tErrorRRlttuplet UnknownErrorsRW(#Rat pkg_pairsRRRtaddedtremovedtupdatedtadd_pkgtrem_pkgtcomboRRBRRntcur_timet last_installtcfgpubstinstpubstaltpubstnewpubsRtnpubtmcdirtmpathRRRRitcpathRtfptorig_state_roottmsgtelist((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytupdate_pkg_installed_state sP                                        cCsx|iptdn|ii|}|p |i|}||i||i|i}x%|i|iD]\}}|dSWdS(sReturns an fmri of the installed package matching the package stem of the given fmri or None if no match is found.iN(RRtfmris_by_versionRhR(RaRRtverRx((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytget_version_installed s   c Cs|ipt|i|i}|i|}|djodSy|dd}Wntj odSX|pdS|id|i}ti|i }g}|i D]!}|i |jo ||qq~} | pdS| |_ |S(sReturns the repository object containing the origins that should be used to retrieve the specified package or None if it can be retrieved from all sources or is not a known package. NRotsourcesR( RRRRRRRRRRRR( RaRRRBtslistRRRtotnorigins((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt get_pkg_repo s& $ cCs?|i|i}|i|}|djogS|ddS(s:Returns the list of states a package is in for this image.RoRnN(RRRR(RaRRRB((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt get_pkg_state s  cCsw|i|ip|i|i}n|i|i}|i|}|djotS|dd}ti|jS(s^Returns a boolean value indicating whether the specified package is installed.RoRnN( t_Image__catalog_loadedRRRRRRR}R(RaRRRBRn((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR s cCsu|o,|iii}|i||i}n|iii}|dj o |i}n|iii}||gS(s Generate a list of callables that each return True if an action is to be included in the image using the currently defined variants & facets for the image, or an updated set if new_variants or new_facets are specified.N(R-RRRRiRR(RaRwRxtnew_varstvar_calltfac_call((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyRc* s    cCs|iiiS(s, return a copy of the current image variants(R-RR(Ra((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt get_variants= scCs|iiiS(s* Return a copy of the current image facets(R-RR(Ra((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt get_facetsA scCstii|i|iS(sbReturn the path to a flag file indicating that the image catalog is being updated.(RRRXR$t_Image__STATE_UPDATING_FILE(Ra((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__state_updating_pathnameE scCs|i}tii|otSti}y!t|dti||Wnjt j o^}|i t i jot i |in|i t ijot i|innXtS(sCalled when we start updating the image catalog. Normally returns False, but will return True if a previous update was interrupted.RH(t_Image__state_updating_pathnameRRRWR^RRRLRRRRRUR;RRRR(RaRt file_modeR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__start_state_updateJ s   cCs|i}yti|Wnjtj o^}|itijoti|in|iti joti |innXdS(s2Called when we're done updating the image catalog.N( RRRRRRRUR;RRR(RaRR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__end_state_updatee s c0Cs |idjoti|in|pti}n|it|i}t i i |i\}}|i i dd|d|tii}|i|i}|i}xti|iD]k}||ijoqntii|i|} tii| o#ti| tii||qqWtiidtdtii||i dt!} g} |D]} | | i"| ifq}~ } h}xd"|fg| D]\}}x|i$dtd |o |gpt%D]T}|i&|i'd#\}}|i|jo#|it(|if||i'd| d|d|}*n|*d"j ox|*dD]}+|+i1dpqvnd|+jp d|+jpqvnyti?i@|+},Wnti?iAj o qvnX|,i:diBdjoqvn|,i:ddjo|i4t*iCqv|,i:ddjo1|,iD|d| pqvn|i4t*iEqvqvWn||(d <|!i3d |d|d| d|d||'o,|"i3d |d|d| d|d|qqWqlWg}-x|iFD]}|i0|dt}.| i0|}!|i0|}"|i1d}#d"}(x|.i)D]\}}|\} }}| |jp9||| jp(||| |jp|| ||oqWn|#o|d }(tG|(d }|iHt*i5|i&|d%\}}| p|d"j o!||jo|iHt*i8n"|d"j o|i3t*i8nt||(d | |fD]0}tKiL|iM|iNd |-|iOq W|iP|id!t}/tiQ||itRiS|/t|iT|iU|i iVd"S(&sVRebuilds the image catalogs based on the available publisher catalogs.isrebuild-image-catalogsRRRjR7RltlastRc ssNxG|]@\}}x1|iD]&}||||i|dtfVqWqWdS(t must_existN(tpartstget_partR^(RRRRi((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pys s  RoRnis catalog.base.scatalog.dependency.CRtop_timeRtstemRs Build-Releaset constraintRRCs pkg.obsoletes pkg.renamedtvaluettrueRiRR4RRN(NN(NN(NN(WR4RUR<RRPRQRRRaRuRRRR.RtdatetimetutcnowRRR,RRYR$RRRXRRRR:R RsR^RRRRRxRRyRhRt tuple_entriesR}RRRcRtget_frozen_listRRt iteritemsRRR~RRRRRR+t is_successortCONSTRAINT_AUTOtPKG_STATE_FROZENRRtfromstrRtlowertPKG_STATE_OBSOLETERktPKG_STATE_RENAMEDRRCRR^RrRRR7RRRRRRR(RXR(0RaRtpublistRRRtold_icatRRRRRRRRRRRbRtsnvertspartst inst_stemsttRBRnRRRRLRt frozen_pkgsRitsparttnkparttniparttbasetcat_vertdptsentryR Rtf_vertdpenttaRUt final_fmristipartR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__rebuild_image_catalogsv sr    ' -   %    ;                            cCs|idjoti|in|pti}ntii|i\}}|i i dd|d|g}|p+g}|i D] } || q~}n|p|i d|dSx|D]x} | } t | tip|id| } n| io,ti| } |i id| | n|i| qW|p|i id t idSy|id |Wn+tij o} tit| nXy|iWn+tj o} |i id| nX|it|d |g} d } t}|i }x|D]} | d 7} |i!| zy-| i"d |d|d|o t#}nWnYti$j o} | i| | fPn/ti%j o} | i| | fw,nXWd|i&| X|i'| i(q,W|i)|o|i d|n |i*| o8ti+| | t|} |i id| | n|p|i id t idS|i idS(sRefreshes the metadata (e.g. catalog) for one or more publishers. Callers are responsible for locking the image. 'full_refresh' is an optional boolean value indicating whether a full retrieval of publisher metadata (e.g. catalogs) or only an update to the existing metadata should be performed. When True, 'immediate' is also set to True. 'immediate' is an optional boolean value indicating whether the a refresh should occur now. If False, a publisher's selected repository will only be checked for updates if the update interval period recorded in the image configuration has been exceeded. 'pubs' is a list of publisher prefixes or publisher objects to refresh. Passing an empty list or using the default value implies all publishers.isrefresh-publishersRRRNRRtresultRRiit immediate(,R4RUR<RRPRQRRRR.RRuR<R4RRRRtDisabledPublisherRRtRESULT_NOTHING_TO_DORR>R?RRRRt refresh_startR[RCt_Image__start_state_updatetrefresh_start_pubRR^R;t ApiExceptiontrefresh_end_pubRRt refresh_donet_Image__end_state_updatetCatalogRefreshException(RaRR RRRRtpubs_to_refreshRRRRtfailedttotalt succeededR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR s +               cCs|idjotSdS(NiR (R4R(Ra((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt_get_publisher_meta_dir scCstii|idd|S(NR R(RRRXRo(RaR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR scCstii|i|i|S(N(RRRXRoR(RaR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR6# scCs[|idjo*|i|o|id|ndSg}|iD]-}|i|ijo||i|qKqK~}|p|inyxwti|i D]c}|djoqnti i |i |}ti i |ot i|qti|qWg} |D]} | ti i| q~ } ti i |i d} xti| D]} ti i | | }|| jot i|qhnxJti|D]9}ti i ||}||joti|qqWqhWt i|i|idtWn$tj o} ti| nX|o|id|ndS(sRemoves the metadata for the specified publisher object, except data for installed packages. 'pub' is the object of the publisher to remove the data for. 'progtrack' is an optional ProgressTracker object. 'rebuild' is an optional boolean specifying whether image catalogs should be rebuilt after removing the publisher's metadata. iRNR:R(R4tremove_meta_rootR<RRRRRRYR7RRXRZRRRRRRR^RRUR(RaRRRRRbtexcludedRBRRRtexdirstmroottpdirtproottmnameR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR:' sR    0  -      ccsc|i|i}xJ|idtD]6}|o$d|didddVq%n|Vq%WdS(sA generator function that produces FMRI strings as it iterates over the list of installed packages. This is faster than gen_installed_pkgs when only the FMRI string is needed.tobjectsspkg:/%siR{iiN(RRRxRtsplit(RatanarchyRRb((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytgen_installed_pkg_namesv sccs>|i|i}x%|id|d|D] }|Vq+WdS(s3Return an iteration through the installed packages.RtorderedN(RRRx(RaRR(RRb((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR scCsL|i|i}|i|ijpttd|id|DS(s(Return the number of installed packages.css"x|]\}}}|VqWdS(N((RRt pkg_countt_ignored((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pys s R(RRt package_counttpackage_version_countRtsumR(RaRR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytcount_installed_pkgs s ccs|i|i}|i}x|iD]{}xr|i|tiiigd|D]L}|i djo6|i ddjo"||i |i di fVqVqVWq+WdS(sReturn an iteration through all the tracked pkg stems in the set of currently installed packages. Return value is group pkg fmri, stemRLtdependRtgroupR^N( RRRcRxtget_entry_actionsR:R Rst DEPENDENCYRiR+t strtofmriRh(RaRRLRbR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytgen_tracked_stems s   $ c Cs)|pti}nd|_d|_tii|id}tii|id}tii|id}|i }g}h}ddk l }l } |i |ix|iD]} |i|i|i| dt} x| id|D]} | ipqn| i||| i| i| i| | f|i| ih|| ii| i| ig|| i| i| ii| | fqWqW|i|iyjh} |idt\}}|idt\}}|idt\}}ti|d }ti|d }ti|d }tt i }|i!d ||i!d ||i!d dd|i"}}}d }xM|oEt#|dd jo|i|in| |}|d\}} | i| i}| i|jp ||jo|djo1|djpt$|d7}| i}|}q|d jpt$|i!d||||f||f| ||f<| i||i"}}}d}n |d7}|i!d|| fqW|dj os|dj pt$|dj pt$|d jpt$|i!d||||f||f| ||fs N(RRRXR-RLRURVR`RaRRCRRR(RaRRRGR4R((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt_load_conflicting_keyss& c cs|o|djo t}n|i}x|iD]}|i|}t}xG|i|d|D]0}|o|i|idn||fVqkW|oXti i i }xF|i |D]1} | |jo|d| dd|fVqqWq7q7WdS(sIterates through the installed actions of type 'atype'. If 'implicit_dirs' is True and 'atype' is 'dir', then include directories only implicitly defined by other filesystem actions.tdirRLRtimplicitRN( RRcRR`RCRbRR+R:Rt directorytDirectoryActiontget_directories( Ratatypet implicit_dirsRLRRtdirsRUtdaR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytgen_installed_actions_bytypes&     cCs|i|i}|iS(s`Returns a set containing the prefixes of all publishers with installed packages.(RRR(RaR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyRscCstii||idS(Ns Build-Release(R:R^RrR+(Ratmyfmri((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR3scCstii||idS(Ns Build-Release(R:R^tMatchingPkgFmriR+(RaRx((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytstrtomatchingfmris cCsF|ii|d}|dj o|Sti||i|itjS(N(RFRyRRtget_user_by_nameRRR(RaRituid((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR{s  cCsLy#ti||i|itjSWn"tj o|o|SnXdS(N(Rtget_name_by_uidRRRR(RaR|t returnuid((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR}scCsF|ii|d}|dj o|Sti||i|itjS(N(RGRyRRtget_group_by_nameRRR(RaRitgid((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyRs  cCsLy#ti||i|itjSWn"tj o|o|SnXdS(N(Rtget_name_by_gidRRRR(RaRt returngid((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyRsRcCsT|i|ijo"tii|id||_ntii|i||_dS(sSince the index directory will not reliably be updated when the image root is, this should be called prior to using the index directory. R N(R4RRRRXRoR2(Ratpostfix((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR% scCsti|itdS(sbClean up any downloads that were in progress but that did not successfully finish.N(RRR8R^(Ra((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytcleanup_downloadsscCs|iitipdSg}xX|iD]J\}}}}|p|io|i|ioq.n|i|q.W|pdS|pti }n|i |i dt |x.|D]&}t i|t|i|i qW|i|i dS(s'Delete the directory that stores all of our cached downloaded content. This may take a while for a large directory hierarchy. Don't clean up caches if the user overrode the underlying setting using PKG_CACHEDIR or PKG_CACHEROOT. NR(R-RRrtFLUSH_CONTENT_CACHERR7RRRPRQRRR[RRR^RR(RaRRRRRtlayout((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytcleanup_cached_contents& cCs2|i|io|i|idd}ntii|o)tii|ditii}ntii tii |i d|dt i d}tii|}tii|pti|ntii tii |i|}ti|||p|i|iddn|S(sCalled when unexpected file or directory is found during package operations; returns the path of the salvage directory where the item was stored. Can be called with either image-relative or absolute (current) path to file/dir to be salvaged. If full_path is False (the default), remove the current mountpoint of the image from the returned directory pathRiis lost+foundt-s%Y%m%dT%H%M%SZ(RRtreplaceRRtisabsRtlstripR#RRXRoR?RRRWRRtmove(RaRRtsdirtparenttorig((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR<s ) $cCsptiitii|i|}xEti|D]4}titii||tii||q4WdS(s}Called when recovering directory contents to implement "salvage-from" directive... full_dest_path must exist.N(RRRRXRRYRR(Rat local_spathtfull_dest_patht source_patht file_name((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytrecovercs $c Cs+yti|iWnWtitifj o?tidd|_ti t i |idt |i SXy0tid|i}ti|ti|SWntj oz}|itijp|itijo<tidd|_ti t i |idt |i Sti|nXdS(sCreate a temp directory under the image directory for various purposes. If the process is unable to create a directory in the image's temporary directory, a replacement location is found.Rspkg5tmp-RRnN(RRR#RUR;RR.R/R0R1RRR^R,RRt PKG_DIR_MODERRRRR(RatrvalR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR,ks&  &  c CsTyti|iWn]titifj oEtidd|_ti t i |idt |i d|SXy7tid|i\}}|oti|nWntj o}|itijp|itijoBtidd|_ti t i |idt |i d|Sti|nX|o|S||fSdS(s7Create a temporary file under the image directory for various purposes. If 'close' is True, close the file descriptor; otherwise leave it open. If the process is unable to create a file in the image's temporary directory, a replacement is found.Rspkg5tmp-RR]RnN(RRR#RUR;RR.R/R0R1RRR^R=tmkstempRR]RRRRR(RaR]tfdRiR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR=s, & c Csg}t}td|iiD}xN|D]F\}}|i|jo*|i|i|i||fq8q8Wt}t|djog}t} xj|D]b\}}|dpqn|dt i jo t }n| i|i|i||fqW|}| }n|ot|djotg}t} xR|D]J\}}|dt i jo*| i|i|i||fqWqWW|}| }n||fS(s*Attempts to eliminate redundant matches found during packaging operations: * First, stems of installed packages for publishers that are now unknown (no longer present in the image configuration) are dropped. * Second, if multiple matches are still present, stems of of installed packages, that are not presently in the corresponding publisher's catalog, are dropped. * Finally, if multiple matches are still present, all stems except for those in state PKG_STATE_INSTALLED are dropped. Returns a list of the filtered matches, along with a dict of their unique names.cssx|]}|iVqWdS(N(R(RR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pys s it in_catalogR( RCRRRRt get_pkg_stemRRR[R}RR^( RatmatchestolisttonamesRRtstt found_statetmlisttmnames((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__filter_install_matchessB "         c Cs]|idiiz<ti}|i|it|i|||i BWdQXdS(s_Avoid the specified packages... use pattern matching on names; ignore versions.tavoidN( RRURVR0RAt_avoid_set_savet avoid_set_getRCtmatch_user_stemstMATCH_UNINSTALLED(Ratpat_listRt check_canceltip((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt avoid_pkgss  c Cs|idiizti}t|i|||i}|i}||}|ot i d|ng}|i D]$\} } | |jo || qq~} | ot i d| n|i ||WdQXdS(saUnavoid the specified packages... use pattern matching on names; ignore versions.tunavoidt not_avoidedt would_installN( RRURVR0RARCRt MATCH_ALLRRUtPlanCreationExceptionR4R( RaRRRRt unavoid_sett current_setRRRbRR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt unavoid_pkgss   !cCsbtd|iD}x?|iD]1\}}||jo||i|iq)q)W|S(s\ return dict of lists (avoided stem, pkgs w/ group dependencies on this pkg)css"x|]}|tfVqWdS(N(Ra(RR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pys s (RRR4RRh(RaRR^R0((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytget_avoid_dict s   c sdfd}|o|iSidiiz|}i}titi} |i g} |i D](\} } | | t | || ffq~ i ||iSWdQXdS(sFreeze the specified packages... use pattern matching on names. The 'pat_list' parameter contains the list of patterns of packages to freeze. The 'progtrack' parameter contains the progress tracker for this operation. The 'check_cancel' parameter contains a function to call to check if the operation has been canceled. The 'dry_run' parameter controls whether packages are actually frozen. The 'comment' parameter contains the comment, if any, which will be associated with the packages that are frozen. cSs"tii|d}d|_|S(Ns5.11(R:R^RyRR(tpatR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__make_publisherless_fmri's csRtii}tg}|iD]\}}|||fq)~S(N(R0RAtfreeze_pkgs_matchRR(tstems_and_patsRRR(t_Image__make_publisherless_fmriRaR(s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt __calc_frozen,s   tfreezeN( RRRURVt_Image__freeze_dict_loadtcalendarttimegmR?tgmtimeRRRt_freeze_dict_save( RaRRRtdry_runtcommentt_Image__calc_frozenRRRRRRR((RRaRs6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt freeze_pkgss    < c sfd}|o |dSidiizE|\}}x|D]}|i|dqVWi||SWdQXdS(s-Unfreeze the specified packages... use pattern matching on names; ignore versions. The 'pat_list' parameter contains the list of patterns of packages to freeze. The 'progtrack' parameter contains the progress tracker for this operation. The 'check_cancel' parameter contains a function to call to check if the operation has been canceled. The 'dry_run' parameter controls whether packages are actually frozen.c sji}ti}t|i|idtdg}|iD]}|d|fqD~|fS(Ntraise_unmatchedtuniverse( RR0RARCRRRR.R(RRRRZ(RaR(s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__calc_unfrozenOs   iRN(RRURVRRR( RaRRRRt_Image__calc_unfrozent unfrozen_setRR((RaRs6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt unfreeze_pkgs?s   cCs|iio|i|i_ny|iWnOtij o@||_|iio d|idt|i_ nnX||_|iio|idt|i_ ndS(Ns$Unevaluated: merged plan had errors tfull( R.toperation_nametget_plantoperation_start_statetevaluateRUtConflictingActionErrorsR0Rtoperation_end_state(RaR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__call_imageplan_evaluateds     c KsLtidotii|id}t|dii}z&|~} | i t ti WdQXx)tii |ot idqpWnd|_ti||||d|} |izpy|o| i|n|tititigjo| i|nd|titigjo| i|n:|tijo| i|n|tijo| i|n|ti jo| i!|n|ti"jo| i#|n|ti$jo| i%|n|ti&jo| i'|nt|ti(jo| i)|nS|ti*jo| i+|n2|ti,jo| i-|nt.d|Wn_t/i0j o } nFt1i2i3j o} t/i4| gnt/i5j o nXy|i6| WnGt/i0j o } n.t1i2i3j o} t/i4| gnXWd|i7XdS(scPrivate helper function to perform base plan creation and cleanup. ssimulate-plan-hangs pkg5.hangRHNit noexecutesUnknown api op: %s(8RRRRRXRoRLRURVRRR+RWR?tsleepRR0RAR(t plan_noopR}t API_OP_ATTACHt API_OP_DETACHt API_OP_SYNCt plan_synctAPI_OP_CHANGE_FACETtAPI_OP_CHANGE_VARIANTtplan_change_varcetstAPI_OP_DEHYDRATEtplan_dehydratetAPI_OP_INSTALLt plan_installtAPI_OP_EXACT_INSTALLtplan_exact_installt API_OP_FIXtplan_fixtAPI_OP_REHYDRATEtplan_rehydratet API_OP_REVERTt plan_reverttAPI_OP_SET_MEDIATORtplan_set_mediatorstAPI_OP_UNINSTALLtplan_uninstallt API_OP_UPDATEt plan_updateR$RURR:RRRRt_Image__call_imageplan_evaluateR( Rat_opt _progtrackt _check_cancelt _noexecutet_ip_noopRmt hang_fileRRbRR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__make_plan_common}sr&   c Cs:|i|i||||d|d||idS(sTake a list of packages, specified in pkgs_inst, and attempt to assemble an appropriate image plan. This is a helper routine for some common operations in the client. t pkgs_instt reject_listN(tplan_all_startt_Image__make_plan_commont plan_all_done(RaRRRRRR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytmake_install_plans   c Cs|i|o>t|i}t|iii} t|| }nb|oZ|i} xA|D]9} || djo| i| dqi|| | | t i|dt\} } | p|| f|| d5s cssx|]}|dfVqWdS(R%N((RR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pys 6s sCannot save avoid list: %s(RR^RIRHRJRRRXR$RRRR&tdumpR(R]RRRR?R)RR(Ratnew_setR%R*ttmp_filettfRR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR#s*        cCsRg}|iiD]4}|tii|ddd|d|dfq~S(sjReturn a list of tuples containing the fmri that was frozen, and the reason it was frozen.it build_releases5.11ii(RRR:R^Ry(RaRtv((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyRKscCstii|id}tii|oytit|\}}WnGtj o}t i |n%t j o}t i |nX||i jot i||i |n|ShS(sTLoad the dictionary containing the current state of frozen packages.t frozen_dict(RRRXR$RR&R'RRRURR tInvalidFreezeFilet_Image__FROZEN_DICT_VERSIONtUnknownFreezeFileVersion(RaR*R4RR((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__freeze_dict_loadUs  c Cstii|id}tii|id}yYt|dii}z&|~}ti|i |f|WdQXt i ||Wn$t j o}t i|nX|idS(s'Save the dictionary of frozen packages.R2sfrozen_dict.newRHN(RRRXR$RLRURVR&R,R4RRRRURR<(Ratnew_dictR*R.RR/R((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyRhs&csfd}|S(sA boolean function that will be added to the pkg(5) exclude mechanism to determine if an action is allowed to be installed based on whether its publisher is going to be dehydrated or has been currently dehydrated.cs|jotS|i}|djoH|i}|iddjotSd|jp d|jotStS|djotStS(NRRstfalsetpreservetoverlayR\(R^RiR+RyR(RURtanameR+(tdehydrated_pubs(s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyt__allow_action_dehydrates     ((R<t_Image__allow_action_dehydrate((R<s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyRjxs (t__name__t __module__t__doc__RRRRRRR^RRRgRR(t staticmethodRnRRoRpRRzR|RRRRRRRTRSRRRRRR]R3RSRWRRRRTRRRRRRRuRR`RRRRRRRR RRRRR"R"RRtR'R)R*R+R{R%RR@R5RlRzRRRRRRRR`RRRtRt_Image__remove_catalogsRRRRRcRRRRRR<RRRR6R:R'RR.R4R[R]RlRbRmRwRR3RzR{R}RRR%RRRRR,R=t_Image__filter_install_matchesRRRRRRRRRR R RRRRRRRR"R(RR#R?RR4RRRRj(((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pyR XsV    4  ( + #" ! @  ! "< K      4   8  $      &            B y        &       4q   O    C           '   ! ?  - %  M   @   w   &  (atM2CryptoRR0RRRRRRRRRt simplejsonR&tstatRER.R?Rpt contextlibRt pkg.clientRR?t pkg.actionsR:t pkg.catalogtpkg.client.api_errorstclientt api_errorsRUtpkg.client.bootenvRtpkg.client.historyR.tpkg.client.imageconfigRrtpkg.client.imageplanR0tpkg.client.linkedimaget linkedimageRQtpkg.client.pkgdefsR}tpkg.client.pkgplantpkgplantpkg.client.plandesctplandesctpkg.client.progressRPtpkg.client.publisherRtpkg.client.sigpolicyRutpkg.client.transport.transportRNt pkg.configtconfigR-tpkg.file_layout.layoutRRRtpkg.fmrit pkg.lockfileR't pkg.manifestRt pkg.mediatorRORStpkg.miscRt pkg.nrlocktpkg.pkgsubprocesst pkgsubprocessRNt pkg.portableRtpkg.server.catalogtpkg.smfRt pkg.versiontpkg.client.debugvaluesRtpkg.client.imagetypesRRtpkg.client.transport.exceptionRRRRRRtobjectR (((s6/usr/lib/python2.6/vendor-packages/pkg/client/image.pytsn