Cfc^z:dZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#e"eeee$eeee$fZ%e"e$ee%fZ&eZ'ee(e'fZ)ee(e'fZ*ddl+Z+e!ddZ,ddl-m.Z.m/Z/dd l1m2Z2m3Z3m4Z4m5Z5dd l6m7Z7ddl8Z9ddl:Z9 ddl;Z;e;jxd Z=dZ?ejddZAeBdgZCdZDejdZFGddeGZHGddeHZIe#re)ZJnejj0ZJGddeJZLe#re*ZMnejj2ZMGddeMZNGddeNZOe#r ee(ee(fZPneQZPGddePZRGdd eSZTe#ree(efZUneQZUGd!d"eUZVe#r Gd#d$eZWGd%d&eSZXGd'd(eSZYGd)d*eOZZGd+d,eZZ[Gd-d.e[eXZ\Gd/d0e[eXZ]Gd1d2e[eYeXZ^Gd3d4eZZ_Gd5d6eZZ`Gd7d8e\eYZaGd9d:eOeYeXZbGd;d<ejdd?eOZeGd@dAeSZfy#e0$rdZ#e#sd Zd Ze$de(diZdZ)dZ&YwxYw#e0e>f$rdZ=YwxYw)Ba Dictionary-like interfaces to RFC822-like files The Python deb822 aims to provide a dict-like interface to various RFC822-like Debian data formats, like Packages/Sources, .changes/.dsc, pdiff Index files, etc. As well as the generic :class:`Deb822` class, the specialised versions of these classes (:class:`Packages`, :class:`Sources`, :class:`Changes` etc) know about special fields that contain specially formatted data such as dependency lists or whitespace separated sub-fields. This module has few external dependencies, but can use python-apt if available to parse the data, which gives a very significant performance boost when iterating over big Packages files. Whitespace separated data within fields are known as "multifields". The "Files" field in Sources files, for instance, has three subfields, while "Files" in .changes files, has five; the relevant classes here know this and correctly handle these cases. Key lookup in Deb822 objects and their multifields is case-insensitive, but the original case is always preserved, for example when printing the object. The Debian project and individual developers make extensive use of GPG signatures including in-line signatures. GPG signatures are automatically detected, verified and the payload then offered to the parser. Relevant documentation on the Deb822 file formats available here. - `deb-control(5) `_, the `control` file in the binary package (generated from `debian/control` in the source package) - `deb-changes(5) `_, `changes` files that developers upload to add new packages to the archive. - `dsc(5) `_, Debian Source Control file that defines the files that are part of a source package. - `Debian mirror format `_, including documentation for Packages, Sources files etc. Overview of deb822 Classes -------------------------- Classes that deb822 provides: * :class:`Deb822` base class with no multifields. A Deb822 object holds a single entry from a Deb822-style file, where paragraphs are separated by blank lines and there may be many paragraphs within a file. The :func:`~Deb822.iter_paragraphs` function yields paragraphs from a data source. * :class:`Packages` represents a Packages file from a Debian mirror. It extends the Deb822 class by interpreting fields that are package relationships (Depends, Recommends etc). Iteration is forced through python-apt for performance and conformance. * :class:`Dsc` represents .dsc files (Debian Source Control) that are the metadata file of the source package. Multivalued fields: * Files: md5sum, size, name * Checksums-Sha1: sha1, size, name * Checksums-Sha256: sha256, size, name * Checksums-Sha512: sha512, size, name * :class:`Sources` represents a Sources file from a Debian mirror. It extends the Dsc class by interpreting fields that are package relationships (Build-Depends, Build-Conflicts etc). Iteration is forced through python-apt for performance and conformance. * :class:`Release` represents a Release file from a Debian mirror. Multivalued fields: * MD5Sum: md5sum, size, name * SHA1: sha1, size, name * SHA256: sha256, size, name * SHA512: sha512, size, name * :class:`Changes` represents a .changes file that is uploaded to "change the archive" by including new source or binary packages. Multivalued fields: * Files: md5sum, size, section, priority, name * Checksums-Sha1: sha1, size, name * Checksums-Sha256: sha256, size, name * Checksums-Sha512: sha512, size, name * :class:`PdiffIndex` represents a pdiff Index file (`foo`.diff/Index) file from a Debian mirror. Multivalued fields: * SHA1-Current: SHA1, size * SHA1-History: SHA1, size, date * SHA1-Patches: SHA1, size, date * SHA1-Download: SHA1, size, filename * X-Unmerged-SHA1-History: SHA1, size, date * X-Unmerged-SHA1-Patches: SHA1, size, date * X-Unmerged-SHA1-Download: SHA1, size, filename * SHA256-Current: SHA256, size * SHA256-History: SHA256, size, date * SHA256-Patches: SHA256, size, date * SHA256-Download: SHA256, size, filename * X-Unmerged-SHA256-History: SHA256, size, date * X-Unmerged-SHA256-Patches: SHA256, size, date * X-Unmerged-SHA256-Download: SHA256, size, filename * :class:`Removals` represents the ftp-master removals file listing when and why source and binary packages are removed from the archive. Input ===== Deb822 objects are normally initialized from a file object (from which at most one paragraph is read) or a string. Alternatively, any sequence that returns one line of input at a time may be used, e.g a list of strings. PGP signatures, if present, will be stripped. Example:: >>> from debian.deb822 import Deb822 >>> filename = '/var/lib/apt/lists/deb.debian.org_debian_dists_sid_InRelease' >>> with open(filename) as fh: # doctest: +SKIP ... rel = Deb822(fh) >>> print('Origin: {Origin}\nCodename: {Codename}\nDate: {Date}'.format_map( # doctest: +SKIP ... rel)) Origin: Debian Codename: sid Date: Sat, 07 Apr 2018 14:41:12 UTC >>> print(list(rel.keys())) # doctest: +SKIP ['Origin', 'Label', 'Suite', 'Codename', 'Changelogs', 'Date', 'Valid-Until', 'Acquire-By-Hash', 'Architectures', 'Components', 'Description', 'MD5Sum', 'SHA256'] In the above, the `MD5Sum` and `SHA256` fields are just a very long string. If instead the :class:`Release` class is used, these fields are interpreted and can be addressed:: >>> from debian.deb822 import Release >>> filename = '/var/lib/apt/lists/deb.debian.org_debian_dists_sid_InRelease' >>> with open(filename) as fh: # doctest: +SKIP ... rel = Release(fh) >>> wanted = 'main/binary-amd64/Packages' >>> [(l['sha256'], l['size']) for l in rel['SHA256'] if l['name'] == wanted] # doctest: +SKIP [('c0f7aa0b92ebd6971c0b64f93f52a8b2e15b0b818413ca13438c50eb82586665', '45314424')] Iteration ========= All classes use the :func:`~Deb822.iter_paragraphs` class method to easily iterate through each paragraph in a file that contains multiple entries (e.g. a Packages.gz file). For example:: >>> with open('/mirror/debian/dists/sid/main/binary-i386/Sources') as f: # doctest: +SKIP ... for src in Sources.iter_paragraphs(f): ... print(src['Package'], src['Version']) The `iter_paragraphs` methods can use python-apt if available to parse the data, since it significantly boosts performance. If python-apt is not present and the file is a compressed file, it must first be decompressed manually. Note that python-apt should not be used on `debian/control` files since python-apt is designed to be strict and fast while the syntax of `debian/control` is a superset of what python-apt is designed to parse. This function is overridden to force use of the python-apt parser using `use_apt_pkg` in the :func:`~Packages.iter_paragraphs` and :func:`~Sources.iter_paragraphs` functions. Sample usage ============ Manipulating a .dsc file:: from debian import deb822 with open('foo_1.1.dsc') as f: d = deb822.Dsc(f) source = d['Source'] version = d['Version'] for f in d['Files']: print('Name:', f['name']) print('Size:', f['size']) print('MD5sum:', f['md5sum']) # If we like, we can change fields d['Standards-Version'] = '3.7.2' # And then dump the new contents with open('foo_1.1.dsc2', 'w') as new_dsc: d.dump(new_dsc) (TODO: Improve, expand) Deb822 Classes -------------- N)AnyCallablecastDict FrozenSet GeneratorIteratorIterableIOListMappingMutableMappingOptionaloverloadProtocolSetTextTupleTypeTypeVarUnion TYPE_CHECKING T_Deb822Dict Deb822Dictbound)Literal TypedDictFcyNfs //usr/lib/python3/dist-packages/debian/deb822.pyr%,c|Sr r!)tvs r$r%r%-sAr') OrderedSet_CaseInsensitiveString_strIdefault_field_sort_key)function_deprecated_byTcd |jy#ttjf$rYywxYw)zp test that a file-like object is really a filehandle Only filehandles can be given to apt_pkg.TagFile. TF)filenoAttributeErrorioUnsupportedOperationr"s r$ _has_filenor5Ks0    B33 4s //ct|Sr )r-)r*s r$ _cached_strIr8Ys  8Or'z&/usr/share/keyrings/debian-keyring.gpgz /usr/bin/gpgvz debian.deb822ceZdZdZy)Errorz0Base class for custom exceptions in this module.N__name__ __module__ __qualname____doc__r!r'r$r:r:fs:r'r:ceZdZdZy)RestrictedFieldErrorz>Raised when modifying the raw value of a field is not allowed.Nr;r!r'r$rArAjsHr'rAc8eZdZdZ dfd ZdZdZdZxZS)TagSectionWrapperzWrap a TagSection object, using its find_raw method to get field values This allows us to pick which whitespace to strip off the beginning and end of the data, so we don't lose leading newlines. c^||_|xs t|_tt|yr )_TagSectionWrapper__section _AutoDecoderdecodersuperrC__init__)selfsectionrG __class__s r$rIzTagSectionWrapper.__init__{s( !0,.  /1r'c#vK|jjD]}|jdr|ywN#)rEkeys startswithrJkeys r$__iter__zTagSectionWrapper.__iter__s3>>&&( C>>#&  s/99ct|jjDcgc]}|jds|c}Scc}wrN)lenrErPrQrRs r$__len__zTagSectionWrapper.__len__sA4>>#6#6#80C>>#.01 10sAc|jj|}|jj|}| t |||j ddzd}|j djdS)N:z  )rEfind_rawrGdecodeKeyErrorfindlstriprstrip)rJrSsrawsdatas r$ __getitem__zTagSectionWrapper.__getitem__sq~~&&s+ LL   % 93- Q {{5!((..r'r ) r<r=r>r?rIrTrWre __classcell__rLs@r$rCrCts!2 1 /r'rCceZdZdZ dfd ZdZdZdZdZdZ d Z d Z d Z d Z d ZddZdZdZdZdZxZS)ra3A dictionary-like object suitable for storing RFC822-like data. Deb822Dict behaves like a normal dict, except: - key lookup is case-insensitive - key order is preserved - if initialized with a _parsed parameter, it will pull values from that dictionary-like object as needed (rather than making a copy). The _parsed dict is expected to be able to handle case-insensitive keys. If _parsed is not None, an optional _fields parameter specifies which keys in the _parsed dictionary are exposed. Nci|_t|_d|_||_t |j|_tt|'|;g}t|dr|j}n t|} |D] \}}|||<  |||_|=|jj|jDcgc] }t!|c}y|jj|D cgc]} | |jvst!| c} yy#t$r4t|j}t||} td|| fzwxYwcc}wcc} w)NitemszCdictionary update sequence element #%d has length %d; 2 is required)_Deb822Dict__dictr+_Deb822Dict__keys_Deb822Dict__parsedencodingrFrGrHrrIhasattrrjlist ValueErrorrVextendr8) rJ_dict_parsed_fieldsrnrjkr*thislen_r#rLs r$rIzDeb822Dict.__init__sI  l    #DMM2  j$(*  Eug& U  ?! DAqDG   #DM ""T]]#KLO#KL ""W#[T]]HZLO#[\  ?4;;'5;' /26>?? ?$L#[s?D=E0E E=Ec#HK|jD]}t|ywr )rlstrrRs r$rTzDeb822Dict.__iter__s";; Cc(N s "c,t|jSr )rVrlrJs r$rWzDeb822Dict.__len__s4;;r'cnt|}|jj|||j|<yr )r8rladdrk)rJrSvaluekeyis r$ __setitem__zDeb822Dict.__setitem__s,C  ! Dr'ct|} |j|}|j j |S#t$r.|j||jvr|j|}nYQwxYwr )r-rkr^rmrlrGr])rJrSrrs r$rezDeb822Dict.__getitem__sqSz KK%E||""5)) }}(TT[[-@ d+ s74A.-A.ct|}|jj| |j|=y#t$rYywxYwr )r-rlremoverkr^rJrSrs r$ __delitem__zDeb822Dict.__delitem__sBSz 4   D!   s 6 AAc4t|}||jvSr )r-rlrs r$ __contains__zDeb822Dict.__contains__sSzt{{""r'cL|jjt|y)z9Re-order the given field so it is "last" in the paragraphN)rl order_lastr-rJfields r$rzDeb822Dict.order_lasts uU|,r'cL|jjt|y)z:Re-order the given field so it is "first" in the paragraphN)rl order_firstr-rs r$rzDeb822Dict.order_firsts e -r'c`|jjt|t|y)zRe-order the given field so appears directly after the reference field in the paragraph The reference field must be present.N)rl order_beforer-rJrreference_fields r$rzDeb822Dict.order_before#s!   uu_/EFr'c`|jjt|t|y)zRe-order the given field so appears directly before the reference field in the paragraph The reference field must be present. N)rl order_afterr-rs r$rzDeb822Dict.order_after*s! e eO.DEr'c^|t}tt|j||_y)a Re-order all fields :param key: Provide a key function (same semantics as for sorted). Keep in mind that Deb822 preserve the cases for field names - in generally, callers are recommended to use "lower()" to normalize the case. N)rS)r.r+sortedrlrRs r$ sort_fieldszDeb822Dict.sort_fields2s% ;(C  !=> r'c ddj|jDcgc] \}}|d|c}}zScc}}w)Nz{%s}, : )joinrj)rJrvr*s r$__repr__zDeb822Dict.__repr__>s3 "NAq!#4"NOOO"Ns; cdt|}t|}||k(sy|D]}||||k7syy)NFT)r)rJothermykeys otherkeysrSs r$__eq__zDeb822Dict.__eq__BsF5M " CCyE#J&  r'c(|j|}|Sr rg)rJcopys r$rzDeb822Dict.copyTs~~d# r')NNNutf-8r )r<r=r>r?rIrTrWrrerrrrrrrrr__hash__rrfrgs@r$rrsm "! ']V  "*$ #- . GF ?P  Hr'cPeZdZdZ d%dZer eddZe d&dZ e dZ dZ e je d zZe jd Z d'd Zd Zd ZdZdZdZdZdZdZedZe d(dZe d)dZe d*dZe d*dZ d*dZe dZeeZe dZeeZ dZ!ee!Z" d+dZ#ee#Z$e jdZ%e d+dZ&e d+d Z'ed+d!Z(d+d"Z)d#Z*d$Z+y),Deb822uZ Generic Deb822 data :param sequence: a string, or any object that returns a line of input each time, normally a file. Alternately, sequence can be a dict that contains the initial key-value pairs. When python-apt is present, sequence can also be a compressed object, for example a file object associated to something.gz. :param fields: if given, it is interpreted as a list of fields that should be parsed (the rest will be discarded). :param _parsed: internal parameter. :param encoding: When parsing strings, interpret them in this encoding. (All values are given back as unicode objects, so an encoding is necessary in order to properly interpret the strings.) :param strict: Dict controlling the strictness of the internal parser to permit tuning of its behaviour between "generous in what it accepts" and "strict conformance". Known keys are described below. *Internal parser tuning* - `whitespace-separates-paragraphs`: (default: `True`) Blank lines between paragraphs should not have any whitespace in them at all. However: - Policy §5.1 permits `debian/control` in source packages to separate packages with lines containing whitespace to allow human edited files to have stray whitespace. Failing to honour this breaks tools such as `wrap-and-sort `_ (see, for example, `Debian Bug 715558 `_). - `apt_pkg.TagFile` accepts whitespace-only lines within the `Description` field; strictly matching the behaviour of apt's Deb822 parser requires setting this key to `False` (as is done by default for :class:`Sources` and :class:`Packages`. (see, for example, `Debian Bug 913274 `_). Note that these tuning parameter are only for the parser that is internal to `Deb822` and do not apply to python-apt's apt_pkg.TagFile parser which would normally be used for Packages and Sources files. Nci}d}t|drtt|}ntt|}tj |||||| |j |||d|_yd|_y#t$r Yd|_ywxYw)Nrj)rsrtrurn) ror Deb822Mapping InputDataTyperrI_internal_parserEOFErrorgpg_info)rJsequencefieldsrtrnstrictrsiterables r$rIzDeb822.__init__s 8W %1EM84HDw%-  /   %%h?     sA22 BBT_Deb822rc #"K|xr t|}|rtsd}tj|n|r|sd}tj|trF|rDt j |d} | D]'} ||t | t||} | s$| )yg} t|trt|j} n5t|trt|j} n t|} || |||} | sy| w)aGenerator that yields a Deb822 object for each paragraph in sequence. :param sequence: same as in __init__. :param fields: likewise. :param use_apt_pkg: if sequence is a file, apt_pkg can be used if available to parse the file, since it's much much faster. Set this parameter to True to enable use of apt_pkg. Note that the TagFile parser from apt_pkg is a much stricter parser of the Deb822 format, particularly with regards whitespace between paragraphs and comments within paragraphs. If these features are required (for example in debian/control files), ensure that this parameter is set to False. :param shared_storage: not used, here for historical reasons. Deb822 objects never use shared storage anymore. :param encoding: Interpret the paragraphs in this encoding. (All values are given back as unicode objects, so an encoding is necessary in order to properly interpret the strings.) :param strict: dict of settings to tune the internal parser if that is being used. See the documentation for :class:`Deb822` for details. z}Parsing of Deb822 data with python3-apt's apt_pkg was requested but this package is not importable. Is python3-apt installed?zjParsing of Deb822 data with python3-apt's apt_pkg was requested but this cannot be done on non-file input.T)bytes)rrtrn)rnrN) r5 _have_apt_pkgwarningswarnapt_pkgTagFilerCrF isinstancerziter splitlinesr)clsrr use_apt_pkgshared_storagernrapt_pkg_allowedmsgparserrK paragraphrxs r$iter_paragraphszDeb822.iter_paragraphssD&?+h*? },  MM#  G  MM#  ___XT:F! $v(9'&8FK s BDA=Dc#Kd}|D]N}t|tr|j}|jdr5|r|j dsId}|Pyw)zyYields only lines that do not begin with '#'. Also skips any blank lines at the beginning of the input. T# FN)rrzencoderQra)r at_beginninglines r$_skip_useless_lineszDeb822._skip_useless_liness^  D$${{}t${{7+$ J sAAz!^(?P[^: \t\n\r\f\v]+)\s*:\s*z(?P(?:\S+(\s+\S+)*)?)\s*$z((?P[^ ]+)( \((?P.+)\))?cfd}t|ttfr|j}d}d}|j |j ||D]}|j j|}|jj|} | r5|r|||<| jd}||sd}^| jd}p|ss|djs|jr|d|zz }|r|||<yy)Ncduxs|vSr r!)r#rs r$ wanted_fieldz-Deb822._internal_parser..wanted_field'sT>0Q&[ 0r'rSrdrr[) rrzrr_gpg_stripped_paragraphrrG decode_bytes _new_field_rematchgroupisspace) rJrrrrcurkeycontent linebytesrms ` r$rzDeb822._internal_parser s 1 he -**,H55((2F< I<<,,Y7D""((.A#*DL#F+!F''&/Q)$,,.4$;&+ . "DL r'c.|j}||SdSNrdumprJds r$__str__zDeb822.__str__K IIKMq)r)r'c.|j}||SdSrrrs r$ __unicode__zDeb822.__unicode__Prr'c`|j}||j|jSdS)Nr')rrrnrs r$ __bytes__zDeb822.__bytes__Us) IIK*+-qxx &@S@r'ct||S)zReturn the self[key] as a string (or unicode) The default implementation just returns unicode(self[key]); however, this can be overridden in subclasses (e.g. _multivalued) that can take special values. rzrRs r$ get_as_stringzDeb822.get_as_string\s49~r'c#zK|D]2}|j|}|r|ddk(r |d|d}n|d|d}|4yw)Nrr[rYr)r)rJrSrentrys r$ _dump_formatzDeb822._dump_formatfsN C&&s+EE!H, &)%0&)51K s9;c@dj|jSr)rrr|s r$ _dump_strzDeb822._dump_strtswwt((*++r'cn|jD]"}|j|j|$yr )rwriter)rJfdrnrs r$ _dump_fd_bzDeb822._dump_fd_bxs1 &&( -E HHU\\(+ , -r'cP|jD]}|j|yr )rr)rJrrs r$ _dump_fd_tzDeb822._dump_fd_ts'&&( E HHUO r'cyr r!r|s r$rz Deb822.dumps r'cyr r!rJrrn text_modes r$rz Deb822.dump r'cyr r!rs r$rz Deb822.dumprr'cyr r!rs r$rz Deb822.dumprr'cyr r!rs r$rz Deb822.dumprr'c||jS|r'|jttt|y| |j }|j ttt||y)aDump the contents in the original format :param fd: file-like object to which the data should be written (see notes below) :param encoding: str, optional (Defaults to object default). Encoding to use when writing out the data. :param text_mode: bool, optional (Defaults to ``False``). Encoding should be undertaken by this function rather than by the caller. If fd is None, returns a unicode object. Otherwise, fd is assumed to be a file-like object, and this method will write the data to it instead of returning a unicode object. If fd is not none and text_mode is False, the data will be encoded to a byte string before writing to the file. The encoding used is chosen via the encoding parameter; None means to use the encoding the object was initialized with (utf-8 by default). This will raise UnicodeEncodeError if the encoding can't support all the characters in the Deb822Dict values. N)rrrr rzrnrrrs r$rz Deb822.dumpse@ :>># #  OODC"- .  == OODEB/ :r'c&|jd S)Nr[)countrcs r$is_single_linezDeb822.is_single_lines774=  r'c.tj| Sr )rrrs r$ is_multi_linezDeb822.is_multi_lines((+++r'c|s|S|s|S|j|rl|j|r[d}||zjdrd}t||z|zj|}|dx}}|ddD]}||k(r ||z|z}|}|S|j |rE|j |r4|j dD]}||j dvs|dz|z} |St )N rrrZTr[)rrrsplitrrrq)rJs1s2delimLprevmergeditems r$ _merge_fieldszDeb822._merge_fieldss II   r "t':':2'> ERt$U R..u56AaD D6!" 4<%$.   M   b !d&8&8&< d+ *r}}T22dT)B *Ir'c||}|}n|}|}||vr||vr|j||||}n||vr||}n||vr||}nt||||<y|Sr )rr^)rJrSd1d2x1x2r s r$ merge_fieldszDeb822.merge_fieldss :BBBB "9''3C9F BYWF BYWFN :DI r's=^-----(?PBEGIN|END) PGP (?P[^-]+)-----[\r\t ]*$cBd|D}tj||S)aReturn a (gpg_pre, payload, gpg_post) tuple Each element of the returned tuple is a list of lines (with trailing whitespace stripped). :param sequence: iterable. An iterable that yields lines of data (str, unicode, bytes) to be parsed, possibly including a GPG in-line signature. :param strict: dict, optional. Control over the strictness of the parser. See the :class:`Deb822` class documentation for details. c3`K|]&}t|tr|jn|(ywr )rrzr).0rs r$ z/Deb822.split_gpg_and_payload..Vs$W:a+=QXXZ1DWs,.)r)r_split_gpg_and_payload)rr_encoded_sequences r$split_gpg_and_payloadzDeb822.split_gpg_and_payloadAs'*XhW,,->v,NNr'c|si}g}g}g}d}|jdd}d}|D]B}|jd}|r|r|jr*d}|jdrtj j |nd} |r| xs|jn| } | sR|dk(r| s|j||rn|dk(r| rd}|j||dk(s|j|| jd d k(r| jd }n'| jd d k(r|j|n-| r|s|j|2|j|E|r|||fStd )NsSAFEwhitespace-separates-paragraphsTrF-sSIGNED MESSAGEs SIGNATUREactionsBEGINwhatsENDzonly blank lines found in input) getstriprrQr_gpgrerappendrr) rr gpg_pre_lineslinesgpg_post_linesstateaccept_empty_or_whitespace first_linerr is_empty_lines r$rzDeb822._split_gpg_and_payloadYsF &,ZZ0QSW%X" ) 4D::g&Dt||~" -1__T-B ##D)A;UH6 ^bZbMG#( T*,"//$ '%,,T2l*"))$/778$0GGFOEWWX&&0"))$/$ %,,T2&--d3S) 4V !5.9 9899r'c,|j||dS)NrZ)r)rrrs r$rzDeb822._gpg_stripped_paragraphs))(F;A>>r'ct|ds td|j&tj |j ||_|jS)a Return a GpgInfo object with GPG signature information This method will raise ValueError if the signature is not available (e.g. the original text cannot be found). :param keyrings: list of keyrings to use (see GpgInfo.from_sequence) raw_textzoriginal text cannot be found)keyrings)rorqrGpgInfo from_sequencer.)rJr/s r$ get_gpg_infozDeb822.get_gpg_infosStZ(<= = == $11$--;C2EDM}}r'cd|vry|jdr tdt|jD]6\}}|dk(r |s td|dj r-tdy)zRaise ValueError if value is not a valid value for key Subclasses that do interesting things for different keys may wish to override this method. r[Nzvalue must not end in '\n'rzvalue must not have blank linesz$each line must start with whitespace)endswithrq enumeraterr)rJrSrnors r$validate_inputzDeb822.validate_inputs u   >>$ :; ; "%"2"2"45 IHBQw !BCC7??$ !GHH  Ir'cV|j||tj|||yr )r7rr)rJrSrs r$rzDeb822.__setitem__s$ C'tS%0r')NNNrN)NFFrNNNNF)NT)NNFr ),r<r=r>r?rIrrr classmethodr staticmethodr _key_partrecompiler_explicit_source_rerrrrrrrrrrrrr/ isSingleLiner isMultiLiner _mergeFieldsr mergeFieldsr#rrrr2r7rr!r'r$rr]sA,^! 8:X6 $$)',!(# MMb.5IBJJy+MMNM %"** #!% $)#V* * A ,-          ,`!!*.9L,,)7K%N*-8L "H)6KRZZ>?F%)OO.&*A:A:F??0I:1r'rczeZdZdZdZfdZdZdZed dZ e d dZ e dZ ed Z xZS) r0a"A wrapper around gnupg parsable output obtained via --status-fd This class is really a dictionary containing parsed output from gnupg plus some methods to make sense of the data. Keys are keywords and values are arguments suitably split. See /usr/share/doc/gnupg/DETAILS.gz)GOODSIGEXPSIG EXPKEYSIG REVKEYSIGBADSIGcHtt| |i|d|_d|_yr )rHr0rIouterrrJargskwargsrLs r$rIzGpgInfo.__init__s% gt%t6v6r'cd|vxsd|vS)zIs the signature valid?rFVALIDSIGr!r|s r$validz GpgInfo.validsD 6J$$66r'cy)z>Return the primary ID of the signee key, None is not availableNr!r|s r$uidz GpgInfo.uidr&r'c|}t|tr|jd|_n||_t|tr|jd|_n||_d}|jD]}|j |s|t |d}|jd}|jd}|d|}||jvr||dzdjdd}n||dzdjd}|dvr|||<|S)a" Create a GpgInfo object based on the gpg or gpgv output Create a new GpgInfo object from gpg(v) --status-fd output (out) and optionally collect stderr as well (err). Both out and err can be lines in newline-terminated sequence or regular strings. r[z [GNUPG:] NrrZ)NEWSINEWSIGKEY_CONSIDEREDPROGRESS) rrzrrLrMrQrVr"r_uidkeys) rrLrMnheaderrrcrSrs r$ from_outputzGpgInfo.from_outputs  E c3 IIdOAEAE c3 IIdOAEAEEE D??6*F %D::d#D #Ar(Cckk!QqST ((a0QqST ((- GGAcF/ 0r'c<|xst}|xstg}t|}|jddg|D]}|jd|gd|vr t dt j |t jt jt jd5}t|tr|}n|j|}|j|\}} ddd|jjd jdS#1swY9xYw) aCreate a new GpgInfo object from the given sequence. :param sequence: sequence of lines of bytes or a single byte string :param keyrings: list of keyrings to use (default: ['/usr/share/keyrings/debian-keyring.gpg']) :param executable: list of args for subprocess.Popen, the first element being the gpgv executable (default: ['/usr/bin/gpgv']) z --status-fd1z --keyringz'cannot access any of the given keyringsF)stdinstdoutstderruniversal_newlinesNr)GPGV_DEFAULT_KEYRINGSGPGV_EXECUTABLErprrIOError subprocessPopenPIPErr_get_full_bytes communicater^r]) rrr/ executablerOrvpinprLrMs r$r1zGpgInfo.from_sequence3s $444O#4 J ]C() *A KKa( ) * d "CD D       $ *(E*))(3}}S)HC *szz'2"zz'24 4 * *s !9DDct|} t|}d}|jdrd}||z|j |zS#t$rYywxYw)zReturn a byte string from a sequence of lines of bytes. This method detects if the sequence's lines are newline-terminated, and constructs the byte string appropriately. r' )rnext StopIterationr4r)r sequence_iterr*join_strs r$rkzGpgInfo._get_full_bytesascX  m,J   u %HH$x}}]'CCC   s A AAcrt|d5}|j|g|i|cdddS#1swYyxYw)z]Create a new GpgInfo object from the given file. See GpgInfo.from_sequence. rbN)openr1)rtargetrOrP target_files r$ from_filezGpgInfo.from_filetsC&$  C;$3$$[B4B6B C C Cs-6r r9)r<r=r>r?r[rIrSrUr;r^r1r<rkr{rfrgs@r$r0r0s~+HG 7M00d $!%+4+4ZDD$CCr'r0c eZdZdZej dZej dZej dZej dZ ej dZ ej dZ e jdd d gZe jd d d gZer)ed eeeeeeefeedeeeddZedZedZy) PkgRelationzInter-package relationships Structured representation of the relationships of a package to another, i.e. of what can appear in a Deb882 field like Depends, Recommends, Suggests, ... (see Debian Policy 7.1). z^\s*(?P[a-zA-Z0-9][a-zA-Z0-9.+\-]*)(:(?P([a-zA-Z0-9][a-zA-Z0-9-]*)))?(\s*\(\s*(?P[>=<]+)\s*(?P[0-9a-zA-Z:\-+~.]+)\s*\))?(\s*\[(?P[\s!\w\-]+)\])?\s*((?P<.+>))?\s*$z\s*,\s*z\s*\|\s*z\s+z>\s*\!)?(?P[^\s]+)ArchRestrictionenabledarchBuildRestrictionprofileParsedRelationzPkgRelation.ArchRestrictionzPkgRelation.BuildRestrictionnamearchqualversionr restrictionsc fdfdfd}jj|j}tjj|}|Dcgc]}|Dcgc] }|| c}c}}Scc}wcc}}w)z|Parse a package relationship string (i.e. the value of a field like Depends, Recommends, Build-Depends ...) cg}jj|jD]3}|ddk(}|r|dd}|jj | |5|S)Nr!rZ)_PkgRelation__blank_sep_RErr"r$r~)rawarchsrdisabledrs r$ parse_archsz0PkgRelation.parse_relations..parse_archssoE**00= F7c>8D S00XtDE  F Lr'c g}jj|jjd}|D]}g}jj|D]Z}j j |}|s!|j}|jj|ddk7|d\|j||S)aZ split a restriction formula into a list of restriction lists Each term in the restriction list is a namedtuple of form: (enabled, label) where enabled: bool: whether the restriction is positive or negative profile: the profile name of the term e.g. 'stage1' z<> rrr) _PkgRelation__restriction_sep_RErlowerr"r_PkgRelation__restriction_REr groupdictr$r) rrgroupsrgrpr restrictionrpartsrs r$parse_restrictionsz7PkgRelation.parse_relations..parse_restrictionssL--33CIIK4E4Ee4LMF +##5#;#;D#AK0066{CE % 1 00 %i 0C 7 %i 0 ##E* + r'c4jj|}|r]|j}|d|ddddd}|ds|dr |d|df|d<|dr|d|d<|dr|d|d<|Stj d ||dddddS) Nrrrreloprrrrz8cannot parse package relationship "%s", returning it raw)_PkgRelation__dep_RErrloggerwarning)rrrrrrrs r$ parse_relz.PkgRelation.parse_relations..parse_relsLL&&s+E)!&M %j 1# $( >U9%5$)'NE)4D#EAiL> +E'N ;AfI((:n-)/An% NN78; =  $  r')_PkgRelation__comma_sep_RErr"map_PkgRelation__pipe_sep_RE) rrrtl_depscnfor_depsor_deprrs ` @@r$parse_relationszPkgRelation.parse_relationssp  8 @$$**399;7###))73ILMg9v6"9MM9Ms# B ,B ;B B c\ddfddjtfd|S)zFormat to string structured inter-package relationships Perform the inverse operation of parse_relations, returning a string suitable to be written in a package stanza. c>|jrdnd|jS)Nrr)rr) arch_specs r$pp_archz PkgRelation.str..pp_archs% ''S0 r'cg}|D]/}|j|jrdnd|j1ddj|zS)Nrrz<%s>r)r$rrr)rrcterms r$pp_restrictionsz(PkgRelation.str..pp_restrictions sQA$ "ll3  CHHQK' 'r'cP|d}|jd |d|dzz }|jd}||d|zz }|jd}|!|ddjt|zz }|jd }|!|d djt|zz }|S) Nrrz:%srz (%s %s)rz [%s]rr %s)r!rr)deprcr*arrrs r$ pp_atomic_depz&PkgRelation.str..pp_atomic_depsF Awwz".US_,, "A}Z!^#A}WsxxGQ888'A}USXXc/1&=>>>Hr'rc:djt|S)Nz | rr)depsrs r$r%z!PkgRelation.str..+sUZZM4(@Ar'r)relsrrrs @@@r$rzzPkgRelation.strs2  ( &yy A4 HJ Jr'N)r<r=r>r?r>r?rrrrrr collections namedtupler~rrrrzrrr rr;rr<r!r'r$r}r}s7rzz H RZZ +NBJJ{+MRZZ'N%2::h/!rzz  -k,,->.7-@BO-{--.@/8).DF" $SM#E#s(O4 &C!DE (d3Q.R)S T    NNNN`.J.Jr'r}ceZdZdZdZy)_lowercase_dictz4Dictionary wrapper which lowercase keys upon lookup.cJtj||jSr )dictrerrRs r$rez_lowercase_dict.__getitem__7sciik22r'N)r<r=r>r?rer!r'r$rr4s >3r'rceZdZdZdZy)_HasVersionFieldProtocolcyr r!)rJrcs r$rez$_HasVersionFieldProtocol.__getitem__? r'cyr r!)rJrcr*s r$rz$_HasVersionFieldProtocol.__setitem__Crr'N)r<r=r>rerr!r'r$rr=s   r'rceZdZdZdZdZy)_VersionAccessorMixinz>Give access to Version keys as debian_support.Version objects.cFtjj|dSNVersion)debiandebian_supportrr|s r$ get_versionz!_VersionAccessorMixin.get_versionJs$$,,T)_==r'c t||d<yrr)rJrs r$ set_versionz!_VersionAccessorMixin.set_versionNsg,Yr'N)r<r=r>r?rrr!r'r$rrHsH>'r'rc*eZdZdZgZdZedZy)_PkgRelationMixinaPackage relationship mixin Inheriting from this mixin you can extend a :class:`Deb822` object with attributes letting you access inter-package relationship in a structured way, rather than as strings. For example, while you can usually use ``pkg['depends']`` to obtain the Depends string of package pkg, mixing in with this class you gain pkg.depends to access Depends as a Pkgrel instance To use, subclass _PkgRelationMixin from a class with a _relationship_fields attribute. It should be a list of field names for which structured access is desired; for each of them a method wild be added to the inherited class. The method name will be the lowercase version of field name; '-' will be mangled as '_'. The method would return relationships in the same format of the PkgRelation' relations property. See Packages and Sources as examples. cti|_d|_|jD]5}|j }||vrd|j|<'g|j|<7yr:)r_PkgRelationMixin__relations#_PkgRelationMixin__parsed_relations_relationship_fieldsr)rJrOrPrkeynames r$rIz_PkgRelationMixin.__init__isd +2."'-- /DjjlGt|,0  )-/  ) /r'cjsZtfdjj}|D]'}tj |j|<)d_jS)a Return a dictionary of inter-package relationships among the current and other packages. Dictionary keys depend on the package kind. Binary packages have keys like 'depends', 'recommends', ... while source packages have keys like 'build-depends', 'build-depends-indep' and so on. See the Debian policy for the comprehensive field list. Dictionary values are package relationships returned as lists of lists of dictionaries (see below for some examples). The encoding of package relationships is as follows: - the top-level lists corresponds to the comma-separated list of :class:`Deb822`, their components form a conjunction, i.e. they have to be AND-ed together - the inner lists corresponds to the pipe-separated list of :class:`Deb822`, their components form a disjunction, i.e. they have to be OR-ed together - member of the inner lists are dictionaries with the following keys: ``name`` package (or virtual package) name ``version`` A pair <`operator`, `version`> if the relationship is versioned, None otherwise. operator is one of ``<<``, ``<=``, ``=``, ``>=``, ``>>``; version is the given version as a string. ``arch`` A list of pairs <`enabled`, `arch`> if the relationship is architecture specific, None otherwise. Enabled is a boolean (``False`` if the architecture is negated with ``!``, ``True`` otherwise), arch the Debian architecture name as a string. ``restrictions`` A list of lists of tuples <`enabled`, `profile`> if there is a restriction formula defined, ``None`` otherwise. Each list of tuples represents a restriction list while each tuple represents an individual term within the restriction list. Enabled is a boolean (``False`` if the restriction is negated with ``!``, ``True`` otherwise). The profile is the name of the build restriction. https://wiki.debian.org/BuildProfileSpec The arch and restrictions tuples are available as named tuples so elements are available as `term[0]` or alternatively as `term.enabled` (and so forth). Examples: ``"emacs | emacsen, make, debianutils (>= 1.7)"`` becomes:: [ [ {'name': 'emacs'}, {'name': 'emacsen'} ], [ {'name': 'make'} ], [ {'name': 'debianutils', 'version': ('>=', '1.7')} ] ] ``"tcl8.4-dev, procps [!hurd-i386]"`` becomes:: [ [ {'name': 'tcl8.4-dev'} ], [ {'name': 'procps', 'arch': (false, 'hurd-i386')} ] ] ``"texlive "`` becomes:: [ [ {'name': 'texlive', 'restriction': [[(false, 'cross')]]} ] ] c&j|duSr )r)r\rJs r$r%z-_PkgRelationMixin.relations..s)9)9!)<)Dr'T)rfilterrrPr}r)rJ lazy_relsr\s` r$ relationsz_PkgRelationMixin.relationsst^&&D#//4468I K&1&A&A$q'&J  # K'+D #r'N)r<r=r>r?rrIpropertyrr!r'r$rrTs*$/.U U r'rc2eZdZdZiZdZfdZdZxZS) _multivaluedaUA class with (R/W) support for multivalued fields. To use, create a subclass with a _multivalued_fields attribute. It should be a dictionary with *lower-case* keys, with lists of human-readable identifiers of the fields as the values. Please see :class:`Dsc`, :class:`Changes`, and :class:`PdiffIndex` as examples. c tj|g|i||jjD]\}} ||}|j |rg||<||j }nt||<||j}td|jD]+}|tt||j-y#t$rYwxYwr ) rrI_multivalued_fieldsrjr^rr$rupdaterrzipr)rJrOrPrrcontentsupdater_methodrs r$rIz_multivalued.__init__s.t.v.!55;;= FME6 ;!!(+ U !%e!3!3(lU !%e!3!3tX%8%8%:; Fz#fdjjl*CDE F F  sC  CCch|j|jvrytt|||yr )rrrHrr7)rJrSrrLs r$r7z_multivalued.validate_inputs- 99;$22 2  , 4S% @r'c|j}||jvrtj}t ||dr||g}n|j d||}|j|}i} |j }|D]k}|D]S}t||} |||} | t| z dz| z} d| vrtd|z|j d| zU|j dm|jjdStj||S#t$rYwxYw#t$r| } YwxYw)NrPr[rz5'\n' not allowed in component of multivalued field %sr)rrr3StringIOror_fixed_field_lengthsr2rzrVr^rqgetvaluerarr) rJrSkeylrarrayorder field_lengthsr r raw_valuelengthrs r$rz_multivalued.get_as_stringskyy{ 4++ +BtCy&)c S ,,T2EM  $ 9 9   ,A #DG IL!.t!4Q!7"(#i.!8C ?) Ku}(*@BE*FGGHHUU]+ , ;;=''- -##D#..%"  $* )*s$1 D"D1" D.-D.1 D?>D?) r<r=r>r?rrIr7rrfrgs@r$rrs!F( A!/r'rc&eZdZdZdZedZy)_gpg_multivaluedaA _multivalued class that can support gpg signed objects This class's feature is that it stores the raw text before parsing so that gpg can verify the signature. Use it just like you would use the _multivalued class. This class only stores raw text if it is given a raw string, or if it detects a gpg signature when given a file or sequence of lines (see Deb822.split_gpg_and_payload for details). c d_ |d}|jdd}|^t|ddxs|jddxsd t |t r |_n t |t r|j _nt|drn j fd|D|\}}}|r|rtj}|jdj||jd |jdj||jd |jdj||j_ t!|} || d<t#| }t%j&g|i|y#t$r|jdd}YwxYw#t$r gx}x}}YwxYw#t$r||d<YbwxYw) Nrrrrnrrjc3BK|]}j|ywr )_bytes)rrcrnrJs r$rz,_gpg_multivalued.__init__..QsH!T[[H5Hsrqs )r. IndexErrorr!getattrrrrzrrorrr3BytesIOrrrrptuplerrI) rJrOrPrrr%r&r'r.argslrns ` @r$rIz_gpg_multivalued.__init__3s  4AwHHd+   *d;F!::j':F>E (E* ( Hc* ( 9 7+@22HxH"$9M5.!^!zz|HNN5::m#<=NN7+NN5::e#45NN7+NN5::n#=>$,$5$5$7DM/ JE$E!H r?rIr<rr!r'r$rr's# 25h N Nr'rc.eZdZdZgdgdgdgddZy)Dscz Representation of a .dsc (Debian Source Control) file This class is a thin wrapper around the transparent GPG handling of :class:`_gpg_multivalued` and the parsing of :class:`Deb822`. md5sumsizersha1rrsha256rrsha512rrfileschecksums-sha1checksums-sha256checksums-sha512N)r<r=r>r?rr!r'r$rrus ,266 r'rc4eZdZdZgdgdgdgddZdZy) Changesz Representation of a .changes (archive changes) file This class is a thin wrapper around the transparent GPG handling of :class:`_gpg_multivalued` and the parsing of :class:`Deb822`. )rrrKpriorityrrrrrc|ddd} |jd\}}|djdr |ddd }n|dd}d |d|d|dS#t$rd}Y@wxYw) z>Return the path in the pool where the files would be installedrrrK/mainsourcelibNzpool/)rrqrQ)rJrcrK_subdirs r$ get_pool_pathzChanges.get_pool_paths M! Y ' JGQ > $ $U +(^BQ'F(^A&F")64>BB G sA A"!A"N)r<r=r>r?rrr!r'r$r r s$ C266 Cr'r ceZdZdZgdgdgdgddZdgZdZd Zd Zd Z d Z d Z dZ dZ dZdZdZGddZedZy) BuildInfoaW Representation of a .buildinfo (build environment description) file This class is a thin wrapper around the transparent GPG handling of :class:`_gpg_multivalued`, the field parsing of :class:`_PkgRelationMixin`, and the format parsing of :class:`Deb822`. Note that the 'relations' structure returned by the `relations` method is identical to that produced by other classes in this module. Consequently, existing code to consume this structure can be used here, although it means that there are redundant lists and tuples within the structure. Example:: >>> from debian.deb822 import BuildInfo >>> filename = 'package.buildinfo' >>> with open(filename) as fh: # doctest: +SKIP ... info = BuildInfo(fh) >>> print(info.get_environment()) # doctest: +SKIP {'DEB_BUILD_OPTIONS': 'parallel=4', 'LANG': 'en_AU.UTF-8', 'LC_ALL': 'C.UTF-8', 'LC_TIME': 'en_GB.UTF-8', 'LD_LIBRARY_PATH': '/usr/lib/libeatmydata', 'SOURCE_DATE_EPOCH': '1601784586'} >>> installed = info.relations['installed-build-depends'] # doctest: +SKIP >>> for dep in installed: # doctest: +SKIP ... print("Installed %s/%s" % (dep[0]['name'], dep[0]['version'][1])) Installed autoconf/2.69-11.1 Installed automake/1:1.16.2-4 Installed autopoint/0.19.8.1-10 Installed autotools-dev/20180224.1 ... etc ... >>> changelog = info.get_changelog() # doctest: +SKIP >>> print(changelog.author) # doctest: +SKIP 'xyz Build Daemon (xyz-01) ' >>> print(changelog[0].changes()) # doctest: +SKIP ['', ' * Binary-only non-maintainer upload for amd64; no source changes.', ' * Add Python 3.9 as supported version', ''] )md5rrrrr)z checksums-md5r r r zinstalled-build-dependschtj|g|i|tj|g|i|yr )rrIrrJrOrPs r$rIzBuildInfo.__init__s2!!$888""49$9&9r'c||vrtdj|t||jddj j S)Nz'{}' not found in buildinfor[r)r^formatrpreplacer"rrs r$_get_array_valuezBuildInfo._get_array_valuesO  8??FG GDK''b1779??ABBr'c^ttj|jddS)zReturn the build environment that was recorded The environment is returned as a dict in the style of `os.environ`. The backslash quoting of values described in deb-buildinfo(5) is removed. Environmentr)rr_env_deserialiser!r|s r$get_environmentzBuildInfo.get_environments%I..txx r/JKLLr'cd|vry|dj}|Dcgc]}|dk(rdn|dd}}tjj|Scc}w)zReturn the changelog entry from the buildinfo (for binNMUs) If no "Binary-Only-Changes" field is present in the buildinfo file then `None` is returned. zBinary-Only-ChangesNz .rrZ)rr changelog Changelog)rJchlinesrcs r$ get_changelogzBuildInfo.get_changelogsf ! ,,-88:7>?!d2!"-??))'22@sAcd|vr td|jj|d}|s td|j d|j dfS)Nrz%'Source' field not found in buildinfoz Invalid 'Source' field specifiedr)r^r@rrqrrJmatchess r$ get_sourcezBuildInfo.get_sources\ 4 BC C**00h@?@ @}}X& i(@@@r'c$|jdS)NBinaryr r|s r$ get_binaryzBuildInfo.get_binarys$$X..r'cd|vr tdtjj|d}| t dtjj |}t j j|S)Nz build-datez)'Build-Date' field not found in buildinfoz$Invalid 'Build-Date' field specified)r^emailutils parsedate_tzrq mktime_tzdatetime fromtimestamprJ timearraytss r$get_build_datezBuildInfo.get_build_datesl t #FG GKK,,T,-?@  CD D [[ " "9 -  ..r22r'c$|jdS)N Architecturer0r|s r$get_architecturezBuildInfo.get_architectures$$^44r'cl|jDcgc] }|dk(r| }}t|dk(Scc}w)NrrZr?rVrJrarchess r$is_build_sourcezBuildInfo.is_build_source#sC#'#8#8#:'4X%''6{a's1c&d|jvS)Nall)r?r|s r$is_build_arch_allzBuildInfo.is_build_arch_all)s--///r'cj|jDcgc]}|dvr| }}t|dk(Scc}w)N)rFrrZrArBs r$is_build_arch_anyzBuildInfo.is_build_arch_any-sD#'#8#8#:44!22446{a4s 0c eZdZdZdZdZdZdZy)BuildInfo._EnvParserStaterrZrN)r<r=r>IGNORE_WHITESPACEVAR_NAMESTART_VALUE_QUOTEVALUEVALUE_BACKSLASH_ESCAPEr!r'r$_EnvParserStaterK3s!"r'rSc# Ktjj}d}d}|D]}|tjjk(r-|jstjj}|}N|tjjk(r(|dk7r||z }ntjj }d}|tjj k(r,|dk(rtjj }n td|tjj k(rr|dk(rtjj}nP|dk(rB|dk(r td| td||ftjj}d}d}n |J||z }k|tjjk(s|dk(r$|J||z }tjj }n td |tjjk7r td yyw) a extract the environment variables and values from the text Format is: VAR_NAME="value" with ignorable whitespace around the construct (and separating each item). Quote characters within the value are backslash escaped. When producing the buildinfo file, dpkg only includes specifically allowed environment variables and thus there is no defined quoting rules for the variable names. The format is described by deb-buildinfo(5) and implemented in dpkg source scripts/dpkg-genbuildinfo.pl:cleansed_environment(), while the environment variables that are included in the output are listed in dpkg source scripts/Dpkg/Build/Info.pm rN="z6Improper quoting in Environment: begin quote not found\z;Improper formatting in Environment: variable name not foundz>ED 11:::9BJD%55GGEE 11CCC9%55;;E$0 11777:%55LLE3Yrz(6}(7 +%%55GGED E ,,,RKE 11HHH9 ,,,RKE%55;;E$@y< | I--?? ? &  @s F)H-A!HN)r<r=r>r?rrrIr r$r)r-r1r<r?rDrGrIrSr<r#r!r'r$rrs*X1266  ": C M3 A/35 0 ##[[r'rceZdZdZddggdgdgdgdgdgdddggdgdgdgdgdgdd Zed Zd Zy ) PdiffIndexz Representation of a foo.diff/Index file from a Debian mirror This class is a thin wrapper around the transparent GPG handling of :class:`_gpg_multivalued` and the parsing of :class:`Deb822`. SHA1r)r\rdate)r\rfilenameSHA256)r_rr])r_rr^)z sha1-currentz sha1-historyz sha1-patchesz sha1-downloadzx-unmerged-sha1-historyzx-unmerged-sha1-patcheszx-unmerged-sha1-downloadzsha256-currentzsha256-historyzsha256-patcheszsha256-downloadzx-unmerged-sha256-historyzx-unmerged-sha256-patcheszx-unmerged-sha256-downloadc|i}|jD]*}t||dr|j|}d|i||<,|S)NrPr)rro_get_size_field_lengthrJfixed_field_lengthsrSrs r$rzPdiffIndex._fixed_field_lengthssZ!++ 8CtCy&)005F(.'7  $  8#"r'c p||Dcgc]}tt|d}}t|Scc}wNr)rVrzmaxrJrSr lengthss r$raz!PdiffIndex._get_size_field_lengths76:3i@d3s4<()@@7|As3N)r<r=r>r?rrrrar!r'r$r[r[s^  (005#;#;$@#V,449%?%?&D" # #r'r[cbeZdZdZgdgdgdgddZdZdZed eZed Z d Z y ) Releasea9Represents a Release file Set the size_field_behavior attribute to "dak" to make the size field length only as long as the longest actual value. The default, "apt-ftparchive" makes the field 16 characters long regardless. This class is a thin wrapper around the parsing of :class:`Deb822`. rrrr)rrrrapt-ftparchivec0|dvr td||_y)N)rkdakzs 0J0Jr'c\i}|jD]}|j|}d|i||<|Sre)rrarbs r$rzRelease._fixed_field_lengthssG!++ 8C005F(.'7  $ 8#"r'c |jdk(ry|jdk(r2||Dcgc]}tt|d}}t|St dcc}w)Nrkrmrz%Illegal value for size_field_behavior)size_field_behaviorrVrzrfrqrgs r$razRelease._get_size_field_lengthsc  # #'7 7  # #u ,:>s)D$s3tF|,-DGDw< @AAEsAN) r<r=r>r?rrnrprrurrar!r'r$rjrjsW-(,, -+##J#:<##Br'rjcFeZdZdZgdZdZe dfd ZxZS)SourceszRepresent an APT source package list This class is a thin wrapper around the parsing of :class:`Deb822`, using the field parsing of :class:`_PkgRelationMixin`. )z build-dependszbuild-depends-indepzbuild-depends-archzbuild-conflictszbuild-conflicts-indepzbuild-conflicts-archbinarychtj|g|i|tj|g|i|yr )rrIrrs r$rIzSources.__init__ s0 T+D+F+""49$9&9r'c@|sddi}tt| ||||||S)a Generator that yields a Deb822 object for each paragraph in Sources. Note that this overloaded form of the generator uses apt_pkg (a strict but fast parser) by default. See the :func:`~Deb822.iter_paragraphs` function for details. rF)rHrwrrrrrrrnrrLs r$rzSources.iter_paragraphs s9"15FWc2 fk>8VM Mr'NTFrN) r<r=r>r?rrIr;rrfrgs@r$rwrws<  :  $$(',!(# MMr'rwcfeZdZdZgdZdZe dfd ZedZ edZ xZ S)PackageszRepresent an APT binary package list This class is a thin wrapper around the parsing of :class:`Deb822`, using the field parsing of :class:`_PkgRelationMixin`. ) dependsz pre-depends recommendssuggestsbreaks conflictsprovidesreplacesenhancesz built-usingchtj|g|i|tj|g|i|yr )rrIrrs r$rIzPackages.__init__- s0.t.v.""49$9&9r'c@|sddi}tt| ||||||S)a Generator that yields a Deb822 object for each paragraph in Packages. Note that this overloaded form of the generator uses apt_pkg (a strict but fast parser) by default. See the :func:`~Deb822.iter_paragraphs` function for details. rF)rHr~rr{s r$rzPackages.iter_paragraphs2 s9"15FXs3 fk>8VM Mr'cxd|vr|dS|jj|d}|r|jdSy) source package that generates the binary package If the source package and source package version are the same as the binary package, an explicit "Source" field will not be within the paragraph. rpackageN)r@rrr+s r$rzPackages.sourceJ sE 4  ? "**00h@ ==* *r'cd|vr|jS|jj|d}|r#|jdr|jd}n|d}tj j |S)rrrr)rr@rrrrr)rJr,rs r$source_versionzPackages.source_version[ sq 4 ##% %**00h@ w}}Y/mmI.G9oG$$,,W55r'r|) r<r=r>r?rrIr;rrrrrfrgs@r$r~r~! sd  :  $$(',!(# MM. 66r'r~c*eZdZdZ dfd ZxZS)RestrictedFieldzPlaceholder for a property providing access to a restricted field. Use this as an attribute when defining a subclass of RestrictedWrapper. It will be replaced with a property. See the RestrictedWrapper documentation for an example. c4tt| |||||S)aCreate a new RestrictedField placeholder. The getter that will replace this returns (or applies the given to_str function to) None for fields that do not exist in the underlying data object. :param name: The name of the deb822 field. :param from_str: The function to apply for getters (default is to return the string directly). :param to_str: The function to apply for setters (default is to use the value directly). If allow_none is True, this function may return None, in which case the underlying key is deleted. :param allow_none: Whether it is allowed to set the value to None (which results in the underlying key being deleted). )from_strto_str allow_none)rHr__new__)rrrrrrLs r$rzRestrictedField.__new__x s*,_c2 !3# #r')NNT)r<r=r>r?rrfrgs@r$rro s ##r'rzname from_str to_str allow_noneceZdZdZej dZej dZfdZe dZ e dZ e dZ e dZ e d Ze d ZxZS) Removalsa6Represent an ftp-master removals.822 file Removal of packages from the archive are recorded by ftp-masters. See https://ftp-master.debian.org/#removed Note: this API is experimental and backwards-incompatible changes might be required in the future. Please use it and help us improve it! z*\s*(?P.+?)_(?P[^\s]+)\s*z;\s*(?P.+?)_(?P[^\s]+)\s+\[(?P.+)\]cHtt| |i|d|_d|_yr )rHrrI_sources _binariesrNs r$rIzRemovals.__init__ s% h&77 r'ctjj|d}| tdtjj |}t j j |S)z* a datetime object for the removal action r]zNo date specified)r3r4r5rqr6r7r8r9s r$r]z Removals.date sYKK,,T&\:  01 1 [[ " "9 -  ..r22r'cnd|vrgS|djdDcgc] }t|c}Scc}w)z list of bug numbers that had requested the package removal The bug numbers are returned as integers. Note: there is normally only one entry in this list but there may be more than one. bug,rintrJbs r$rz Removals.bug s8  I $U 1 1# 671A7772cnd|vrgS|djdDcgc] }t|c}Scc}w)zk list of WNPP bug numbers closed by the removal The bug numbers are returned as integers. z also-wnpprrrs r$ also_wnppzRemovals.also_wnpp s9 d "I $[ 1 7 7 <=1A===rcnd|vrgS|djdDcgc] }t|c}Scc}w)z list of bug numbers in the package closed by the removal The bug numbers are returned as integers. Removal of a package implicitly also closes all bugs associated with the package. z also-bugsrrrs r$ also_bugszRemovals.also_bugs s9 d "I $[ 1 7 7 <=1A===rc |j |jSg}d|vrh|djD]R}|jj|}|s!|j |j d|j ddT||_|S)a} list of source packages that were removed A list of dicts is returned, each dict has the form:: { 'source': 'some-package-name', 'version': '1.2.3-1' } Note: There may be no source packages removed at all if the removal is only of a binary package. An empty list is returned in that case. sourcesrr)rr)rr_Removals__sources_line_rerr$r)rJrcrr,s r$rzRemovals.sources s == $==   Y224 0066t<HH&-mmI&>'.}}Y'?  r'c p|j |jSg}d|vr|djD]z}|jj|}|s!|j |j d|j dt |j djdd|||_|S)a list of binary packages that were removed A list of dicts is returned, each dict has the form:: { 'package': 'some-package-name', 'version': '1.2.3-1', 'architectures': set(['i386', 'amd64']) } binariesrrrr)rr architectures)rr_Removals__binaries_line_rerr$rsetr)rJrrr,s r$rzRemovals.binaries s >> %>> !   Z(335 1177=HH#*==#;#*==#; g 6 < r?r>r?rrrIrr]rrrrrrfrgs@r$rr s#  $  33 8 8>> > ><r'rc eZdZddZdZdZy)rFNc|xsd|_y)NzUTF-8)rn)rJrns r$rIz_AutoDecoder.__init__" s +G r'cHt|tr|j|S|S)z9If value is not already Unicode, decode it intelligently.)rrrros r$r]z_AutoDecoder.decode& s$ eU #$$U+ + r'c0 |j|jS#t$ro}tj d|jt j |} |j|d}|d|_|cYd}~S#t$r|wxYwd}~wwxYw)Nz?decoding from %s failed; attempting to detect the true encodingrn)r]rnUnicodeDecodeErrorrrchardetdetect)rJreresultdecodeds r$rz_AutoDecoder.decode_bytes- s << . .!  NN/04  ?^^E*F ,,vj'9:!'z 2 %   s, B5BB;B B  BBr )r<r=r>rIr]rr!r'r$rFrF s,r'rF)gr?collections.abcrr7 email.utilsr3 functoolsloggingr3r>rhrrtypingrrrrrrr r r r r rrrrrrrrrrrrIterableInputDataTyperDeb822ValueTyperzrDeb822MutableMappingbuiltinsrtyping_extensionsrr ImportError debian._utilr+r,r-r.debian.deprecationr/debian.debian_supportrdebian.changelogrrrr2r5 lru_cacher8 frozensetrerf getLoggerr Exceptionr:rA_TagSectionWrapper_baseabcrC_Deb822Dict_baserr _BaseGpgInforr0objectr}_lowercase_dict_baserrrrrrrr rr[rjrwr~rrrrFr!r'r$rsNH @2" 4 5      M OC01M)#*>?>>L0 6 OOM S "#K"LM!   ? +;I;I5I+)oo55,//,/^+"55o!oh} 1Z} 1@T#Y'LLXClXCvlJ&lJ^S>3*38'F'B B JK/6K/\KN|KN\  1 #C 5#CLn "35Jnb''T0Bl0Bf'Mc$'MTK6v(*?K6\!#,k,,<>!#FKvK\6yGM " 4    F ^$Ms$A3I-:J -J  J  JJ