ÿØÿà JFIF    ÿÛ „ !.%+&8&+/1555$;@;4?.451 4,$,44444444444414444444444444444444444444444444444444ÿÀ  á á" ÿÄ     ÿÄ ?    !1AQaq"2‘¡±ÁðBRbrÑá#‚’¢²3S CñÿÄ   ÿÄ !    !1QAa‘2ÿÚ   ? 5˜Z¯V¦cø)›t/? z¨±>Õ5€¶‹Á¤·¼z¼Ü¬+ñ®v¤¨_ˆR­BFn©—˜ý®ç̝P8gýt·ÉSTŦˆìät?þé¼íìN/Þa)ì–í6ô… Ï¿øÃj´¿KÇü]ÿ ªô¹-eKànëÕHTx}ýSÜ›ÿ ”7Ø×&µ<¦  ¥ÑO¶[Ù¯ä¨ÞÃÿ PZ-¬;#õ|•oaÿ ©CìÞz3˜öː/¤­ñTûIØ}š^ mÓ%ªxˆ¥ÉŸu=Z+ISe¿45™¼u;ú&WØ÷€æßQ™®{|íx*TC“#ZŠìZ§²‹ 6pv…³¿¡äª*áZÐ%ÒOáˆo"x«OHk w±æ+¬V(kMúŸ5Vö«$ ÁrÏbàb57/luR ¸ÑÛj Òµì`Мq­û žICÀÊ•©4€Âcà¨Ï€O´<èÐ:›ù(Ë^L8þ‘ÍÌ#¸Ð_Ì©ÙK(Öz 4¬û+¸;ü’V’84‘¬ÃŽ:[â‡ÔÌáõp¢~§ªlæ£ö{®G>J¼"°‡7¯ÆÉèßû ‹É‹§ÁòÃýâßî ^ƾÙõ‹×óH#«LP½ïX=xÑÍ$|W?•~• îëÔ©ª‹ {ÝT…Kÿ ”hûâá)J*ö˜–ÔU;iÇ€/ ÆþjóZ\ýwØ=Ìm ºèËL9 ýèÆð/¨’¥öo=nË.%Îì ŽÕ¯È|{Oj²ƒE6e/ßdÄõ²Ìâ1O®ò×TsəԸhOMýíMˆ¿¼H˜l²,7Â¥#MF/Úf°Ö½± ¸–dr‹NýÊ íjqx{œÉ ä-È ¦ øÄër¨q°ð †nцýÑÄÆ’mä…n<0È™;ÁÝá¯ÁZƒ7FÀmì­ É&9ˆîéi¶ùN§Y• ÃZãAâ?•‡©‰ , ó¾IŸŠc1 4â&y­&pŠ­6;M À 0¹qç»p.á …ŸÅáK@%6·y6ƒ‰3?”úºŽ‰éX5ªPT §µ!=Mž«Ú½‹ÅgÂSâÉaþÓoö–¯ÁÔìR>5éÿ üs¶ÆUcÌ kÇR ]ÿ ù¬¼«VŽ;Â|‡~¢¦”ÏŰæ {L™Õ°Óv¹ò¸írޡעCÃ!íVÕ {¶»sŒNPg/ "uÕbkm²“$ďå¿é¹§°½æz¯6 †s¿!s–wÚÝ“™Œ °.ûj>·+™Òa…©Œ&rÝÎtÛë긪Ît’LAVp%c Úý[ÄzJ¾ÇàXXç@˜ó<êL]·T˜¾¥1Ó©V‡g´æ½¦Ý@¹óø!_@´ÞâSÁ —S3™•& ]@JHÚý©ZŽ €×æÔr»Áf!‡yÞ4Mv*èÓã_{‘åóUuљØ«Oïé*®EvÑ Œ÷‡U \"㪒ÍK+À 4“M¡ï:0¥5í!'<@î´”>Ç»&Z–ïCCV˜Ì5Šo&îhè.žû |ÓK©h$s6KìŒëã)¹hI¦GïOåóI;ììü#É$Š0…Ææ¥TØ.5­¾gn´ “ÂÖ\:hœ89G)J@„}œ:’Ò{/Š"¦_Æ×7Æ3VÇŠÊa]ÚŒÙ€Ä–=®uÁßâACZƒ§§£ Qnâ:«,×{tyø¬iÛcœÜÄ€H½ÄÍCk´÷šß .W'b¤Íåh]÷€=,Žv×cÚEÚHXJX¶îo¨FÒtèöŸ>ªª6[J®Fµ£sGÁeqõfe\íjÒÐïÄÐGˆe1Ø‹.Ø”‘Ëuø Y­ˆÜ ŽG|zùªüMpDnQWÄ”%JŠ™)â*p@Örš«ÕT2Ð%ˆG#ª„ ·¤!°ŸOTÂT¸aÚ%4&h™LµšØüÐ.F¿²ÐÞ_Ç‚¾ÅÃaÜ÷09Æ q€öy˜v‡85õN÷]¬äѼóS{°_MެúÔ#°Ç¸0åÞè2ëôPcvÆw9®ií1Ä8F™˜à‰´+‰Ik1òÝ7“Ñ×ÒsÝ\x‚h`ÞÑ`ó"|µEcý£n˜h`}GÞ !±ù²Ápü²ß6 0ïi󜵩SÈÇ7˜-ÕURO˜¦´f$ªž-Í6(œ}<„ éc øs]ŽŽ„*—¾ ìdŽ„)méª\¿êÎIg¾ØÞ~I#C/¼¼´EÁÈŽi8“©õådô·>euä ƒ'Ê×लR1ÉJE1ÐAát`t;ÇР%Ý<‡¥„ÍÆ`×Oyó)õiI€ñQaŸ4Ûù\áàaÃÔ¹HÃu¹*k€¦<„e S‡&õÏ B!ŽhüÞ`yj}mªf×\¿ Ç~æ­9‡û\՞Ǖg²1Žû5V7 !àöšm° c`ܬøÇìµÒ'P"?…´Ö,"§^•õލsÔ)6˜sæéÍR¼ ò|Sl”‹7 nPW Gòú÷½§O¯‡„l¡kSÞŒr½PÊ@æ¢pŽ-mÿ #Ÿ˜Àº¶Áä¦;ïÔæ$1££`“Õ>„—·ž)ßð³ñ#Ï Ô$¶œ‰ÊE‹À;÷º ¯«P:Ñ”8–IÊtpÞ3ª“>ê“þës4ò2OÏÕ­±zô†Õ§‰.÷ä¸;¿˜“'œ›žª}«Œ{ª±Ì 9ÔóÞÕ‡0 $íWV3Üì¬ —@kÝ4@¿r¼±½¬™›?øØæ´'Áé®CË3-g$˜ö‡×auÚi´Žp/êÛ æF›Ú2v‹ã¿¿,nB1̨ƃqÞa5͝@&Æû“él÷ \C²½UÍc ¯k×¢U ÖéQå™—-r wô ÞÏ<Ò=&=ÿ Ôê Òêˈt,i—;LîÜ á¸*ÚÃ1$êL•LÍ <É)ýÐà’ ;F™{ƒ™˜€&'}‚ãÄK`¡ÞT@I;®žZóè‚s’7®°›+§O­Åq©é»²9<Ô J ¼9O’HL»Ùïì¸rk¼Ž_ý‘TŸu[²ßÚŒ·ü÷B%¯E ŸÔX5êO´ Ç•€’I0 ÉJX` ñ¹õ%;µŸD‘«´€àwÒ™U ûئžÖö\×®×´8 ½‡ºÐÆÓ§?Àkmœ=;d5*@-ì0F Rªýš[Ü6âö̃ڸr*KA9· u*µæ£?U¸Âêí†8@¦X4 e-ò„0s{ HâUpU?¼mñRa°®a%Ð'tÉ×’\¾ÊÉ]t›h>·(Ë@R¼¡Ãt h}’O÷au<+nT…Ö…MӐ??Óe95 q>í/;&JSû °¯ÊéÞ øƒ*Ã2½Ài&:nôUl=¾¿5eˆ3”ñc|Ú2V”>„»&eE;«ÚäC p¢Û úy 9š[ŒÌx¼擼A&DåÒ¯ˆ¤ÀÌ;"˜ ÏQä¸åhÊ}Ûq«Û0WžÒ|»€ø®öCm5•\ÇÀ§Pe3£]0ÃàLDÉ‰1øªxjgwT‚÷¿LΨK‹›ùs—xˆÜ±µ kæ¸f‰‰ÜGk/LÛØ6d9ò¶ùA{ƒA3š/¬D¬khÓk‰`˜"㯒r¿±Óã jx‡°e}<Ñø\3y:'À•/h½Í€Ç4~g ?Û(¼]v‘ªlKÎâ~?O‚W%{Ì:“'©úNq¾›úo(X’¥¯ˆ nFê{Ç€ü?º'ë ø‹ì Þ09ŒÌç9Æ —ËC`j@ÓÄ(+a‹un¸#ÂꟋ{K`‘ÑÍÍ'à´»/Û,KW;Þ4²þð ï Nm|~fGÏ(…³Ã)«1ö­Õ ¥‡¨©ƒÃ™ü-s=à=U66Ï«Ýc蓦W¹íž®›nÔ%êÇìŒ<#Ü×84ån®Ð ÒåOC` ñânÑs‡¢ç 1õ%Îhì½Ã½® e:ݼUZo™`  ÅZŸŒÊ«ê1ÏÄo$q¹Þ€©ˆhÐÉä¯ñ[!…Ú˜àJ:x2$Íß&PåT£6ç— ‡Í*4Ýšçjÿ ‰É nófÐ ó(L5C•åÆ\rMÒ@ò }y-W}™üýVù—ú¢=Ù”c®‘< M ž ´Phr ¦©TD ‘ù.$´÷O‡‘V2Æò.=IUŒ=ž‡â¬i™aþÓåÙ?òUø'ØÖ•.~* šTŒ!•-×áºTâ®ä#õü'´ eýlYÅÓeÕKÂrT"CÚ@u!Óxƒ{š3€}1¿(r}%«nËamjÑ%ÑNEò v ˜à  σöK³,*º.àzù¨™Ó ÚçâU¦*¿ 9{%Ö¹ njûdaXöb) kÛÆ±ûÓ\°M7ˆÂ=û›ç¿Ã‚­V»Cg–8ÙêE- j)k$º`Ã-ùEýeBÆÇ]c¡°ñty&Òd0nõ'¡W+ƒ*|–øµFa\GQªEAÔp5\Ǽ·¼Ç8·õ -â§Ú[ ‡ uZeÖ 3}×d'+¹:ð+K†Û®s!Ï$úe€<Û”x)1»a­¡LC]¸µík…ÚàA»AYº{†ªS[¦5HÒ7ù --,ísòDØ€èk ÞÀîÜ ò@â( ËNˆë›4ô½•/¦o‡€Û7 ê•ÆêòðÜy'Án½µ á˜ݦ ndeo…[ì¶Ê,¥R³Ä=À±—–ß;£™´ñSâ*g§”ïaið‘Jå~™ÓÞ ß³Õ¢»8x埒²52>AÊb&-÷\7´éÄù€T˜,w;3{ï˜k…à¹ÄqÀ«œ{€\ ˆ¾[´¨јr &Úé„Ívˆ±8†¿]|¬ņ4I×pÞS1ÈÖz‰#Ìv‡G!YNògñ:màTz¢Ý1ô©^O=~ë|5Bã™ç•¼µõ•bÆ@úÕS¬ÈŒ#¬zünrŸ û” Z²•èðV"ÁHÚý©wÝ €7¼Ìu1hÑa3Éä û f$o¿É ™Ú›ÝçnpÒ3äÌ3†Í§,Äï]$‰/pê †«À¼¸e9­Æê_C]žƒ·ý·frÁN«, E=›Çq -‰öŒ:aÏ¿±í&£Í:-} 84‘ÿ eƒQÑeëSsuiA ³g㟥ú£?ÿ ʼn*”“÷aühe:ÊWa@ÒÞk±eØ] F Ô—r.åä˜ @ö¥ªZoÐýYL·¥S²G/‡ñ <~*ZÆ´è>JlòàÛÆ½ÿ 窘ìGN¢:I®KšJp/`íIÁÀõ#Ä-€ö­šµŒoF4|ÆQØÆ@Ì|£Ô…¢À{9˜è½Üó›€ôYÒÎYsið;ís¤€à²ˆ‚4qÉVŒI$ ‰"° æµ8cXGjœˏ¡Aâý•ËÜ¢ûï e·çLx']á"oÅÎê3¯Ç—¹”ó0nå‚âg{Œñ> S´˜îè°g238‚ãköÝfÚd´6Ò€;ò÷±¢™¼›º ¢Æ'¥Ðx'e¬ç ]bÈÆV¢ó‹kýBO ðÊâ$Ÿ!×T 3Mýמ žìٍàÌü‘8÷€àæØ8æ©6‰©L´«…oãpð„~Çk‰!ñ;‹”ÛžÍ àž±z Ÿôû øŸÝužÏ;ÿ #|u6™Þ¬ÚˆÐõA4¶â|ôl|Ê2ŽÇ¤ÝÅÇY.<#Aí.k§hóF‚”Y; M½Ö4hŸ4&›­¿tès´%FìL¥£Ãk‰ÇT¤haÁ¤ÚxfÉ`ÑìË›>i 3t‚:,–+^÷´–{Û–Nxi"x‘Ûg î¨>¥Õ܁ùZH,2Û“:8xÊ¢Çí9.É-Ìâã-=çjwµS˜dütžçwýGòú®®ûº_ˆýx$–¡ãøO EÚÛÏ÷R„×w+3£Á£öUMyR²¹âŒ°š›¸Ñãò9§Ó_Dl+Ùßc›úšGÅÌc†Ž!Ko=¶.‘Îÿ c²(2®V mª.ÿ ¹B›¹å ù„öŸSV>™ü¯$y:G¢Z×àøúdî¹û­·ýÇ´:•c LÍõi_‹ö+ÎæGÊè>OŠ•äž´§Þ{X}¨1ÚTc›»Qþ•êô°t¿OP?eæ~É{5]•ÙR£r5†nZ\ã@ &îJõ ¾àC°þV>fé¥/ü5ñÊIº_é5 ;e­h<@ Ä&æÃëE%;X,ÒãÆÞ`Oò¦kŸm#˜!ÀyÄ¢| óLšò¥Ä` ¶R=|ÈCâh5ò3DˆïF†ðÒ#ÅìÛœ?¸yhBãœí ZxßÎÄhºRK„`Þödvײ™ÀÈÑÒgŒuY w³%†ƒÓzõ ÖÏp‚dH®¦A´ù§»ÓÇMæ~)ˆð‡û:ù&Ä •vGD´À n ݇¼Ö8Fö óáà£~Ë¥x`oK|Ä?fxiØü%pìR>éò+Û±éÎ>núlFŤ'tq8LZÏvÃ?„¡ß±È⽆¯³íü@x|PöUäèØã¡ð‚ŒAìÏ"vÍwóŸÍ{ ý0.z È•Ö{,N¡£¡ŸKÕÙž>Ýœþ ÍÀ°<×EA!Å‚D™IúOÍ¡>ôG}Â` ÍßkÜL™Ž Þð™ {IøF²¹òQ3&!ÃÂÞz.d&Ï-sH¸,Ôõ˜ŽP€ 77ˆÝ¼ÊëÜw =cÕ Ú,ØÐ5ÎYÐ)ì´öœgŒ[¤ßv㙑8心>h]§µháYš£²ºÑ.{Ï7Sð•?´~×SÃKýJÛ˜ ™Íäiúu<µX¶1õ^kâçIÑ£sZ4h>j*ÔšD:4­¿_ ÷¸ Õxæÿ ¸?Mù _•­ÊÐ ä ÷ý ÑwL œ­ïnTkÛUÍN©ë:¦fV ¶ÜÔÜMªÅâA½–¿R×TXš-%iTÊT•‡Ù‚JôϐZxWÑè‰f‰òG º ×Õû2aZ7OU3[“×AT–ÞŒ…-‘¤”Ì ì&(ˆ¿­•ƒkï’:ðY¦W‘ Å)“†‘˜³Åtcø˜ñTÂwÚÇ4|üLÇªí–v- qˆèU qPE.†â‘˜µ Æ,ÐÅs]8¾„oúÑ i>ÜxxÈó)ƒ ´æÁâØ$À‰vžŸf$Ž |ãw;ÀÁIJ»b` {¦Ó¤Ú$©YÀ‘n@Óïž«9J¼êG m¤ ܯ¹ÌW4€ÐÒÅÛ‡#褕Ÿn-?í|с¥÷Ú¹¬'´ÞÜ9ÓK `hê£SÄSà?7—Wí_´…óB›»:=Ãïq`<8ñÓŒÑlú2d¬ê³£hÖ[l|$vÝro~'R®‰§°ñmY ͧäP |PUª¹·:3Œ[Û{Xÿ ºâ@‚W–Äé u‚ ¯´*=íή.pûÒdt @G‰¬ s¸ ëÉücr ÞæÑ¨Ê@>¤¢Ö±. Þ'¯°ÌME[YéïĵÂCå½ Ué©Áû'Ê9%eÔðNU”ë‘ÌsD3/®+UI˜9h.WC”빓$#:pz:YÓ ¿xž* ³$Í +$kñAŠ‹†¢ Uê>¸)_š¬÷©ßAÂÔb9ÇU ¯¾á•9¯ÏÏ÷O÷¼¼Fähal1‰3Ì[Ïr•´UCksNÐ] R‘¸¥H+§Šé†c©vÖÞ0iÓ76s†î!§=ß ¼~Ô'°Ãmäoäš³ªøi1úÉ)³yV8 CLÄØÁ‘WYïi€H6ÖÑiámø^ÈY´°Ñ7¥Û*—Ñ©L«Qƒï—Ùrÿ ›£Ð*š¸ˆL©ˆ$ˆ ÷¾D§9È®«qbqC)–ˆïv´çñsÑVT­Ø, <àïºÀO«Jý·õ àfPìð .wFšir´þ’2_Y *Æ€x\« ì€9š@ Ž|F⇥ˆkZ@hÖÄ0t¿-<“‹qµ¾*ZL¤Ú)&BJpÓF5=$„at*Zš$’ÑtdûÝRI1 2މ$€$I$#‰SÞ’Hë¬ï;Á$¡t$’`<(ñÇt)$‡Ð.Êf¢X’Kt=Éé$‚ˆªè¢oÝëòI%Rgcª÷ŠyI%¡‰ÿ !ñ)´õ $¤ Ô’IIGÿÙ# vim:set fileencoding=utf-8 et ts=4 sts=4 sw=4: # # apt-listchanges - Show changelog entries between the installed versions # of a set of packages and the versions contained in # corresponding .deb files # # Copyright (C) 2000-2006 Matt Zimmerman # Copyright (C) 2006 Pierre Habouzit # Copyright (C) 2016-2019 Robert Luberda # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. # import re import os import tempfile import gzip import errno import glob import shutil import shlex import signal import subprocess import apt_pkg import ALCLog from ALChacks import _ from functools import reduce # TODO: # indexed lookups by package at least, maybe by arbitrary field def _numeric_urgency(u): urgency_map = { 'critical' : 1, 'emergency' : 1, 'high' : 2, 'medium' : 3, 'low' : 4 } return urgency_map.get(u.lower(), 99) class ControlStanza: source_version_re = re.compile(r'^\S+ \((?P.*)\).*') fields_to_read = [ 'Package', 'Source', 'Version', 'Architecture', 'Status' ] def __init__(self, s): field = None for line in s.split('\n'): if not line: break if line[0] in (' ', '\t'): if field: setattr(self, field, getattr(self, field) + '\n' + line) else: field, value = line.split(':', 1) if field in self.fields_to_read: setattr(self, field, value.lstrip()) else: field = None def source(self): return getattr(self, 'Source', self.Package).split(' ')[0] def installed(self): return hasattr(self, 'Status') and self.Status.split(' ')[2] == 'installed' def version(self): """ This function returns the version of the package. One would like it to be the "binary" version, though we have the tough case of source package whose binary packages versioning scheme is different from the source one (see OOo, linux-source, ...). This code does the following, if the Source field is set with a specified version, then we use the binary version if and only if the source version is a prefix. We must do that because of binNMUs. """ v = self.Version if hasattr(self, 'Source'): match = self.source_version_re.match(self.Source) if match: sv = match.group('version') if not v.startswith(sv): return sv return v class ControlParser: def __init__(self): self.stanzas = [] self.index = {} def makeindex(self, field): self.index[field] = {} for stanza in self.stanzas: self.index[field][getattr(stanza, field)] = stanza def readfile(self, file): try: with open(file, encoding='utf-8', errors='replace') as f: self.stanzas += [ControlStanza(x) for x in f.read().split('\n\n') if x] except Exception as ex: raise RuntimeError(_("Error processing '%(what)s': %(errmsg)s") % {'what': file, 'errmsg': str(ex)}) from ex def readdeb(self, deb): try: command = ['dpkg-deb', '-f', deb] + ControlStanza.fields_to_read output = subprocess.check_output(command) self.stanzas.append(ControlStanza(output.decode('utf-8', 'replace'))) except Exception as ex: raise RuntimeError(_("Error processing '%(what)s': %(errmsg)s") % {'what': deb, 'errmsg': str(ex)}) from ex def find(self, field, value): if field in self.index: if value in self.index[field]: return self.index[field][value] else: return None else: for stanza in self.stanzas: if hasattr(stanza, field) and getattr(stanza, field) == value: return stanza return None class ChangelogEntry: def __init__(self, header, version, urgency, binnmu = False): self._header = header.strip() self._version = version self._numeric_urgency = _numeric_urgency(urgency) self._trailer = '' self._content = '' self._binnmu = binnmu def set_trailer(self, trailer): self._trailer = trailer.rstrip() def add_content(self, content): if self._content: self._content += content elif not content.isspace(): self._content = content @property def version(self): return self._version @property def numeric_urgency(self): return self._numeric_urgency @property def binnmu(self): return self._binnmu @property def header(self): return self._header @property def trailer(self): return self._trailer @property def content(self): return self._content.rstrip() def __str__(self): result = self.header + '\n\n' + self.content + '\n\n' + self.trailer if self.header and self.trailer: return result return result.strip() __repr__ = __str__ class Changes: def __init__(self, package): self._package = package self._entries = [] self._binnmus = [] self._numeric_urgency = _numeric_urgency('low') @property def package(self): return self._package @property def numeric_urgency(self): return self._numeric_urgency @property def entries(self): return self._entries @property def binnmus(self): return self._binnmus @property def changes(self): # for backward compatibility if self._entries: return '\n\n'.join(map(str, self._entries)) + '\n\n' return '' def save_entry(self, entry): if entry.binnmu: self._binnmus.append(entry) else: self._entries.append(entry) self._numeric_urgency = min(self._numeric_urgency, entry.numeric_urgency) def reverse(self): self._entries.reverse() self._binnmus.reverse() class ChangelogParser: _changelog_header = re.compile(r'^\S+ \((?P.*)\) .*;.*urgency=(?P\w+).*') _changelog_header_ancient = re.compile(r'^(\S+ \(?\d.*\)|Old Changelog:|Changes|ChangeLog begins|Mon|Tue|Wed|Thu|Fri|Sat|Sun).*') _changelog_header_emacs = re.compile(r'(;;\s*)?Local\s+variables.*', re.IGNORECASE) _changelog_trailer = re.compile(r'^\s--\s.*<.*@.*>.*$') _binnmu_marker = 'binary-only=yes' def __init__(self, changes): self._changes = changes def parse(self, fd, since_version, latest): '''Parse changelog or news from the given file descriptor. If since_version is specified, only save entries later than the specified version. If latest is specified, only the latest N versions.''' ancient = False entry = None is_debian_changelog = False latest = int(latest) if latest else None for line in fd.readlines(): line = line.decode('utf-8', 'replace') if line.startswith('#'): continue if entry is not None and (line.startswith(' ') or line == '\n'): if not ancient and self._changelog_trailer.match(line): entry.set_trailer(line) else: entry.add_content(line) else: match = self._changelog_header.match(line) if not ancient else None if match: is_debian_changelog = True version = match.group('version') if since_version and apt_pkg.version_compare(version, since_version) <= 0: break self._save_entry(entry) if latest is not None and latest <= len(self._changes.entries): entry = None break entry = ChangelogEntry(line, version, match.group('urgency'), self._binnmu_marker in line) elif self._changelog_header_ancient.match(line): if not is_debian_changelog: # probably upstream changelog in GNU format break ancient = True self._save_entry(entry) entry = ChangelogEntry(line, '', 'low', False) elif self._changelog_header_emacs.match(line): break elif entry is not None: entry.add_content(line) else: break self._save_entry(entry) return is_debian_changelog def _save_entry(self, entry): if entry is not None: self._changes.save_entry(entry) class ChangelogsReader: def __init__(self, source_pkg_name, rootdir, since_version, latest, reverse): self._source_pkg_name = source_pkg_name self._rootdir = rootdir self._since_version = since_version self._latest = latest self._reverse = reverse def read_changelogs(self, filenames, binnmus_filenames): changes = Changes(self._source_pkg_name) find_first = lambda acc, fname: acc or self._read_changelog( os.path.join(self._rootdir, fname), changes) result = reduce(find_first, filenames, False) if binnmus_filenames: result = reduce(find_first, binnmus_filenames, False) or result if not result: return None # none of the files was a valid Debian changelog file if self._reverse: changes.reverse() return changes def _read_changelog(self, filename, changes): fd = self._open_changelog_file(filename) if not fd: return False with fd: return ChangelogParser(changes).parse(fd, self._since_version, self._latest) def _open_changelog_file(self, filename): filenames = glob.glob(filename) for filename in filenames: try: if os.path.isdir(filename): ALCLog.error(_("Ignoring `%s' (seems to be a directory!)") % filename) elif filename.endswith('.gz'): return gzip.GzipFile(filename) else: return open(filename, 'rb') break except IOError as e: if e.errno != errno.ENOENT and e.errno != errno.ELOOP: raise return None class Package: def __init__(self, path): self.path = path parser = ControlParser() parser.readdeb(self.path) pkgdata = parser.stanzas[0] self.binary = pkgdata.Package self.source = pkgdata.source() self.Version = pkgdata.version() self.arch = pkgdata.Architecture def extract_changes(self, which, since_version, latest, reverse): '''Extract changelog and binnmu entries, news or both from the package. Unpacks changelog or news files from the binary package, and parses them. If since_version is specified, only return entries later than the specified version. If latest is specified, only the latest N versions. Returns a tuple of sequences of Changes objects.''' news_filenames = self._changelog_variations('NEWS.Debian') changelog_filenames = self._changelog_variations('changelog.Debian') changelog_filenames_binnmu = self._changelog_variations('changelog.Debian.' + self.arch) changelog_filenames_native = self._changelog_variations('changelog') filenames = [] if which == 'both' or which == 'news': filenames.extend(news_filenames) if which == 'both' or which == 'changelogs': filenames.extend(changelog_filenames) filenames.extend(changelog_filenames_binnmu) filenames.extend(changelog_filenames_native) tempdir = self._extract_contents(filenames) try: reader = ChangelogsReader(self.source, tempdir, since_version, latest, reverse) news = reader.read_changelogs(news_filenames, None) changelog = reader.read_changelogs(changelog_filenames + changelog_filenames_native, changelog_filenames_binnmu) finally: shutil.rmtree(tempdir, 1) return (news, changelog) def extract_changes_via_apt(self, since_version, latest, reverse): '''Run apt-get changelog and parse the downloaded changelog. Retrieve changelog using the "apt-get changelog" command, and parse it. If since_version is specified, only return entries later than the specified version. If latest is specified, only the latest N versions. Returns a single sequence of Changes objects or None on downloading or parsing failure.''' # Retrieve changelog file and save it in a temporary directory tempdir = tempfile.mkdtemp(prefix='apt-listchanges') changelog_file = os.path.join(tempdir, self.binary + '.changelog') changelog_fd = open(changelog_file, 'w') try: command = ['apt-get', '-qq', 'changelog', '%s=%s' % (self.binary, self.Version)] ALCLog.debug(_("Calling %(cmd)s to retrieve changelog") % {'cmd': str(command)}) subprocess.run(command, stdout=changelog_fd, stderr=subprocess.PIPE, timeout=120, check=True) except subprocess.CalledProcessError as ex: ALCLog.error(_('Unable to retrieve changelog for package %(pkg)s; ' + "'apt-get changelog' failed with: %(errmsg)s") % {'pkg': self.binary, 'errmsg': ex.stderr.decode('utf-8', 'replace') if ex.stderr else str(ex)}) except Exception as ex: ALCLog.error(_('Unable to retrieve changelog for package %(pkg)s; ' + "could not run 'apt-get changelog': %(errmsg)s") % {'pkg': self.binary, 'errmsg': str(ex)}) else: return ChangelogsReader(self.source, '', since_version, latest, reverse).read_changelogs([changelog_file], None) finally: changelog_fd.close() shutil.rmtree(tempdir, 1) return None def _extract_contents(self, filenames): tempdir = tempfile.mkdtemp(prefix='apt-listchanges') extract_command = 'dpkg-deb --fsys-tarfile %s | tar xf - --wildcards -C %s %s 2>/dev/null' % ( shlex.quote(self.path), shlex.quote(tempdir), ' '.join([shlex.quote(x) for x in filenames]) ) # tar exits unsuccessfully if _any_ of the files we wanted # were not available, so we can't do much with its status status = os.system(extract_command) if os.WIFSIGNALED(status) and os.WTERMSIG(status) == signal.SIGINT: shutil.rmtree(tempdir, 1) raise KeyboardInterrupt return tempdir def _changelog_variations(self, filename): formats = ['./usr/share/doc/*/%s.gz', './usr/share/doc/*/%s'] return [x % filename for x in formats] __all__ = [ 'ControlParser', 'Package' ]