moduleDebian.ReportwhereimportDebian.Apt.Index(Fetcher,Compression(..),update,controlFromIndex')importDebian.Control.ByteStringimportDebian.SourcesimportDebian.VersionimportData.MaybeimportqualifiedData.MapasMimportqualifiedData.ByteString.Char8asBimportText.XML.HaXmlimportText.XML.HaXml.Posn-- * General Package Map Builders-- |create a map of (package name, extracted field) from a list of index files---- NOTE: we could merge all the files into a single control and then-- run packageMap over that. We currently do it one control file at a-- time to avoid having all the control files loaded in memory at-- once. However, I am not sure that property is actually occuring-- anyway. So, this should be revisited.makePackageMap::(Paragraph->a)->(a->a->a)->[(FilePath,Compression)]->IO(M.MapB.ByteStringa)makePackageMap__[]=returnM.emptymakePackageMapextractValueresolveConflict((path,compression):is)=dor<-controlFromIndex'compressionpathcaserof(Lefte)->error(showe)(Rightc)->doletpm=packageMapextractValueresolveConflictcpms<-makePackageMapextractValueresolveConflictisreturn$M.unionWithresolveConflictpmpms-- |create a map of (package name, max version) from a single control filepackageMap::(Paragraph->a)->(a->a->a)->Control->M.MapB.ByteStringapackageMapextractValueresolveConflictcontrol=M.fromListWithresolveConflict(mappackageTuple(unControlcontrol))wherepackageTupleparagraph=(fromJust$fieldValue"Package"paragraph,extractValueparagraph)-- |extract the version number from a control paragraphextractVersion::Paragraph->MaybeDebianVersionextractVersionparagraph=fmap(parseDebianVersion.B.unpack)$fieldValue"Version"paragraph-- * Trump Report-- |compare two sources.list and find all the packages in the second that trump packages in the first-- see also: |trumpedMap|trumped::Fetcher-- ^ function for downloading package indexes->FilePath-- ^ cache directory to store index files in (must already exist)->String-- ^ binary architecture ->[DebSource]-- ^ sources.list a->[DebSource]-- ^ sources.list b->IO(M.MapB.ByteString(DebianVersion,DebianVersion))-- ^ a map of trumped package names to (version a, version b)trumpedfetchercacheDirarchsourcesAsourcesB=doindexesA<-updatefetchercacheDirarch(filterisDebSrcsourcesA)pmA<-makePackageMap(fromJust.extractVersion)max(mapfromJustindexesA)indexesB<-updatefetchercacheDirarch(filterisDebSrcsourcesB)pmB<-makePackageMap(fromJust.extractVersion)max(mapfromJustindexesB)return(trumpedMappmApmB)whereisDebSrcds=sourceTypeds==DebSrc-- |calculate all the trumped packagestrumpedMap::M.MapB.ByteStringDebianVersion-- ^ package map a->M.MapB.ByteStringDebianVersion-- ^ package map b->M.MapB.ByteString(DebianVersion,DebianVersion)-- ^ trumped packages (version a, version b)trumpedMappmApmB=M.foldWithKey(checkTrumpedpmB)M.emptypmAwherecheckTrumpedpmpackageaVersiontrumpedPM=caseM.lookuppackagepmof(JustbVersion)|bVersion>aVersion->M.insertpackage(aVersion,bVersion)trumpedPM_->trumpedPM-- |create <trumped /> XML element and children from a trumped MaptrumpedXML::M.MapB.ByteString(DebianVersion,DebianVersion)->CFilterPosntrumpedXMLtrumpedMap'=mkElem"trumped"(mapmkTrumpedPackage(M.toAscListtrumpedMap'))wheremkTrumpedPackage(package,(oldVersion,newVersion))=mkElem"trumpedPackage"[mkElem"package"[cdata(B.unpackpackage)],mkElem"oldVersion"[cdata(show(prettyDebianVersionoldVersion))],mkElem"newVersion"[cdata(show(prettyDebianVersionnewVersion))]]