From: simonmar Date: Thu, 10 Feb 2005 15:12:22 +0000 (+0000) Subject: [project @ 2005-02-10 15:12:22 by simonmar] X-Git-Tag: Initial_conversion_from_CVS_complete~1085 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=6866c11202fcd08921d699ec8a175dd060669982 [project @ 2005-02-10 15:12:22 by simonmar] Make sure we don't register a package with an identifier that cannot be parsed later. --- diff --git a/ghc/utils/ghc-pkg/Main.hs b/ghc/utils/ghc-pkg/Main.hs index 1b5f8f7..abf06cd 100644 --- a/ghc/utils/ghc-pkg/Main.hs +++ b/ghc/utils/ghc-pkg/Main.hs @@ -505,6 +505,7 @@ validatePackageConfig :: InstalledPackageInfo -> Bool -- force -> IO () validatePackageConfig pkg db_stack auto_ghci_libs update force = do + checkPackageId pkg checkDuplicates db_stack pkg update mapM_ (checkDep db_stack force) (depends pkg) mapM_ (checkDir force) (importDirs pkg) @@ -515,6 +516,17 @@ validatePackageConfig pkg db_stack auto_ghci_libs update force = do -- extra_libraries :: [String], -- c_includes :: [String], +-- When the package name and version are put together, sometimes we can +-- end up with a package id that cannot be parsed. This will lead to +-- difficulties when the user wants to refer to the package later, so +-- we check that the package id can be parsed properly here. +checkPackageId :: InstalledPackageInfo -> IO () +checkPackageId ipi = + let str = showPackageId (package ipi) in + case [ x | (x,ys) <- readP_to_S parsePackageId str, all isSpace ys ] of + [_] -> return () + [] -> die ("invalid package identifier: " ++ str) + _ -> die ("ambiguous package identifier: " ++ str) checkDuplicates :: PackageDBStack -> InstalledPackageInfo -> Bool -> IO () checkDuplicates db_stack pkg update = do