Permalink
Browse files

Fix 'hackport list' to handle package names properly

  • Loading branch information...
1 parent 8543927 commit 88e7a14ec2d105a4da2acd21357385a8cb6e1900 @kolmodin kolmodin committed Feb 8, 2009
Showing with 19 additions and 10 deletions.
  1. +7 −6 Main.hs
  2. +12 −4 Portage/PackageId.hs
View
13 Main.hs
@@ -32,6 +32,7 @@ import Distribution.Client.Update
import qualified Distribution.Client.IndexUtils as Index
import Portage.Overlay as Overlay ( loadLazy, inOverlay )
+import Portage.PackageId ( normalizeCabalPackageName, normalizeCabalPackageId )
import Network.URI
import System.Environment ( getArgs, getProgName )
@@ -109,15 +110,15 @@ listAction flags extraArgs globalFlags = do
overlay <- Overlay.loadLazy overlayPath
let pkgs | null extraArgs = PackageIndex.allPackages index
| otherwise = concatMap (PackageIndex.searchByNameSubstring index) extraArgs
- let decorated = map (\p -> (Overlay.inOverlay overlay (packageInfoId p), p)) pkgs
+ normalized = map (normalizeCabalPackageId . packageInfoId) pkgs
+ let decorated = map (\p -> (Overlay.inOverlay overlay p, p)) normalized
mapM_ (putStrLn . pretty) decorated
where
- pretty :: (Bool, AvailablePackage) -> String
- pretty (inOverlay, pkg) =
- let pkgId = packageInfoId pkg
- dec | inOverlay = " * "
+ pretty :: (Bool, Cabal.PackageIdentifier) -> String
+ pretty (inOverlay, pkgId) =
+ let dec | inOverlay = " * "
| otherwise = " "
- in dec ++ display (Cabal.pkgName pkgId) <-> display (Cabal.pkgVersion pkgId)
+ in dec ++ display pkgId
-----------------------------------------------------------------------
View
16 Portage/PackageId.hs
@@ -6,7 +6,9 @@ module Portage.PackageId (
PackageId(..),
fromCabalPackageId,
toCabalPackageId,
- parseFriendlyPackage
+ parseFriendlyPackage,
+ normalizeCabalPackageName,
+ normalizeCabalPackageId
) where
import qualified Data.Char as Char (isAlphaNum, isDigit, isSpace, toLower)
@@ -51,10 +53,16 @@ instance Text PN where
fromCabalPackageId :: Category -> Cabal.PackageIdentifier -> PackageId
fromCabalPackageId category (Cabal.PackageIdentifier name version) =
- PackageId (PackageName category (lowercase name))
+ PackageId (PackageName category (normalizeCabalPackageName name))
(Portage.fromCabalVersion version)
- where
- lowercase (Cabal.PackageName name) = Cabal.PackageName (map Char.toLower name)
+
+normalizeCabalPackageName :: Cabal.PackageName -> Cabal.PackageName
+normalizeCabalPackageName (Cabal.PackageName name) =
+ Cabal.PackageName (map Char.toLower name)
+
+normalizeCabalPackageId :: Cabal.PackageIdentifier -> Cabal.PackageIdentifier
+normalizeCabalPackageId (Cabal.PackageIdentifier name version) =
+ Cabal.PackageIdentifier (normalizeCabalPackageName name) version
toCabalPackageId :: PackageId -> Maybe Cabal.PackageIdentifier
toCabalPackageId (PackageId (PackageName _cat name) version) =

0 comments on commit 88e7a14

Please sign in to comment.