v_c@s_ddlZddlZddlZddlZddlZddlmZmZddlmZddl m Z dZ e Z dZdZdd Zd Zd Zd Zd ZdZdZddgZdejfdYZdddZdddYZdefdYZdefdYZdddYZdS( iN(twrite32utFNAME(t URLGrabError(terrorcCstj|IJdS(N(tsyststderr(tnumtmsg((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pytlog scCs|S(N((R((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyt_scCst|}d}|jdkr*d}n-||jksN||jkrWd}n|rtdtd||fndS(scheck a header by opening it and comparing the results to the name and arch we believe it to be for. if it fails raise URLGrabError(-1)iiis1Header cannot be opened or does not match %s, %s.N(t Header_WorkthdrtNonetnametarchRR (t headerfileR Rthtfail((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyt checkheaders  $ "icCstjdtj|tj}ytj|Wntjk rQ}d}nXd}tj|tjd|r|st dt d|qdSn|SdS(sdtake a package, check it out by trying to open it, return 1 if it's good return 0 if it's nottmd5iitdefaultisRPM %s fails md5 checkN( ttst sigCheckingtostopentO_RDONLYt hdrFromFdnotrpmRtcloseRR (tpackaget urlgraberrortfdnotetgood((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyt checkRpmMD5%s    cCstjdtj|tj}ytj|}Wnntjk r}t|dkr`dSt|dkrvdSt|dkrdSt|dkrdSn6Xt |\}}|d krtj |~d S~tj |d S( s take a package, check it's sigs, return 0 if they are all fine, return 1 if the gpg key can't be found, 2 if the header is in someway damaged, 3 if the key is not trusted, 4 if the pkg is not gpg or pgp signedRspublic key not availaiableispublic key not availablespublic key not trustediserror reading package headeriieii( RRRRRRRRtstrt getSigInfoR(RRR R Rtsiginfo((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pytcheckSig;s*    cCssd}|j|}|dkrBd}|jd\}}}nd}d}d}d}|||f}||fS(sEchecks if a computerhand back signature information and an error codes%|DSAHEADER?{%{DSAHEADER:pgpsig}}:{%|RSAHEADER?{%{RSAHEADER:pgpsig}}:{%|SIGGPG?{%{SIGGPG:pgpsig}}:{%|SIGPGP?{%{SIGPGP:pgpsig}}:{(none)}|}|}|}|s(none)it,ietMD5R (tsprintftsplit(R tstringR%Rtsigtypetsigdatetsigidt infotuple((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyR$Ws cCsXg}|tj}|dkr"n2t|tjkrG|j|n |j||S(N(RtRPMTAG_PROVIDENAMER ttypettypestListTypetextendtappend(theadert provnamestprovides((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyt getProvidesgs   c Cs|\}}}|\}}}d}||}||}||}||}||}||}tj|||f|||f} tdd||||||| f| S(NcSs4t|tjkr0|dkr0t|}n|S(N(R1R2t StringTypeR R#(targ((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyt rpmOutToStrvs!is%s, %s, %s vs %s, %s, %s = %s(Rt labelCompareR( t.0t.1te1tv1tr1te2tv2tr2R<trc((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyt compareEVRrs       $&cCs|r|tjtjBtjB@r.|d}n|tj@rH|d}n|tj@rb|d}n|tj@r|d}|d|}qn|S(Nt tt=s %s(Rt RPMSENSE_LESStRPMSENSE_GREATERtRPMSENSE_EQUAL(R tversiontflags((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyt formatRequires       cCsFytjtj}Wn)tjk rA}tdtdnX|S(NisFCould not open RPM database for reading. Perhaps it is already in use?(RtTransactionSettconft installrootRterrorlogR (tdbR ((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyt openrpmdbs tGzipFileRcBseZdZRS(cCs|jjd|jjd|jd }d}|rBt}n|jjt|t|jtd|jjd|jjd|r|jj|dndS(Nssiisst(tfileobjtwritetfilenameRtchrRtlong(tselftfnameRP((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyt_write_gzip_headers  (t__name__t __module__Ra(((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyRXstrbi cCst|||S(N(RX(R\tmodet compresslevel((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyt _gzipOpenst RPM_Base_WorkcBskeZdZdZdZdZdZdZdZdZ dZ d Z d Z RS( cCs d|_dS(N(R R (R_((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyt__init__scCs=|jdkr2tdtdtjdn|j|S(Nis-Got an empty Header, something has gone wrongi(R R RUR Rtexit(R_ttag((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyt_getTagscCs!|jddkrdSdSdS(Nt sourcepackageii(Rl(R_((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pytisSourcescCs |jdS(NR (Rl(R_((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyR scCs |jdS(NR(Rl(R_((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyRscCs |jdS(Ntepoch(Rl(R_((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyRoscCs |jdS(NRO(Rl(R_((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyROscCs |jdS(Ntrelease(Rl(R_((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyRpscCs:|jd}|jd}|jd}|||fS(NRoRORp(Rl(R_R tvtr((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pytevrscCs^|jd}|jd}|jd}|jd}|jd}|||||fS(NR RoRORpR(Rl(R_tnR RqRrta((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pytnevras c Cs|j\}}}}}|dkr0d}n|jrXd|||||f}nd||||||f}|rt|d} nt|d} | j|jjd| j|S(Nt0s%s/%s-%s-%s-%s.src.hdrs%s/%s-%s-%s-%s.%s.hdrtwi( RvR RnRgRR[R tunloadR( R_t headerdirtcompressR RotvertrelRtheaderfnt headerout((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyt writeHeaders    ( RbRcRiRlRnR RRoRORpRsRvR(((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyRhs          R cBseZdZdZRS(sfor operating on hdrs in and out of the rpmdb if the first arg is a string then it's a filename otherwise it's an rpm hdrcCslt|tjkrYyetj|d}ytj|j}Wn3tjk rx}t dt d|d}nXWnt k r}t|d}ytj|j}WqLtjk r}t dt d|d}qLXn_t k r}t dt d|d}n0tk rK}t dt d|d}nX|jn|}||_dS(NRrisDamaged Header %s(R1R2R:tgzipRRt headerLoadtreadRRUR R tIOErrort ValueErrort zlibErrorRR (R_R6tfdRR ((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyRis0    (RbRct__doc__Ri(((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyR stRPM_WorkcBseZdZRS(cCstjtjtj|tj}ytj||_Wn<tj k rz}t dt d||fd|_nXtj |dS(NisError opening rpm %s - error %s(Rt setVSFlagsRt_RPMVSF_NOSIGNATURESRRRRR RRUR R R(R_trpmfnRR ((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyRis (RbRcRi(((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyRst Rpm_Ts_WorkcBs>eZdZddZdZddddZdZRS(sThis should operate on groups of headers/matches/etc in the rpmdb - ideally it will operate with a list of the Base objects above, so I can refer to any one object there not sure the best way to do this yet, more thinking involvedt/c Csy+tjr*tjdkr*tj}q*nWntk r@}nXtj||_dddddddd d d d g |_dS( NRt addInstalltaddErasetruntchecktorderRtcloseDBtdbMatchtsetFlagsRt setProbFilter(RSRTt NameErrorRRRRtmethods(R_tdbPathR ((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyRi!s cCs,||jkrt|j|St|dS(N(RtgetattrRtAttributeError(R_t attribute((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyt __getattr__.scCsOg}|dkr<|dkr<|dkr<|jj}n|dkr`|jj||}n|dkr|jj}|j|tj|n|dkr|jj}|j|tj|nY|dkr|jj}|j|tj|n%|jj}|j|tj|x'|D]}t |}|j |q(W|S(s(hands back a list of Header_Work objectstglobtregextstrcmpN( R RRtpatternRt RPMMIRE_GLOBt RPMMIRE_REGEXtRPMMIRE_STRCMPtRPMMIRE_DEFAULTR R5(R_RktsearchtmirethwlistthdrlistR thdrobj((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pytmatch4s($      cCs||dkr*|jjtjtjBnN|dkrM|jjtjn+|dkro|jjtjn t|dS(sApass type of check you want to occur, default is to have them offRtnoneRN(RRRt RPMVSF_NOMD5tRPMVSF_NEEDPAYLOADRtRPMVSF_DEFAULTR(R_tsig((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyRSs   N(RbRcRRiRR RR(((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyRs  (((RR2RRRRRturlgrabber.grabberRtzlibRRRRUR RR"R&R$R9RGRQRWt__all__RXRgRhR RR(((s5/usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyts2              A