3 ft`@sddlmZddlmZddlmZddlmZddlZddl Zddl Z ddZ d d Z d d Z e dJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dEZdFdGZdHdIZdS)a)absolute_import)unicode_literals) transaction) is_py3bytesNc )Cstj|d}|jtjtjBxztjjD]l}tj j rDt |d}y|j d|}Wn<t tjfk r}ztjjdt|WYdd}~XnXt|sq,y t|}Wn$tk rd}tjj|YnX|d}yy|tjj|}Wn,tk r|tjj|jd}YnX|tj|} |tj|} | tjkrd| rd|d ||jdfkrd| }Wntttfk rYnXt|rt|d}|SWdS) z-Calculate the release version for the system.)rootzutf-8Zprovidesz Error: %sNz:Error: rpmdb failed to list provides. Try: rpm --rebuilddbversionutf8name)rinitReadOnlyTransactionZ pushVSFlagsrpmZ_RPMVSF_NOSIGNATURESZ_RPMVSF_NODIGESTSdnfconstZ DISTROVERPKGZpycompZPY3bytesZdbMatch TypeErrorerror exceptionsErrorstrlennext StopIterationZRPMTAG_PROVIDENAMEindex ValueErrordecodeZRPMTAG_PROVIDEFLAGSZRPMTAG_PROVIDEVERSIONZRPMSENSE_EQUALKeyError IndexErrorr) Z installroottsZ distroverpkgidxehdrmsgZ releaseverZoffflagZverr#/usr/lib/python3.6/__init__.pydetect_releaseversB  &   r%cCsptj}t|V}|j}y|j|}Wn8tjk r`}ztjj dj ||WYdd}~XnX|SQRXdS)zReturn RPM header of the file.z {0}: '{1}'N) rr openfilenoZ hdrFromFdnor rr rrformat)pathrpackageZfdnor rr#r#r$_headerIs &r+csfddDS)Ncs i|]}|D] }||qqSr#r#).0kv)dctr#r$ Vsz_invert..r#)r/r#)r/r$_invertUsr1aarch64alphaalphaev4 alphaev45alphaev5 alphaev56alphaev6 alphaev67 alphaev68alphaev7 alphapca56 armv5tejlarmv5telarmv5tlarmv6larmv7larmv8larmv6hlarmv7hlarmv7hnlarmv8hli386athlongeodei486i586i686ia64mipsmipselmips64mips64elnoarchppcppc64 ppc64iseriesppc64p7 ppc64pseriesppc64leriscv32riscv64riscv128s390s390xsh3sh4sh4asparcsparc64sparc64vsparcv8sparcv9sparcv9vx86_64amd64ia32e)r2r3ZarmZarmhfprGrMrNrOrPrQrRrSrTrXrYrZr[r\r]r^r_rargcCst|S)N) _BASEARCH_MAP)Zarchr#r#r$basearchusrkcCs||}t|rt|d}|S)z Returns value of rpm_hdr[key] as a string. Rpm has switched from bytes to str and we need to handle both properly. zutf-8)rr)Zrpm_hdrkeyvaluer#r#r$ getheaderzs rn)r2) r3r4r5r6r7r8r9r:r;r<)r=r>r?r@rArB)rCrDrErF)rGrHrIrGrJrKrL)rM)rN)rO)rP)rQ)rR)rS)rTrUrVrW)rX)rY)rZ)r[)r\)r])r^)r_r`)rarbrcrdrerf)rgrhri)Z __future__rrrZ dnf.pycomprZ dnf.constr Zdnf.exceptionsr r%r+r1rjrkrnr#r#r#r$sJ    ,