{-# LANGUAGE ScopedTypeVariables #-}-- |Functions for dealing with source and binary packages in an abstract-waymoduleDebian.Apt.Packagewhere-- Standard GHC ModulesimportqualifiedData.MapasMap-- Local ModulesimportDebian.VersionimportDebian.RelationtypePackageNameMapa=Map.MapBinPkgName[a]-- |'packageNameMap' creates a map from a package name to all the versions of that package-- NOTE: Provides are not included in the map-- NOTE: the sort order is random -- this is perhaps a bug-- see also: 'addProvides'packageNameMap::(a->BinPkgName)->[a]->PackageNameMapapackageNameMapgetNamepackages=foldl(\mp->Map.insertWith(++)(getNamep)[p]m)Map.emptypackages-- |'addProvides' finds packages that Provide other packages and adds-- them to the PackageNameMap. They will be adde to the end of the-- list, so that real packages have 'higher priority' than virtual-- packages.-- NOTE: Does not check for duplication or multiple useaddProvides::(p->[BinPkgName])->[p]->PackageNameMapp->PackageNameMappaddProvidesprovidesfpspnm=letprovides=findProvidesprovidesfpsinfoldl(\m(packageName,package)->Map.insertWith(flip(++))packageName[package]m)pnmprovides-- |'findProvides'findProvides::forallp.(p->[BinPkgName])->[p]->[(BinPkgName,p)]findProvidesprovidesfpackages=foldladdProvides[]packageswhereaddProvides::[(BinPkgName,p)]->p->[(BinPkgName,p)]addProvidesprovidesListpackage=foldl(\plpkgName->(pkgName,package):pl)providesList(providesfpackage)-- |'lookupPackageByRel' returns all the packages that satisfy the specified relation-- TODO: Add architecture checklookupPackageByRel::PackageNameMapa->(a->(BinPkgName,DebianVersion))->Relation->[a]lookupPackageByRelpmpackageVersionF(RelpkgNamemVerReq_mArch)=caseMap.lookuppkgNamepmofNothing->[]Justpackages->filterfilterVerpackageswherefilterVerp=casemVerReqofNothing->TrueJust_verReq->let(pName,pVersion)=packageVersionFpinifpName/=pkgNamethenFalse-- package is a virtual package, hence we can not do a version reqelsecheckVersionReqmVerReq(JustpVersion)