~eddlZddlmZddlmZddlmZdZdZdZdZ d Z d ezZ d ezZ d ezZ d ezZdezZde zZde zZGddeZGddZdZ ddZddZy)N)_PY3)unicode)sha1iiiiiiiceZdZdZy)PackageTypeErrorzDRaised when an unsupported package type is passed to build_skeleton.N)__name__ __module__ __qualname____doc__D/usr/lib/python3/dist-packages/landscape/lib/apt/package/skeleton.pyr r sNrr c<eZdZdZdZdZdZdZdZdZ dZ dZ dZ y)PackageSkeletonNc<||_||_||_g|_yN)typenameversion relations)selfrrrs r__init__zPackageSkeleton.__init__$s   rc>|jj||fyr)rappend)rrinfos r add_relationzPackageSkeleton.add_relation*s tTl+rc|j |jSd|jdd|jd|jdj d}t |}|j j|j D]0}|jd|ddd|ddj d2|jS)zCalculate the package hash. If C{set_hash} has been used, that hash will be returned and the hash won't be the calculated value. [d ]asciirr) _hashrrrencoderrsortupdatedigest)r package_infor,pairs rget_hashzPackageSkeleton.get_hash-s :: !:: DIIa=$))Adll^1EMM  l# NN HD MMQtAwqk47)15==gF G H}}rc||_y)aZSet the hash to an explicit value. This should be used when the hash is previously known and can't be calculated from the relations anymore. The only use case for this is package resurrection. We're planning on getting rid of package resurrection, and this code can be removed when that is done. N)r()r package_hashs rset_hashzPackageSkeleton.set_hash@s " r) r rrsectionsummary descriptionsizeinstalled_sizer(rr!r/r2rrrrrs4GGK DN E ,& "rrc0|\}}}|}|r |d|d|z }|S)aConvert an apt relation to a string representation. @param relation_tuple: A tuple, (name, version, relation). version and relation can be the empty string, if the relation is on a name only. Returns something like "name > 1.0" r%r)relation_tuplerr relation_typerelation_strings rrelation_to_stringr<Ms5$2 D'=OQ}oQwi88 rct}|D]}g}t|tjjr:|D]4}|j |j |j|jf6n|j |ddf|Dcgc] }t|}}|} t|dkDr|} dj|} |j| | f|Scc}w)aParse an apt C{Dependency} list and return skeleton relations @param dependencies: list of dependencies returned by get_dependencies() this function also accepts the special case for version.provides which is a list of string @param relation_type: The deb relation that can be passed to C{skeleton.add_relation()} @param or_relation_type: The deb relation that should be used if there is more than one value in a relation. rz | ) set isinstanceaptpackage Dependencyrrrrelationr<lenjoinadd) dependenciesr:or_relation_typer dependencydependbasedependencyrD value_stringsvalue_relation_typer;s rparse_record_dependenciesrO]s"I">  j#++"8"8 9",  &++&..&//  MM:r2. /GMM(+H5M M+ }  !"2 **]3 *O<=->0 NsCc^|jj|j}}|rt|t|}}t t ||}t }|jt|jt|jt|jjd|jf|jt|jdtt|jt|jdtt|jt |jjd|jf|jt|jdt"|jt|jdt"t%||_|r|j(|_|j*|_|j,|_|j.|_|j0dkDr|j0|_|rt2sz|j(j5d|_|j*j5d|_t7|j,ts |j,j5d|_|S) aSBuild a package skeleton from an apt package. @param version: An instance of C{apt.package.Version} @param with_info: Whether to extract extra information about the package, like description, summary, size. @param with_unicode: Whether the C{name} and C{version} of the skeleton should be unicode strings. z = PreDependsDependsz < ConflictsBreaksrzutf-8)rBrrrr DEB_PACKAGEr?r+rOprovides DEB_PROVIDESrGDEB_NAME_PROVIDESget_dependencies DEB_REQUIRESDEB_OR_REQUIRES DEB_UPGRADES DEB_CONFLICTSsortedrr3r4r5r6r7rdecoder@)r with_info with_unicoderversion_stringskeletonrs rbuild_skeleton_aptrds4#??//.D&t}gn.En{D.AHI .w/?/?NO MM ##$C'8 9  !  $ $\ 2   !  $ $Y /   MM '//../s7??2CDE!  $ $[ 1   !  $ $X .    *H"??"??&22   ! !A %&-&<&rms %(&       ! h&! H$! )# OyO/"/"d &*ZEr