diff options
| author | simonmar <unknown> | 2001-03-15 15:53:28 +0000 |
|---|---|---|
| committer | simonmar <unknown> | 2001-03-15 15:53:28 +0000 |
| commit | 6c42179eb1c7e0643485f99b4b6e24b213c1fa90 (patch) | |
| tree | 9391414fc5d9b5dff9f696d1ea5b3facb51b8fce /ghc/compiler/main/PackageMaintenance.hs | |
| parent | 88ce01861a6e2ef0f20628e85c53e7c0d6de907b (diff) | |
| download | haskell-6c42179eb1c7e0643485f99b4b6e24b213c1fa90.tar.gz | |
[project @ 2001-03-15 15:53:28 by simonmar]
Remove package management support into a separate tool (ghc-pkg), and
don't duplicate the definition of PackageConfig.
Diffstat (limited to 'ghc/compiler/main/PackageMaintenance.hs')
| -rw-r--r-- | ghc/compiler/main/PackageMaintenance.hs | 139 |
1 files changed, 0 insertions, 139 deletions
diff --git a/ghc/compiler/main/PackageMaintenance.hs b/ghc/compiler/main/PackageMaintenance.hs deleted file mode 100644 index 0abf5c1f26..0000000000 --- a/ghc/compiler/main/PackageMaintenance.hs +++ /dev/null @@ -1,139 +0,0 @@ ------------------------------------------------------------------------------ --- $Id: PackageMaintenance.hs,v 1.10 2001/03/12 14:06:47 simonpj Exp $ --- --- GHC Driver program --- --- (c) Simon Marlow 2000 --- ------------------------------------------------------------------------------ - -module PackageMaintenance - ( listPackages, newPackage, deletePackage - ) where - -import CmStaticInfo -import DriverState -import TmpFiles -import Panic - -import Exception -import IOExts -import Pretty - -import IO -import Directory -import System -import Monad - ------------------------------------------------------------------------------ --- Package maintenance - -listPackages :: IO () -listPackages = do - details <- readIORef v_Package_details - hPutStr stdout (listPkgs details) - hPutChar stdout '\n' - exitWith ExitSuccess - -newPackage :: IO () -newPackage = do - error "wibble" {- - checkConfigAccess - details <- readIORef v_Package_details - hPutStr stdout "Reading package info from stdin... " - stuff <- getContents - let new_pkg = read stuff :: PackageConfig - catchAll new_pkg - (\_ -> throwDyn (OtherError "parse error in package info")) - hPutStrLn stdout "done." - if (name new_pkg `elem` map name details) - then throwDyn (OtherError ("package `" ++ name new_pkg ++ - "' already installed")) - else do - conf_file <- readIORef v_Path_package_config - savePackageConfig conf_file - maybeRestoreOldConfig conf_file $ do - writeNewConfig conf_file ( ++ [new_pkg]) - exitWith ExitSuccess --} - -deletePackage :: String -> IO () -deletePackage pkg = do - checkConfigAccess - details <- readIORef v_Package_details - if (pkg `notElem` map name details) - then throwDyn (OtherError ("package `" ++ pkg ++ "' not installed")) - else do - conf_file <- readIORef v_Path_package_config - savePackageConfig conf_file - maybeRestoreOldConfig conf_file $ do - writeNewConfig conf_file (filter ((/= pkg) . name)) - exitWith ExitSuccess - -checkConfigAccess :: IO () -checkConfigAccess = do - conf_file <- readIORef v_Path_package_config - access <- getPermissions conf_file - unless (writable access) - (throwDyn (OtherError "you don't have permission to modify the package configuration file")) - -maybeRestoreOldConfig :: String -> IO () -> IO () -maybeRestoreOldConfig conf_file io - = catchAllIO io (\e -> do - hPutStr stdout "\nWARNING: an error was encountered while the new \n\ - \configuration was being written. Attempting to \n\ - \restore the old configuration... " - kludgedSystem ("cp " ++ conf_file ++ ".old " ++ conf_file) "Restoring old configuration" - hPutStrLn stdout "done." - throw e - ) - -writeNewConfig :: String -> ([PackageConfig] -> [PackageConfig]) -> IO () -writeNewConfig conf_file fn = do - hPutStr stdout "Writing new package config file... " - old_details <- readIORef v_Package_details - h <- openFile conf_file WriteMode - hPutStr h (dumpPackages (fn old_details)) - hClose h - hPutStrLn stdout "done." - -savePackageConfig :: String -> IO () -savePackageConfig conf_file = do - hPutStr stdout "Saving old package config file... " - -- mv rather than cp because we've already done an hGetContents - -- on this file so we won't be able to open it for writing - -- unless we move the old one out of the way... - kludgedSystem ("mv " ++ conf_file ++ " " ++ conf_file ++ ".old") "Saving package configuration" - hPutStrLn stdout "done." - ------------------------------------------------------------------------------ --- Pretty printing package info - -listPkgs :: [PackageConfig] -> String -listPkgs pkgs = render (fsep (punctuate comma (map (text . name) pkgs))) - -dumpPackages :: [PackageConfig] -> String -dumpPackages pkgs = - render (brackets (vcat (punctuate comma (map dumpPkgGuts pkgs)))) - -dumpPkgGuts :: PackageConfig -> Doc -dumpPkgGuts pkg = - text "Package" $$ nest 3 (braces ( - sep (punctuate comma [ - text "name = " <> text (show (name pkg)), - dumpField "import_dirs" (import_dirs pkg), - dumpField "library_dirs" (library_dirs pkg), - dumpField "hs_libraries" (hs_libraries pkg), - dumpField "extra_libraries" (extra_libraries pkg), - dumpField "include_dirs" (include_dirs pkg), - dumpField "c_includes" (c_includes pkg), - dumpField "package_deps" (package_deps pkg), - dumpField "extra_ghc_opts" (extra_ghc_opts pkg), - dumpField "extra_cc_opts" (extra_cc_opts pkg), - dumpField "extra_ld_opts" (extra_ld_opts pkg) - ]))) - -dumpField :: String -> [String] -> Doc -dumpField name val = - hang (text name <+> equals) 2 - (brackets (sep (punctuate comma (map (text . show) val)))) |
