o ak@sdZddlZddlZddlZz&ddlmZmZmZmZm Z m Z m Z m Z m Z mZmZmZmZmZmZmZWn ey=YnwddlmZz ddlZedZWn ey[dZYnwz ddlZejZWn eyrddZYnwz ddlZejZ Wn eyd d Z YnwGd d d e!Z"Gd dde#Z$Gddde$Z%Gddde$Z&erGddde%Z'nGddde&Z'ddZ(GdddZ)GdddZ*Gddde*Z+ddZ,ee,Z-e,Z.d6d d!Z/ee/Z0[-[,d"d#Z1d$d%Z2ee2Z3d&Z4e5e4Z6e5e47d'Z8 d6d(d)Z9ee9Z:d*d+Z;ee;Zd.d/Z?ee?Z@d0d1ZAeeAZBd8d2d3ZCeeCZDd4d5ZEeeEZFdS)9z2 Facilities to deal with Debian-specific metadata N)AnyAnyStrBinaryIODictIterableIterator GeneratorListMatchNoReturnOptionalPatternTextTextIOTupleUnion)function_deprecated_byTFcGtdNzBuilt-in sha1 implementation not found; cannot use hashlib implementation because it depends on OpenSSL, which may not be linked with this library due to license incompatibilitiesNotImplementedErrorargsr7/usr/lib/python3/dist-packages/debian/debian_support.pynew_sha1?rcGrrrrrrr new_sha256Nrrcs@eZdZdZfddZddZddZdd ZeeZ Z S) ParseErrorzAn exception which is used to signal a parse failure. Attributes: filename - name of the file lineno - line number in the file msg - error message cs4t|tsJ||_||_||_tt||dSN) isinstanceintfilenamelinenomsgsuperr__init__)selfr"r#r$ __class__rrr&bs zParseError.__init__cC|jSr)r$r'rrr__str__nzParseError.__str__cCsd|j|j|jfS)NzParseError(%r, %d, %r))r"r#r$r+rrr__repr__rszParseError.__repr__cCs&|d|j|j|jf|dS)z0Writes a machine-parsable error message to file.z %s:%d: %s N)writer"r#r$flush)r'filerrr print_outxs zParseError.print_out) __name__ __module__ __qualname____doc__r&r,r.r2rprintOut __classcell__rrr(rrWs  rcseZdZdZedZdZddZddZ fdd Z fd d Z d d Z ddZ ddZddZddZddZddZddZddZddZd d!ZZS)" BaseVersionaBase class for classes representing Debian versions It doesn't implement any comparison, but it does check for valid versions according to Section 5.6.12 in the Debian Policy Manual. Since splitting the version into epoch, upstream_version, and debian_revision components is pretty much free with the validation, it sets those fields as properties of the object, and sets the raw version to the full_version property. A missing epoch or debian_revision results in the respective property set to None. Setting any of the properties results in the full_version being recomputed and the rest of the properties set from that. It also implements __str__, just returning the raw version given to the initializer. zd^((?P\d+):)?(?P[A-Za-z0-9.+:~-]+?)(-(?P[A-Za-z0-9+.~]+))?$) full_versionepochupstream_versiondebian_revisiondebian_versioncCst|tr t|}||_dSr)r r9strr:r'versionrrrr&s  zBaseVersion.__init__cCsr|j|}|std||ddur"d|dvr"td|||_|d|_|d|_|d|_dS)NzInvalid version string %rr;:r<r=)re_valid_versionmatch ValueErrorgroup_BaseVersion__full_version_BaseVersion__epoch_BaseVersion__upstream_version_BaseVersion__debian_revision)r'rAmrrr_set_full_versions     zBaseVersion._set_full_versioncs||jvrtt|||dS|dkrd}|dkr#|t|dS|dur+t|}d|}t||}t|||z|WdSt yZt||||t d||fw)Nr>r=r:_BaseVersion__%sz+Setting %s to %r results in invalid version) magic_attrsr%r9 __setattr__rLr?getattrsetattr_update_full_versionrE)r'attrvalueprivate old_valuer(rrrOs*     zBaseVersion.__setattr__cs8||jvr tt||S|dkrd}d|}t||S)Nr>r=rM)rNr%r9__getattribute__rP)r'rSrUr(rr __getattr__s  zBaseVersion.__getattr__cCsDd}|jdur||jd7}||j7}|jr|d|j7}||_dS)NrB-)rHrIrJr:r@rrrrRs   z BaseVersion._update_full_versioncCs|jdur|jSdS)NrY)r:r+rrrr,zBaseVersion.__str__cCsd|jj|fS)Nz%s('%s'))r)r3r+rrrr.szBaseVersion.__repr__cCstrrr'otherrrr_compareszBaseVersion._comparecCs||dkSNrr^r\rrr__lt__zBaseVersion.__lt__cCs||dkSr_r`r\rrr__le__rbzBaseVersion.__le__cCs||dkSr_r`r\rrr__eq__rbzBaseVersion.__eq__cCs||dkSr_r`r\rrr__ne__rbzBaseVersion.__ne__cCs||dkSr_r`r\rrr__ge__rbzBaseVersion.__ge__cCs||dkSr_r`r\rrr__gt__rbzBaseVersion.__gt__cCs tt|Sr)hashr?r+rrr__hash__ zBaseVersion.__hash__)r3r4r5r6recompilerCrNr&rLrOrXrRr,r.r^rarcrdrerfrgrir8rrr(rr9s*    r9cs(eZdZdZfddZddZZS) AptPkgVersionzARepresents a Debian package version, using apt_pkg.VersionComparecs tstdtt||dS)Nz5apt_pkg not available; install the python-apt package) _have_apt_pkgrr%rmr&r@r(rrr&szAptPkgVersion.__init__cCstt|t|Sr)apt_pkgversion_comparer?r\rrrr^r[zAptPkgVersion._compare)r3r4r5r6r&r^r8rrr(rrm s rmc@sdeZdZdZedZedZedZedZ ddZ e dd Z e d d Z e d d ZdS) NativeVersionzBRepresents a Debian package version, with native Python comparisonz\d+|\D+z\d+z\dz[A-Za-z]c Cs|durdSt|ts(ztt|}Wnty'}ztd||fd}~wwt|jp-d}t|jp4d}||krSz5NativeVersion._version_cmp_string..crrrrrrrrTrrrtrr)pop)rvavblalbabrrr_version_cmp_stringPs   z!NativeVersion._version_cmp_stringc Cs|j|}|j|}|s|rSd}d}|r|d}|r"|d}|j|rC|j|rCt|}t|}||krt}|D]}t|tr||q||dq|SNUTF-8)rr rupdateencode hexdigestlinesrKlrrrread_lines_sha256W   rcCrr)rr rrrrrrrrread_lines_sha1brrz^(\d+)(?:,(\d+))?([acd])$rc cs.t|}|}|D]}|st|trtnt}||}|dur%td||\}}}t|} |dur6dnt|} t |dkrS| d} | durL| d} | | gfVq t |dkrf| durctd|| } n | d} | durr| d} g} |D]} | dvrtd|| d vrn| | qv| | | fVq dS) a1Converts source to a stream of patches. Patches are triples of line indexes: - number of the first line to be replaced - one plus the number of the last line to be replaced - list of line replacements This is enough to model arbitrary additions, deletions and replacements. Nzinvalid patch command: %rdrrazinvalid patch argument: %r)rYzend of stream in command: %r)z. .s. .) iterr r _patch_re_b _patch_rerDrErr!r~r) sourcere_cmdipatch_rerrDfirst_last_cmdfirstlastrcrrrpatches_from_ed_scriptusD        rcCs |D] \}}}||||<qdS)z2Applies patches to lines. Updates lines in place.Nr)rpatchesrrrrrr patch_linessrc Cs|d}z7t|d|d}|D]}||qWdn1s!wYt||Wtj|r:t|dSdStj|rHt|ww)Nz.newzw+r)rr/osrenamepathexistsunlink)rlocalr local_newnew_filerrrr replace_files   rc Csddl}ddl}ddlm}|\}}z6t||||\}}||d }|} Wdn1s6wYWt || SWt || St |w)z[Downloads a file from a remote location and gunzips it. Returns the lines in the file.rN) urlretrievert) gziptempfileurllib.requestrmkstemprcloser readlinesr) remoterr rhandlefnamer"_gfilerrrrdownload_gunzip_liness         rcCst|d}t|||S)zCopies a gzipped remote file to the local system. remote - URL, without the .gz suffix local - name of the local file .gz)rr)rrrrrr download_files  rcCszt|ddd }|}Wdn1swYWnty1|r*tdt||YSwg}i}ddlm}|d}td } z||} t t || } Wdn1s\wYWn't yv|rotd t||YSty|rtd t||YSwd d d| Dvr|rtdd} t |} t }n|rtdd} t |} t }| D]y}|D]t\}}|| dkr| |\}}| |kr|rtd|Sq|| dkr|D]}|dkrq| |\}}}|s|| kr||qq|| dkr!|D]}|dkrq | |\}}}|||<q q|r*td|qq|s<|r7td| t||S|D]0}|rItd|t|d|d}||||krbtd|t |}t|t|q>||}||krtd||ft|||S)zjUpdates the local file by downloading a remote patch. Returns a list of lines in the local file. rrrNz1update_file: no local copy, downloading full filer)urlopenz .diff/Indexz\s+z1update_file: could not interpret patch index filez0update_file: could not download patch index filezSHA256-CurrentcSsg|] }|D]\}}|qqSrr)rfieldskvrrrr$szupdate_file..zupdate_file: using sha256SHA256zupdate_file: using sha1SHA1z-Currentz%update_file: local file is up-to-datez-HistoryrYz-Patcheszupdate_file: field %r ignoredz*update_file: could not find historic entryz!update_file: downloading patch %rz.diff/rzpatch %r was garbledz"patch failed, got %s instead of %s)rr IOErrorprintrr rrkrllistrrrrsplit splitlinesrrrErrr)rrverbose local_filerpatches_to_apply patch_hashesr index_name re_whitespace index_url index_fieldsprefix local_hash read_linesrfieldrT remote_hashrentry hist_hash patch_name patch_hashpatch_contentspatch_contents_unicodenew_hashrrr update_files                  !      r6cGs(i}|D] }|D]}d||<qqt|S)zdCreate an order set (represented as a list) of the objects in the sequences passed as arguments.T)sorted)rsryrrr merge_as_setsns  r:r)r)F)Gr6ros.pathrktypingrrrrrrrr r r r r rrrr ImportErrordebian.deprecationrroinitrn_sha1sha1r_sha256sha256r Exceptionrobjectr9rmrqrrprrrr listReleasesrr internReleaserr readLinesSHA1 _patch_re_rawrlrrrrpatchesFromEdScriptr patchLinesr replaceFilerdownloadGunzipLinesr downloadFiler6 updateFiler: mergeAsSetsrrrrsL           * _ R1      ;  n